repo_name
stringlengths 7
104
| file_path
stringlengths 13
198
| context
stringlengths 67
7.15k
| import_statement
stringlengths 16
4.43k
| code
stringlengths 40
6.98k
| prompt
stringlengths 227
8.27k
| next_line
stringlengths 8
795
|
---|---|---|---|---|---|---|
PhantomThief/more-lambdas-java | core/src/test/java/com/github/phantomthief/concurrent/MoreFuturesTest3.java | // Path: core/src/main/java/com/github/phantomthief/concurrent/MoreFutures.java
// @Nonnull
// public static <F extends Future<V>, V> Map<F, V> tryWait(@Nonnull Iterable<F> futures,
// @Nonnull Duration duration) throws TryWaitFutureUncheckedException {
// checkNotNull(futures);
// checkNotNull(duration);
// return tryWait(futures, duration.toNanos(), NANOSECONDS);
// }
| import static com.github.phantomthief.concurrent.MoreFutures.tryWait;
import static com.google.common.base.Stopwatch.createStarted;
import static com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly;
import static java.util.concurrent.Executors.newFixedThreadPool;
import static java.util.concurrent.TimeUnit.SECONDS;
import static java.util.stream.Collectors.toList;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.stream.IntStream;
import org.junit.jupiter.api.Test;
import com.google.common.base.Stopwatch; | package com.github.phantomthief.concurrent;
/**
* @author w.vela
* Created on 2020-05-26.
*/
class MoreFuturesTest3 {
@Test
void test() {
ExecutorService executor = newFixedThreadPool(20);
List<Integer> keys = IntStream.range(1, 10).boxed().collect(toList());
Stopwatch stopWatch = createStarted(); | // Path: core/src/main/java/com/github/phantomthief/concurrent/MoreFutures.java
// @Nonnull
// public static <F extends Future<V>, V> Map<F, V> tryWait(@Nonnull Iterable<F> futures,
// @Nonnull Duration duration) throws TryWaitFutureUncheckedException {
// checkNotNull(futures);
// checkNotNull(duration);
// return tryWait(futures, duration.toNanos(), NANOSECONDS);
// }
// Path: core/src/test/java/com/github/phantomthief/concurrent/MoreFuturesTest3.java
import static com.github.phantomthief.concurrent.MoreFutures.tryWait;
import static com.google.common.base.Stopwatch.createStarted;
import static com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly;
import static java.util.concurrent.Executors.newFixedThreadPool;
import static java.util.concurrent.TimeUnit.SECONDS;
import static java.util.stream.Collectors.toList;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.stream.IntStream;
import org.junit.jupiter.api.Test;
import com.google.common.base.Stopwatch;
package com.github.phantomthief.concurrent;
/**
* @author w.vela
* Created on 2020-05-26.
*/
class MoreFuturesTest3 {
@Test
void test() {
ExecutorService executor = newFixedThreadPool(20);
List<Integer> keys = IntStream.range(1, 10).boxed().collect(toList());
Stopwatch stopWatch = createStarted(); | Map<Integer, String> result = tryWait(keys, 5, SECONDS, it -> executor.submit(() -> { |
PhantomThief/more-lambdas-java | core/src/main/java/com/github/phantomthief/pool/impl/LazyBlockingQueue.java | // Path: core/src/main/java/com/github/phantomthief/util/MoreSuppliers.java
// public static <T> CloseableSupplier<T> lazy(Supplier<T> delegate) {
// return lazy(delegate, true);
// }
| import static com.github.phantomthief.util.MoreSuppliers.lazy;
import java.util.Collection;
import java.util.Iterator;
import java.util.Spliterator;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.function.Supplier;
import javax.annotation.Nonnull; | package com.github.phantomthief.pool.impl;
/**
* @author w.vela
* Created on 2020-08-19.
*/
class LazyBlockingQueue<E> implements BlockingQueue<E> {
private final Supplier<BlockingQueue<E>> factory;
LazyBlockingQueue(@Nonnull Supplier<BlockingQueue<E>> factory) { | // Path: core/src/main/java/com/github/phantomthief/util/MoreSuppliers.java
// public static <T> CloseableSupplier<T> lazy(Supplier<T> delegate) {
// return lazy(delegate, true);
// }
// Path: core/src/main/java/com/github/phantomthief/pool/impl/LazyBlockingQueue.java
import static com.github.phantomthief.util.MoreSuppliers.lazy;
import java.util.Collection;
import java.util.Iterator;
import java.util.Spliterator;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.function.Supplier;
import javax.annotation.Nonnull;
package com.github.phantomthief.pool.impl;
/**
* @author w.vela
* Created on 2020-08-19.
*/
class LazyBlockingQueue<E> implements BlockingQueue<E> {
private final Supplier<BlockingQueue<E>> factory;
LazyBlockingQueue(@Nonnull Supplier<BlockingQueue<E>> factory) { | this.factory = lazy(factory); |
PhantomThief/more-lambdas-java | core/src/test/java/com/github/phantomthief/test/MoreIterablesTest.java | // Path: core/src/main/java/com/github/phantomthief/util/MoreIterables.java
// public final class MoreIterables {
//
// /**
// * 工具类,禁止实例化成对象
// */
// private MoreIterables() {
// throw new UnsupportedOperationException();
// }
//
// /**
// * 取得一个闭区间的long类型的数列,并按批次的大小进行分组,返回一个{@link Stream}
// *
// * @param from 起始值(含)
// * @param to 终止值(含)
// * @param batch 分组批次大小
// * @return 分组序列Stream
// */
// public static Stream<List<Long>> batchClosedRangeStream(long from, long to, int batch) {
// return toStream(batchClosedRange(from, to, batch));
// }
//
// /**
// * 取得一个闭区间的long类型的数列,并按批次的大小进行分组,返回一个{@link Iterable}
// *
// * @param from 起始值(含)
// * @param to 终止值(含)
// * @param batch 分组批次大小
// * @return 分组序列Iterable
// */
// public static Iterable<List<Long>> batchClosedRange(long from, long to, int batch) {
// checkArgument(batch > 0);
// if (from == to) {
// return singleton(singletonList(from));
// }
// LongStream longStream;
// if (from > to) {
// longStream = LongStream.rangeClosed(to, from).map(i -> from + to - i);
// } else {
// longStream = LongStream.rangeClosed(from, to);
// }
// return partition(longStream.boxed()::iterator, batch);
// }
//
// /**
// * 取得一个闭区间的long类型的数列,并按批次的大小进行分组,返回一个{@link Stream},使用{@link Range}承载
// *
// * @param from 起始值(含)
// * @param to 终止值(含)
// * @param batch 分组批次大小
// * @return 分组序列Stream
// */
// public static Stream<Range<Long>> batchClosedSimpleRangeStream(long from, long to, int batch) {
// return toStream(batchClosedSimpleRange(from, to, batch));
// }
//
// /**
// * 取得一个闭区间的long类型的数列,并按批次的大小进行分组,返回一个{@link Iterable},使用{@link Range}承载
// *
// * @param from 起始值(含)
// * @param to 终止值(含)
// * @param batch 分组批次大小
// * @return 分组序列Iterable
// */
// public static Iterable<Range<Long>> batchClosedSimpleRange(long from, long to, int batch) {
// checkArgument(batch > 0);
// if (from == to) {
// return singleton(Range.closed(from, to));
// }
// boolean reversed = from > to;
// return () -> new Iterator<Range<Long>>() {
//
// private Range<Long> current = reversed ? Range.closed((max(from - batch, to) + 1), from)
// : Range.closed(from, min(batch + from, to) - 1);
//
// @Override
// public boolean hasNext() {
// return current != null && !current.isEmpty();
// }
//
// @Override
// public Range<Long> next() {
// if (current == null) {
// throw new NoSuchElementException();
// }
// Range<Long> result = current;
// calcNext();
// return result;
// }
//
// private void calcNext() {
// if (current.isEmpty()) {
// current = null;
// return;
// }
// long newStart;
// if (reversed) {
// newStart = current.lowerEndpoint() - 1;
// } else {
// newStart = current.upperEndpoint() + 1;
// }
// if ((!reversed && newStart > to) || (reversed && to > newStart)) {
// current = null;
// return;
// }
// long newEnd;
// if (reversed) {
// newEnd = max(to, newStart - batch + 1);
// } else {
// newEnd = min(to, newStart + batch - 1);
// }
// current = reversed ? Range.closed(newEnd, newStart) : Range.closed(newStart,
// newEnd);
// }
// };
// }
// }
| import org.junit.jupiter.api.Test;
import com.github.phantomthief.util.MoreIterables; | package com.github.phantomthief.test;
/**
* @author w.vela
*/
class MoreIterablesTest {
@Test
void testIterable() { | // Path: core/src/main/java/com/github/phantomthief/util/MoreIterables.java
// public final class MoreIterables {
//
// /**
// * 工具类,禁止实例化成对象
// */
// private MoreIterables() {
// throw new UnsupportedOperationException();
// }
//
// /**
// * 取得一个闭区间的long类型的数列,并按批次的大小进行分组,返回一个{@link Stream}
// *
// * @param from 起始值(含)
// * @param to 终止值(含)
// * @param batch 分组批次大小
// * @return 分组序列Stream
// */
// public static Stream<List<Long>> batchClosedRangeStream(long from, long to, int batch) {
// return toStream(batchClosedRange(from, to, batch));
// }
//
// /**
// * 取得一个闭区间的long类型的数列,并按批次的大小进行分组,返回一个{@link Iterable}
// *
// * @param from 起始值(含)
// * @param to 终止值(含)
// * @param batch 分组批次大小
// * @return 分组序列Iterable
// */
// public static Iterable<List<Long>> batchClosedRange(long from, long to, int batch) {
// checkArgument(batch > 0);
// if (from == to) {
// return singleton(singletonList(from));
// }
// LongStream longStream;
// if (from > to) {
// longStream = LongStream.rangeClosed(to, from).map(i -> from + to - i);
// } else {
// longStream = LongStream.rangeClosed(from, to);
// }
// return partition(longStream.boxed()::iterator, batch);
// }
//
// /**
// * 取得一个闭区间的long类型的数列,并按批次的大小进行分组,返回一个{@link Stream},使用{@link Range}承载
// *
// * @param from 起始值(含)
// * @param to 终止值(含)
// * @param batch 分组批次大小
// * @return 分组序列Stream
// */
// public static Stream<Range<Long>> batchClosedSimpleRangeStream(long from, long to, int batch) {
// return toStream(batchClosedSimpleRange(from, to, batch));
// }
//
// /**
// * 取得一个闭区间的long类型的数列,并按批次的大小进行分组,返回一个{@link Iterable},使用{@link Range}承载
// *
// * @param from 起始值(含)
// * @param to 终止值(含)
// * @param batch 分组批次大小
// * @return 分组序列Iterable
// */
// public static Iterable<Range<Long>> batchClosedSimpleRange(long from, long to, int batch) {
// checkArgument(batch > 0);
// if (from == to) {
// return singleton(Range.closed(from, to));
// }
// boolean reversed = from > to;
// return () -> new Iterator<Range<Long>>() {
//
// private Range<Long> current = reversed ? Range.closed((max(from - batch, to) + 1), from)
// : Range.closed(from, min(batch + from, to) - 1);
//
// @Override
// public boolean hasNext() {
// return current != null && !current.isEmpty();
// }
//
// @Override
// public Range<Long> next() {
// if (current == null) {
// throw new NoSuchElementException();
// }
// Range<Long> result = current;
// calcNext();
// return result;
// }
//
// private void calcNext() {
// if (current.isEmpty()) {
// current = null;
// return;
// }
// long newStart;
// if (reversed) {
// newStart = current.lowerEndpoint() - 1;
// } else {
// newStart = current.upperEndpoint() + 1;
// }
// if ((!reversed && newStart > to) || (reversed && to > newStart)) {
// current = null;
// return;
// }
// long newEnd;
// if (reversed) {
// newEnd = max(to, newStart - batch + 1);
// } else {
// newEnd = min(to, newStart + batch - 1);
// }
// current = reversed ? Range.closed(newEnd, newStart) : Range.closed(newStart,
// newEnd);
// }
// };
// }
// }
// Path: core/src/test/java/com/github/phantomthief/test/MoreIterablesTest.java
import org.junit.jupiter.api.Test;
import com.github.phantomthief.util.MoreIterables;
package com.github.phantomthief.test;
/**
* @author w.vela
*/
class MoreIterablesTest {
@Test
void testIterable() { | MoreIterables.batchClosedRange(2, 15, 4).forEach(System.out::println); |
chenzj-king/RvHelper | demo/src/main/java/com/dreamliner/lib/rvhelper/sample/view/decoration/TitleItemDecoration.java | // Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/utils/PixelUtil.java
// public class PixelUtil {
//
// /**
// * The mContext.
// */
// private static Context mContext;
//
// public static void init(Context context) {
// mContext = context;
// }
//
// /**
// * dp转 px.
// *
// * @param value the value
// * @return the int
// */
// public static int dp2px(float value) {
// final float scale = mContext.getResources().getDisplayMetrics().densityDpi;
// return (int) (value * (scale / 160) + 0.5f);
// }
//
// /**
// * dp转 px.
// *
// * @param value the value
// * @param context the mContext
// * @return the int
// */
// public static int dp2px(float value, Context context) {
// final float scale = context.getResources().getDisplayMetrics().densityDpi;
// return (int) (value * (scale / 160) + 0.5f);
// }
//
// /**
// * px转dp.
// *
// * @param value the value
// * @return the int
// */
// public static int px2dp(float value) {
// final float scale = mContext.getResources().getDisplayMetrics().densityDpi;
// return (int) ((value * 160) / scale + 0.5f);
// }
//
// /**
// * px转dp.
// *
// * @param value the value
// * @param context the mContext
// * @return the int
// */
// public static int px2dp(float value, Context context) {
// final float scale = context.getResources().getDisplayMetrics().densityDpi;
// return (int) ((value * 160) / scale + 0.5f);
// }
//
// /**
// * sp转px.
// *
// * @param value the value
// * @return the int
// */
// public static int sp2px(float value) {
// Resources r;
// if (mContext == null) {
// r = Resources.getSystem();
// } else {
// r = mContext.getResources();
// }
// float spvalue = value * r.getDisplayMetrics().scaledDensity;
// return (int) (spvalue + 0.5f);
// }
//
// /**
// * sp转px.
// *
// * @param value the value
// * @param context the mContext
// * @return the int
// */
// public static int sp2px(float value, Context context) {
// Resources r;
// if (context == null) {
// r = Resources.getSystem();
// } else {
// r = context.getResources();
// }
// float spvalue = value * r.getDisplayMetrics().scaledDensity;
// return (int) (spvalue + 0.5f);
// }
//
// /**
// * px转sp.
// *
// * @param value the value
// * @return the int
// */
// public static int px2sp(float value) {
// final float scale = mContext.getResources().getDisplayMetrics().scaledDensity;
// return (int) (value / scale + 0.5f);
// }
//
// /**
// * px转sp.
// *
// * @param value the value
// * @param context the mContext
// * @return the int
// */
// public static int px2sp(float value, Context context) {
// final float scale = context.getResources().getDisplayMetrics().scaledDensity;
// return (int) (value / scale + 0.5f);
// }
//
//
// }
| import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import androidx.recyclerview.widget.RecyclerView;
import android.util.TypedValue;
import android.view.View;
import com.dreamliner.lib.rvhelper.sample.utils.PixelUtil;
import java.util.List; | String currentTag = mDatas.get(position).getTag();
if (!currentTag.equals(mTopTag) && (position == 0 || !currentTag.equals(mDatas.get(position - 1).getTag()))) {
//不为空 且跟前一个tag不一样了,说明是新的分类,也要title
drawTitleArea(c, left, right, child, params, position);
}
}
}
}
/**
* 绘制Title区域背景和文字的方法
*
* @param c
* @param left
* @param right
* @param child
* @param params
* @param position
*/
private void drawTitleArea(Canvas c, int left, int right, View child, RecyclerView.LayoutParams params, int position) {
//最先调用,绘制在最下层
mPaint.setColor(COLOR_TITLE_BG);
c.drawRect(left, child.getTop() - params.topMargin - mTitleHeight, right, child.getTop() - params.topMargin, mPaint);
mPaint.setColor(COLOR_TITLE_FONT);
/*
Paint.FontMetricsInt fontMetrics = mPaint.getFontMetricsInt();
int baseline = (getMeasuredHeight() - fontMetrics.bottom + fontMetrics.top) / 2 - fontMetrics.top;
*/
mPaint.getTextBounds(mDatas.get(position).getTag(), 0, mDatas.get(position).getTag().length(), mBounds);
| // Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/utils/PixelUtil.java
// public class PixelUtil {
//
// /**
// * The mContext.
// */
// private static Context mContext;
//
// public static void init(Context context) {
// mContext = context;
// }
//
// /**
// * dp转 px.
// *
// * @param value the value
// * @return the int
// */
// public static int dp2px(float value) {
// final float scale = mContext.getResources().getDisplayMetrics().densityDpi;
// return (int) (value * (scale / 160) + 0.5f);
// }
//
// /**
// * dp转 px.
// *
// * @param value the value
// * @param context the mContext
// * @return the int
// */
// public static int dp2px(float value, Context context) {
// final float scale = context.getResources().getDisplayMetrics().densityDpi;
// return (int) (value * (scale / 160) + 0.5f);
// }
//
// /**
// * px转dp.
// *
// * @param value the value
// * @return the int
// */
// public static int px2dp(float value) {
// final float scale = mContext.getResources().getDisplayMetrics().densityDpi;
// return (int) ((value * 160) / scale + 0.5f);
// }
//
// /**
// * px转dp.
// *
// * @param value the value
// * @param context the mContext
// * @return the int
// */
// public static int px2dp(float value, Context context) {
// final float scale = context.getResources().getDisplayMetrics().densityDpi;
// return (int) ((value * 160) / scale + 0.5f);
// }
//
// /**
// * sp转px.
// *
// * @param value the value
// * @return the int
// */
// public static int sp2px(float value) {
// Resources r;
// if (mContext == null) {
// r = Resources.getSystem();
// } else {
// r = mContext.getResources();
// }
// float spvalue = value * r.getDisplayMetrics().scaledDensity;
// return (int) (spvalue + 0.5f);
// }
//
// /**
// * sp转px.
// *
// * @param value the value
// * @param context the mContext
// * @return the int
// */
// public static int sp2px(float value, Context context) {
// Resources r;
// if (context == null) {
// r = Resources.getSystem();
// } else {
// r = context.getResources();
// }
// float spvalue = value * r.getDisplayMetrics().scaledDensity;
// return (int) (spvalue + 0.5f);
// }
//
// /**
// * px转sp.
// *
// * @param value the value
// * @return the int
// */
// public static int px2sp(float value) {
// final float scale = mContext.getResources().getDisplayMetrics().scaledDensity;
// return (int) (value / scale + 0.5f);
// }
//
// /**
// * px转sp.
// *
// * @param value the value
// * @param context the mContext
// * @return the int
// */
// public static int px2sp(float value, Context context) {
// final float scale = context.getResources().getDisplayMetrics().scaledDensity;
// return (int) (value / scale + 0.5f);
// }
//
//
// }
// Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/view/decoration/TitleItemDecoration.java
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import androidx.recyclerview.widget.RecyclerView;
import android.util.TypedValue;
import android.view.View;
import com.dreamliner.lib.rvhelper.sample.utils.PixelUtil;
import java.util.List;
String currentTag = mDatas.get(position).getTag();
if (!currentTag.equals(mTopTag) && (position == 0 || !currentTag.equals(mDatas.get(position - 1).getTag()))) {
//不为空 且跟前一个tag不一样了,说明是新的分类,也要title
drawTitleArea(c, left, right, child, params, position);
}
}
}
}
/**
* 绘制Title区域背景和文字的方法
*
* @param c
* @param left
* @param right
* @param child
* @param params
* @param position
*/
private void drawTitleArea(Canvas c, int left, int right, View child, RecyclerView.LayoutParams params, int position) {
//最先调用,绘制在最下层
mPaint.setColor(COLOR_TITLE_BG);
c.drawRect(left, child.getTop() - params.topMargin - mTitleHeight, right, child.getTop() - params.topMargin, mPaint);
mPaint.setColor(COLOR_TITLE_FONT);
/*
Paint.FontMetricsInt fontMetrics = mPaint.getFontMetricsInt();
int baseline = (getMeasuredHeight() - fontMetrics.bottom + fontMetrics.top) / 2 - fontMetrics.top;
*/
mPaint.getTextBounds(mDatas.get(position).getTag(), 0, mDatas.get(position).getTag().length(), mBounds);
| int textPaddingLeft = PixelUtil.dp2px(12); |
chenzj-king/RvHelper | library/src/main/java/com/dreamliner/rvhelper/adapter/BaseMixtureAdapter.java | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemLongListener.java
// public interface ItemLongListener {
// boolean onLongClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseViewHolder.java
// public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
//
// private ItemClickListener mItemClickListener;
// private ItemLongListener mItemLongListener;
//
// public BaseViewHolder(View itemView) {
// super(itemView);
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// }
//
// public BaseViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView);
// mItemLongListener = itemLongListener;
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mItemClickListener.onItemClick(v, position);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mItemLongListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mItemLongListener.onLongClick(v, position);
// }
// return false;
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/FooterViewHolder.java
// public class FooterViewHolder extends BaseViewHolder {
//
// public FooterViewHolder(View itemView) {
// super(itemView);
// }
//
// public FooterViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView, itemClickListener);
// }
//
// public FooterViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView, itemLongListener);
// }
//
// public FooterViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView, itemClickListener, itemLongListener);
// }
// }
| import androidx.recyclerview.widget.RecyclerView;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.interfaces.ItemLongListener;
import com.dreamliner.rvhelper.viewholder.BaseViewHolder;
import com.dreamliner.rvhelper.viewholder.FooterViewHolder; | package com.dreamliner.rvhelper.adapter;
/**
* @author chenzj
* @Title: BaseAdapter
* @Description: 类的描述 -
* @date 2016/6/12 09:05
* @email [email protected]
*/
public abstract class BaseMixtureAdapter<T> extends BaseNormalAdapter<T, BaseViewHolder> {
public BaseMixtureAdapter() {
}
| // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemLongListener.java
// public interface ItemLongListener {
// boolean onLongClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseViewHolder.java
// public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
//
// private ItemClickListener mItemClickListener;
// private ItemLongListener mItemLongListener;
//
// public BaseViewHolder(View itemView) {
// super(itemView);
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// }
//
// public BaseViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView);
// mItemLongListener = itemLongListener;
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mItemClickListener.onItemClick(v, position);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mItemLongListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mItemLongListener.onLongClick(v, position);
// }
// return false;
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/FooterViewHolder.java
// public class FooterViewHolder extends BaseViewHolder {
//
// public FooterViewHolder(View itemView) {
// super(itemView);
// }
//
// public FooterViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView, itemClickListener);
// }
//
// public FooterViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView, itemLongListener);
// }
//
// public FooterViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView, itemClickListener, itemLongListener);
// }
// }
// Path: library/src/main/java/com/dreamliner/rvhelper/adapter/BaseMixtureAdapter.java
import androidx.recyclerview.widget.RecyclerView;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.interfaces.ItemLongListener;
import com.dreamliner.rvhelper.viewholder.BaseViewHolder;
import com.dreamliner.rvhelper.viewholder.FooterViewHolder;
package com.dreamliner.rvhelper.adapter;
/**
* @author chenzj
* @Title: BaseAdapter
* @Description: 类的描述 -
* @date 2016/6/12 09:05
* @email [email protected]
*/
public abstract class BaseMixtureAdapter<T> extends BaseNormalAdapter<T, BaseViewHolder> {
public BaseMixtureAdapter() {
}
| public BaseMixtureAdapter(ItemClickListener itemClickListener) { |
chenzj-king/RvHelper | library/src/main/java/com/dreamliner/rvhelper/adapter/BaseMixtureAdapter.java | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemLongListener.java
// public interface ItemLongListener {
// boolean onLongClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseViewHolder.java
// public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
//
// private ItemClickListener mItemClickListener;
// private ItemLongListener mItemLongListener;
//
// public BaseViewHolder(View itemView) {
// super(itemView);
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// }
//
// public BaseViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView);
// mItemLongListener = itemLongListener;
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mItemClickListener.onItemClick(v, position);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mItemLongListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mItemLongListener.onLongClick(v, position);
// }
// return false;
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/FooterViewHolder.java
// public class FooterViewHolder extends BaseViewHolder {
//
// public FooterViewHolder(View itemView) {
// super(itemView);
// }
//
// public FooterViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView, itemClickListener);
// }
//
// public FooterViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView, itemLongListener);
// }
//
// public FooterViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView, itemClickListener, itemLongListener);
// }
// }
| import androidx.recyclerview.widget.RecyclerView;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.interfaces.ItemLongListener;
import com.dreamliner.rvhelper.viewholder.BaseViewHolder;
import com.dreamliner.rvhelper.viewholder.FooterViewHolder; | package com.dreamliner.rvhelper.adapter;
/**
* @author chenzj
* @Title: BaseAdapter
* @Description: 类的描述 -
* @date 2016/6/12 09:05
* @email [email protected]
*/
public abstract class BaseMixtureAdapter<T> extends BaseNormalAdapter<T, BaseViewHolder> {
public BaseMixtureAdapter() {
}
public BaseMixtureAdapter(ItemClickListener itemClickListener) {
super(itemClickListener);
}
| // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemLongListener.java
// public interface ItemLongListener {
// boolean onLongClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseViewHolder.java
// public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
//
// private ItemClickListener mItemClickListener;
// private ItemLongListener mItemLongListener;
//
// public BaseViewHolder(View itemView) {
// super(itemView);
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// }
//
// public BaseViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView);
// mItemLongListener = itemLongListener;
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mItemClickListener.onItemClick(v, position);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mItemLongListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mItemLongListener.onLongClick(v, position);
// }
// return false;
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/FooterViewHolder.java
// public class FooterViewHolder extends BaseViewHolder {
//
// public FooterViewHolder(View itemView) {
// super(itemView);
// }
//
// public FooterViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView, itemClickListener);
// }
//
// public FooterViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView, itemLongListener);
// }
//
// public FooterViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView, itemClickListener, itemLongListener);
// }
// }
// Path: library/src/main/java/com/dreamliner/rvhelper/adapter/BaseMixtureAdapter.java
import androidx.recyclerview.widget.RecyclerView;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.interfaces.ItemLongListener;
import com.dreamliner.rvhelper.viewholder.BaseViewHolder;
import com.dreamliner.rvhelper.viewholder.FooterViewHolder;
package com.dreamliner.rvhelper.adapter;
/**
* @author chenzj
* @Title: BaseAdapter
* @Description: 类的描述 -
* @date 2016/6/12 09:05
* @email [email protected]
*/
public abstract class BaseMixtureAdapter<T> extends BaseNormalAdapter<T, BaseViewHolder> {
public BaseMixtureAdapter() {
}
public BaseMixtureAdapter(ItemClickListener itemClickListener) {
super(itemClickListener);
}
| public BaseMixtureAdapter(ItemLongListener itemLongListener) { |
chenzj-king/RvHelper | library/src/main/java/com/dreamliner/rvhelper/adapter/BaseMixtureAdapter.java | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemLongListener.java
// public interface ItemLongListener {
// boolean onLongClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseViewHolder.java
// public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
//
// private ItemClickListener mItemClickListener;
// private ItemLongListener mItemLongListener;
//
// public BaseViewHolder(View itemView) {
// super(itemView);
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// }
//
// public BaseViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView);
// mItemLongListener = itemLongListener;
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mItemClickListener.onItemClick(v, position);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mItemLongListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mItemLongListener.onLongClick(v, position);
// }
// return false;
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/FooterViewHolder.java
// public class FooterViewHolder extends BaseViewHolder {
//
// public FooterViewHolder(View itemView) {
// super(itemView);
// }
//
// public FooterViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView, itemClickListener);
// }
//
// public FooterViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView, itemLongListener);
// }
//
// public FooterViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView, itemClickListener, itemLongListener);
// }
// }
| import androidx.recyclerview.widget.RecyclerView;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.interfaces.ItemLongListener;
import com.dreamliner.rvhelper.viewholder.BaseViewHolder;
import com.dreamliner.rvhelper.viewholder.FooterViewHolder; | package com.dreamliner.rvhelper.adapter;
/**
* @author chenzj
* @Title: BaseAdapter
* @Description: 类的描述 -
* @date 2016/6/12 09:05
* @email [email protected]
*/
public abstract class BaseMixtureAdapter<T> extends BaseNormalAdapter<T, BaseViewHolder> {
public BaseMixtureAdapter() {
}
public BaseMixtureAdapter(ItemClickListener itemClickListener) {
super(itemClickListener);
}
public BaseMixtureAdapter(ItemLongListener itemLongListener) {
super(itemLongListener);
}
public BaseMixtureAdapter(ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
super(itemClickListener, itemLongListener);
}
@Override
public final void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemLongListener.java
// public interface ItemLongListener {
// boolean onLongClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseViewHolder.java
// public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
//
// private ItemClickListener mItemClickListener;
// private ItemLongListener mItemLongListener;
//
// public BaseViewHolder(View itemView) {
// super(itemView);
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// }
//
// public BaseViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView);
// mItemLongListener = itemLongListener;
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mItemClickListener.onItemClick(v, position);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mItemLongListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mItemLongListener.onLongClick(v, position);
// }
// return false;
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/FooterViewHolder.java
// public class FooterViewHolder extends BaseViewHolder {
//
// public FooterViewHolder(View itemView) {
// super(itemView);
// }
//
// public FooterViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView, itemClickListener);
// }
//
// public FooterViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView, itemLongListener);
// }
//
// public FooterViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView, itemClickListener, itemLongListener);
// }
// }
// Path: library/src/main/java/com/dreamliner/rvhelper/adapter/BaseMixtureAdapter.java
import androidx.recyclerview.widget.RecyclerView;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.interfaces.ItemLongListener;
import com.dreamliner.rvhelper.viewholder.BaseViewHolder;
import com.dreamliner.rvhelper.viewholder.FooterViewHolder;
package com.dreamliner.rvhelper.adapter;
/**
* @author chenzj
* @Title: BaseAdapter
* @Description: 类的描述 -
* @date 2016/6/12 09:05
* @email [email protected]
*/
public abstract class BaseMixtureAdapter<T> extends BaseNormalAdapter<T, BaseViewHolder> {
public BaseMixtureAdapter() {
}
public BaseMixtureAdapter(ItemClickListener itemClickListener) {
super(itemClickListener);
}
public BaseMixtureAdapter(ItemLongListener itemLongListener) {
super(itemLongListener);
}
public BaseMixtureAdapter(ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
super(itemClickListener, itemLongListener);
}
@Override
public final void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { | if (!(holder instanceof FooterViewHolder)) { |
chenzj-king/RvHelper | demo/src/main/java/com/dreamliner/lib/rvhelper/sample/utils/DataBindingAdapter.java | // Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/ui/activity/banner/ImageAdapter.java
// public class ImageAdapter extends BannerAdapter<String, ImageAdapter.BannerViewHolder> {
//
// public ImageAdapter(List<String> dataList) {
// super(dataList);
// }
//
// @Override
// public BannerViewHolder onCreateHolder(ViewGroup parent, int viewType) {
// ImageView imageView = new ImageView(parent.getContext());
// imageView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
// imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
// return new BannerViewHolder(imageView);
// }
//
// @Override
// public void onBindView(BannerViewHolder holder, String data, int position, int size) {
// Glide.with(holder.imageView).load(data).into(holder.imageView);
// }
//
// static class BannerViewHolder extends RecyclerView.ViewHolder {
// ImageView imageView;
//
// BannerViewHolder(@NonNull ImageView view) {
// super(view);
// this.imageView = view;
// }
// }
// }
| import android.graphics.drawable.Drawable;
import android.widget.ImageView;
import com.dreamliner.lib.rvhelper.sample.R;
import com.dreamliner.lib.rvhelper.sample.ui.activity.banner.ImageAdapter;
import com.youth.banner.Banner;
import com.youth.banner.config.IndicatorConfig;
import com.youth.banner.indicator.CircleIndicator;
import com.youth.banner.listener.OnBannerListener;
import com.youth.banner.util.BannerUtils;
import java.util.ArrayList;
import java.util.List;
import androidx.databinding.BindingAdapter; | package com.dreamliner.lib.rvhelper.sample.utils;
/**
* Created by chenzj on 2017/3/8.
*/
public class DataBindingAdapter {
@BindingAdapter(value = {"imageUrl", "defaultImg", "radius"}, requireAll = false)
public static void setImage(ImageView imageView, String imageUrl, Drawable defaultImg, int radius) {
// RequestOptions requestOptions = new RequestOptions();
// requestOptions.optionalCenterCrop();
//
// if (defaultImg != null) {
// requestOptions.placeholder(defaultImg).error(defaultImg);
// } else {
// requestOptions.placeholder(R.drawable.bg_image_loading).error(R.drawable.bg_image_loading);
// }
// if (radius > 0) {
// requestOptions.bitmapTransform(new CenterCrop(imageView.getContext()),
// new RoundedCornersTransformation(PixelUtil.dp2px(radius), 0, RoundedCornersTransformation.CornerType.ALL));
// } else {
// requestOptions.bitmapTransform(new CenterCrop(imageView.getContext()));
// }
// Glide.with(imageView.getContext()).load(imageUrl).apply(requestOptions).into(imageView);
}
@BindingAdapter(value = {"data", "bannerListener"}, requireAll = false)
public static void setSlider(Banner banner, String data, OnBannerListener onBannerListener) {
List<String> banners = new ArrayList<>();
banners.add("https://res.darryring.com/activity/drSEM_storeLandingPage/temp/part04_banner01.jpg");
banners.add("https://res.darryring.com/activity/drSEM_storeLandingPage/temp/part04_banner02.jpg");
banners.add("https://res.darryring.com/activity/drSEM_storeLandingPage/temp/part04_banner03.jpg");
banners.add("https://static.darryring.com/ueditor/2017-03-28/1490687105.jpg");
| // Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/ui/activity/banner/ImageAdapter.java
// public class ImageAdapter extends BannerAdapter<String, ImageAdapter.BannerViewHolder> {
//
// public ImageAdapter(List<String> dataList) {
// super(dataList);
// }
//
// @Override
// public BannerViewHolder onCreateHolder(ViewGroup parent, int viewType) {
// ImageView imageView = new ImageView(parent.getContext());
// imageView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
// imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
// return new BannerViewHolder(imageView);
// }
//
// @Override
// public void onBindView(BannerViewHolder holder, String data, int position, int size) {
// Glide.with(holder.imageView).load(data).into(holder.imageView);
// }
//
// static class BannerViewHolder extends RecyclerView.ViewHolder {
// ImageView imageView;
//
// BannerViewHolder(@NonNull ImageView view) {
// super(view);
// this.imageView = view;
// }
// }
// }
// Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/utils/DataBindingAdapter.java
import android.graphics.drawable.Drawable;
import android.widget.ImageView;
import com.dreamliner.lib.rvhelper.sample.R;
import com.dreamliner.lib.rvhelper.sample.ui.activity.banner.ImageAdapter;
import com.youth.banner.Banner;
import com.youth.banner.config.IndicatorConfig;
import com.youth.banner.indicator.CircleIndicator;
import com.youth.banner.listener.OnBannerListener;
import com.youth.banner.util.BannerUtils;
import java.util.ArrayList;
import java.util.List;
import androidx.databinding.BindingAdapter;
package com.dreamliner.lib.rvhelper.sample.utils;
/**
* Created by chenzj on 2017/3/8.
*/
public class DataBindingAdapter {
@BindingAdapter(value = {"imageUrl", "defaultImg", "radius"}, requireAll = false)
public static void setImage(ImageView imageView, String imageUrl, Drawable defaultImg, int radius) {
// RequestOptions requestOptions = new RequestOptions();
// requestOptions.optionalCenterCrop();
//
// if (defaultImg != null) {
// requestOptions.placeholder(defaultImg).error(defaultImg);
// } else {
// requestOptions.placeholder(R.drawable.bg_image_loading).error(R.drawable.bg_image_loading);
// }
// if (radius > 0) {
// requestOptions.bitmapTransform(new CenterCrop(imageView.getContext()),
// new RoundedCornersTransformation(PixelUtil.dp2px(radius), 0, RoundedCornersTransformation.CornerType.ALL));
// } else {
// requestOptions.bitmapTransform(new CenterCrop(imageView.getContext()));
// }
// Glide.with(imageView.getContext()).load(imageUrl).apply(requestOptions).into(imageView);
}
@BindingAdapter(value = {"data", "bannerListener"}, requireAll = false)
public static void setSlider(Banner banner, String data, OnBannerListener onBannerListener) {
List<String> banners = new ArrayList<>();
banners.add("https://res.darryring.com/activity/drSEM_storeLandingPage/temp/part04_banner01.jpg");
banners.add("https://res.darryring.com/activity/drSEM_storeLandingPage/temp/part04_banner02.jpg");
banners.add("https://res.darryring.com/activity/drSEM_storeLandingPage/temp/part04_banner03.jpg");
banners.add("https://static.darryring.com/ueditor/2017-03-28/1490687105.jpg");
| banner.setAdapter(new ImageAdapter(banners)); |
chenzj-king/RvHelper | demo/src/main/java/com/dreamliner/lib/rvhelper/sample/view/DlLoadmoreView.java | // Path: library/src/main/java/com/dreamliner/loadmore/LoadMoreContainer.java
// public interface LoadMoreContainer {
//
// public void setShowLoadingForFirstPage(boolean showLoading);
//
// public void setAutoLoadMore(boolean autoLoadMore);
//
// public void setLoadMoreView(View view);
//
// public void setLoadMoreUIHandler(LoadMoreUIHandler handler);
//
// public void setLoadMoreHandler(LoadMoreHandler handler);
//
// /**
// * When data has loaded
// *
// * @param emptyResult
// * @param hasMore
// */
// public void loadMoreFinish(boolean emptyResult, boolean hasMore);
//
// /**
// * When something unexpected happened while loading the data
// *
// * @param errorCode
// * @param errorMessage
// */
// public void loadMoreError(int errorCode, String errorMessage);
// }
//
// Path: library/src/main/java/com/dreamliner/loadmore/LoadMoreUIHandler.java
// public interface LoadMoreUIHandler {
//
// public void onLoading(LoadMoreContainer container);
//
// public void onLoadFinish(LoadMoreContainer container, boolean empty, boolean hasMore);
//
// public void onWaitToLoadMore(LoadMoreContainer container);
//
// public void onLoadError(LoadMoreContainer container, int errorCode, String errorMessage);
// }
| import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.sample.R;
import com.dreamliner.loadingdrawable.LoadingView;
import com.dreamliner.loadmore.LoadMoreContainer;
import com.dreamliner.loadmore.LoadMoreUIHandler;
import androidx.annotation.StringRes; | package com.dreamliner.lib.rvhelper.sample.view;
/**
* @author chenzj
* @Title: DlLoadmoreView
* @Description: 类的描述 -
* @date 2016/10/9 22:18
* @email [email protected]
*/
public class DlLoadmoreView extends RelativeLayout implements LoadMoreUIHandler {
private LoadingView mLoadingView;
private TextView mFooterTv;
public DlLoadmoreView(Context context) {
this(context, null);
}
public DlLoadmoreView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public DlLoadmoreView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
setupViews();
}
private void setupViews() {
LayoutInflater.from(getContext()).inflate(R.layout.layout_dl_footerview, this);
mLoadingView = (LoadingView) findViewById(R.id.footer_indicatorview);
mFooterTv = (TextView) findViewById(R.id.footer_tv);
}
@Override | // Path: library/src/main/java/com/dreamliner/loadmore/LoadMoreContainer.java
// public interface LoadMoreContainer {
//
// public void setShowLoadingForFirstPage(boolean showLoading);
//
// public void setAutoLoadMore(boolean autoLoadMore);
//
// public void setLoadMoreView(View view);
//
// public void setLoadMoreUIHandler(LoadMoreUIHandler handler);
//
// public void setLoadMoreHandler(LoadMoreHandler handler);
//
// /**
// * When data has loaded
// *
// * @param emptyResult
// * @param hasMore
// */
// public void loadMoreFinish(boolean emptyResult, boolean hasMore);
//
// /**
// * When something unexpected happened while loading the data
// *
// * @param errorCode
// * @param errorMessage
// */
// public void loadMoreError(int errorCode, String errorMessage);
// }
//
// Path: library/src/main/java/com/dreamliner/loadmore/LoadMoreUIHandler.java
// public interface LoadMoreUIHandler {
//
// public void onLoading(LoadMoreContainer container);
//
// public void onLoadFinish(LoadMoreContainer container, boolean empty, boolean hasMore);
//
// public void onWaitToLoadMore(LoadMoreContainer container);
//
// public void onLoadError(LoadMoreContainer container, int errorCode, String errorMessage);
// }
// Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/view/DlLoadmoreView.java
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.sample.R;
import com.dreamliner.loadingdrawable.LoadingView;
import com.dreamliner.loadmore.LoadMoreContainer;
import com.dreamliner.loadmore.LoadMoreUIHandler;
import androidx.annotation.StringRes;
package com.dreamliner.lib.rvhelper.sample.view;
/**
* @author chenzj
* @Title: DlLoadmoreView
* @Description: 类的描述 -
* @date 2016/10/9 22:18
* @email [email protected]
*/
public class DlLoadmoreView extends RelativeLayout implements LoadMoreUIHandler {
private LoadingView mLoadingView;
private TextView mFooterTv;
public DlLoadmoreView(Context context) {
this(context, null);
}
public DlLoadmoreView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public DlLoadmoreView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
setupViews();
}
private void setupViews() {
LayoutInflater.from(getContext()).inflate(R.layout.layout_dl_footerview, this);
mLoadingView = (LoadingView) findViewById(R.id.footer_indicatorview);
mFooterTv = (TextView) findViewById(R.id.footer_tv);
}
@Override | public void onLoading(LoadMoreContainer container) { |
chenzj-king/RvHelper | demo/src/main/java/com/dreamliner/lib/rvhelper/sample/ui/activity/addressbook/AddressbookAdapter.java | // Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/entity/Addressbook.java
// public class Addressbook implements Serializable, ItemDecorationTag {
//
// private String realname;
//
// private String itemDecorationtag;
//
// public Addressbook() {
// }
//
// public Addressbook(String realname) {
// this.realname = realname;
// }
//
// public String getRealname() {
// return realname;
// }
//
// public void setRealname(String realname) {
// this.realname = realname;
// }
//
// public String getItemDecorationtag() {
// return itemDecorationtag;
// }
//
// public void setItemDecorationtag(String itemDecorationtag) {
// this.itemDecorationtag = itemDecorationtag;
// }
//
// @Override
// public String getTag() {
// return TextUtils.isEmpty(itemDecorationtag) ? "#" : itemDecorationtag;
// }
//
// @Override
// public String toString() {
// return "Addressbook{" +
// ", realname='" + realname + '\'' +
// ", itemDecorationtag='" + itemDecorationtag + '\'' +
// '}';
// }
// }
//
// Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/utils/CollectionUtils.java
// public class CollectionUtils {
//
// public static boolean isNotNull(Collection<?> collection) {
// if (collection != null && collection.size() > 0) {
// return true;
// }
// return false;
// }
//
// public static boolean isNotNull(HashMap<?, ?> collection) {
// if (collection != null && collection.size() > 0) {
// return true;
// }
// return false;
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/adapter/BaseMixtureAdapter.java
// public abstract class BaseMixtureAdapter<T> extends BaseNormalAdapter<T, BaseViewHolder> {
//
// public BaseMixtureAdapter() {
// }
//
// public BaseMixtureAdapter(ItemClickListener itemClickListener) {
// super(itemClickListener);
// }
//
// public BaseMixtureAdapter(ItemLongListener itemLongListener) {
// super(itemLongListener);
// }
//
// public BaseMixtureAdapter(ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemClickListener, itemLongListener);
// }
//
// @Override
// public final void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
// if (!(holder instanceof FooterViewHolder)) {
// bindView((BaseViewHolder) holder, position);
// }
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseViewHolder.java
// public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
//
// private ItemClickListener mItemClickListener;
// private ItemLongListener mItemLongListener;
//
// public BaseViewHolder(View itemView) {
// super(itemView);
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// }
//
// public BaseViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView);
// mItemLongListener = itemLongListener;
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mItemClickListener.onItemClick(v, position);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mItemLongListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mItemLongListener.onLongClick(v, position);
// }
// return false;
// }
// }
| import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.sample.R;
import com.dreamliner.lib.rvhelper.sample.entity.Addressbook;
import com.dreamliner.lib.rvhelper.sample.utils.CollectionUtils;
import com.dreamliner.rvhelper.adapter.BaseMixtureAdapter;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.viewholder.BaseViewHolder;
import java.util.HashMap;
import java.util.List;
import androidx.annotation.NonNull;
import butterknife.BindView;
import butterknife.ButterKnife; | package com.dreamliner.lib.rvhelper.sample.ui.activity.addressbook;
/**
* @author chenzj
* @Title: AddressbookAdapter
* @Description: 类的描述 -
* @date 2016/10/12 14:04
* @email [email protected]
*/
public class AddressbookAdapter extends BaseMixtureAdapter<Addressbook> {
private HashMap<String, Integer> mHashMap;
private final int ASSIST_SIGN = 0;
private final int NEW_SIGN = 1;
private final int LABEL = 2;
private final int NORAML = 3;
| // Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/entity/Addressbook.java
// public class Addressbook implements Serializable, ItemDecorationTag {
//
// private String realname;
//
// private String itemDecorationtag;
//
// public Addressbook() {
// }
//
// public Addressbook(String realname) {
// this.realname = realname;
// }
//
// public String getRealname() {
// return realname;
// }
//
// public void setRealname(String realname) {
// this.realname = realname;
// }
//
// public String getItemDecorationtag() {
// return itemDecorationtag;
// }
//
// public void setItemDecorationtag(String itemDecorationtag) {
// this.itemDecorationtag = itemDecorationtag;
// }
//
// @Override
// public String getTag() {
// return TextUtils.isEmpty(itemDecorationtag) ? "#" : itemDecorationtag;
// }
//
// @Override
// public String toString() {
// return "Addressbook{" +
// ", realname='" + realname + '\'' +
// ", itemDecorationtag='" + itemDecorationtag + '\'' +
// '}';
// }
// }
//
// Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/utils/CollectionUtils.java
// public class CollectionUtils {
//
// public static boolean isNotNull(Collection<?> collection) {
// if (collection != null && collection.size() > 0) {
// return true;
// }
// return false;
// }
//
// public static boolean isNotNull(HashMap<?, ?> collection) {
// if (collection != null && collection.size() > 0) {
// return true;
// }
// return false;
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/adapter/BaseMixtureAdapter.java
// public abstract class BaseMixtureAdapter<T> extends BaseNormalAdapter<T, BaseViewHolder> {
//
// public BaseMixtureAdapter() {
// }
//
// public BaseMixtureAdapter(ItemClickListener itemClickListener) {
// super(itemClickListener);
// }
//
// public BaseMixtureAdapter(ItemLongListener itemLongListener) {
// super(itemLongListener);
// }
//
// public BaseMixtureAdapter(ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemClickListener, itemLongListener);
// }
//
// @Override
// public final void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
// if (!(holder instanceof FooterViewHolder)) {
// bindView((BaseViewHolder) holder, position);
// }
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseViewHolder.java
// public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
//
// private ItemClickListener mItemClickListener;
// private ItemLongListener mItemLongListener;
//
// public BaseViewHolder(View itemView) {
// super(itemView);
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// }
//
// public BaseViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView);
// mItemLongListener = itemLongListener;
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mItemClickListener.onItemClick(v, position);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mItemLongListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mItemLongListener.onLongClick(v, position);
// }
// return false;
// }
// }
// Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/ui/activity/addressbook/AddressbookAdapter.java
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.sample.R;
import com.dreamliner.lib.rvhelper.sample.entity.Addressbook;
import com.dreamliner.lib.rvhelper.sample.utils.CollectionUtils;
import com.dreamliner.rvhelper.adapter.BaseMixtureAdapter;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.viewholder.BaseViewHolder;
import java.util.HashMap;
import java.util.List;
import androidx.annotation.NonNull;
import butterknife.BindView;
import butterknife.ButterKnife;
package com.dreamliner.lib.rvhelper.sample.ui.activity.addressbook;
/**
* @author chenzj
* @Title: AddressbookAdapter
* @Description: 类的描述 -
* @date 2016/10/12 14:04
* @email [email protected]
*/
public class AddressbookAdapter extends BaseMixtureAdapter<Addressbook> {
private HashMap<String, Integer> mHashMap;
private final int ASSIST_SIGN = 0;
private final int NEW_SIGN = 1;
private final int LABEL = 2;
private final int NORAML = 3;
| public AddressbookAdapter(ItemClickListener itemClickListener) { |
chenzj-king/RvHelper | demo/src/main/java/com/dreamliner/lib/rvhelper/sample/ui/activity/addressbook/AddressbookAdapter.java | // Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/entity/Addressbook.java
// public class Addressbook implements Serializable, ItemDecorationTag {
//
// private String realname;
//
// private String itemDecorationtag;
//
// public Addressbook() {
// }
//
// public Addressbook(String realname) {
// this.realname = realname;
// }
//
// public String getRealname() {
// return realname;
// }
//
// public void setRealname(String realname) {
// this.realname = realname;
// }
//
// public String getItemDecorationtag() {
// return itemDecorationtag;
// }
//
// public void setItemDecorationtag(String itemDecorationtag) {
// this.itemDecorationtag = itemDecorationtag;
// }
//
// @Override
// public String getTag() {
// return TextUtils.isEmpty(itemDecorationtag) ? "#" : itemDecorationtag;
// }
//
// @Override
// public String toString() {
// return "Addressbook{" +
// ", realname='" + realname + '\'' +
// ", itemDecorationtag='" + itemDecorationtag + '\'' +
// '}';
// }
// }
//
// Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/utils/CollectionUtils.java
// public class CollectionUtils {
//
// public static boolean isNotNull(Collection<?> collection) {
// if (collection != null && collection.size() > 0) {
// return true;
// }
// return false;
// }
//
// public static boolean isNotNull(HashMap<?, ?> collection) {
// if (collection != null && collection.size() > 0) {
// return true;
// }
// return false;
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/adapter/BaseMixtureAdapter.java
// public abstract class BaseMixtureAdapter<T> extends BaseNormalAdapter<T, BaseViewHolder> {
//
// public BaseMixtureAdapter() {
// }
//
// public BaseMixtureAdapter(ItemClickListener itemClickListener) {
// super(itemClickListener);
// }
//
// public BaseMixtureAdapter(ItemLongListener itemLongListener) {
// super(itemLongListener);
// }
//
// public BaseMixtureAdapter(ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemClickListener, itemLongListener);
// }
//
// @Override
// public final void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
// if (!(holder instanceof FooterViewHolder)) {
// bindView((BaseViewHolder) holder, position);
// }
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseViewHolder.java
// public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
//
// private ItemClickListener mItemClickListener;
// private ItemLongListener mItemLongListener;
//
// public BaseViewHolder(View itemView) {
// super(itemView);
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// }
//
// public BaseViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView);
// mItemLongListener = itemLongListener;
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mItemClickListener.onItemClick(v, position);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mItemLongListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mItemLongListener.onLongClick(v, position);
// }
// return false;
// }
// }
| import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.sample.R;
import com.dreamliner.lib.rvhelper.sample.entity.Addressbook;
import com.dreamliner.lib.rvhelper.sample.utils.CollectionUtils;
import com.dreamliner.rvhelper.adapter.BaseMixtureAdapter;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.viewholder.BaseViewHolder;
import java.util.HashMap;
import java.util.List;
import androidx.annotation.NonNull;
import butterknife.BindView;
import butterknife.ButterKnife; | package com.dreamliner.lib.rvhelper.sample.ui.activity.addressbook;
/**
* @author chenzj
* @Title: AddressbookAdapter
* @Description: 类的描述 -
* @date 2016/10/12 14:04
* @email [email protected]
*/
public class AddressbookAdapter extends BaseMixtureAdapter<Addressbook> {
private HashMap<String, Integer> mHashMap;
private final int ASSIST_SIGN = 0;
private final int NEW_SIGN = 1;
private final int LABEL = 2;
private final int NORAML = 3;
public AddressbookAdapter(ItemClickListener itemClickListener) {
super(itemClickListener);
mHashMap = new HashMap<>();
}
@Override
public int getItemViewType(int position) {
if (position == ASSIST_SIGN) {
return ASSIST_SIGN;
} else if (position == NEW_SIGN) {
return NEW_SIGN;
} else if (position == LABEL) {
return LABEL;
} else if (super.getItemViewType(position) != FOOTER_TYPE) {
return NORAML;
} else {
return super.getItemViewType(position);
}
}
@Override | // Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/entity/Addressbook.java
// public class Addressbook implements Serializable, ItemDecorationTag {
//
// private String realname;
//
// private String itemDecorationtag;
//
// public Addressbook() {
// }
//
// public Addressbook(String realname) {
// this.realname = realname;
// }
//
// public String getRealname() {
// return realname;
// }
//
// public void setRealname(String realname) {
// this.realname = realname;
// }
//
// public String getItemDecorationtag() {
// return itemDecorationtag;
// }
//
// public void setItemDecorationtag(String itemDecorationtag) {
// this.itemDecorationtag = itemDecorationtag;
// }
//
// @Override
// public String getTag() {
// return TextUtils.isEmpty(itemDecorationtag) ? "#" : itemDecorationtag;
// }
//
// @Override
// public String toString() {
// return "Addressbook{" +
// ", realname='" + realname + '\'' +
// ", itemDecorationtag='" + itemDecorationtag + '\'' +
// '}';
// }
// }
//
// Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/utils/CollectionUtils.java
// public class CollectionUtils {
//
// public static boolean isNotNull(Collection<?> collection) {
// if (collection != null && collection.size() > 0) {
// return true;
// }
// return false;
// }
//
// public static boolean isNotNull(HashMap<?, ?> collection) {
// if (collection != null && collection.size() > 0) {
// return true;
// }
// return false;
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/adapter/BaseMixtureAdapter.java
// public abstract class BaseMixtureAdapter<T> extends BaseNormalAdapter<T, BaseViewHolder> {
//
// public BaseMixtureAdapter() {
// }
//
// public BaseMixtureAdapter(ItemClickListener itemClickListener) {
// super(itemClickListener);
// }
//
// public BaseMixtureAdapter(ItemLongListener itemLongListener) {
// super(itemLongListener);
// }
//
// public BaseMixtureAdapter(ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemClickListener, itemLongListener);
// }
//
// @Override
// public final void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
// if (!(holder instanceof FooterViewHolder)) {
// bindView((BaseViewHolder) holder, position);
// }
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseViewHolder.java
// public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
//
// private ItemClickListener mItemClickListener;
// private ItemLongListener mItemLongListener;
//
// public BaseViewHolder(View itemView) {
// super(itemView);
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// }
//
// public BaseViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView);
// mItemLongListener = itemLongListener;
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mItemClickListener.onItemClick(v, position);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mItemLongListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mItemLongListener.onLongClick(v, position);
// }
// return false;
// }
// }
// Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/ui/activity/addressbook/AddressbookAdapter.java
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.sample.R;
import com.dreamliner.lib.rvhelper.sample.entity.Addressbook;
import com.dreamliner.lib.rvhelper.sample.utils.CollectionUtils;
import com.dreamliner.rvhelper.adapter.BaseMixtureAdapter;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.viewholder.BaseViewHolder;
import java.util.HashMap;
import java.util.List;
import androidx.annotation.NonNull;
import butterknife.BindView;
import butterknife.ButterKnife;
package com.dreamliner.lib.rvhelper.sample.ui.activity.addressbook;
/**
* @author chenzj
* @Title: AddressbookAdapter
* @Description: 类的描述 -
* @date 2016/10/12 14:04
* @email [email protected]
*/
public class AddressbookAdapter extends BaseMixtureAdapter<Addressbook> {
private HashMap<String, Integer> mHashMap;
private final int ASSIST_SIGN = 0;
private final int NEW_SIGN = 1;
private final int LABEL = 2;
private final int NORAML = 3;
public AddressbookAdapter(ItemClickListener itemClickListener) {
super(itemClickListener);
mHashMap = new HashMap<>();
}
@Override
public int getItemViewType(int position) {
if (position == ASSIST_SIGN) {
return ASSIST_SIGN;
} else if (position == NEW_SIGN) {
return NEW_SIGN;
} else if (position == LABEL) {
return LABEL;
} else if (super.getItemViewType(position) != FOOTER_TYPE) {
return NORAML;
} else {
return super.getItemViewType(position);
}
}
@Override | public BaseViewHolder createCustomViewHolder(ViewGroup parent, int viewType) { |
chenzj-king/RvHelper | demo/src/main/java/com/dreamliner/lib/rvhelper/sample/ui/base/BaseActivity.java | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
| import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.View;
import android.widget.Toast;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import java.lang.ref.WeakReference;
import androidx.annotation.StringRes;
import androidx.appcompat.app.AppCompatActivity;
import butterknife.ButterKnife; | // 防止遮盖虚拟按键
runOnUiThread(new Runnable() {
@Override
public void run() {
if (!TextUtils.isEmpty(msg)) {
if (mToast == null) {
mToast = Toast.makeText(getApplicationContext(), "" + msg, Toast.LENGTH_SHORT);
}
mToast.setText(msg);
mToast.show();
}
}
});
}
public void showToast(@StringRes final int resId) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (mToast == null) {
mToast = Toast.makeText(getApplicationContext(), resId, Toast.LENGTH_SHORT);
}
mToast.setText(resId);
mToast.show();
}
});
}
| // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
// Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/ui/base/BaseActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.View;
import android.widget.Toast;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import java.lang.ref.WeakReference;
import androidx.annotation.StringRes;
import androidx.appcompat.app.AppCompatActivity;
import butterknife.ButterKnife;
// 防止遮盖虚拟按键
runOnUiThread(new Runnable() {
@Override
public void run() {
if (!TextUtils.isEmpty(msg)) {
if (mToast == null) {
mToast = Toast.makeText(getApplicationContext(), "" + msg, Toast.LENGTH_SHORT);
}
mToast.setText(msg);
mToast.show();
}
}
});
}
public void showToast(@StringRes final int resId) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (mToast == null) {
mToast = Toast.makeText(getApplicationContext(), resId, Toast.LENGTH_SHORT);
}
mToast.setText(resId);
mToast.show();
}
});
}
| protected static class ItemClickIml implements ItemClickListener { |
chenzj-king/RvHelper | library/src/main/java/com/dreamliner/rvhelper/empty/DefaultEmptyLayout.java | // Path: library/src/main/java/com/dreamliner/rvhelper/view/CustomizedClickableSpan.java
// public class CustomizedClickableSpan extends ClickableSpan {
//
// private int mColorId;
// private Context mContext;
// private WeakReference<OnClickListener> mOnClickListener;
//
// public CustomizedClickableSpan(@ColorRes int colorId, Context context, OnClickListener onClickListener) {
// mColorId = colorId;
// mContext = context;
// mOnClickListener = new WeakReference<>(onClickListener);
// }
//
// @Override
// public void updateDrawState(TextPaint ds) {
// ds.setColor(mContext.getResources().getColor(mColorId));
// }
//
// @Override
// public void onClick(View widget) {
// OnClickListener onClickListener = mOnClickListener.get();
// if (null != onClickListener) {
// onClickListener.onClick(widget);
// }
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int DEFAULT_NULL = Integer.MAX_VALUE - 2;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NET_ERROR = Integer.MAX_VALUE;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NO_RESULT = Integer.MAX_VALUE - 1;
| import android.content.Context;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.AttributeSet;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.R;
import com.dreamliner.rvhelper.view.CustomizedClickableSpan;
import static com.dreamliner.rvhelper.util.StatusConstant.DEFAULT_NULL;
import static com.dreamliner.rvhelper.util.StatusConstant.NET_ERROR;
import static com.dreamliner.rvhelper.util.StatusConstant.NO_RESULT; | package com.dreamliner.rvhelper.empty;
/**
* @author chenzj
* @Title: DefaultEmptyLayout
* @Description: 类的描述 -
* @date 2016/10/8 23:19
* @email [email protected]
*/
public class DefaultEmptyLayout extends EmptyLayout {
private TextView mEmptyTipTv; | // Path: library/src/main/java/com/dreamliner/rvhelper/view/CustomizedClickableSpan.java
// public class CustomizedClickableSpan extends ClickableSpan {
//
// private int mColorId;
// private Context mContext;
// private WeakReference<OnClickListener> mOnClickListener;
//
// public CustomizedClickableSpan(@ColorRes int colorId, Context context, OnClickListener onClickListener) {
// mColorId = colorId;
// mContext = context;
// mOnClickListener = new WeakReference<>(onClickListener);
// }
//
// @Override
// public void updateDrawState(TextPaint ds) {
// ds.setColor(mContext.getResources().getColor(mColorId));
// }
//
// @Override
// public void onClick(View widget) {
// OnClickListener onClickListener = mOnClickListener.get();
// if (null != onClickListener) {
// onClickListener.onClick(widget);
// }
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int DEFAULT_NULL = Integer.MAX_VALUE - 2;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NET_ERROR = Integer.MAX_VALUE;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NO_RESULT = Integer.MAX_VALUE - 1;
// Path: library/src/main/java/com/dreamliner/rvhelper/empty/DefaultEmptyLayout.java
import android.content.Context;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.AttributeSet;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.R;
import com.dreamliner.rvhelper.view.CustomizedClickableSpan;
import static com.dreamliner.rvhelper.util.StatusConstant.DEFAULT_NULL;
import static com.dreamliner.rvhelper.util.StatusConstant.NET_ERROR;
import static com.dreamliner.rvhelper.util.StatusConstant.NO_RESULT;
package com.dreamliner.rvhelper.empty;
/**
* @author chenzj
* @Title: DefaultEmptyLayout
* @Description: 类的描述 -
* @date 2016/10/8 23:19
* @email [email protected]
*/
public class DefaultEmptyLayout extends EmptyLayout {
private TextView mEmptyTipTv; | private CustomizedClickableSpan mClickableSpan; |
chenzj-king/RvHelper | library/src/main/java/com/dreamliner/rvhelper/empty/DefaultEmptyLayout.java | // Path: library/src/main/java/com/dreamliner/rvhelper/view/CustomizedClickableSpan.java
// public class CustomizedClickableSpan extends ClickableSpan {
//
// private int mColorId;
// private Context mContext;
// private WeakReference<OnClickListener> mOnClickListener;
//
// public CustomizedClickableSpan(@ColorRes int colorId, Context context, OnClickListener onClickListener) {
// mColorId = colorId;
// mContext = context;
// mOnClickListener = new WeakReference<>(onClickListener);
// }
//
// @Override
// public void updateDrawState(TextPaint ds) {
// ds.setColor(mContext.getResources().getColor(mColorId));
// }
//
// @Override
// public void onClick(View widget) {
// OnClickListener onClickListener = mOnClickListener.get();
// if (null != onClickListener) {
// onClickListener.onClick(widget);
// }
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int DEFAULT_NULL = Integer.MAX_VALUE - 2;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NET_ERROR = Integer.MAX_VALUE;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NO_RESULT = Integer.MAX_VALUE - 1;
| import android.content.Context;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.AttributeSet;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.R;
import com.dreamliner.rvhelper.view.CustomizedClickableSpan;
import static com.dreamliner.rvhelper.util.StatusConstant.DEFAULT_NULL;
import static com.dreamliner.rvhelper.util.StatusConstant.NET_ERROR;
import static com.dreamliner.rvhelper.util.StatusConstant.NO_RESULT; | this(context, null);
}
public DefaultEmptyLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public DefaultEmptyLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mEmptyTipTv = (TextView) findViewById(R.id.empty_status_tv);
}
private void setEmptyTv(TextView textView, String tipStr, String clickStr) {
if (!TextUtils.isEmpty(clickStr)) {
SpannableString spStr = new SpannableString(tipStr + clickStr);
mClickableSpan = new CustomizedClickableSpan(R.color.new_bg, getContext().getApplicationContext(), mOnClickListener);
spStr.setSpan(mClickableSpan, tipStr.length(), tipStr.length() + clickStr.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
textView.setText(spStr);
textView.setMovementMethod(LinkMovementMethod.getInstance());
}
}
@Override
public void setEmptyType(int type) {
switch (type) { | // Path: library/src/main/java/com/dreamliner/rvhelper/view/CustomizedClickableSpan.java
// public class CustomizedClickableSpan extends ClickableSpan {
//
// private int mColorId;
// private Context mContext;
// private WeakReference<OnClickListener> mOnClickListener;
//
// public CustomizedClickableSpan(@ColorRes int colorId, Context context, OnClickListener onClickListener) {
// mColorId = colorId;
// mContext = context;
// mOnClickListener = new WeakReference<>(onClickListener);
// }
//
// @Override
// public void updateDrawState(TextPaint ds) {
// ds.setColor(mContext.getResources().getColor(mColorId));
// }
//
// @Override
// public void onClick(View widget) {
// OnClickListener onClickListener = mOnClickListener.get();
// if (null != onClickListener) {
// onClickListener.onClick(widget);
// }
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int DEFAULT_NULL = Integer.MAX_VALUE - 2;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NET_ERROR = Integer.MAX_VALUE;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NO_RESULT = Integer.MAX_VALUE - 1;
// Path: library/src/main/java/com/dreamliner/rvhelper/empty/DefaultEmptyLayout.java
import android.content.Context;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.AttributeSet;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.R;
import com.dreamliner.rvhelper.view.CustomizedClickableSpan;
import static com.dreamliner.rvhelper.util.StatusConstant.DEFAULT_NULL;
import static com.dreamliner.rvhelper.util.StatusConstant.NET_ERROR;
import static com.dreamliner.rvhelper.util.StatusConstant.NO_RESULT;
this(context, null);
}
public DefaultEmptyLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public DefaultEmptyLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mEmptyTipTv = (TextView) findViewById(R.id.empty_status_tv);
}
private void setEmptyTv(TextView textView, String tipStr, String clickStr) {
if (!TextUtils.isEmpty(clickStr)) {
SpannableString spStr = new SpannableString(tipStr + clickStr);
mClickableSpan = new CustomizedClickableSpan(R.color.new_bg, getContext().getApplicationContext(), mOnClickListener);
spStr.setSpan(mClickableSpan, tipStr.length(), tipStr.length() + clickStr.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
textView.setText(spStr);
textView.setMovementMethod(LinkMovementMethod.getInstance());
}
}
@Override
public void setEmptyType(int type) {
switch (type) { | case NET_ERROR: |
chenzj-king/RvHelper | library/src/main/java/com/dreamliner/rvhelper/empty/DefaultEmptyLayout.java | // Path: library/src/main/java/com/dreamliner/rvhelper/view/CustomizedClickableSpan.java
// public class CustomizedClickableSpan extends ClickableSpan {
//
// private int mColorId;
// private Context mContext;
// private WeakReference<OnClickListener> mOnClickListener;
//
// public CustomizedClickableSpan(@ColorRes int colorId, Context context, OnClickListener onClickListener) {
// mColorId = colorId;
// mContext = context;
// mOnClickListener = new WeakReference<>(onClickListener);
// }
//
// @Override
// public void updateDrawState(TextPaint ds) {
// ds.setColor(mContext.getResources().getColor(mColorId));
// }
//
// @Override
// public void onClick(View widget) {
// OnClickListener onClickListener = mOnClickListener.get();
// if (null != onClickListener) {
// onClickListener.onClick(widget);
// }
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int DEFAULT_NULL = Integer.MAX_VALUE - 2;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NET_ERROR = Integer.MAX_VALUE;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NO_RESULT = Integer.MAX_VALUE - 1;
| import android.content.Context;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.AttributeSet;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.R;
import com.dreamliner.rvhelper.view.CustomizedClickableSpan;
import static com.dreamliner.rvhelper.util.StatusConstant.DEFAULT_NULL;
import static com.dreamliner.rvhelper.util.StatusConstant.NET_ERROR;
import static com.dreamliner.rvhelper.util.StatusConstant.NO_RESULT; | public DefaultEmptyLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public DefaultEmptyLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mEmptyTipTv = (TextView) findViewById(R.id.empty_status_tv);
}
private void setEmptyTv(TextView textView, String tipStr, String clickStr) {
if (!TextUtils.isEmpty(clickStr)) {
SpannableString spStr = new SpannableString(tipStr + clickStr);
mClickableSpan = new CustomizedClickableSpan(R.color.new_bg, getContext().getApplicationContext(), mOnClickListener);
spStr.setSpan(mClickableSpan, tipStr.length(), tipStr.length() + clickStr.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
textView.setText(spStr);
textView.setMovementMethod(LinkMovementMethod.getInstance());
}
}
@Override
public void setEmptyType(int type) {
switch (type) {
case NET_ERROR:
setEmptyTv(mEmptyTipTv, "亲,网络有点差哦", "重新加载");
break; | // Path: library/src/main/java/com/dreamliner/rvhelper/view/CustomizedClickableSpan.java
// public class CustomizedClickableSpan extends ClickableSpan {
//
// private int mColorId;
// private Context mContext;
// private WeakReference<OnClickListener> mOnClickListener;
//
// public CustomizedClickableSpan(@ColorRes int colorId, Context context, OnClickListener onClickListener) {
// mColorId = colorId;
// mContext = context;
// mOnClickListener = new WeakReference<>(onClickListener);
// }
//
// @Override
// public void updateDrawState(TextPaint ds) {
// ds.setColor(mContext.getResources().getColor(mColorId));
// }
//
// @Override
// public void onClick(View widget) {
// OnClickListener onClickListener = mOnClickListener.get();
// if (null != onClickListener) {
// onClickListener.onClick(widget);
// }
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int DEFAULT_NULL = Integer.MAX_VALUE - 2;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NET_ERROR = Integer.MAX_VALUE;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NO_RESULT = Integer.MAX_VALUE - 1;
// Path: library/src/main/java/com/dreamliner/rvhelper/empty/DefaultEmptyLayout.java
import android.content.Context;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.AttributeSet;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.R;
import com.dreamliner.rvhelper.view.CustomizedClickableSpan;
import static com.dreamliner.rvhelper.util.StatusConstant.DEFAULT_NULL;
import static com.dreamliner.rvhelper.util.StatusConstant.NET_ERROR;
import static com.dreamliner.rvhelper.util.StatusConstant.NO_RESULT;
public DefaultEmptyLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public DefaultEmptyLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mEmptyTipTv = (TextView) findViewById(R.id.empty_status_tv);
}
private void setEmptyTv(TextView textView, String tipStr, String clickStr) {
if (!TextUtils.isEmpty(clickStr)) {
SpannableString spStr = new SpannableString(tipStr + clickStr);
mClickableSpan = new CustomizedClickableSpan(R.color.new_bg, getContext().getApplicationContext(), mOnClickListener);
spStr.setSpan(mClickableSpan, tipStr.length(), tipStr.length() + clickStr.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
textView.setText(spStr);
textView.setMovementMethod(LinkMovementMethod.getInstance());
}
}
@Override
public void setEmptyType(int type) {
switch (type) {
case NET_ERROR:
setEmptyTv(mEmptyTipTv, "亲,网络有点差哦", "重新加载");
break; | case NO_RESULT: |
chenzj-king/RvHelper | library/src/main/java/com/dreamliner/rvhelper/empty/DefaultEmptyLayout.java | // Path: library/src/main/java/com/dreamliner/rvhelper/view/CustomizedClickableSpan.java
// public class CustomizedClickableSpan extends ClickableSpan {
//
// private int mColorId;
// private Context mContext;
// private WeakReference<OnClickListener> mOnClickListener;
//
// public CustomizedClickableSpan(@ColorRes int colorId, Context context, OnClickListener onClickListener) {
// mColorId = colorId;
// mContext = context;
// mOnClickListener = new WeakReference<>(onClickListener);
// }
//
// @Override
// public void updateDrawState(TextPaint ds) {
// ds.setColor(mContext.getResources().getColor(mColorId));
// }
//
// @Override
// public void onClick(View widget) {
// OnClickListener onClickListener = mOnClickListener.get();
// if (null != onClickListener) {
// onClickListener.onClick(widget);
// }
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int DEFAULT_NULL = Integer.MAX_VALUE - 2;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NET_ERROR = Integer.MAX_VALUE;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NO_RESULT = Integer.MAX_VALUE - 1;
| import android.content.Context;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.AttributeSet;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.R;
import com.dreamliner.rvhelper.view.CustomizedClickableSpan;
import static com.dreamliner.rvhelper.util.StatusConstant.DEFAULT_NULL;
import static com.dreamliner.rvhelper.util.StatusConstant.NET_ERROR;
import static com.dreamliner.rvhelper.util.StatusConstant.NO_RESULT; |
public DefaultEmptyLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mEmptyTipTv = (TextView) findViewById(R.id.empty_status_tv);
}
private void setEmptyTv(TextView textView, String tipStr, String clickStr) {
if (!TextUtils.isEmpty(clickStr)) {
SpannableString spStr = new SpannableString(tipStr + clickStr);
mClickableSpan = new CustomizedClickableSpan(R.color.new_bg, getContext().getApplicationContext(), mOnClickListener);
spStr.setSpan(mClickableSpan, tipStr.length(), tipStr.length() + clickStr.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
textView.setText(spStr);
textView.setMovementMethod(LinkMovementMethod.getInstance());
}
}
@Override
public void setEmptyType(int type) {
switch (type) {
case NET_ERROR:
setEmptyTv(mEmptyTipTv, "亲,网络有点差哦", "重新加载");
break;
case NO_RESULT:
setEmptyTv(mEmptyTipTv, "亲,暂无数据", "重新加载");
break; | // Path: library/src/main/java/com/dreamliner/rvhelper/view/CustomizedClickableSpan.java
// public class CustomizedClickableSpan extends ClickableSpan {
//
// private int mColorId;
// private Context mContext;
// private WeakReference<OnClickListener> mOnClickListener;
//
// public CustomizedClickableSpan(@ColorRes int colorId, Context context, OnClickListener onClickListener) {
// mColorId = colorId;
// mContext = context;
// mOnClickListener = new WeakReference<>(onClickListener);
// }
//
// @Override
// public void updateDrawState(TextPaint ds) {
// ds.setColor(mContext.getResources().getColor(mColorId));
// }
//
// @Override
// public void onClick(View widget) {
// OnClickListener onClickListener = mOnClickListener.get();
// if (null != onClickListener) {
// onClickListener.onClick(widget);
// }
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int DEFAULT_NULL = Integer.MAX_VALUE - 2;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NET_ERROR = Integer.MAX_VALUE;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NO_RESULT = Integer.MAX_VALUE - 1;
// Path: library/src/main/java/com/dreamliner/rvhelper/empty/DefaultEmptyLayout.java
import android.content.Context;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.AttributeSet;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.R;
import com.dreamliner.rvhelper.view.CustomizedClickableSpan;
import static com.dreamliner.rvhelper.util.StatusConstant.DEFAULT_NULL;
import static com.dreamliner.rvhelper.util.StatusConstant.NET_ERROR;
import static com.dreamliner.rvhelper.util.StatusConstant.NO_RESULT;
public DefaultEmptyLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mEmptyTipTv = (TextView) findViewById(R.id.empty_status_tv);
}
private void setEmptyTv(TextView textView, String tipStr, String clickStr) {
if (!TextUtils.isEmpty(clickStr)) {
SpannableString spStr = new SpannableString(tipStr + clickStr);
mClickableSpan = new CustomizedClickableSpan(R.color.new_bg, getContext().getApplicationContext(), mOnClickListener);
spStr.setSpan(mClickableSpan, tipStr.length(), tipStr.length() + clickStr.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
textView.setText(spStr);
textView.setMovementMethod(LinkMovementMethod.getInstance());
}
}
@Override
public void setEmptyType(int type) {
switch (type) {
case NET_ERROR:
setEmptyTv(mEmptyTipTv, "亲,网络有点差哦", "重新加载");
break;
case NO_RESULT:
setEmptyTv(mEmptyTipTv, "亲,暂无数据", "重新加载");
break; | case DEFAULT_NULL: |
chenzj-king/RvHelper | library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseViewHolder.java | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemLongListener.java
// public interface ItemLongListener {
// boolean onLongClick(View view, int position);
// }
| import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.interfaces.ItemLongListener; | package com.dreamliner.rvhelper.viewholder;
/**
* @author chenzj
* @Title: BaseViewHolder
* @Description: 类的描述 - ViewHolder基类.实现了相关的点击回调
* @date 2016/6/14 15:18
* @email [email protected]
*/
public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
private ItemClickListener mItemClickListener; | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemLongListener.java
// public interface ItemLongListener {
// boolean onLongClick(View view, int position);
// }
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseViewHolder.java
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.interfaces.ItemLongListener;
package com.dreamliner.rvhelper.viewholder;
/**
* @author chenzj
* @Title: BaseViewHolder
* @Description: 类的描述 - ViewHolder基类.实现了相关的点击回调
* @date 2016/6/14 15:18
* @email [email protected]
*/
public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
private ItemClickListener mItemClickListener; | private ItemLongListener mItemLongListener; |
chenzj-king/RvHelper | library/src/main/java/com/dreamliner/rvhelper/viewholder/FooterViewHolder.java | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemLongListener.java
// public interface ItemLongListener {
// boolean onLongClick(View view, int position);
// }
| import android.view.View;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.interfaces.ItemLongListener; | package com.dreamliner.rvhelper.viewholder;
/**
* @author chenzj
* @Title: FooterViewHolder
* @Description: 类的描述 -
* @date 2016/9/25 19:57
* @email [email protected]
*/
public class FooterViewHolder extends BaseViewHolder {
public FooterViewHolder(View itemView) {
super(itemView);
}
| // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemLongListener.java
// public interface ItemLongListener {
// boolean onLongClick(View view, int position);
// }
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/FooterViewHolder.java
import android.view.View;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.interfaces.ItemLongListener;
package com.dreamliner.rvhelper.viewholder;
/**
* @author chenzj
* @Title: FooterViewHolder
* @Description: 类的描述 -
* @date 2016/9/25 19:57
* @email [email protected]
*/
public class FooterViewHolder extends BaseViewHolder {
public FooterViewHolder(View itemView) {
super(itemView);
}
| public FooterViewHolder(View itemView, ItemClickListener itemClickListener) { |
chenzj-king/RvHelper | library/src/main/java/com/dreamliner/rvhelper/viewholder/FooterViewHolder.java | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemLongListener.java
// public interface ItemLongListener {
// boolean onLongClick(View view, int position);
// }
| import android.view.View;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.interfaces.ItemLongListener; | package com.dreamliner.rvhelper.viewholder;
/**
* @author chenzj
* @Title: FooterViewHolder
* @Description: 类的描述 -
* @date 2016/9/25 19:57
* @email [email protected]
*/
public class FooterViewHolder extends BaseViewHolder {
public FooterViewHolder(View itemView) {
super(itemView);
}
public FooterViewHolder(View itemView, ItemClickListener itemClickListener) {
super(itemView, itemClickListener);
}
| // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemLongListener.java
// public interface ItemLongListener {
// boolean onLongClick(View view, int position);
// }
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/FooterViewHolder.java
import android.view.View;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.interfaces.ItemLongListener;
package com.dreamliner.rvhelper.viewholder;
/**
* @author chenzj
* @Title: FooterViewHolder
* @Description: 类的描述 -
* @date 2016/9/25 19:57
* @email [email protected]
*/
public class FooterViewHolder extends BaseViewHolder {
public FooterViewHolder(View itemView) {
super(itemView);
}
public FooterViewHolder(View itemView, ItemClickListener itemClickListener) {
super(itemView, itemClickListener);
}
| public FooterViewHolder(View itemView, ItemLongListener itemLongListener) { |
chenzj-king/RvHelper | demo/src/main/java/com/dreamliner/lib/rvhelper/sample/view/DlEmptyLayout.java | // Path: library/src/main/java/com/dreamliner/rvhelper/empty/EmptyLayout.java
// public abstract class EmptyLayout extends LinearLayout implements EmptyUIHandler {
//
// public EmptyLayout(Context context, AttributeSet attrs, int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/view/CustomizedClickableSpan.java
// public class CustomizedClickableSpan extends ClickableSpan {
//
// private int mColorId;
// private Context mContext;
// private WeakReference<OnClickListener> mOnClickListener;
//
// public CustomizedClickableSpan(@ColorRes int colorId, Context context, OnClickListener onClickListener) {
// mColorId = colorId;
// mContext = context;
// mOnClickListener = new WeakReference<>(onClickListener);
// }
//
// @Override
// public void updateDrawState(TextPaint ds) {
// ds.setColor(mContext.getResources().getColor(mColorId));
// }
//
// @Override
// public void onClick(View widget) {
// OnClickListener onClickListener = mOnClickListener.get();
// if (null != onClickListener) {
// onClickListener.onClick(widget);
// }
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int DEFAULT_NULL = Integer.MAX_VALUE - 2;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NET_ERROR = Integer.MAX_VALUE;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NO_RESULT = Integer.MAX_VALUE - 1;
| import android.content.Context;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.sample.R;
import com.dreamliner.rvhelper.empty.EmptyLayout;
import com.dreamliner.rvhelper.view.CustomizedClickableSpan;
import static com.dreamliner.rvhelper.util.StatusConstant.DEFAULT_NULL;
import static com.dreamliner.rvhelper.util.StatusConstant.NET_ERROR;
import static com.dreamliner.rvhelper.util.StatusConstant.NO_RESULT; | package com.dreamliner.lib.rvhelper.sample.view;
/**
* @author chenzj
* @Title: DlEmptyLayout
* @Description: 类的描述 -
* @date 2016/10/9 22:57
* @email [email protected]
*/
public class DlEmptyLayout extends EmptyLayout {
private ImageView mEmptyIv;
private TextView mEmtptTipTv; | // Path: library/src/main/java/com/dreamliner/rvhelper/empty/EmptyLayout.java
// public abstract class EmptyLayout extends LinearLayout implements EmptyUIHandler {
//
// public EmptyLayout(Context context, AttributeSet attrs, int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/view/CustomizedClickableSpan.java
// public class CustomizedClickableSpan extends ClickableSpan {
//
// private int mColorId;
// private Context mContext;
// private WeakReference<OnClickListener> mOnClickListener;
//
// public CustomizedClickableSpan(@ColorRes int colorId, Context context, OnClickListener onClickListener) {
// mColorId = colorId;
// mContext = context;
// mOnClickListener = new WeakReference<>(onClickListener);
// }
//
// @Override
// public void updateDrawState(TextPaint ds) {
// ds.setColor(mContext.getResources().getColor(mColorId));
// }
//
// @Override
// public void onClick(View widget) {
// OnClickListener onClickListener = mOnClickListener.get();
// if (null != onClickListener) {
// onClickListener.onClick(widget);
// }
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int DEFAULT_NULL = Integer.MAX_VALUE - 2;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NET_ERROR = Integer.MAX_VALUE;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NO_RESULT = Integer.MAX_VALUE - 1;
// Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/view/DlEmptyLayout.java
import android.content.Context;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.sample.R;
import com.dreamliner.rvhelper.empty.EmptyLayout;
import com.dreamliner.rvhelper.view.CustomizedClickableSpan;
import static com.dreamliner.rvhelper.util.StatusConstant.DEFAULT_NULL;
import static com.dreamliner.rvhelper.util.StatusConstant.NET_ERROR;
import static com.dreamliner.rvhelper.util.StatusConstant.NO_RESULT;
package com.dreamliner.lib.rvhelper.sample.view;
/**
* @author chenzj
* @Title: DlEmptyLayout
* @Description: 类的描述 -
* @date 2016/10/9 22:57
* @email [email protected]
*/
public class DlEmptyLayout extends EmptyLayout {
private ImageView mEmptyIv;
private TextView mEmtptTipTv; | private CustomizedClickableSpan mClickableSpan; |
chenzj-king/RvHelper | demo/src/main/java/com/dreamliner/lib/rvhelper/sample/view/DlEmptyLayout.java | // Path: library/src/main/java/com/dreamliner/rvhelper/empty/EmptyLayout.java
// public abstract class EmptyLayout extends LinearLayout implements EmptyUIHandler {
//
// public EmptyLayout(Context context, AttributeSet attrs, int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/view/CustomizedClickableSpan.java
// public class CustomizedClickableSpan extends ClickableSpan {
//
// private int mColorId;
// private Context mContext;
// private WeakReference<OnClickListener> mOnClickListener;
//
// public CustomizedClickableSpan(@ColorRes int colorId, Context context, OnClickListener onClickListener) {
// mColorId = colorId;
// mContext = context;
// mOnClickListener = new WeakReference<>(onClickListener);
// }
//
// @Override
// public void updateDrawState(TextPaint ds) {
// ds.setColor(mContext.getResources().getColor(mColorId));
// }
//
// @Override
// public void onClick(View widget) {
// OnClickListener onClickListener = mOnClickListener.get();
// if (null != onClickListener) {
// onClickListener.onClick(widget);
// }
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int DEFAULT_NULL = Integer.MAX_VALUE - 2;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NET_ERROR = Integer.MAX_VALUE;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NO_RESULT = Integer.MAX_VALUE - 1;
| import android.content.Context;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.sample.R;
import com.dreamliner.rvhelper.empty.EmptyLayout;
import com.dreamliner.rvhelper.view.CustomizedClickableSpan;
import static com.dreamliner.rvhelper.util.StatusConstant.DEFAULT_NULL;
import static com.dreamliner.rvhelper.util.StatusConstant.NET_ERROR;
import static com.dreamliner.rvhelper.util.StatusConstant.NO_RESULT; | package com.dreamliner.lib.rvhelper.sample.view;
/**
* @author chenzj
* @Title: DlEmptyLayout
* @Description: 类的描述 -
* @date 2016/10/9 22:57
* @email [email protected]
*/
public class DlEmptyLayout extends EmptyLayout {
private ImageView mEmptyIv;
private TextView mEmtptTipTv;
private CustomizedClickableSpan mClickableSpan;
private OnClickListener mOnClickListener;
public DlEmptyLayout(Context context) {
this(context, null);
}
public DlEmptyLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public DlEmptyLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mEmptyIv = (ImageView) findViewById(R.id.empty_status_iv);
mEmtptTipTv = (TextView) findViewById(R.id.empty_status_tv);
}
@Override
public void setEmptyType(int type) {
switch (type) { | // Path: library/src/main/java/com/dreamliner/rvhelper/empty/EmptyLayout.java
// public abstract class EmptyLayout extends LinearLayout implements EmptyUIHandler {
//
// public EmptyLayout(Context context, AttributeSet attrs, int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/view/CustomizedClickableSpan.java
// public class CustomizedClickableSpan extends ClickableSpan {
//
// private int mColorId;
// private Context mContext;
// private WeakReference<OnClickListener> mOnClickListener;
//
// public CustomizedClickableSpan(@ColorRes int colorId, Context context, OnClickListener onClickListener) {
// mColorId = colorId;
// mContext = context;
// mOnClickListener = new WeakReference<>(onClickListener);
// }
//
// @Override
// public void updateDrawState(TextPaint ds) {
// ds.setColor(mContext.getResources().getColor(mColorId));
// }
//
// @Override
// public void onClick(View widget) {
// OnClickListener onClickListener = mOnClickListener.get();
// if (null != onClickListener) {
// onClickListener.onClick(widget);
// }
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int DEFAULT_NULL = Integer.MAX_VALUE - 2;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NET_ERROR = Integer.MAX_VALUE;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NO_RESULT = Integer.MAX_VALUE - 1;
// Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/view/DlEmptyLayout.java
import android.content.Context;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.sample.R;
import com.dreamliner.rvhelper.empty.EmptyLayout;
import com.dreamliner.rvhelper.view.CustomizedClickableSpan;
import static com.dreamliner.rvhelper.util.StatusConstant.DEFAULT_NULL;
import static com.dreamliner.rvhelper.util.StatusConstant.NET_ERROR;
import static com.dreamliner.rvhelper.util.StatusConstant.NO_RESULT;
package com.dreamliner.lib.rvhelper.sample.view;
/**
* @author chenzj
* @Title: DlEmptyLayout
* @Description: 类的描述 -
* @date 2016/10/9 22:57
* @email [email protected]
*/
public class DlEmptyLayout extends EmptyLayout {
private ImageView mEmptyIv;
private TextView mEmtptTipTv;
private CustomizedClickableSpan mClickableSpan;
private OnClickListener mOnClickListener;
public DlEmptyLayout(Context context) {
this(context, null);
}
public DlEmptyLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public DlEmptyLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mEmptyIv = (ImageView) findViewById(R.id.empty_status_iv);
mEmtptTipTv = (TextView) findViewById(R.id.empty_status_tv);
}
@Override
public void setEmptyType(int type) {
switch (type) { | case NET_ERROR: |
chenzj-king/RvHelper | demo/src/main/java/com/dreamliner/lib/rvhelper/sample/view/DlEmptyLayout.java | // Path: library/src/main/java/com/dreamliner/rvhelper/empty/EmptyLayout.java
// public abstract class EmptyLayout extends LinearLayout implements EmptyUIHandler {
//
// public EmptyLayout(Context context, AttributeSet attrs, int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/view/CustomizedClickableSpan.java
// public class CustomizedClickableSpan extends ClickableSpan {
//
// private int mColorId;
// private Context mContext;
// private WeakReference<OnClickListener> mOnClickListener;
//
// public CustomizedClickableSpan(@ColorRes int colorId, Context context, OnClickListener onClickListener) {
// mColorId = colorId;
// mContext = context;
// mOnClickListener = new WeakReference<>(onClickListener);
// }
//
// @Override
// public void updateDrawState(TextPaint ds) {
// ds.setColor(mContext.getResources().getColor(mColorId));
// }
//
// @Override
// public void onClick(View widget) {
// OnClickListener onClickListener = mOnClickListener.get();
// if (null != onClickListener) {
// onClickListener.onClick(widget);
// }
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int DEFAULT_NULL = Integer.MAX_VALUE - 2;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NET_ERROR = Integer.MAX_VALUE;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NO_RESULT = Integer.MAX_VALUE - 1;
| import android.content.Context;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.sample.R;
import com.dreamliner.rvhelper.empty.EmptyLayout;
import com.dreamliner.rvhelper.view.CustomizedClickableSpan;
import static com.dreamliner.rvhelper.util.StatusConstant.DEFAULT_NULL;
import static com.dreamliner.rvhelper.util.StatusConstant.NET_ERROR;
import static com.dreamliner.rvhelper.util.StatusConstant.NO_RESULT; | package com.dreamliner.lib.rvhelper.sample.view;
/**
* @author chenzj
* @Title: DlEmptyLayout
* @Description: 类的描述 -
* @date 2016/10/9 22:57
* @email [email protected]
*/
public class DlEmptyLayout extends EmptyLayout {
private ImageView mEmptyIv;
private TextView mEmtptTipTv;
private CustomizedClickableSpan mClickableSpan;
private OnClickListener mOnClickListener;
public DlEmptyLayout(Context context) {
this(context, null);
}
public DlEmptyLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public DlEmptyLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mEmptyIv = (ImageView) findViewById(R.id.empty_status_iv);
mEmtptTipTv = (TextView) findViewById(R.id.empty_status_tv);
}
@Override
public void setEmptyType(int type) {
switch (type) {
case NET_ERROR:
mEmptyIv.setImageResource(R.drawable.ic_list_status_net_error);
setEmptyTv(mEmtptTipTv, "亲,网络有点差哦", "自定义重新加载");
break; | // Path: library/src/main/java/com/dreamliner/rvhelper/empty/EmptyLayout.java
// public abstract class EmptyLayout extends LinearLayout implements EmptyUIHandler {
//
// public EmptyLayout(Context context, AttributeSet attrs, int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/view/CustomizedClickableSpan.java
// public class CustomizedClickableSpan extends ClickableSpan {
//
// private int mColorId;
// private Context mContext;
// private WeakReference<OnClickListener> mOnClickListener;
//
// public CustomizedClickableSpan(@ColorRes int colorId, Context context, OnClickListener onClickListener) {
// mColorId = colorId;
// mContext = context;
// mOnClickListener = new WeakReference<>(onClickListener);
// }
//
// @Override
// public void updateDrawState(TextPaint ds) {
// ds.setColor(mContext.getResources().getColor(mColorId));
// }
//
// @Override
// public void onClick(View widget) {
// OnClickListener onClickListener = mOnClickListener.get();
// if (null != onClickListener) {
// onClickListener.onClick(widget);
// }
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int DEFAULT_NULL = Integer.MAX_VALUE - 2;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NET_ERROR = Integer.MAX_VALUE;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NO_RESULT = Integer.MAX_VALUE - 1;
// Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/view/DlEmptyLayout.java
import android.content.Context;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.sample.R;
import com.dreamliner.rvhelper.empty.EmptyLayout;
import com.dreamliner.rvhelper.view.CustomizedClickableSpan;
import static com.dreamliner.rvhelper.util.StatusConstant.DEFAULT_NULL;
import static com.dreamliner.rvhelper.util.StatusConstant.NET_ERROR;
import static com.dreamliner.rvhelper.util.StatusConstant.NO_RESULT;
package com.dreamliner.lib.rvhelper.sample.view;
/**
* @author chenzj
* @Title: DlEmptyLayout
* @Description: 类的描述 -
* @date 2016/10/9 22:57
* @email [email protected]
*/
public class DlEmptyLayout extends EmptyLayout {
private ImageView mEmptyIv;
private TextView mEmtptTipTv;
private CustomizedClickableSpan mClickableSpan;
private OnClickListener mOnClickListener;
public DlEmptyLayout(Context context) {
this(context, null);
}
public DlEmptyLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public DlEmptyLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mEmptyIv = (ImageView) findViewById(R.id.empty_status_iv);
mEmtptTipTv = (TextView) findViewById(R.id.empty_status_tv);
}
@Override
public void setEmptyType(int type) {
switch (type) {
case NET_ERROR:
mEmptyIv.setImageResource(R.drawable.ic_list_status_net_error);
setEmptyTv(mEmtptTipTv, "亲,网络有点差哦", "自定义重新加载");
break; | case NO_RESULT: |
chenzj-king/RvHelper | demo/src/main/java/com/dreamliner/lib/rvhelper/sample/view/DlEmptyLayout.java | // Path: library/src/main/java/com/dreamliner/rvhelper/empty/EmptyLayout.java
// public abstract class EmptyLayout extends LinearLayout implements EmptyUIHandler {
//
// public EmptyLayout(Context context, AttributeSet attrs, int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/view/CustomizedClickableSpan.java
// public class CustomizedClickableSpan extends ClickableSpan {
//
// private int mColorId;
// private Context mContext;
// private WeakReference<OnClickListener> mOnClickListener;
//
// public CustomizedClickableSpan(@ColorRes int colorId, Context context, OnClickListener onClickListener) {
// mColorId = colorId;
// mContext = context;
// mOnClickListener = new WeakReference<>(onClickListener);
// }
//
// @Override
// public void updateDrawState(TextPaint ds) {
// ds.setColor(mContext.getResources().getColor(mColorId));
// }
//
// @Override
// public void onClick(View widget) {
// OnClickListener onClickListener = mOnClickListener.get();
// if (null != onClickListener) {
// onClickListener.onClick(widget);
// }
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int DEFAULT_NULL = Integer.MAX_VALUE - 2;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NET_ERROR = Integer.MAX_VALUE;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NO_RESULT = Integer.MAX_VALUE - 1;
| import android.content.Context;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.sample.R;
import com.dreamliner.rvhelper.empty.EmptyLayout;
import com.dreamliner.rvhelper.view.CustomizedClickableSpan;
import static com.dreamliner.rvhelper.util.StatusConstant.DEFAULT_NULL;
import static com.dreamliner.rvhelper.util.StatusConstant.NET_ERROR;
import static com.dreamliner.rvhelper.util.StatusConstant.NO_RESULT; | public DlEmptyLayout(Context context) {
this(context, null);
}
public DlEmptyLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public DlEmptyLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mEmptyIv = (ImageView) findViewById(R.id.empty_status_iv);
mEmtptTipTv = (TextView) findViewById(R.id.empty_status_tv);
}
@Override
public void setEmptyType(int type) {
switch (type) {
case NET_ERROR:
mEmptyIv.setImageResource(R.drawable.ic_list_status_net_error);
setEmptyTv(mEmtptTipTv, "亲,网络有点差哦", "自定义重新加载");
break;
case NO_RESULT:
mEmptyIv.setImageResource(R.drawable.ic_list_status_no_result);
setEmptyTv(mEmtptTipTv, "亲,暂无数据", "自定义重新加载");
break; | // Path: library/src/main/java/com/dreamliner/rvhelper/empty/EmptyLayout.java
// public abstract class EmptyLayout extends LinearLayout implements EmptyUIHandler {
//
// public EmptyLayout(Context context, AttributeSet attrs, int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/view/CustomizedClickableSpan.java
// public class CustomizedClickableSpan extends ClickableSpan {
//
// private int mColorId;
// private Context mContext;
// private WeakReference<OnClickListener> mOnClickListener;
//
// public CustomizedClickableSpan(@ColorRes int colorId, Context context, OnClickListener onClickListener) {
// mColorId = colorId;
// mContext = context;
// mOnClickListener = new WeakReference<>(onClickListener);
// }
//
// @Override
// public void updateDrawState(TextPaint ds) {
// ds.setColor(mContext.getResources().getColor(mColorId));
// }
//
// @Override
// public void onClick(View widget) {
// OnClickListener onClickListener = mOnClickListener.get();
// if (null != onClickListener) {
// onClickListener.onClick(widget);
// }
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int DEFAULT_NULL = Integer.MAX_VALUE - 2;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NET_ERROR = Integer.MAX_VALUE;
//
// Path: library/src/main/java/com/dreamliner/rvhelper/util/StatusConstant.java
// public static final int NO_RESULT = Integer.MAX_VALUE - 1;
// Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/view/DlEmptyLayout.java
import android.content.Context;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.sample.R;
import com.dreamliner.rvhelper.empty.EmptyLayout;
import com.dreamliner.rvhelper.view.CustomizedClickableSpan;
import static com.dreamliner.rvhelper.util.StatusConstant.DEFAULT_NULL;
import static com.dreamliner.rvhelper.util.StatusConstant.NET_ERROR;
import static com.dreamliner.rvhelper.util.StatusConstant.NO_RESULT;
public DlEmptyLayout(Context context) {
this(context, null);
}
public DlEmptyLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public DlEmptyLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mEmptyIv = (ImageView) findViewById(R.id.empty_status_iv);
mEmtptTipTv = (TextView) findViewById(R.id.empty_status_tv);
}
@Override
public void setEmptyType(int type) {
switch (type) {
case NET_ERROR:
mEmptyIv.setImageResource(R.drawable.ic_list_status_net_error);
setEmptyTv(mEmtptTipTv, "亲,网络有点差哦", "自定义重新加载");
break;
case NO_RESULT:
mEmptyIv.setImageResource(R.drawable.ic_list_status_no_result);
setEmptyTv(mEmtptTipTv, "亲,暂无数据", "自定义重新加载");
break; | case DEFAULT_NULL: |
chenzj-king/RvHelper | demo/src/main/java/com/dreamliner/lib/rvhelper/sample/view/LetterView.java | // Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/utils/PixelUtil.java
// public class PixelUtil {
//
// /**
// * The mContext.
// */
// private static Context mContext;
//
// public static void init(Context context) {
// mContext = context;
// }
//
// /**
// * dp转 px.
// *
// * @param value the value
// * @return the int
// */
// public static int dp2px(float value) {
// final float scale = mContext.getResources().getDisplayMetrics().densityDpi;
// return (int) (value * (scale / 160) + 0.5f);
// }
//
// /**
// * dp转 px.
// *
// * @param value the value
// * @param context the mContext
// * @return the int
// */
// public static int dp2px(float value, Context context) {
// final float scale = context.getResources().getDisplayMetrics().densityDpi;
// return (int) (value * (scale / 160) + 0.5f);
// }
//
// /**
// * px转dp.
// *
// * @param value the value
// * @return the int
// */
// public static int px2dp(float value) {
// final float scale = mContext.getResources().getDisplayMetrics().densityDpi;
// return (int) ((value * 160) / scale + 0.5f);
// }
//
// /**
// * px转dp.
// *
// * @param value the value
// * @param context the mContext
// * @return the int
// */
// public static int px2dp(float value, Context context) {
// final float scale = context.getResources().getDisplayMetrics().densityDpi;
// return (int) ((value * 160) / scale + 0.5f);
// }
//
// /**
// * sp转px.
// *
// * @param value the value
// * @return the int
// */
// public static int sp2px(float value) {
// Resources r;
// if (mContext == null) {
// r = Resources.getSystem();
// } else {
// r = mContext.getResources();
// }
// float spvalue = value * r.getDisplayMetrics().scaledDensity;
// return (int) (spvalue + 0.5f);
// }
//
// /**
// * sp转px.
// *
// * @param value the value
// * @param context the mContext
// * @return the int
// */
// public static int sp2px(float value, Context context) {
// Resources r;
// if (context == null) {
// r = Resources.getSystem();
// } else {
// r = context.getResources();
// }
// float spvalue = value * r.getDisplayMetrics().scaledDensity;
// return (int) (spvalue + 0.5f);
// }
//
// /**
// * px转sp.
// *
// * @param value the value
// * @return the int
// */
// public static int px2sp(float value) {
// final float scale = mContext.getResources().getDisplayMetrics().scaledDensity;
// return (int) (value / scale + 0.5f);
// }
//
// /**
// * px转sp.
// *
// * @param value the value
// * @param context the mContext
// * @return the int
// */
// public static int px2sp(float value, Context context) {
// final float scale = context.getResources().getDisplayMetrics().scaledDensity;
// return (int) (value / scale + 0.5f);
// }
//
//
// }
| import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.sample.R;
import com.dreamliner.lib.rvhelper.sample.utils.PixelUtil; | package com.dreamliner.lib.rvhelper.sample.view;
/**
* @文件名: MyLetterView
* @功能描述: 通讯录右侧快速滚动栏
* @Create by chenzj on 2015-12-6 下午8:35:01
* @email: [email protected]
* @修改记录:
*/
public class LetterView extends View {
// 触摸事件
private OnTouchingLetterChangedListener onTouchingLetterChangedListener;
// 26个字母
public static String[] b = {"↑", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q",
"R", "S", "T", "U", "V", "W", "X", "Y", "Z", "#"};
private int choose = -1;// 选中
private Paint paint = new Paint();
private TextView mTextDialog;
public void setTextView(TextView mTextDialog) {
this.mTextDialog = mTextDialog;
}
public LetterView(Context context) {
super(context);
}
public LetterView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public LetterView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
/**
* 重写这个方法
*/
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// 获取焦点改变背景颜色.
int height = getHeight();// 获取对应高度
int width = getWidth(); // 获取对应宽度
int singleHeight = height / b.length;// 获取每一个字母的高度
for (int i = 0; i < b.length; i++) {
paint.setColor(Color.parseColor("#9da0a4"));
paint.setTypeface(Typeface.DEFAULT_BOLD);
paint.setAntiAlias(true); | // Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/utils/PixelUtil.java
// public class PixelUtil {
//
// /**
// * The mContext.
// */
// private static Context mContext;
//
// public static void init(Context context) {
// mContext = context;
// }
//
// /**
// * dp转 px.
// *
// * @param value the value
// * @return the int
// */
// public static int dp2px(float value) {
// final float scale = mContext.getResources().getDisplayMetrics().densityDpi;
// return (int) (value * (scale / 160) + 0.5f);
// }
//
// /**
// * dp转 px.
// *
// * @param value the value
// * @param context the mContext
// * @return the int
// */
// public static int dp2px(float value, Context context) {
// final float scale = context.getResources().getDisplayMetrics().densityDpi;
// return (int) (value * (scale / 160) + 0.5f);
// }
//
// /**
// * px转dp.
// *
// * @param value the value
// * @return the int
// */
// public static int px2dp(float value) {
// final float scale = mContext.getResources().getDisplayMetrics().densityDpi;
// return (int) ((value * 160) / scale + 0.5f);
// }
//
// /**
// * px转dp.
// *
// * @param value the value
// * @param context the mContext
// * @return the int
// */
// public static int px2dp(float value, Context context) {
// final float scale = context.getResources().getDisplayMetrics().densityDpi;
// return (int) ((value * 160) / scale + 0.5f);
// }
//
// /**
// * sp转px.
// *
// * @param value the value
// * @return the int
// */
// public static int sp2px(float value) {
// Resources r;
// if (mContext == null) {
// r = Resources.getSystem();
// } else {
// r = mContext.getResources();
// }
// float spvalue = value * r.getDisplayMetrics().scaledDensity;
// return (int) (spvalue + 0.5f);
// }
//
// /**
// * sp转px.
// *
// * @param value the value
// * @param context the mContext
// * @return the int
// */
// public static int sp2px(float value, Context context) {
// Resources r;
// if (context == null) {
// r = Resources.getSystem();
// } else {
// r = context.getResources();
// }
// float spvalue = value * r.getDisplayMetrics().scaledDensity;
// return (int) (spvalue + 0.5f);
// }
//
// /**
// * px转sp.
// *
// * @param value the value
// * @return the int
// */
// public static int px2sp(float value) {
// final float scale = mContext.getResources().getDisplayMetrics().scaledDensity;
// return (int) (value / scale + 0.5f);
// }
//
// /**
// * px转sp.
// *
// * @param value the value
// * @param context the mContext
// * @return the int
// */
// public static int px2sp(float value, Context context) {
// final float scale = context.getResources().getDisplayMetrics().scaledDensity;
// return (int) (value / scale + 0.5f);
// }
//
//
// }
// Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/view/LetterView.java
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.sample.R;
import com.dreamliner.lib.rvhelper.sample.utils.PixelUtil;
package com.dreamliner.lib.rvhelper.sample.view;
/**
* @文件名: MyLetterView
* @功能描述: 通讯录右侧快速滚动栏
* @Create by chenzj on 2015-12-6 下午8:35:01
* @email: [email protected]
* @修改记录:
*/
public class LetterView extends View {
// 触摸事件
private OnTouchingLetterChangedListener onTouchingLetterChangedListener;
// 26个字母
public static String[] b = {"↑", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q",
"R", "S", "T", "U", "V", "W", "X", "Y", "Z", "#"};
private int choose = -1;// 选中
private Paint paint = new Paint();
private TextView mTextDialog;
public void setTextView(TextView mTextDialog) {
this.mTextDialog = mTextDialog;
}
public LetterView(Context context) {
super(context);
}
public LetterView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public LetterView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
/**
* 重写这个方法
*/
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// 获取焦点改变背景颜色.
int height = getHeight();// 获取对应高度
int width = getWidth(); // 获取对应宽度
int singleHeight = height / b.length;// 获取每一个字母的高度
for (int i = 0; i < b.length; i++) {
paint.setColor(Color.parseColor("#9da0a4"));
paint.setTypeface(Typeface.DEFAULT_BOLD);
paint.setAntiAlias(true); | paint.setTextSize(PixelUtil.sp2px(12)); |
chenzj-king/RvHelper | demo/src/main/java/com/dreamliner/lib/rvhelper/sample/AppContext.java | // Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/utils/PixelUtil.java
// public class PixelUtil {
//
// /**
// * The mContext.
// */
// private static Context mContext;
//
// public static void init(Context context) {
// mContext = context;
// }
//
// /**
// * dp转 px.
// *
// * @param value the value
// * @return the int
// */
// public static int dp2px(float value) {
// final float scale = mContext.getResources().getDisplayMetrics().densityDpi;
// return (int) (value * (scale / 160) + 0.5f);
// }
//
// /**
// * dp转 px.
// *
// * @param value the value
// * @param context the mContext
// * @return the int
// */
// public static int dp2px(float value, Context context) {
// final float scale = context.getResources().getDisplayMetrics().densityDpi;
// return (int) (value * (scale / 160) + 0.5f);
// }
//
// /**
// * px转dp.
// *
// * @param value the value
// * @return the int
// */
// public static int px2dp(float value) {
// final float scale = mContext.getResources().getDisplayMetrics().densityDpi;
// return (int) ((value * 160) / scale + 0.5f);
// }
//
// /**
// * px转dp.
// *
// * @param value the value
// * @param context the mContext
// * @return the int
// */
// public static int px2dp(float value, Context context) {
// final float scale = context.getResources().getDisplayMetrics().densityDpi;
// return (int) ((value * 160) / scale + 0.5f);
// }
//
// /**
// * sp转px.
// *
// * @param value the value
// * @return the int
// */
// public static int sp2px(float value) {
// Resources r;
// if (mContext == null) {
// r = Resources.getSystem();
// } else {
// r = mContext.getResources();
// }
// float spvalue = value * r.getDisplayMetrics().scaledDensity;
// return (int) (spvalue + 0.5f);
// }
//
// /**
// * sp转px.
// *
// * @param value the value
// * @param context the mContext
// * @return the int
// */
// public static int sp2px(float value, Context context) {
// Resources r;
// if (context == null) {
// r = Resources.getSystem();
// } else {
// r = context.getResources();
// }
// float spvalue = value * r.getDisplayMetrics().scaledDensity;
// return (int) (spvalue + 0.5f);
// }
//
// /**
// * px转sp.
// *
// * @param value the value
// * @return the int
// */
// public static int px2sp(float value) {
// final float scale = mContext.getResources().getDisplayMetrics().scaledDensity;
// return (int) (value / scale + 0.5f);
// }
//
// /**
// * px转sp.
// *
// * @param value the value
// * @param context the mContext
// * @return the int
// */
// public static int px2sp(float value, Context context) {
// final float scale = context.getResources().getDisplayMetrics().scaledDensity;
// return (int) (value / scale + 0.5f);
// }
//
//
// }
| import android.app.Application;
import com.dreamliner.lib.rvhelper.sample.utils.PixelUtil; | package com.dreamliner.lib.rvhelper.sample;
/**
* @author chenzj
* @Title: AppContext
* @Description: 类的描述 -
* @date 2016/6/12 17:05
* @email [email protected]
*/
public class AppContext extends Application {
private static AppContext mInstance;
private boolean isDebug;
public static AppContext getInstance() {
return mInstance;
}
@Override
public void onCreate() {
super.onCreate();
mInstance = this;
initDebug();
initNet(); | // Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/utils/PixelUtil.java
// public class PixelUtil {
//
// /**
// * The mContext.
// */
// private static Context mContext;
//
// public static void init(Context context) {
// mContext = context;
// }
//
// /**
// * dp转 px.
// *
// * @param value the value
// * @return the int
// */
// public static int dp2px(float value) {
// final float scale = mContext.getResources().getDisplayMetrics().densityDpi;
// return (int) (value * (scale / 160) + 0.5f);
// }
//
// /**
// * dp转 px.
// *
// * @param value the value
// * @param context the mContext
// * @return the int
// */
// public static int dp2px(float value, Context context) {
// final float scale = context.getResources().getDisplayMetrics().densityDpi;
// return (int) (value * (scale / 160) + 0.5f);
// }
//
// /**
// * px转dp.
// *
// * @param value the value
// * @return the int
// */
// public static int px2dp(float value) {
// final float scale = mContext.getResources().getDisplayMetrics().densityDpi;
// return (int) ((value * 160) / scale + 0.5f);
// }
//
// /**
// * px转dp.
// *
// * @param value the value
// * @param context the mContext
// * @return the int
// */
// public static int px2dp(float value, Context context) {
// final float scale = context.getResources().getDisplayMetrics().densityDpi;
// return (int) ((value * 160) / scale + 0.5f);
// }
//
// /**
// * sp转px.
// *
// * @param value the value
// * @return the int
// */
// public static int sp2px(float value) {
// Resources r;
// if (mContext == null) {
// r = Resources.getSystem();
// } else {
// r = mContext.getResources();
// }
// float spvalue = value * r.getDisplayMetrics().scaledDensity;
// return (int) (spvalue + 0.5f);
// }
//
// /**
// * sp转px.
// *
// * @param value the value
// * @param context the mContext
// * @return the int
// */
// public static int sp2px(float value, Context context) {
// Resources r;
// if (context == null) {
// r = Resources.getSystem();
// } else {
// r = context.getResources();
// }
// float spvalue = value * r.getDisplayMetrics().scaledDensity;
// return (int) (spvalue + 0.5f);
// }
//
// /**
// * px转sp.
// *
// * @param value the value
// * @return the int
// */
// public static int px2sp(float value) {
// final float scale = mContext.getResources().getDisplayMetrics().scaledDensity;
// return (int) (value / scale + 0.5f);
// }
//
// /**
// * px转sp.
// *
// * @param value the value
// * @param context the mContext
// * @return the int
// */
// public static int px2sp(float value, Context context) {
// final float scale = context.getResources().getDisplayMetrics().scaledDensity;
// return (int) (value / scale + 0.5f);
// }
//
//
// }
// Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/AppContext.java
import android.app.Application;
import com.dreamliner.lib.rvhelper.sample.utils.PixelUtil;
package com.dreamliner.lib.rvhelper.sample;
/**
* @author chenzj
* @Title: AppContext
* @Description: 类的描述 -
* @date 2016/6/12 17:05
* @email [email protected]
*/
public class AppContext extends Application {
private static AppContext mInstance;
private boolean isDebug;
public static AppContext getInstance() {
return mInstance;
}
@Override
public void onCreate() {
super.onCreate();
mInstance = this;
initDebug();
initNet(); | PixelUtil.init(this); |
chenzj-king/RvHelper | library/src/main/java/com/dreamliner/rvhelper/adapter/BaseAdapter.java | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemLongListener.java
// public interface ItemLongListener {
// boolean onLongClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseViewHolder.java
// public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
//
// private ItemClickListener mItemClickListener;
// private ItemLongListener mItemLongListener;
//
// public BaseViewHolder(View itemView) {
// super(itemView);
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// }
//
// public BaseViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView);
// mItemLongListener = itemLongListener;
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mItemClickListener.onItemClick(v, position);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mItemLongListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mItemLongListener.onLongClick(v, position);
// }
// return false;
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/FooterViewHolder.java
// public class FooterViewHolder extends BaseViewHolder {
//
// public FooterViewHolder(View itemView) {
// super(itemView);
// }
//
// public FooterViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView, itemClickListener);
// }
//
// public FooterViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView, itemLongListener);
// }
//
// public FooterViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView, itemClickListener, itemLongListener);
// }
// }
| import androidx.recyclerview.widget.RecyclerView;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.interfaces.ItemLongListener;
import com.dreamliner.rvhelper.viewholder.BaseViewHolder;
import com.dreamliner.rvhelper.viewholder.FooterViewHolder; | package com.dreamliner.rvhelper.adapter;
/**
* @author chenzj
* @Title: BaseAdapter
* @Description: 类的描述 -
* @date 2016/6/12 09:05
* @email [email protected]
*/
public abstract class BaseAdapter<T, VH extends BaseViewHolder> extends BaseNormalAdapter<T, VH> {
public BaseAdapter() {
super();
}
| // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemLongListener.java
// public interface ItemLongListener {
// boolean onLongClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseViewHolder.java
// public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
//
// private ItemClickListener mItemClickListener;
// private ItemLongListener mItemLongListener;
//
// public BaseViewHolder(View itemView) {
// super(itemView);
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// }
//
// public BaseViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView);
// mItemLongListener = itemLongListener;
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mItemClickListener.onItemClick(v, position);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mItemLongListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mItemLongListener.onLongClick(v, position);
// }
// return false;
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/FooterViewHolder.java
// public class FooterViewHolder extends BaseViewHolder {
//
// public FooterViewHolder(View itemView) {
// super(itemView);
// }
//
// public FooterViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView, itemClickListener);
// }
//
// public FooterViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView, itemLongListener);
// }
//
// public FooterViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView, itemClickListener, itemLongListener);
// }
// }
// Path: library/src/main/java/com/dreamliner/rvhelper/adapter/BaseAdapter.java
import androidx.recyclerview.widget.RecyclerView;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.interfaces.ItemLongListener;
import com.dreamliner.rvhelper.viewholder.BaseViewHolder;
import com.dreamliner.rvhelper.viewholder.FooterViewHolder;
package com.dreamliner.rvhelper.adapter;
/**
* @author chenzj
* @Title: BaseAdapter
* @Description: 类的描述 -
* @date 2016/6/12 09:05
* @email [email protected]
*/
public abstract class BaseAdapter<T, VH extends BaseViewHolder> extends BaseNormalAdapter<T, VH> {
public BaseAdapter() {
super();
}
| public BaseAdapter(ItemClickListener itemClickListener) { |
chenzj-king/RvHelper | library/src/main/java/com/dreamliner/rvhelper/adapter/BaseAdapter.java | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemLongListener.java
// public interface ItemLongListener {
// boolean onLongClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseViewHolder.java
// public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
//
// private ItemClickListener mItemClickListener;
// private ItemLongListener mItemLongListener;
//
// public BaseViewHolder(View itemView) {
// super(itemView);
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// }
//
// public BaseViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView);
// mItemLongListener = itemLongListener;
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mItemClickListener.onItemClick(v, position);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mItemLongListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mItemLongListener.onLongClick(v, position);
// }
// return false;
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/FooterViewHolder.java
// public class FooterViewHolder extends BaseViewHolder {
//
// public FooterViewHolder(View itemView) {
// super(itemView);
// }
//
// public FooterViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView, itemClickListener);
// }
//
// public FooterViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView, itemLongListener);
// }
//
// public FooterViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView, itemClickListener, itemLongListener);
// }
// }
| import androidx.recyclerview.widget.RecyclerView;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.interfaces.ItemLongListener;
import com.dreamliner.rvhelper.viewholder.BaseViewHolder;
import com.dreamliner.rvhelper.viewholder.FooterViewHolder; | package com.dreamliner.rvhelper.adapter;
/**
* @author chenzj
* @Title: BaseAdapter
* @Description: 类的描述 -
* @date 2016/6/12 09:05
* @email [email protected]
*/
public abstract class BaseAdapter<T, VH extends BaseViewHolder> extends BaseNormalAdapter<T, VH> {
public BaseAdapter() {
super();
}
public BaseAdapter(ItemClickListener itemClickListener) {
super();
mItemClickListener = itemClickListener;
}
| // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemLongListener.java
// public interface ItemLongListener {
// boolean onLongClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseViewHolder.java
// public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
//
// private ItemClickListener mItemClickListener;
// private ItemLongListener mItemLongListener;
//
// public BaseViewHolder(View itemView) {
// super(itemView);
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// }
//
// public BaseViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView);
// mItemLongListener = itemLongListener;
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mItemClickListener.onItemClick(v, position);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mItemLongListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mItemLongListener.onLongClick(v, position);
// }
// return false;
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/FooterViewHolder.java
// public class FooterViewHolder extends BaseViewHolder {
//
// public FooterViewHolder(View itemView) {
// super(itemView);
// }
//
// public FooterViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView, itemClickListener);
// }
//
// public FooterViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView, itemLongListener);
// }
//
// public FooterViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView, itemClickListener, itemLongListener);
// }
// }
// Path: library/src/main/java/com/dreamliner/rvhelper/adapter/BaseAdapter.java
import androidx.recyclerview.widget.RecyclerView;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.interfaces.ItemLongListener;
import com.dreamliner.rvhelper.viewholder.BaseViewHolder;
import com.dreamliner.rvhelper.viewholder.FooterViewHolder;
package com.dreamliner.rvhelper.adapter;
/**
* @author chenzj
* @Title: BaseAdapter
* @Description: 类的描述 -
* @date 2016/6/12 09:05
* @email [email protected]
*/
public abstract class BaseAdapter<T, VH extends BaseViewHolder> extends BaseNormalAdapter<T, VH> {
public BaseAdapter() {
super();
}
public BaseAdapter(ItemClickListener itemClickListener) {
super();
mItemClickListener = itemClickListener;
}
| public BaseAdapter(ItemLongListener itemLongListener) { |
chenzj-king/RvHelper | library/src/main/java/com/dreamliner/rvhelper/adapter/BaseAdapter.java | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemLongListener.java
// public interface ItemLongListener {
// boolean onLongClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseViewHolder.java
// public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
//
// private ItemClickListener mItemClickListener;
// private ItemLongListener mItemLongListener;
//
// public BaseViewHolder(View itemView) {
// super(itemView);
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// }
//
// public BaseViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView);
// mItemLongListener = itemLongListener;
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mItemClickListener.onItemClick(v, position);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mItemLongListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mItemLongListener.onLongClick(v, position);
// }
// return false;
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/FooterViewHolder.java
// public class FooterViewHolder extends BaseViewHolder {
//
// public FooterViewHolder(View itemView) {
// super(itemView);
// }
//
// public FooterViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView, itemClickListener);
// }
//
// public FooterViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView, itemLongListener);
// }
//
// public FooterViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView, itemClickListener, itemLongListener);
// }
// }
| import androidx.recyclerview.widget.RecyclerView;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.interfaces.ItemLongListener;
import com.dreamliner.rvhelper.viewholder.BaseViewHolder;
import com.dreamliner.rvhelper.viewholder.FooterViewHolder; | package com.dreamliner.rvhelper.adapter;
/**
* @author chenzj
* @Title: BaseAdapter
* @Description: 类的描述 -
* @date 2016/6/12 09:05
* @email [email protected]
*/
public abstract class BaseAdapter<T, VH extends BaseViewHolder> extends BaseNormalAdapter<T, VH> {
public BaseAdapter() {
super();
}
public BaseAdapter(ItemClickListener itemClickListener) {
super();
mItemClickListener = itemClickListener;
}
public BaseAdapter(ItemLongListener itemLongListener) {
super();
mItemLongListener = itemLongListener;
}
public BaseAdapter(ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
super();
mItemClickListener = itemClickListener;
mItemLongListener = itemLongListener;
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemLongListener.java
// public interface ItemLongListener {
// boolean onLongClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseViewHolder.java
// public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
//
// private ItemClickListener mItemClickListener;
// private ItemLongListener mItemLongListener;
//
// public BaseViewHolder(View itemView) {
// super(itemView);
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// }
//
// public BaseViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView);
// mItemLongListener = itemLongListener;
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mItemClickListener.onItemClick(v, position);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mItemLongListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mItemLongListener.onLongClick(v, position);
// }
// return false;
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/FooterViewHolder.java
// public class FooterViewHolder extends BaseViewHolder {
//
// public FooterViewHolder(View itemView) {
// super(itemView);
// }
//
// public FooterViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView, itemClickListener);
// }
//
// public FooterViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView, itemLongListener);
// }
//
// public FooterViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView, itemClickListener, itemLongListener);
// }
// }
// Path: library/src/main/java/com/dreamliner/rvhelper/adapter/BaseAdapter.java
import androidx.recyclerview.widget.RecyclerView;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.interfaces.ItemLongListener;
import com.dreamliner.rvhelper.viewholder.BaseViewHolder;
import com.dreamliner.rvhelper.viewholder.FooterViewHolder;
package com.dreamliner.rvhelper.adapter;
/**
* @author chenzj
* @Title: BaseAdapter
* @Description: 类的描述 -
* @date 2016/6/12 09:05
* @email [email protected]
*/
public abstract class BaseAdapter<T, VH extends BaseViewHolder> extends BaseNormalAdapter<T, VH> {
public BaseAdapter() {
super();
}
public BaseAdapter(ItemClickListener itemClickListener) {
super();
mItemClickListener = itemClickListener;
}
public BaseAdapter(ItemLongListener itemLongListener) {
super();
mItemLongListener = itemLongListener;
}
public BaseAdapter(ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
super();
mItemClickListener = itemClickListener;
mItemLongListener = itemLongListener;
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { | if (!(holder instanceof FooterViewHolder)) { |
chenzj-king/RvHelper | library/src/main/java/com/dreamliner/rvhelper/adapter/BaseDBAdapter.java | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemClickListener.java
// public interface OnItemClickListener<T> {
// void onItemClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemLongClickListener.java
// public interface OnItemLongClickListener<T> {
// boolean onItemLongClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseBindViewHolder.java
// public class BaseBindViewHolder<Binding extends ViewDataBinding, T> extends RecyclerView.ViewHolder implements View.OnClickListener,
// View.OnLongClickListener {
//
// private final Binding mBinding;
//
// private T mItem;
// private OnItemClickListener<T> mOnItemClickListener;
// private OnItemLongClickListener<T> mOnItemLongClickListener;
//
// public BaseBindViewHolder(Binding binding) {
// super(binding.getRoot());
// mBinding = binding;
// }
//
// public Binding getBinding() {
// return mBinding;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mOnItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mOnItemClickListener.onItemClick(v, position, mItem);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mOnItemLongClickListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mOnItemLongClickListener.onItemLongClick(v, position, mItem);
// }
// return false;
// }
//
// public void setItem(T item) {
// mItem = item;
// }
//
// public void setOnItemClickListener(OnItemClickListener<T> onItemClickListener) {
// mOnItemClickListener = onItemClickListener;
// }
//
// public void setOnItemLongClickListener(OnItemLongClickListener<T> onItemLongClickListener) {
// mOnItemLongClickListener = onItemLongClickListener;
// }
// }
| import android.view.LayoutInflater;
import android.view.ViewGroup;
import com.dreamliner.rvhelper.interfaces.OnItemClickListener;
import com.dreamliner.rvhelper.interfaces.OnItemLongClickListener;
import com.dreamliner.rvhelper.viewholder.BaseBindViewHolder;
import androidx.annotation.LayoutRes;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding; | package com.dreamliner.rvhelper.adapter;
/**
* Created by chenzj on 2017/3/21.
*/
public class BaseDBAdapter<T> extends BaseDataDBAdapter<T> {
protected int mLayoutRes;
public BaseDBAdapter(@LayoutRes int layoutRes) {
mLayoutRes = layoutRes;
}
| // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemClickListener.java
// public interface OnItemClickListener<T> {
// void onItemClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemLongClickListener.java
// public interface OnItemLongClickListener<T> {
// boolean onItemLongClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseBindViewHolder.java
// public class BaseBindViewHolder<Binding extends ViewDataBinding, T> extends RecyclerView.ViewHolder implements View.OnClickListener,
// View.OnLongClickListener {
//
// private final Binding mBinding;
//
// private T mItem;
// private OnItemClickListener<T> mOnItemClickListener;
// private OnItemLongClickListener<T> mOnItemLongClickListener;
//
// public BaseBindViewHolder(Binding binding) {
// super(binding.getRoot());
// mBinding = binding;
// }
//
// public Binding getBinding() {
// return mBinding;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mOnItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mOnItemClickListener.onItemClick(v, position, mItem);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mOnItemLongClickListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mOnItemLongClickListener.onItemLongClick(v, position, mItem);
// }
// return false;
// }
//
// public void setItem(T item) {
// mItem = item;
// }
//
// public void setOnItemClickListener(OnItemClickListener<T> onItemClickListener) {
// mOnItemClickListener = onItemClickListener;
// }
//
// public void setOnItemLongClickListener(OnItemLongClickListener<T> onItemLongClickListener) {
// mOnItemLongClickListener = onItemLongClickListener;
// }
// }
// Path: library/src/main/java/com/dreamliner/rvhelper/adapter/BaseDBAdapter.java
import android.view.LayoutInflater;
import android.view.ViewGroup;
import com.dreamliner.rvhelper.interfaces.OnItemClickListener;
import com.dreamliner.rvhelper.interfaces.OnItemLongClickListener;
import com.dreamliner.rvhelper.viewholder.BaseBindViewHolder;
import androidx.annotation.LayoutRes;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
package com.dreamliner.rvhelper.adapter;
/**
* Created by chenzj on 2017/3/21.
*/
public class BaseDBAdapter<T> extends BaseDataDBAdapter<T> {
protected int mLayoutRes;
public BaseDBAdapter(@LayoutRes int layoutRes) {
mLayoutRes = layoutRes;
}
| public BaseDBAdapter(OnItemClickListener<T> onItemClickListener, @LayoutRes int layoutRes) { |
chenzj-king/RvHelper | library/src/main/java/com/dreamliner/rvhelper/adapter/BaseDBAdapter.java | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemClickListener.java
// public interface OnItemClickListener<T> {
// void onItemClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemLongClickListener.java
// public interface OnItemLongClickListener<T> {
// boolean onItemLongClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseBindViewHolder.java
// public class BaseBindViewHolder<Binding extends ViewDataBinding, T> extends RecyclerView.ViewHolder implements View.OnClickListener,
// View.OnLongClickListener {
//
// private final Binding mBinding;
//
// private T mItem;
// private OnItemClickListener<T> mOnItemClickListener;
// private OnItemLongClickListener<T> mOnItemLongClickListener;
//
// public BaseBindViewHolder(Binding binding) {
// super(binding.getRoot());
// mBinding = binding;
// }
//
// public Binding getBinding() {
// return mBinding;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mOnItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mOnItemClickListener.onItemClick(v, position, mItem);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mOnItemLongClickListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mOnItemLongClickListener.onItemLongClick(v, position, mItem);
// }
// return false;
// }
//
// public void setItem(T item) {
// mItem = item;
// }
//
// public void setOnItemClickListener(OnItemClickListener<T> onItemClickListener) {
// mOnItemClickListener = onItemClickListener;
// }
//
// public void setOnItemLongClickListener(OnItemLongClickListener<T> onItemLongClickListener) {
// mOnItemLongClickListener = onItemLongClickListener;
// }
// }
| import android.view.LayoutInflater;
import android.view.ViewGroup;
import com.dreamliner.rvhelper.interfaces.OnItemClickListener;
import com.dreamliner.rvhelper.interfaces.OnItemLongClickListener;
import com.dreamliner.rvhelper.viewholder.BaseBindViewHolder;
import androidx.annotation.LayoutRes;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding; | package com.dreamliner.rvhelper.adapter;
/**
* Created by chenzj on 2017/3/21.
*/
public class BaseDBAdapter<T> extends BaseDataDBAdapter<T> {
protected int mLayoutRes;
public BaseDBAdapter(@LayoutRes int layoutRes) {
mLayoutRes = layoutRes;
}
public BaseDBAdapter(OnItemClickListener<T> onItemClickListener, @LayoutRes int layoutRes) {
super(onItemClickListener);
mLayoutRes = layoutRes;
}
| // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemClickListener.java
// public interface OnItemClickListener<T> {
// void onItemClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemLongClickListener.java
// public interface OnItemLongClickListener<T> {
// boolean onItemLongClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseBindViewHolder.java
// public class BaseBindViewHolder<Binding extends ViewDataBinding, T> extends RecyclerView.ViewHolder implements View.OnClickListener,
// View.OnLongClickListener {
//
// private final Binding mBinding;
//
// private T mItem;
// private OnItemClickListener<T> mOnItemClickListener;
// private OnItemLongClickListener<T> mOnItemLongClickListener;
//
// public BaseBindViewHolder(Binding binding) {
// super(binding.getRoot());
// mBinding = binding;
// }
//
// public Binding getBinding() {
// return mBinding;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mOnItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mOnItemClickListener.onItemClick(v, position, mItem);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mOnItemLongClickListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mOnItemLongClickListener.onItemLongClick(v, position, mItem);
// }
// return false;
// }
//
// public void setItem(T item) {
// mItem = item;
// }
//
// public void setOnItemClickListener(OnItemClickListener<T> onItemClickListener) {
// mOnItemClickListener = onItemClickListener;
// }
//
// public void setOnItemLongClickListener(OnItemLongClickListener<T> onItemLongClickListener) {
// mOnItemLongClickListener = onItemLongClickListener;
// }
// }
// Path: library/src/main/java/com/dreamliner/rvhelper/adapter/BaseDBAdapter.java
import android.view.LayoutInflater;
import android.view.ViewGroup;
import com.dreamliner.rvhelper.interfaces.OnItemClickListener;
import com.dreamliner.rvhelper.interfaces.OnItemLongClickListener;
import com.dreamliner.rvhelper.viewholder.BaseBindViewHolder;
import androidx.annotation.LayoutRes;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
package com.dreamliner.rvhelper.adapter;
/**
* Created by chenzj on 2017/3/21.
*/
public class BaseDBAdapter<T> extends BaseDataDBAdapter<T> {
protected int mLayoutRes;
public BaseDBAdapter(@LayoutRes int layoutRes) {
mLayoutRes = layoutRes;
}
public BaseDBAdapter(OnItemClickListener<T> onItemClickListener, @LayoutRes int layoutRes) {
super(onItemClickListener);
mLayoutRes = layoutRes;
}
| public BaseDBAdapter(OnItemLongClickListener<T> onItemLongClickListener, @LayoutRes int layoutRes) { |
chenzj-king/RvHelper | library/src/main/java/com/dreamliner/rvhelper/adapter/BaseDBAdapter.java | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemClickListener.java
// public interface OnItemClickListener<T> {
// void onItemClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemLongClickListener.java
// public interface OnItemLongClickListener<T> {
// boolean onItemLongClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseBindViewHolder.java
// public class BaseBindViewHolder<Binding extends ViewDataBinding, T> extends RecyclerView.ViewHolder implements View.OnClickListener,
// View.OnLongClickListener {
//
// private final Binding mBinding;
//
// private T mItem;
// private OnItemClickListener<T> mOnItemClickListener;
// private OnItemLongClickListener<T> mOnItemLongClickListener;
//
// public BaseBindViewHolder(Binding binding) {
// super(binding.getRoot());
// mBinding = binding;
// }
//
// public Binding getBinding() {
// return mBinding;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mOnItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mOnItemClickListener.onItemClick(v, position, mItem);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mOnItemLongClickListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mOnItemLongClickListener.onItemLongClick(v, position, mItem);
// }
// return false;
// }
//
// public void setItem(T item) {
// mItem = item;
// }
//
// public void setOnItemClickListener(OnItemClickListener<T> onItemClickListener) {
// mOnItemClickListener = onItemClickListener;
// }
//
// public void setOnItemLongClickListener(OnItemLongClickListener<T> onItemLongClickListener) {
// mOnItemLongClickListener = onItemLongClickListener;
// }
// }
| import android.view.LayoutInflater;
import android.view.ViewGroup;
import com.dreamliner.rvhelper.interfaces.OnItemClickListener;
import com.dreamliner.rvhelper.interfaces.OnItemLongClickListener;
import com.dreamliner.rvhelper.viewholder.BaseBindViewHolder;
import androidx.annotation.LayoutRes;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding; | package com.dreamliner.rvhelper.adapter;
/**
* Created by chenzj on 2017/3/21.
*/
public class BaseDBAdapter<T> extends BaseDataDBAdapter<T> {
protected int mLayoutRes;
public BaseDBAdapter(@LayoutRes int layoutRes) {
mLayoutRes = layoutRes;
}
public BaseDBAdapter(OnItemClickListener<T> onItemClickListener, @LayoutRes int layoutRes) {
super(onItemClickListener);
mLayoutRes = layoutRes;
}
public BaseDBAdapter(OnItemLongClickListener<T> onItemLongClickListener, @LayoutRes int layoutRes) {
super(onItemLongClickListener);
mLayoutRes = layoutRes;
}
public BaseDBAdapter(OnItemClickListener<T> onItemClickListener, OnItemLongClickListener<T> onItemLongClickListener,
@LayoutRes int layoutRes) {
super(onItemClickListener, onItemLongClickListener);
mLayoutRes = layoutRes;
}
@Override | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemClickListener.java
// public interface OnItemClickListener<T> {
// void onItemClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemLongClickListener.java
// public interface OnItemLongClickListener<T> {
// boolean onItemLongClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseBindViewHolder.java
// public class BaseBindViewHolder<Binding extends ViewDataBinding, T> extends RecyclerView.ViewHolder implements View.OnClickListener,
// View.OnLongClickListener {
//
// private final Binding mBinding;
//
// private T mItem;
// private OnItemClickListener<T> mOnItemClickListener;
// private OnItemLongClickListener<T> mOnItemLongClickListener;
//
// public BaseBindViewHolder(Binding binding) {
// super(binding.getRoot());
// mBinding = binding;
// }
//
// public Binding getBinding() {
// return mBinding;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mOnItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mOnItemClickListener.onItemClick(v, position, mItem);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mOnItemLongClickListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mOnItemLongClickListener.onItemLongClick(v, position, mItem);
// }
// return false;
// }
//
// public void setItem(T item) {
// mItem = item;
// }
//
// public void setOnItemClickListener(OnItemClickListener<T> onItemClickListener) {
// mOnItemClickListener = onItemClickListener;
// }
//
// public void setOnItemLongClickListener(OnItemLongClickListener<T> onItemLongClickListener) {
// mOnItemLongClickListener = onItemLongClickListener;
// }
// }
// Path: library/src/main/java/com/dreamliner/rvhelper/adapter/BaseDBAdapter.java
import android.view.LayoutInflater;
import android.view.ViewGroup;
import com.dreamliner.rvhelper.interfaces.OnItemClickListener;
import com.dreamliner.rvhelper.interfaces.OnItemLongClickListener;
import com.dreamliner.rvhelper.viewholder.BaseBindViewHolder;
import androidx.annotation.LayoutRes;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
package com.dreamliner.rvhelper.adapter;
/**
* Created by chenzj on 2017/3/21.
*/
public class BaseDBAdapter<T> extends BaseDataDBAdapter<T> {
protected int mLayoutRes;
public BaseDBAdapter(@LayoutRes int layoutRes) {
mLayoutRes = layoutRes;
}
public BaseDBAdapter(OnItemClickListener<T> onItemClickListener, @LayoutRes int layoutRes) {
super(onItemClickListener);
mLayoutRes = layoutRes;
}
public BaseDBAdapter(OnItemLongClickListener<T> onItemLongClickListener, @LayoutRes int layoutRes) {
super(onItemLongClickListener);
mLayoutRes = layoutRes;
}
public BaseDBAdapter(OnItemClickListener<T> onItemClickListener, OnItemLongClickListener<T> onItemLongClickListener,
@LayoutRes int layoutRes) {
super(onItemClickListener, onItemLongClickListener);
mLayoutRes = layoutRes;
}
@Override | public BaseBindViewHolder createCustomViewHolder(ViewGroup parent, int viewType) { |
chenzj-king/RvHelper | library/src/main/java/com/dreamliner/rvhelper/adapter/BaseNormalAdapter.java | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemLongListener.java
// public interface ItemLongListener {
// boolean onLongClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseViewHolder.java
// public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
//
// private ItemClickListener mItemClickListener;
// private ItemLongListener mItemLongListener;
//
// public BaseViewHolder(View itemView) {
// super(itemView);
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// }
//
// public BaseViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView);
// mItemLongListener = itemLongListener;
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mItemClickListener.onItemClick(v, position);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mItemLongListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mItemLongListener.onLongClick(v, position);
// }
// return false;
// }
// }
| import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.interfaces.ItemLongListener;
import com.dreamliner.rvhelper.viewholder.BaseViewHolder; | package com.dreamliner.rvhelper.adapter;
/**
* Created by chenzj on 2017/12/20.
*/
public abstract class BaseNormalAdapter<T, VH extends BaseViewHolder> extends BaseDataAdapter<T, BaseViewHolder> {
//普通adapter相关点击接口
protected ItemClickListener mItemClickListener; | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemLongListener.java
// public interface ItemLongListener {
// boolean onLongClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseViewHolder.java
// public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
//
// private ItemClickListener mItemClickListener;
// private ItemLongListener mItemLongListener;
//
// public BaseViewHolder(View itemView) {
// super(itemView);
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// }
//
// public BaseViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView);
// mItemLongListener = itemLongListener;
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mItemClickListener.onItemClick(v, position);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mItemLongListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mItemLongListener.onLongClick(v, position);
// }
// return false;
// }
// }
// Path: library/src/main/java/com/dreamliner/rvhelper/adapter/BaseNormalAdapter.java
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.interfaces.ItemLongListener;
import com.dreamliner.rvhelper.viewholder.BaseViewHolder;
package com.dreamliner.rvhelper.adapter;
/**
* Created by chenzj on 2017/12/20.
*/
public abstract class BaseNormalAdapter<T, VH extends BaseViewHolder> extends BaseDataAdapter<T, BaseViewHolder> {
//普通adapter相关点击接口
protected ItemClickListener mItemClickListener; | protected ItemLongListener mItemLongListener; |
chenzj-king/RvHelper | library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseBindViewHolder.java | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemClickListener.java
// public interface OnItemClickListener<T> {
// void onItemClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemLongClickListener.java
// public interface OnItemLongClickListener<T> {
// boolean onItemLongClick(View v, int position, T t);
// }
| import androidx.databinding.ViewDataBinding;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import com.dreamliner.rvhelper.interfaces.OnItemClickListener;
import com.dreamliner.rvhelper.interfaces.OnItemLongClickListener; | package com.dreamliner.rvhelper.viewholder;
/**
* Created by chenzj on 2017/3/21.
*/
public class BaseBindViewHolder<Binding extends ViewDataBinding, T> extends RecyclerView.ViewHolder implements View.OnClickListener,
View.OnLongClickListener {
private final Binding mBinding;
private T mItem; | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemClickListener.java
// public interface OnItemClickListener<T> {
// void onItemClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemLongClickListener.java
// public interface OnItemLongClickListener<T> {
// boolean onItemLongClick(View v, int position, T t);
// }
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseBindViewHolder.java
import androidx.databinding.ViewDataBinding;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import com.dreamliner.rvhelper.interfaces.OnItemClickListener;
import com.dreamliner.rvhelper.interfaces.OnItemLongClickListener;
package com.dreamliner.rvhelper.viewholder;
/**
* Created by chenzj on 2017/3/21.
*/
public class BaseBindViewHolder<Binding extends ViewDataBinding, T> extends RecyclerView.ViewHolder implements View.OnClickListener,
View.OnLongClickListener {
private final Binding mBinding;
private T mItem; | private OnItemClickListener<T> mOnItemClickListener; |
chenzj-king/RvHelper | library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseBindViewHolder.java | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemClickListener.java
// public interface OnItemClickListener<T> {
// void onItemClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemLongClickListener.java
// public interface OnItemLongClickListener<T> {
// boolean onItemLongClick(View v, int position, T t);
// }
| import androidx.databinding.ViewDataBinding;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import com.dreamliner.rvhelper.interfaces.OnItemClickListener;
import com.dreamliner.rvhelper.interfaces.OnItemLongClickListener; | package com.dreamliner.rvhelper.viewholder;
/**
* Created by chenzj on 2017/3/21.
*/
public class BaseBindViewHolder<Binding extends ViewDataBinding, T> extends RecyclerView.ViewHolder implements View.OnClickListener,
View.OnLongClickListener {
private final Binding mBinding;
private T mItem;
private OnItemClickListener<T> mOnItemClickListener; | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemClickListener.java
// public interface OnItemClickListener<T> {
// void onItemClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemLongClickListener.java
// public interface OnItemLongClickListener<T> {
// boolean onItemLongClick(View v, int position, T t);
// }
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseBindViewHolder.java
import androidx.databinding.ViewDataBinding;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import com.dreamliner.rvhelper.interfaces.OnItemClickListener;
import com.dreamliner.rvhelper.interfaces.OnItemLongClickListener;
package com.dreamliner.rvhelper.viewholder;
/**
* Created by chenzj on 2017/3/21.
*/
public class BaseBindViewHolder<Binding extends ViewDataBinding, T> extends RecyclerView.ViewHolder implements View.OnClickListener,
View.OnLongClickListener {
private final Binding mBinding;
private T mItem;
private OnItemClickListener<T> mOnItemClickListener; | private OnItemLongClickListener<T> mOnItemLongClickListener; |
chenzj-king/RvHelper | library/src/main/java/com/dreamliner/rvhelper/adapter/BaseDataDBAdapter.java | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemClickListener.java
// public interface OnItemClickListener<T> {
// void onItemClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemLongClickListener.java
// public interface OnItemLongClickListener<T> {
// boolean onItemLongClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseBindViewHolder.java
// public class BaseBindViewHolder<Binding extends ViewDataBinding, T> extends RecyclerView.ViewHolder implements View.OnClickListener,
// View.OnLongClickListener {
//
// private final Binding mBinding;
//
// private T mItem;
// private OnItemClickListener<T> mOnItemClickListener;
// private OnItemLongClickListener<T> mOnItemLongClickListener;
//
// public BaseBindViewHolder(Binding binding) {
// super(binding.getRoot());
// mBinding = binding;
// }
//
// public Binding getBinding() {
// return mBinding;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mOnItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mOnItemClickListener.onItemClick(v, position, mItem);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mOnItemLongClickListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mOnItemLongClickListener.onItemLongClick(v, position, mItem);
// }
// return false;
// }
//
// public void setItem(T item) {
// mItem = item;
// }
//
// public void setOnItemClickListener(OnItemClickListener<T> onItemClickListener) {
// mOnItemClickListener = onItemClickListener;
// }
//
// public void setOnItemLongClickListener(OnItemLongClickListener<T> onItemLongClickListener) {
// mOnItemLongClickListener = onItemLongClickListener;
// }
// }
| import androidx.recyclerview.widget.RecyclerView;
import com.dreamliner.lib.rvhelper.BR;
import com.dreamliner.rvhelper.interfaces.OnItemClickListener;
import com.dreamliner.rvhelper.interfaces.OnItemLongClickListener;
import com.dreamliner.rvhelper.viewholder.BaseBindViewHolder; | package com.dreamliner.rvhelper.adapter;
/**
* Created by chenzj on 2017/3/15.
*/
public abstract class BaseDataDBAdapter<T> extends BaseDataAdapter<T, BaseBindViewHolder> {
//DataBinding相关点击接口
private OnItemClickListener<T> mOnItemClickListener; | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemClickListener.java
// public interface OnItemClickListener<T> {
// void onItemClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemLongClickListener.java
// public interface OnItemLongClickListener<T> {
// boolean onItemLongClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseBindViewHolder.java
// public class BaseBindViewHolder<Binding extends ViewDataBinding, T> extends RecyclerView.ViewHolder implements View.OnClickListener,
// View.OnLongClickListener {
//
// private final Binding mBinding;
//
// private T mItem;
// private OnItemClickListener<T> mOnItemClickListener;
// private OnItemLongClickListener<T> mOnItemLongClickListener;
//
// public BaseBindViewHolder(Binding binding) {
// super(binding.getRoot());
// mBinding = binding;
// }
//
// public Binding getBinding() {
// return mBinding;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mOnItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mOnItemClickListener.onItemClick(v, position, mItem);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mOnItemLongClickListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mOnItemLongClickListener.onItemLongClick(v, position, mItem);
// }
// return false;
// }
//
// public void setItem(T item) {
// mItem = item;
// }
//
// public void setOnItemClickListener(OnItemClickListener<T> onItemClickListener) {
// mOnItemClickListener = onItemClickListener;
// }
//
// public void setOnItemLongClickListener(OnItemLongClickListener<T> onItemLongClickListener) {
// mOnItemLongClickListener = onItemLongClickListener;
// }
// }
// Path: library/src/main/java/com/dreamliner/rvhelper/adapter/BaseDataDBAdapter.java
import androidx.recyclerview.widget.RecyclerView;
import com.dreamliner.lib.rvhelper.BR;
import com.dreamliner.rvhelper.interfaces.OnItemClickListener;
import com.dreamliner.rvhelper.interfaces.OnItemLongClickListener;
import com.dreamliner.rvhelper.viewholder.BaseBindViewHolder;
package com.dreamliner.rvhelper.adapter;
/**
* Created by chenzj on 2017/3/15.
*/
public abstract class BaseDataDBAdapter<T> extends BaseDataAdapter<T, BaseBindViewHolder> {
//DataBinding相关点击接口
private OnItemClickListener<T> mOnItemClickListener; | private OnItemLongClickListener<T> mOnItemLongClickListener; |
chenzj-king/RvHelper | demo/src/main/java/com/dreamliner/lib/rvhelper/sample/ui/adapter/TextAdapter.java | // Path: library/src/main/java/com/dreamliner/rvhelper/adapter/BaseAdapter.java
// public abstract class BaseAdapter<T, VH extends BaseViewHolder> extends BaseNormalAdapter<T, VH> {
//
// public BaseAdapter() {
// super();
// }
//
// public BaseAdapter(ItemClickListener itemClickListener) {
// super();
// mItemClickListener = itemClickListener;
// }
//
// public BaseAdapter(ItemLongListener itemLongListener) {
// super();
// mItemLongListener = itemLongListener;
// }
//
// public BaseAdapter(ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super();
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
// if (!(holder instanceof FooterViewHolder)) {
// bindView((VH) holder, position);
// }
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseViewHolder.java
// public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
//
// private ItemClickListener mItemClickListener;
// private ItemLongListener mItemLongListener;
//
// public BaseViewHolder(View itemView) {
// super(itemView);
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// }
//
// public BaseViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView);
// mItemLongListener = itemLongListener;
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mItemClickListener.onItemClick(v, position);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mItemLongListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mItemLongListener.onLongClick(v, position);
// }
// return false;
// }
// }
| import android.annotation.SuppressLint;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.sample.R;
import com.dreamliner.rvhelper.adapter.BaseAdapter;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.viewholder.BaseViewHolder;
import butterknife.BindView;
import butterknife.ButterKnife; | package com.dreamliner.lib.rvhelper.sample.ui.adapter;
/**
* @author chenzj
* @Title: TextAdapter
* @Description: 类的描述 -
* @date 2016/6/13 09:58
* @email [email protected]
*/
public class TextAdapter extends BaseAdapter<String, TextAdapter.ViewHolder> {
public TextAdapter() {
super();
}
| // Path: library/src/main/java/com/dreamliner/rvhelper/adapter/BaseAdapter.java
// public abstract class BaseAdapter<T, VH extends BaseViewHolder> extends BaseNormalAdapter<T, VH> {
//
// public BaseAdapter() {
// super();
// }
//
// public BaseAdapter(ItemClickListener itemClickListener) {
// super();
// mItemClickListener = itemClickListener;
// }
//
// public BaseAdapter(ItemLongListener itemLongListener) {
// super();
// mItemLongListener = itemLongListener;
// }
//
// public BaseAdapter(ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super();
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
// if (!(holder instanceof FooterViewHolder)) {
// bindView((VH) holder, position);
// }
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseViewHolder.java
// public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
//
// private ItemClickListener mItemClickListener;
// private ItemLongListener mItemLongListener;
//
// public BaseViewHolder(View itemView) {
// super(itemView);
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// }
//
// public BaseViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView);
// mItemLongListener = itemLongListener;
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mItemClickListener.onItemClick(v, position);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mItemLongListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mItemLongListener.onLongClick(v, position);
// }
// return false;
// }
// }
// Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/ui/adapter/TextAdapter.java
import android.annotation.SuppressLint;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.sample.R;
import com.dreamliner.rvhelper.adapter.BaseAdapter;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.viewholder.BaseViewHolder;
import butterknife.BindView;
import butterknife.ButterKnife;
package com.dreamliner.lib.rvhelper.sample.ui.adapter;
/**
* @author chenzj
* @Title: TextAdapter
* @Description: 类的描述 -
* @date 2016/6/13 09:58
* @email [email protected]
*/
public class TextAdapter extends BaseAdapter<String, TextAdapter.ViewHolder> {
public TextAdapter() {
super();
}
| public TextAdapter(ItemClickListener itemClickListener) { |
chenzj-king/RvHelper | demo/src/main/java/com/dreamliner/lib/rvhelper/sample/ui/adapter/TextAdapter.java | // Path: library/src/main/java/com/dreamliner/rvhelper/adapter/BaseAdapter.java
// public abstract class BaseAdapter<T, VH extends BaseViewHolder> extends BaseNormalAdapter<T, VH> {
//
// public BaseAdapter() {
// super();
// }
//
// public BaseAdapter(ItemClickListener itemClickListener) {
// super();
// mItemClickListener = itemClickListener;
// }
//
// public BaseAdapter(ItemLongListener itemLongListener) {
// super();
// mItemLongListener = itemLongListener;
// }
//
// public BaseAdapter(ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super();
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
// if (!(holder instanceof FooterViewHolder)) {
// bindView((VH) holder, position);
// }
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseViewHolder.java
// public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
//
// private ItemClickListener mItemClickListener;
// private ItemLongListener mItemLongListener;
//
// public BaseViewHolder(View itemView) {
// super(itemView);
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// }
//
// public BaseViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView);
// mItemLongListener = itemLongListener;
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mItemClickListener.onItemClick(v, position);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mItemLongListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mItemLongListener.onLongClick(v, position);
// }
// return false;
// }
// }
| import android.annotation.SuppressLint;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.sample.R;
import com.dreamliner.rvhelper.adapter.BaseAdapter;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.viewholder.BaseViewHolder;
import butterknife.BindView;
import butterknife.ButterKnife; | package com.dreamliner.lib.rvhelper.sample.ui.adapter;
/**
* @author chenzj
* @Title: TextAdapter
* @Description: 类的描述 -
* @date 2016/6/13 09:58
* @email [email protected]
*/
public class TextAdapter extends BaseAdapter<String, TextAdapter.ViewHolder> {
public TextAdapter() {
super();
}
public TextAdapter(ItemClickListener itemClickListener) {
super(itemClickListener);
}
@Override
public ViewHolder createCustomViewHolder(ViewGroup parent, int viewType) {
return new ViewHolder(getView(R.layout.item_text, parent), getItemClickListener());
}
@SuppressLint("SetTextI18n")
@Override
protected void bindView(ViewHolder holder, int position) {
String itemData = getItem(position);
holder.mTextTv.setText("" + itemData);
}
| // Path: library/src/main/java/com/dreamliner/rvhelper/adapter/BaseAdapter.java
// public abstract class BaseAdapter<T, VH extends BaseViewHolder> extends BaseNormalAdapter<T, VH> {
//
// public BaseAdapter() {
// super();
// }
//
// public BaseAdapter(ItemClickListener itemClickListener) {
// super();
// mItemClickListener = itemClickListener;
// }
//
// public BaseAdapter(ItemLongListener itemLongListener) {
// super();
// mItemLongListener = itemLongListener;
// }
//
// public BaseAdapter(ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super();
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
// if (!(holder instanceof FooterViewHolder)) {
// bindView((VH) holder, position);
// }
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseViewHolder.java
// public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
//
// private ItemClickListener mItemClickListener;
// private ItemLongListener mItemLongListener;
//
// public BaseViewHolder(View itemView) {
// super(itemView);
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// }
//
// public BaseViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView);
// mItemLongListener = itemLongListener;
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mItemClickListener.onItemClick(v, position);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mItemLongListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mItemLongListener.onLongClick(v, position);
// }
// return false;
// }
// }
// Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/ui/adapter/TextAdapter.java
import android.annotation.SuppressLint;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.sample.R;
import com.dreamliner.rvhelper.adapter.BaseAdapter;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.viewholder.BaseViewHolder;
import butterknife.BindView;
import butterknife.ButterKnife;
package com.dreamliner.lib.rvhelper.sample.ui.adapter;
/**
* @author chenzj
* @Title: TextAdapter
* @Description: 类的描述 -
* @date 2016/6/13 09:58
* @email [email protected]
*/
public class TextAdapter extends BaseAdapter<String, TextAdapter.ViewHolder> {
public TextAdapter() {
super();
}
public TextAdapter(ItemClickListener itemClickListener) {
super(itemClickListener);
}
@Override
public ViewHolder createCustomViewHolder(ViewGroup parent, int viewType) {
return new ViewHolder(getView(R.layout.item_text, parent), getItemClickListener());
}
@SuppressLint("SetTextI18n")
@Override
protected void bindView(ViewHolder holder, int position) {
String itemData = getItem(position);
holder.mTextTv.setText("" + itemData);
}
| static class ViewHolder extends BaseViewHolder { |
chenzj-king/RvHelper | library/src/main/java/com/dreamliner/rvhelper/adapter/BaseMixtureDBAdapter.java | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemClickListener.java
// public interface OnItemClickListener<T> {
// void onItemClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemLongClickListener.java
// public interface OnItemLongClickListener<T> {
// boolean onItemLongClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseBindViewHolder.java
// public class BaseBindViewHolder<Binding extends ViewDataBinding, T> extends RecyclerView.ViewHolder implements View.OnClickListener,
// View.OnLongClickListener {
//
// private final Binding mBinding;
//
// private T mItem;
// private OnItemClickListener<T> mOnItemClickListener;
// private OnItemLongClickListener<T> mOnItemLongClickListener;
//
// public BaseBindViewHolder(Binding binding) {
// super(binding.getRoot());
// mBinding = binding;
// }
//
// public Binding getBinding() {
// return mBinding;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mOnItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mOnItemClickListener.onItemClick(v, position, mItem);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mOnItemLongClickListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mOnItemLongClickListener.onItemLongClick(v, position, mItem);
// }
// return false;
// }
//
// public void setItem(T item) {
// mItem = item;
// }
//
// public void setOnItemClickListener(OnItemClickListener<T> onItemClickListener) {
// mOnItemClickListener = onItemClickListener;
// }
//
// public void setOnItemLongClickListener(OnItemLongClickListener<T> onItemLongClickListener) {
// mOnItemLongClickListener = onItemLongClickListener;
// }
// }
| import android.util.SparseIntArray;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import com.dreamliner.lib.rvhelper.R;
import com.dreamliner.rvhelper.interfaces.OnItemClickListener;
import com.dreamliner.rvhelper.interfaces.OnItemLongClickListener;
import com.dreamliner.rvhelper.viewholder.BaseBindViewHolder;
import androidx.annotation.LayoutRes;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding; | package com.dreamliner.rvhelper.adapter;
/**
* @author chenzj
* @Title: BaseAdapter
* @Description: 类的描述 -
* @date 2016/6/12 09:05
* @email [email protected]
*/
public class BaseMixtureDBAdapter<T> extends BaseDataDBAdapter<T> {
private static final int NO_FOUND_TYPE = -1;
private SparseIntArray mItemTypeToLayoutMap = new SparseIntArray();
public BaseMixtureDBAdapter(SparseIntArray itemTypeToLayoutMap) {
super();
mItemTypeToLayoutMap = itemTypeToLayoutMap;
}
| // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemClickListener.java
// public interface OnItemClickListener<T> {
// void onItemClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemLongClickListener.java
// public interface OnItemLongClickListener<T> {
// boolean onItemLongClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseBindViewHolder.java
// public class BaseBindViewHolder<Binding extends ViewDataBinding, T> extends RecyclerView.ViewHolder implements View.OnClickListener,
// View.OnLongClickListener {
//
// private final Binding mBinding;
//
// private T mItem;
// private OnItemClickListener<T> mOnItemClickListener;
// private OnItemLongClickListener<T> mOnItemLongClickListener;
//
// public BaseBindViewHolder(Binding binding) {
// super(binding.getRoot());
// mBinding = binding;
// }
//
// public Binding getBinding() {
// return mBinding;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mOnItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mOnItemClickListener.onItemClick(v, position, mItem);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mOnItemLongClickListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mOnItemLongClickListener.onItemLongClick(v, position, mItem);
// }
// return false;
// }
//
// public void setItem(T item) {
// mItem = item;
// }
//
// public void setOnItemClickListener(OnItemClickListener<T> onItemClickListener) {
// mOnItemClickListener = onItemClickListener;
// }
//
// public void setOnItemLongClickListener(OnItemLongClickListener<T> onItemLongClickListener) {
// mOnItemLongClickListener = onItemLongClickListener;
// }
// }
// Path: library/src/main/java/com/dreamliner/rvhelper/adapter/BaseMixtureDBAdapter.java
import android.util.SparseIntArray;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import com.dreamliner.lib.rvhelper.R;
import com.dreamliner.rvhelper.interfaces.OnItemClickListener;
import com.dreamliner.rvhelper.interfaces.OnItemLongClickListener;
import com.dreamliner.rvhelper.viewholder.BaseBindViewHolder;
import androidx.annotation.LayoutRes;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
package com.dreamliner.rvhelper.adapter;
/**
* @author chenzj
* @Title: BaseAdapter
* @Description: 类的描述 -
* @date 2016/6/12 09:05
* @email [email protected]
*/
public class BaseMixtureDBAdapter<T> extends BaseDataDBAdapter<T> {
private static final int NO_FOUND_TYPE = -1;
private SparseIntArray mItemTypeToLayoutMap = new SparseIntArray();
public BaseMixtureDBAdapter(SparseIntArray itemTypeToLayoutMap) {
super();
mItemTypeToLayoutMap = itemTypeToLayoutMap;
}
| public BaseMixtureDBAdapter(OnItemClickListener<T> onItemClickListener, SparseIntArray itemTypeToLayoutMap) { |
chenzj-king/RvHelper | library/src/main/java/com/dreamliner/rvhelper/adapter/BaseMixtureDBAdapter.java | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemClickListener.java
// public interface OnItemClickListener<T> {
// void onItemClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemLongClickListener.java
// public interface OnItemLongClickListener<T> {
// boolean onItemLongClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseBindViewHolder.java
// public class BaseBindViewHolder<Binding extends ViewDataBinding, T> extends RecyclerView.ViewHolder implements View.OnClickListener,
// View.OnLongClickListener {
//
// private final Binding mBinding;
//
// private T mItem;
// private OnItemClickListener<T> mOnItemClickListener;
// private OnItemLongClickListener<T> mOnItemLongClickListener;
//
// public BaseBindViewHolder(Binding binding) {
// super(binding.getRoot());
// mBinding = binding;
// }
//
// public Binding getBinding() {
// return mBinding;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mOnItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mOnItemClickListener.onItemClick(v, position, mItem);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mOnItemLongClickListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mOnItemLongClickListener.onItemLongClick(v, position, mItem);
// }
// return false;
// }
//
// public void setItem(T item) {
// mItem = item;
// }
//
// public void setOnItemClickListener(OnItemClickListener<T> onItemClickListener) {
// mOnItemClickListener = onItemClickListener;
// }
//
// public void setOnItemLongClickListener(OnItemLongClickListener<T> onItemLongClickListener) {
// mOnItemLongClickListener = onItemLongClickListener;
// }
// }
| import android.util.SparseIntArray;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import com.dreamliner.lib.rvhelper.R;
import com.dreamliner.rvhelper.interfaces.OnItemClickListener;
import com.dreamliner.rvhelper.interfaces.OnItemLongClickListener;
import com.dreamliner.rvhelper.viewholder.BaseBindViewHolder;
import androidx.annotation.LayoutRes;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding; | package com.dreamliner.rvhelper.adapter;
/**
* @author chenzj
* @Title: BaseAdapter
* @Description: 类的描述 -
* @date 2016/6/12 09:05
* @email [email protected]
*/
public class BaseMixtureDBAdapter<T> extends BaseDataDBAdapter<T> {
private static final int NO_FOUND_TYPE = -1;
private SparseIntArray mItemTypeToLayoutMap = new SparseIntArray();
public BaseMixtureDBAdapter(SparseIntArray itemTypeToLayoutMap) {
super();
mItemTypeToLayoutMap = itemTypeToLayoutMap;
}
public BaseMixtureDBAdapter(OnItemClickListener<T> onItemClickListener, SparseIntArray itemTypeToLayoutMap) {
super(onItemClickListener);
mItemTypeToLayoutMap = itemTypeToLayoutMap;
}
| // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemClickListener.java
// public interface OnItemClickListener<T> {
// void onItemClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemLongClickListener.java
// public interface OnItemLongClickListener<T> {
// boolean onItemLongClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseBindViewHolder.java
// public class BaseBindViewHolder<Binding extends ViewDataBinding, T> extends RecyclerView.ViewHolder implements View.OnClickListener,
// View.OnLongClickListener {
//
// private final Binding mBinding;
//
// private T mItem;
// private OnItemClickListener<T> mOnItemClickListener;
// private OnItemLongClickListener<T> mOnItemLongClickListener;
//
// public BaseBindViewHolder(Binding binding) {
// super(binding.getRoot());
// mBinding = binding;
// }
//
// public Binding getBinding() {
// return mBinding;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mOnItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mOnItemClickListener.onItemClick(v, position, mItem);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mOnItemLongClickListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mOnItemLongClickListener.onItemLongClick(v, position, mItem);
// }
// return false;
// }
//
// public void setItem(T item) {
// mItem = item;
// }
//
// public void setOnItemClickListener(OnItemClickListener<T> onItemClickListener) {
// mOnItemClickListener = onItemClickListener;
// }
//
// public void setOnItemLongClickListener(OnItemLongClickListener<T> onItemLongClickListener) {
// mOnItemLongClickListener = onItemLongClickListener;
// }
// }
// Path: library/src/main/java/com/dreamliner/rvhelper/adapter/BaseMixtureDBAdapter.java
import android.util.SparseIntArray;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import com.dreamliner.lib.rvhelper.R;
import com.dreamliner.rvhelper.interfaces.OnItemClickListener;
import com.dreamliner.rvhelper.interfaces.OnItemLongClickListener;
import com.dreamliner.rvhelper.viewholder.BaseBindViewHolder;
import androidx.annotation.LayoutRes;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
package com.dreamliner.rvhelper.adapter;
/**
* @author chenzj
* @Title: BaseAdapter
* @Description: 类的描述 -
* @date 2016/6/12 09:05
* @email [email protected]
*/
public class BaseMixtureDBAdapter<T> extends BaseDataDBAdapter<T> {
private static final int NO_FOUND_TYPE = -1;
private SparseIntArray mItemTypeToLayoutMap = new SparseIntArray();
public BaseMixtureDBAdapter(SparseIntArray itemTypeToLayoutMap) {
super();
mItemTypeToLayoutMap = itemTypeToLayoutMap;
}
public BaseMixtureDBAdapter(OnItemClickListener<T> onItemClickListener, SparseIntArray itemTypeToLayoutMap) {
super(onItemClickListener);
mItemTypeToLayoutMap = itemTypeToLayoutMap;
}
| public BaseMixtureDBAdapter(OnItemLongClickListener<T> onItemLongClickListener, SparseIntArray itemTypeToLayoutMap) { |
chenzj-king/RvHelper | library/src/main/java/com/dreamliner/rvhelper/adapter/BaseMixtureDBAdapter.java | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemClickListener.java
// public interface OnItemClickListener<T> {
// void onItemClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemLongClickListener.java
// public interface OnItemLongClickListener<T> {
// boolean onItemLongClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseBindViewHolder.java
// public class BaseBindViewHolder<Binding extends ViewDataBinding, T> extends RecyclerView.ViewHolder implements View.OnClickListener,
// View.OnLongClickListener {
//
// private final Binding mBinding;
//
// private T mItem;
// private OnItemClickListener<T> mOnItemClickListener;
// private OnItemLongClickListener<T> mOnItemLongClickListener;
//
// public BaseBindViewHolder(Binding binding) {
// super(binding.getRoot());
// mBinding = binding;
// }
//
// public Binding getBinding() {
// return mBinding;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mOnItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mOnItemClickListener.onItemClick(v, position, mItem);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mOnItemLongClickListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mOnItemLongClickListener.onItemLongClick(v, position, mItem);
// }
// return false;
// }
//
// public void setItem(T item) {
// mItem = item;
// }
//
// public void setOnItemClickListener(OnItemClickListener<T> onItemClickListener) {
// mOnItemClickListener = onItemClickListener;
// }
//
// public void setOnItemLongClickListener(OnItemLongClickListener<T> onItemLongClickListener) {
// mOnItemLongClickListener = onItemLongClickListener;
// }
// }
| import android.util.SparseIntArray;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import com.dreamliner.lib.rvhelper.R;
import com.dreamliner.rvhelper.interfaces.OnItemClickListener;
import com.dreamliner.rvhelper.interfaces.OnItemLongClickListener;
import com.dreamliner.rvhelper.viewholder.BaseBindViewHolder;
import androidx.annotation.LayoutRes;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding; | package com.dreamliner.rvhelper.adapter;
/**
* @author chenzj
* @Title: BaseAdapter
* @Description: 类的描述 -
* @date 2016/6/12 09:05
* @email [email protected]
*/
public class BaseMixtureDBAdapter<T> extends BaseDataDBAdapter<T> {
private static final int NO_FOUND_TYPE = -1;
private SparseIntArray mItemTypeToLayoutMap = new SparseIntArray();
public BaseMixtureDBAdapter(SparseIntArray itemTypeToLayoutMap) {
super();
mItemTypeToLayoutMap = itemTypeToLayoutMap;
}
public BaseMixtureDBAdapter(OnItemClickListener<T> onItemClickListener, SparseIntArray itemTypeToLayoutMap) {
super(onItemClickListener);
mItemTypeToLayoutMap = itemTypeToLayoutMap;
}
public BaseMixtureDBAdapter(OnItemLongClickListener<T> onItemLongClickListener, SparseIntArray itemTypeToLayoutMap) {
super(onItemLongClickListener);
mItemTypeToLayoutMap = itemTypeToLayoutMap;
}
public BaseMixtureDBAdapter(OnItemClickListener<T> onItemClickListener, OnItemLongClickListener<T> onItemLongClickListener,
SparseIntArray itemTypeToLayoutMap) {
super(onItemClickListener, onItemLongClickListener);
mItemTypeToLayoutMap = itemTypeToLayoutMap;
}
@LayoutRes
protected int getLayoutRes(int viewType) {
if (mItemTypeToLayoutMap.get(viewType, NO_FOUND_TYPE) != NO_FOUND_TYPE) {
return mItemTypeToLayoutMap.get(viewType);
}
return R.layout.item_databinding_null;
}
@Override | // Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemClickListener.java
// public interface OnItemClickListener<T> {
// void onItemClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/OnItemLongClickListener.java
// public interface OnItemLongClickListener<T> {
// boolean onItemLongClick(View v, int position, T t);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseBindViewHolder.java
// public class BaseBindViewHolder<Binding extends ViewDataBinding, T> extends RecyclerView.ViewHolder implements View.OnClickListener,
// View.OnLongClickListener {
//
// private final Binding mBinding;
//
// private T mItem;
// private OnItemClickListener<T> mOnItemClickListener;
// private OnItemLongClickListener<T> mOnItemLongClickListener;
//
// public BaseBindViewHolder(Binding binding) {
// super(binding.getRoot());
// mBinding = binding;
// }
//
// public Binding getBinding() {
// return mBinding;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mOnItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mOnItemClickListener.onItemClick(v, position, mItem);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mOnItemLongClickListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mOnItemLongClickListener.onItemLongClick(v, position, mItem);
// }
// return false;
// }
//
// public void setItem(T item) {
// mItem = item;
// }
//
// public void setOnItemClickListener(OnItemClickListener<T> onItemClickListener) {
// mOnItemClickListener = onItemClickListener;
// }
//
// public void setOnItemLongClickListener(OnItemLongClickListener<T> onItemLongClickListener) {
// mOnItemLongClickListener = onItemLongClickListener;
// }
// }
// Path: library/src/main/java/com/dreamliner/rvhelper/adapter/BaseMixtureDBAdapter.java
import android.util.SparseIntArray;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import com.dreamliner.lib.rvhelper.R;
import com.dreamliner.rvhelper.interfaces.OnItemClickListener;
import com.dreamliner.rvhelper.interfaces.OnItemLongClickListener;
import com.dreamliner.rvhelper.viewholder.BaseBindViewHolder;
import androidx.annotation.LayoutRes;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
package com.dreamliner.rvhelper.adapter;
/**
* @author chenzj
* @Title: BaseAdapter
* @Description: 类的描述 -
* @date 2016/6/12 09:05
* @email [email protected]
*/
public class BaseMixtureDBAdapter<T> extends BaseDataDBAdapter<T> {
private static final int NO_FOUND_TYPE = -1;
private SparseIntArray mItemTypeToLayoutMap = new SparseIntArray();
public BaseMixtureDBAdapter(SparseIntArray itemTypeToLayoutMap) {
super();
mItemTypeToLayoutMap = itemTypeToLayoutMap;
}
public BaseMixtureDBAdapter(OnItemClickListener<T> onItemClickListener, SparseIntArray itemTypeToLayoutMap) {
super(onItemClickListener);
mItemTypeToLayoutMap = itemTypeToLayoutMap;
}
public BaseMixtureDBAdapter(OnItemLongClickListener<T> onItemLongClickListener, SparseIntArray itemTypeToLayoutMap) {
super(onItemLongClickListener);
mItemTypeToLayoutMap = itemTypeToLayoutMap;
}
public BaseMixtureDBAdapter(OnItemClickListener<T> onItemClickListener, OnItemLongClickListener<T> onItemLongClickListener,
SparseIntArray itemTypeToLayoutMap) {
super(onItemClickListener, onItemLongClickListener);
mItemTypeToLayoutMap = itemTypeToLayoutMap;
}
@LayoutRes
protected int getLayoutRes(int viewType) {
if (mItemTypeToLayoutMap.get(viewType, NO_FOUND_TYPE) != NO_FOUND_TYPE) {
return mItemTypeToLayoutMap.get(viewType);
}
return R.layout.item_databinding_null;
}
@Override | public BaseBindViewHolder createCustomViewHolder(ViewGroup parent, int viewType) { |
chenzj-king/RvHelper | demo/src/main/java/com/dreamliner/lib/rvhelper/sample/ui/adapter/TypeAdapter.java | // Path: library/src/main/java/com/dreamliner/rvhelper/adapter/BaseAdapter.java
// public abstract class BaseAdapter<T, VH extends BaseViewHolder> extends BaseNormalAdapter<T, VH> {
//
// public BaseAdapter() {
// super();
// }
//
// public BaseAdapter(ItemClickListener itemClickListener) {
// super();
// mItemClickListener = itemClickListener;
// }
//
// public BaseAdapter(ItemLongListener itemLongListener) {
// super();
// mItemLongListener = itemLongListener;
// }
//
// public BaseAdapter(ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super();
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
// if (!(holder instanceof FooterViewHolder)) {
// bindView((VH) holder, position);
// }
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseViewHolder.java
// public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
//
// private ItemClickListener mItemClickListener;
// private ItemLongListener mItemLongListener;
//
// public BaseViewHolder(View itemView) {
// super(itemView);
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// }
//
// public BaseViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView);
// mItemLongListener = itemLongListener;
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mItemClickListener.onItemClick(v, position);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mItemLongListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mItemLongListener.onLongClick(v, position);
// }
// return false;
// }
// }
| import android.annotation.SuppressLint;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.sample.R;
import com.dreamliner.rvhelper.adapter.BaseAdapter;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.viewholder.BaseViewHolder;
import butterknife.BindView;
import butterknife.ButterKnife; | package com.dreamliner.lib.rvhelper.sample.ui.adapter;
/**
* @author chenzj
* @Title: TypeAdapter
* @Description: 类的描述 -
* @date 2016/10/11 14:21
* @email [email protected]
*/
public class TypeAdapter extends BaseAdapter<String, TypeAdapter.ViewHolder> {
public TypeAdapter(ItemClickListener itemClickListener) {
super(itemClickListener);
}
@Override
public ViewHolder createCustomViewHolder(ViewGroup parent, int viewType) {
return new ViewHolder(getView(R.layout.item_type, parent), getItemClickListener());
}
@SuppressLint("SetTextI18n")
@Override
protected void bindView(ViewHolder holder, int position) {
String itemData = getItem(position);
holder.mTypeTv.setText("" + itemData);
}
| // Path: library/src/main/java/com/dreamliner/rvhelper/adapter/BaseAdapter.java
// public abstract class BaseAdapter<T, VH extends BaseViewHolder> extends BaseNormalAdapter<T, VH> {
//
// public BaseAdapter() {
// super();
// }
//
// public BaseAdapter(ItemClickListener itemClickListener) {
// super();
// mItemClickListener = itemClickListener;
// }
//
// public BaseAdapter(ItemLongListener itemLongListener) {
// super();
// mItemLongListener = itemLongListener;
// }
//
// public BaseAdapter(ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super();
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
// if (!(holder instanceof FooterViewHolder)) {
// bindView((VH) holder, position);
// }
// }
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/interfaces/ItemClickListener.java
// public interface ItemClickListener {
// public void onItemClick(View view, int position);
// }
//
// Path: library/src/main/java/com/dreamliner/rvhelper/viewholder/BaseViewHolder.java
// public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
//
// private ItemClickListener mItemClickListener;
// private ItemLongListener mItemLongListener;
//
// public BaseViewHolder(View itemView) {
// super(itemView);
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// }
//
// public BaseViewHolder(View itemView, ItemLongListener itemLongListener) {
// super(itemView);
// mItemLongListener = itemLongListener;
// }
//
// public BaseViewHolder(View itemView, ItemClickListener itemClickListener, ItemLongListener itemLongListener) {
// super(itemView);
// mItemClickListener = itemClickListener;
// mItemLongListener = itemLongListener;
// }
//
// @Override
// public void onClick(View v) {
// if (null != mItemClickListener) {
// int position = getAdapterPosition();
// if (position != RecyclerView.NO_POSITION) {
// mItemClickListener.onItemClick(v, position);
// }
// }
// }
//
// @Override
// public boolean onLongClick(View v) {
// if (null != mItemLongListener) {
// int position = getAdapterPosition();
// return position == RecyclerView.NO_POSITION || mItemLongListener.onLongClick(v, position);
// }
// return false;
// }
// }
// Path: demo/src/main/java/com/dreamliner/lib/rvhelper/sample/ui/adapter/TypeAdapter.java
import android.annotation.SuppressLint;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.dreamliner.lib.rvhelper.sample.R;
import com.dreamliner.rvhelper.adapter.BaseAdapter;
import com.dreamliner.rvhelper.interfaces.ItemClickListener;
import com.dreamliner.rvhelper.viewholder.BaseViewHolder;
import butterknife.BindView;
import butterknife.ButterKnife;
package com.dreamliner.lib.rvhelper.sample.ui.adapter;
/**
* @author chenzj
* @Title: TypeAdapter
* @Description: 类的描述 -
* @date 2016/10/11 14:21
* @email [email protected]
*/
public class TypeAdapter extends BaseAdapter<String, TypeAdapter.ViewHolder> {
public TypeAdapter(ItemClickListener itemClickListener) {
super(itemClickListener);
}
@Override
public ViewHolder createCustomViewHolder(ViewGroup parent, int viewType) {
return new ViewHolder(getView(R.layout.item_type, parent), getItemClickListener());
}
@SuppressLint("SetTextI18n")
@Override
protected void bindView(ViewHolder holder, int position) {
String itemData = getItem(position);
holder.mTypeTv.setText("" + itemData);
}
| static class ViewHolder extends BaseViewHolder { |
chenzj-king/RvHelper | library/src/main/java/com/dreamliner/ptrlib/header/MaterialProgressDrawable.java | // Path: library/src/main/java/com/dreamliner/ptrlib/util/PtrLocalDisplay.java
// public class PtrLocalDisplay {
//
// public static int SCREEN_WIDTH_PIXELS;
// public static int SCREEN_HEIGHT_PIXELS;
// public static float SCREEN_DENSITY;
// public static int SCREEN_WIDTH_DP;
// public static int SCREEN_HEIGHT_DP;
//
// public static void init(Context context) {
// if (context == null) {
// return;
// }
// DisplayMetrics dm = new DisplayMetrics();
// WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// wm.getDefaultDisplay().getMetrics(dm);
// SCREEN_WIDTH_PIXELS = dm.widthPixels;
// SCREEN_HEIGHT_PIXELS = dm.heightPixels;
// SCREEN_DENSITY = dm.density;
// SCREEN_WIDTH_DP = (int) (SCREEN_WIDTH_PIXELS / dm.density);
// SCREEN_HEIGHT_DP = (int) (SCREEN_HEIGHT_PIXELS / dm.density);
// }
//
// public static int dp2px(float dp) {
// final float scale = SCREEN_DENSITY;
// return (int) (dp * scale + 0.5f);
// }
//
// public static int designedDP2px(float designedDp) {
// if (SCREEN_WIDTH_DP != 320) {
// designedDp = designedDp * SCREEN_WIDTH_DP / 320f;
// }
// return dp2px(designedDp);
// }
//
// public static void setPadding(final View view, float left, float top, float right, float bottom) {
// view.setPadding(designedDP2px(left), dp2px(top), designedDP2px(right), dp2px(bottom));
// }
// }
| import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.PixelFormat;
import android.graphics.RadialGradient;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.os.Build;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
import android.view.animation.Transformation;
import com.dreamliner.ptrlib.util.PtrLocalDisplay;
import java.util.ArrayList; | private double mHeight;
private Animation mFinishAnimation;
private int mBackgroundColor;
private ShapeDrawable mShadow;
public MaterialProgressDrawable(Context context, View parent) {
mParent = parent;
mResources = context.getResources();
mRing = new Ring(mCallback);
mRing.setColors(COLORS);
updateSizes(DEFAULT);
setupAnimators();
}
private void setSizeParameters(double progressCircleWidth, double progressCircleHeight,
double centerRadius, double strokeWidth, float arrowWidth, float arrowHeight) {
final Ring ring = mRing;
final DisplayMetrics metrics = mResources.getDisplayMetrics();
final float screenDensity = metrics.density;
mWidth = progressCircleWidth * screenDensity;
mHeight = progressCircleHeight * screenDensity;
ring.setStrokeWidth((float) strokeWidth * screenDensity);
ring.setCenterRadius(centerRadius * screenDensity);
ring.setColorIndex(0);
ring.setArrowDimensions(arrowWidth * screenDensity, arrowHeight * screenDensity);
ring.setInsets((int) mWidth, (int) mHeight);
setUp(mWidth);
}
private void setUp(final double diameter) { | // Path: library/src/main/java/com/dreamliner/ptrlib/util/PtrLocalDisplay.java
// public class PtrLocalDisplay {
//
// public static int SCREEN_WIDTH_PIXELS;
// public static int SCREEN_HEIGHT_PIXELS;
// public static float SCREEN_DENSITY;
// public static int SCREEN_WIDTH_DP;
// public static int SCREEN_HEIGHT_DP;
//
// public static void init(Context context) {
// if (context == null) {
// return;
// }
// DisplayMetrics dm = new DisplayMetrics();
// WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// wm.getDefaultDisplay().getMetrics(dm);
// SCREEN_WIDTH_PIXELS = dm.widthPixels;
// SCREEN_HEIGHT_PIXELS = dm.heightPixels;
// SCREEN_DENSITY = dm.density;
// SCREEN_WIDTH_DP = (int) (SCREEN_WIDTH_PIXELS / dm.density);
// SCREEN_HEIGHT_DP = (int) (SCREEN_HEIGHT_PIXELS / dm.density);
// }
//
// public static int dp2px(float dp) {
// final float scale = SCREEN_DENSITY;
// return (int) (dp * scale + 0.5f);
// }
//
// public static int designedDP2px(float designedDp) {
// if (SCREEN_WIDTH_DP != 320) {
// designedDp = designedDp * SCREEN_WIDTH_DP / 320f;
// }
// return dp2px(designedDp);
// }
//
// public static void setPadding(final View view, float left, float top, float right, float bottom) {
// view.setPadding(designedDP2px(left), dp2px(top), designedDP2px(right), dp2px(bottom));
// }
// }
// Path: library/src/main/java/com/dreamliner/ptrlib/header/MaterialProgressDrawable.java
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.PixelFormat;
import android.graphics.RadialGradient;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.os.Build;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
import android.view.animation.Transformation;
import com.dreamliner.ptrlib.util.PtrLocalDisplay;
import java.util.ArrayList;
private double mHeight;
private Animation mFinishAnimation;
private int mBackgroundColor;
private ShapeDrawable mShadow;
public MaterialProgressDrawable(Context context, View parent) {
mParent = parent;
mResources = context.getResources();
mRing = new Ring(mCallback);
mRing.setColors(COLORS);
updateSizes(DEFAULT);
setupAnimators();
}
private void setSizeParameters(double progressCircleWidth, double progressCircleHeight,
double centerRadius, double strokeWidth, float arrowWidth, float arrowHeight) {
final Ring ring = mRing;
final DisplayMetrics metrics = mResources.getDisplayMetrics();
final float screenDensity = metrics.density;
mWidth = progressCircleWidth * screenDensity;
mHeight = progressCircleHeight * screenDensity;
ring.setStrokeWidth((float) strokeWidth * screenDensity);
ring.setCenterRadius(centerRadius * screenDensity);
ring.setColorIndex(0);
ring.setArrowDimensions(arrowWidth * screenDensity, arrowHeight * screenDensity);
ring.setInsets((int) mWidth, (int) mHeight);
setUp(mWidth);
}
private void setUp(final double diameter) { | PtrLocalDisplay.init(mParent.getContext()); |
gto76/fun-photo-time | src/main/java/si/gto76/funphototime/dialogs/MyDialog.java | // Path: src/main/java/si/gto76/funphototime/FunPhotoTime.java
// public class FunPhotoTime {
//
// static public FunPhotoTimeFrame frame;
//
// public static void main(String[] args) {
// // Try setting native look and feel if enabled.
// if (Conf.NATIVE_LOOK_AND_FEEL) {
// setNativeLookAndFeel();
// }
// Boolean check = LicenceUtil.check();
// System.out.println("License check: " + check);
// createAndShowGUI();
// }
//
// public static void createAndShowGUI() {
// JFrame.setDefaultLookAndFeelDecorated(true);
// // Create application frame.
// frame = new FunPhotoTimeFrame();
// frame.setSize(Conf.MAIN_WINDOW_WIDTH, Conf.MAIN_WINDOW_HEIGHT);
// // Set diferent icons, depending on main window focus.
// frame.addWindowFocusListener(new WindowAdapter() {
// public void windowGainedFocus(WindowEvent e) {
// frame.setIconImages(FunPhotoTimeFrame.iconsActive);
// }
// public void windowLostFocus(WindowEvent e) {
// frame.setIconImages(FunPhotoTimeFrame.iconsNotActive);
// }
// });
// // What to do on exit.
// frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
// frame.addWindowListener(new WindowAdapter() {
// public void windowClosing(WindowEvent we) {
// onWindowClose();
// }
// });
// // Show frame.
// frame.setVisible(true);
// }
//
// public static void onWindowClose() {
// int noOfFrames = frame.desktop.getComponentCount();
// if (noOfFrames > 0)
// confirmExit();
// else
// System.exit(0);
// }
//
// private static void confirmExit() {
// String ObjButtons[] = { "Yes", "No" };
// int PromptResult = JOptionPane.showOptionDialog(frame,
// "Are you sure you want to exit?", "",
// JOptionPane.DEFAULT_OPTION,
// JOptionPane.WARNING_MESSAGE, null, ObjButtons,
// ObjButtons[1]);
// if (PromptResult == JOptionPane.YES_OPTION) {
// System.exit(0);
// }
// }
//
// private static void setNativeLookAndFeel() {
// try {
// UIManager.setLookAndFeel(
// UIManager.getSystemLookAndFeelClassName());
// }
// catch (UnsupportedLookAndFeelException e) {
// }
// catch (ClassNotFoundException e) {
// }
// catch (InstantiationException e) {
// }
// catch (IllegalAccessException e) {
// }
// }
//
// }
| import java.awt.Component;
import java.awt.Point;
import java.awt.image.BufferedImage;
import java.lang.reflect.Array;
import javax.swing.BoxLayout;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import si.gto76.funphototime.FunPhotoTime; | package si.gto76.funphototime.dialogs;
public abstract class MyDialog {
protected JPanel p;
protected JDialog dlg;
protected JOptionPane op; | // Path: src/main/java/si/gto76/funphototime/FunPhotoTime.java
// public class FunPhotoTime {
//
// static public FunPhotoTimeFrame frame;
//
// public static void main(String[] args) {
// // Try setting native look and feel if enabled.
// if (Conf.NATIVE_LOOK_AND_FEEL) {
// setNativeLookAndFeel();
// }
// Boolean check = LicenceUtil.check();
// System.out.println("License check: " + check);
// createAndShowGUI();
// }
//
// public static void createAndShowGUI() {
// JFrame.setDefaultLookAndFeelDecorated(true);
// // Create application frame.
// frame = new FunPhotoTimeFrame();
// frame.setSize(Conf.MAIN_WINDOW_WIDTH, Conf.MAIN_WINDOW_HEIGHT);
// // Set diferent icons, depending on main window focus.
// frame.addWindowFocusListener(new WindowAdapter() {
// public void windowGainedFocus(WindowEvent e) {
// frame.setIconImages(FunPhotoTimeFrame.iconsActive);
// }
// public void windowLostFocus(WindowEvent e) {
// frame.setIconImages(FunPhotoTimeFrame.iconsNotActive);
// }
// });
// // What to do on exit.
// frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
// frame.addWindowListener(new WindowAdapter() {
// public void windowClosing(WindowEvent we) {
// onWindowClose();
// }
// });
// // Show frame.
// frame.setVisible(true);
// }
//
// public static void onWindowClose() {
// int noOfFrames = frame.desktop.getComponentCount();
// if (noOfFrames > 0)
// confirmExit();
// else
// System.exit(0);
// }
//
// private static void confirmExit() {
// String ObjButtons[] = { "Yes", "No" };
// int PromptResult = JOptionPane.showOptionDialog(frame,
// "Are you sure you want to exit?", "",
// JOptionPane.DEFAULT_OPTION,
// JOptionPane.WARNING_MESSAGE, null, ObjButtons,
// ObjButtons[1]);
// if (PromptResult == JOptionPane.YES_OPTION) {
// System.exit(0);
// }
// }
//
// private static void setNativeLookAndFeel() {
// try {
// UIManager.setLookAndFeel(
// UIManager.getSystemLookAndFeelClassName());
// }
// catch (UnsupportedLookAndFeelException e) {
// }
// catch (ClassNotFoundException e) {
// }
// catch (InstantiationException e) {
// }
// catch (IllegalAccessException e) {
// }
// }
//
// }
// Path: src/main/java/si/gto76/funphototime/dialogs/MyDialog.java
import java.awt.Component;
import java.awt.Point;
import java.awt.image.BufferedImage;
import java.lang.reflect.Array;
import javax.swing.BoxLayout;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import si.gto76.funphototime.FunPhotoTime;
package si.gto76.funphototime.dialogs;
public abstract class MyDialog {
protected JPanel p;
protected JDialog dlg;
protected JOptionPane op; | static public Point location = new Point(FunPhotoTime.frame.getLocation().x+100, |
gto76/fun-photo-time | src/main/java/si/gto76/funphototime/FunPhotoTimeFrame.java | // Path: src/main/java/si/gto76/funphototime/mymenu/MyMenuInterface.java
// public interface MyMenuInterface {
// //how many oppened internal frames does a menu item or a menu need
// //to be active (not grayed out)
// public int noOfOperands();
//
// }
//
// Path: src/main/java/si/gto76/funphototime/mymenu/ViewMenuUtil.java
// public class ViewMenuUtil {
// private static final String MENU_NAME = "Window";
//
// public static void createItem(JFrame mainFrame, JInternalFrame internalFrame) {
// JMenu menu = getViewMenu(mainFrame);
// if (menu == null) return;
// ViewMenuItem menuItem = new ViewMenuItem(internalFrame.getTitle(), internalFrame);
// menuItem.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent e) {
// ViewMenuItem menuItem = (ViewMenuItem) e.getSource();
// try {
// menuItem.internalFrame.setSelected(true);
// } catch (PropertyVetoException e1) {
// e1.printStackTrace();
// }
// }
// });
// menu.add(menuItem);
// refreshItems(mainFrame);
// }
//
// public static void removeItem(JFrame mainFrame, JInternalFrame internalFrame) {
// JMenu menu = getViewMenu(mainFrame);
// if (menu == null) return;
// for (MenuElement menuItem : menu.getSubElements()) {
// JPopupMenu popUp = (JPopupMenu) menuItem;
// for (MenuElement subElement : popUp.getSubElements()) {
// if (!(subElement instanceof ViewMenuItem) /*MyMenuItem*/)
// continue;
// ViewMenuItem viewMenuItem = (ViewMenuItem) subElement;
// if (viewMenuItem.compareTo(internalFrame) == 0) {
// popUp.remove(viewMenuItem);
// refreshItems(mainFrame);
// return;
// }
// }
// }
// }
//
// public static void refreshItems(JFrame mainFrame) {
// boolean first = true;
// boolean next = false;
// ViewMenuItem viewMenuItem = null;
// ViewMenuItem lastMenuItem = null;
// JMenu menu = getViewMenu(mainFrame);
// if (menu == null) return;
// for (MenuElement menuItem : menu.getSubElements()) {
// JPopupMenu popUp = (JPopupMenu) menuItem;
// for (MenuElement subElement : popUp.getSubElements()) {
// if (subElement instanceof MyMenuItem)
// continue;
// lastMenuItem = viewMenuItem;
// viewMenuItem = (ViewMenuItem) subElement;
// viewMenuItem.setAccelerator(null);
//
// if (next) {
// viewMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
// next = false;
// }
//
// JDesktopPane desktop = ((FunPhotoTimeFrame) mainFrame).desktop;
// if (viewMenuItem.compareTo(desktop.getSelectedFrame()) == 0) {
// //viewMenuItem.setText("> "+viewMenuItem.getText());
// if (!first)
// lastMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, ActionEvent.SHIFT_MASK));
// next = true;
// }
//
// if (first) {
// viewMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0));
// first = false;
// }
// }
// }
// if (!first) {
// viewMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0));
// }
// }
//
// /*
// * COMMON
// */
//
// private static JMenu getViewMenu(JFrame mainFrame) {
// JMenuBar menuBar = mainFrame.getJMenuBar();
// MenuElement[] menuElements = menuBar.getSubElements();
// for (MenuElement menuElement : menuElements) {
// if (menuElement instanceof JMenu) {
// JMenu menu = (JMenu) menuElement;
// String name = menu.getText();
// if (name.equalsIgnoreCase(MENU_NAME)) {
// return menu;
// }
// }
// }
// return null;
// }
//
// }
| import java.awt.Component;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JDesktopPane;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JMenu;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu.Separator;
import javax.swing.MenuElement;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
import si.gto76.funphototime.mymenu.MyMenuInterface;
import si.gto76.funphototime.mymenu.ViewMenuUtil; | package si.gto76.funphototime;
public class FunPhotoTimeFrame extends JFrame
implements ContainerListener, MouseWheelListener {
private static final long serialVersionUID = 5772778382924626863L;
public JDesktopPane desktop;
private Menu meni; | // Path: src/main/java/si/gto76/funphototime/mymenu/MyMenuInterface.java
// public interface MyMenuInterface {
// //how many oppened internal frames does a menu item or a menu need
// //to be active (not grayed out)
// public int noOfOperands();
//
// }
//
// Path: src/main/java/si/gto76/funphototime/mymenu/ViewMenuUtil.java
// public class ViewMenuUtil {
// private static final String MENU_NAME = "Window";
//
// public static void createItem(JFrame mainFrame, JInternalFrame internalFrame) {
// JMenu menu = getViewMenu(mainFrame);
// if (menu == null) return;
// ViewMenuItem menuItem = new ViewMenuItem(internalFrame.getTitle(), internalFrame);
// menuItem.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent e) {
// ViewMenuItem menuItem = (ViewMenuItem) e.getSource();
// try {
// menuItem.internalFrame.setSelected(true);
// } catch (PropertyVetoException e1) {
// e1.printStackTrace();
// }
// }
// });
// menu.add(menuItem);
// refreshItems(mainFrame);
// }
//
// public static void removeItem(JFrame mainFrame, JInternalFrame internalFrame) {
// JMenu menu = getViewMenu(mainFrame);
// if (menu == null) return;
// for (MenuElement menuItem : menu.getSubElements()) {
// JPopupMenu popUp = (JPopupMenu) menuItem;
// for (MenuElement subElement : popUp.getSubElements()) {
// if (!(subElement instanceof ViewMenuItem) /*MyMenuItem*/)
// continue;
// ViewMenuItem viewMenuItem = (ViewMenuItem) subElement;
// if (viewMenuItem.compareTo(internalFrame) == 0) {
// popUp.remove(viewMenuItem);
// refreshItems(mainFrame);
// return;
// }
// }
// }
// }
//
// public static void refreshItems(JFrame mainFrame) {
// boolean first = true;
// boolean next = false;
// ViewMenuItem viewMenuItem = null;
// ViewMenuItem lastMenuItem = null;
// JMenu menu = getViewMenu(mainFrame);
// if (menu == null) return;
// for (MenuElement menuItem : menu.getSubElements()) {
// JPopupMenu popUp = (JPopupMenu) menuItem;
// for (MenuElement subElement : popUp.getSubElements()) {
// if (subElement instanceof MyMenuItem)
// continue;
// lastMenuItem = viewMenuItem;
// viewMenuItem = (ViewMenuItem) subElement;
// viewMenuItem.setAccelerator(null);
//
// if (next) {
// viewMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
// next = false;
// }
//
// JDesktopPane desktop = ((FunPhotoTimeFrame) mainFrame).desktop;
// if (viewMenuItem.compareTo(desktop.getSelectedFrame()) == 0) {
// //viewMenuItem.setText("> "+viewMenuItem.getText());
// if (!first)
// lastMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, ActionEvent.SHIFT_MASK));
// next = true;
// }
//
// if (first) {
// viewMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0));
// first = false;
// }
// }
// }
// if (!first) {
// viewMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0));
// }
// }
//
// /*
// * COMMON
// */
//
// private static JMenu getViewMenu(JFrame mainFrame) {
// JMenuBar menuBar = mainFrame.getJMenuBar();
// MenuElement[] menuElements = menuBar.getSubElements();
// for (MenuElement menuElement : menuElements) {
// if (menuElement instanceof JMenu) {
// JMenu menu = (JMenu) menuElement;
// String name = menu.getText();
// if (name.equalsIgnoreCase(MENU_NAME)) {
// return menu;
// }
// }
// }
// return null;
// }
//
// }
// Path: src/main/java/si/gto76/funphototime/FunPhotoTimeFrame.java
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JDesktopPane;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JMenu;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu.Separator;
import javax.swing.MenuElement;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
import si.gto76.funphototime.mymenu.MyMenuInterface;
import si.gto76.funphototime.mymenu.ViewMenuUtil;
package si.gto76.funphototime;
public class FunPhotoTimeFrame extends JFrame
implements ContainerListener, MouseWheelListener {
private static final long serialVersionUID = 5772778382924626863L;
public JDesktopPane desktop;
private Menu meni; | public ViewMenuUtil vmu = new ViewMenuUtil(); |
gto76/fun-photo-time | src/main/java/si/gto76/funphototime/Menu.java | // Path: src/main/java/si/gto76/funphototime/mymenu/MyMenu.java
// public class MyMenu extends JMenu
// implements MyMenuInterface {
//
// private static final long serialVersionUID = -5243862216542202503L;
// private int noOfOperands;
//
// public MyMenu(int noOfOperands) {
// super();
// this.noOfOperands = noOfOperands;
// }
//
// public MyMenu(String text, int noOfOperands) {
// super(text);
// this.noOfOperands = noOfOperands;
// }
//
// public int noOfOperands() {
// return noOfOperands;
// }
// }
//
// Path: src/main/java/si/gto76/funphototime/mymenu/MyMenuItem.java
// public class MyMenuItem extends JMenuItem
// implements MyMenuInterface {
//
// private static final long serialVersionUID = -3854336471073348117L;
// private int noOfOperands;
//
// public MyMenuItem(int noOfOperands) {
// super();
// this.noOfOperands = noOfOperands;
// }
//
// public MyMenuItem(String text, int noOfOperands) {
// super(text);
// this.noOfOperands = noOfOperands;
// }
//
// public int noOfOperands() {
// return noOfOperands;
// }
// }
| import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import javax.swing.JMenuBar;
import javax.swing.KeyStroke;
import si.gto76.funphototime.mymenu.MyMenu;
import si.gto76.funphototime.mymenu.MyMenuItem; | package si.gto76.funphototime;
class Menu {
JMenuBar menuBar = new JMenuBar();
| // Path: src/main/java/si/gto76/funphototime/mymenu/MyMenu.java
// public class MyMenu extends JMenu
// implements MyMenuInterface {
//
// private static final long serialVersionUID = -5243862216542202503L;
// private int noOfOperands;
//
// public MyMenu(int noOfOperands) {
// super();
// this.noOfOperands = noOfOperands;
// }
//
// public MyMenu(String text, int noOfOperands) {
// super(text);
// this.noOfOperands = noOfOperands;
// }
//
// public int noOfOperands() {
// return noOfOperands;
// }
// }
//
// Path: src/main/java/si/gto76/funphototime/mymenu/MyMenuItem.java
// public class MyMenuItem extends JMenuItem
// implements MyMenuInterface {
//
// private static final long serialVersionUID = -3854336471073348117L;
// private int noOfOperands;
//
// public MyMenuItem(int noOfOperands) {
// super();
// this.noOfOperands = noOfOperands;
// }
//
// public MyMenuItem(String text, int noOfOperands) {
// super(text);
// this.noOfOperands = noOfOperands;
// }
//
// public int noOfOperands() {
// return noOfOperands;
// }
// }
// Path: src/main/java/si/gto76/funphototime/Menu.java
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import javax.swing.JMenuBar;
import javax.swing.KeyStroke;
import si.gto76.funphototime.mymenu.MyMenu;
import si.gto76.funphototime.mymenu.MyMenuItem;
package si.gto76.funphototime;
class Menu {
JMenuBar menuBar = new JMenuBar();
| MyMenu menuFile = new MyMenu(0); |
gto76/fun-photo-time | src/main/java/si/gto76/funphototime/Menu.java | // Path: src/main/java/si/gto76/funphototime/mymenu/MyMenu.java
// public class MyMenu extends JMenu
// implements MyMenuInterface {
//
// private static final long serialVersionUID = -5243862216542202503L;
// private int noOfOperands;
//
// public MyMenu(int noOfOperands) {
// super();
// this.noOfOperands = noOfOperands;
// }
//
// public MyMenu(String text, int noOfOperands) {
// super(text);
// this.noOfOperands = noOfOperands;
// }
//
// public int noOfOperands() {
// return noOfOperands;
// }
// }
//
// Path: src/main/java/si/gto76/funphototime/mymenu/MyMenuItem.java
// public class MyMenuItem extends JMenuItem
// implements MyMenuInterface {
//
// private static final long serialVersionUID = -3854336471073348117L;
// private int noOfOperands;
//
// public MyMenuItem(int noOfOperands) {
// super();
// this.noOfOperands = noOfOperands;
// }
//
// public MyMenuItem(String text, int noOfOperands) {
// super(text);
// this.noOfOperands = noOfOperands;
// }
//
// public int noOfOperands() {
// return noOfOperands;
// }
// }
| import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import javax.swing.JMenuBar;
import javax.swing.KeyStroke;
import si.gto76.funphototime.mymenu.MyMenu;
import si.gto76.funphototime.mymenu.MyMenuItem; | package si.gto76.funphototime;
class Menu {
JMenuBar menuBar = new JMenuBar();
MyMenu menuFile = new MyMenu(0); | // Path: src/main/java/si/gto76/funphototime/mymenu/MyMenu.java
// public class MyMenu extends JMenu
// implements MyMenuInterface {
//
// private static final long serialVersionUID = -5243862216542202503L;
// private int noOfOperands;
//
// public MyMenu(int noOfOperands) {
// super();
// this.noOfOperands = noOfOperands;
// }
//
// public MyMenu(String text, int noOfOperands) {
// super(text);
// this.noOfOperands = noOfOperands;
// }
//
// public int noOfOperands() {
// return noOfOperands;
// }
// }
//
// Path: src/main/java/si/gto76/funphototime/mymenu/MyMenuItem.java
// public class MyMenuItem extends JMenuItem
// implements MyMenuInterface {
//
// private static final long serialVersionUID = -3854336471073348117L;
// private int noOfOperands;
//
// public MyMenuItem(int noOfOperands) {
// super();
// this.noOfOperands = noOfOperands;
// }
//
// public MyMenuItem(String text, int noOfOperands) {
// super(text);
// this.noOfOperands = noOfOperands;
// }
//
// public int noOfOperands() {
// return noOfOperands;
// }
// }
// Path: src/main/java/si/gto76/funphototime/Menu.java
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import javax.swing.JMenuBar;
import javax.swing.KeyStroke;
import si.gto76.funphototime.mymenu.MyMenu;
import si.gto76.funphototime.mymenu.MyMenuItem;
package si.gto76.funphototime;
class Menu {
JMenuBar menuBar = new JMenuBar();
MyMenu menuFile = new MyMenu(0); | MyMenuItem menuFileOpen = new MyMenuItem(0); |
xuraylei/floodlight_with_topoguard | src/main/java/net/floodlightcontroller/core/web/CounterResource.java | // Path: src/main/java/net/floodlightcontroller/counter/CounterValue.java
// public class CounterValue {
// public enum CounterType {
// LONG,
// DOUBLE
// }
//
// protected CounterType type;
// protected long longValue;
// protected double doubleValue;
//
// public CounterValue(CounterType type) {
// this.type = CounterType.LONG;
// this.longValue = 0;
// this.doubleValue = 0.0;
// }
//
// /**
// * This method is only applicable to type long.
// * Setter() should be used for type double
// */
// public void increment(long delta) {
// if (this.type == CounterType.LONG) {
// this.longValue += delta;
// } else {
// throw new IllegalArgumentException("Invalid counter type. This counter is not a long type.");
// }
// }
//
// public void setLongValue(long value) {
// if (this.type == CounterType.LONG) {
// this.longValue = value;
// } else {
// throw new IllegalArgumentException("Invalid counter type. This counter is not a long type.");
// }
// }
//
// public void setDoubleValue(double value) {
// if (this.type == CounterType.DOUBLE) {
// this.doubleValue = value;
// } else {
// throw new IllegalArgumentException("Invalid counter type. This counter is not a double type.");
// }
// }
//
// public long getLong() {
// if (this.type == CounterType.LONG) {
// return this.longValue;
// } else {
// throw new IllegalArgumentException("Invalid counter type. This counter is not a long type.");
// }
// }
//
// public double getDouble() {
// if (this.type == CounterType.DOUBLE) {
// return this.doubleValue;
// } else {
// throw new IllegalArgumentException("Invalid counter type. This counter is not a double type.");
// }
// }
//
//
// public CounterType getType() {
// return this.type;
// }
//
// public String toString() {
// String ret = "{type: ";
// if (this.type == CounterType.DOUBLE) {
// ret += "Double" + ", value: " + this.doubleValue + "}";
// } else {
// ret += "Long" + ", value: " + this.longValue + "}";
// }
// return ret;
// }
//
//
// }
//
// Path: src/main/java/net/floodlightcontroller/counter/ICounter.java
// public interface ICounter {
//
// /**
// * Most commonly used method
// */
// public void increment();
//
// /**
// * Used primarily for flushing thread local updates
// */
// public void increment(Date d, long delta);
//
// /**
// * Counter value setter
// */
// public void setCounter(Date d, CounterValue value);
//
// /**
// * Return the most current value
// */
// public Date getCounterDate();
//
// /**
// * Return the most current value
// */
// public CounterValue getCounterValue();
//
// /**
// * Reset the value
// */
// public void reset(Date d);
//
//
// public static enum DateSpan {
// REALTIME,
// SECONDS,
// MINUTES,
// HOURS,
// DAYS,
// WEEKS
// }
// }
| import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import net.floodlightcontroller.counter.CounterValue;
import net.floodlightcontroller.counter.ICounter;
import org.restlet.resource.Get; | /**
* Copyright 2011, Big Switch Networks, Inc.
* Originally created by David Erickson, Stanford University
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
package net.floodlightcontroller.core.web;
public class CounterResource extends CounterResourceBase {
@Get("json")
public Map<String, Object> retrieve() {
String counterTitle =
(String) getRequestAttributes().get("counterTitle");
Map<String, Object> model = new HashMap<String,Object>(); | // Path: src/main/java/net/floodlightcontroller/counter/CounterValue.java
// public class CounterValue {
// public enum CounterType {
// LONG,
// DOUBLE
// }
//
// protected CounterType type;
// protected long longValue;
// protected double doubleValue;
//
// public CounterValue(CounterType type) {
// this.type = CounterType.LONG;
// this.longValue = 0;
// this.doubleValue = 0.0;
// }
//
// /**
// * This method is only applicable to type long.
// * Setter() should be used for type double
// */
// public void increment(long delta) {
// if (this.type == CounterType.LONG) {
// this.longValue += delta;
// } else {
// throw new IllegalArgumentException("Invalid counter type. This counter is not a long type.");
// }
// }
//
// public void setLongValue(long value) {
// if (this.type == CounterType.LONG) {
// this.longValue = value;
// } else {
// throw new IllegalArgumentException("Invalid counter type. This counter is not a long type.");
// }
// }
//
// public void setDoubleValue(double value) {
// if (this.type == CounterType.DOUBLE) {
// this.doubleValue = value;
// } else {
// throw new IllegalArgumentException("Invalid counter type. This counter is not a double type.");
// }
// }
//
// public long getLong() {
// if (this.type == CounterType.LONG) {
// return this.longValue;
// } else {
// throw new IllegalArgumentException("Invalid counter type. This counter is not a long type.");
// }
// }
//
// public double getDouble() {
// if (this.type == CounterType.DOUBLE) {
// return this.doubleValue;
// } else {
// throw new IllegalArgumentException("Invalid counter type. This counter is not a double type.");
// }
// }
//
//
// public CounterType getType() {
// return this.type;
// }
//
// public String toString() {
// String ret = "{type: ";
// if (this.type == CounterType.DOUBLE) {
// ret += "Double" + ", value: " + this.doubleValue + "}";
// } else {
// ret += "Long" + ", value: " + this.longValue + "}";
// }
// return ret;
// }
//
//
// }
//
// Path: src/main/java/net/floodlightcontroller/counter/ICounter.java
// public interface ICounter {
//
// /**
// * Most commonly used method
// */
// public void increment();
//
// /**
// * Used primarily for flushing thread local updates
// */
// public void increment(Date d, long delta);
//
// /**
// * Counter value setter
// */
// public void setCounter(Date d, CounterValue value);
//
// /**
// * Return the most current value
// */
// public Date getCounterDate();
//
// /**
// * Return the most current value
// */
// public CounterValue getCounterValue();
//
// /**
// * Reset the value
// */
// public void reset(Date d);
//
//
// public static enum DateSpan {
// REALTIME,
// SECONDS,
// MINUTES,
// HOURS,
// DAYS,
// WEEKS
// }
// }
// Path: src/main/java/net/floodlightcontroller/core/web/CounterResource.java
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import net.floodlightcontroller.counter.CounterValue;
import net.floodlightcontroller.counter.ICounter;
import org.restlet.resource.Get;
/**
* Copyright 2011, Big Switch Networks, Inc.
* Originally created by David Erickson, Stanford University
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
package net.floodlightcontroller.core.web;
public class CounterResource extends CounterResourceBase {
@Get("json")
public Map<String, Object> retrieve() {
String counterTitle =
(String) getRequestAttributes().get("counterTitle");
Map<String, Object> model = new HashMap<String,Object>(); | CounterValue v; |
xuraylei/floodlight_with_topoguard | src/main/java/net/floodlightcontroller/core/web/CounterResource.java | // Path: src/main/java/net/floodlightcontroller/counter/CounterValue.java
// public class CounterValue {
// public enum CounterType {
// LONG,
// DOUBLE
// }
//
// protected CounterType type;
// protected long longValue;
// protected double doubleValue;
//
// public CounterValue(CounterType type) {
// this.type = CounterType.LONG;
// this.longValue = 0;
// this.doubleValue = 0.0;
// }
//
// /**
// * This method is only applicable to type long.
// * Setter() should be used for type double
// */
// public void increment(long delta) {
// if (this.type == CounterType.LONG) {
// this.longValue += delta;
// } else {
// throw new IllegalArgumentException("Invalid counter type. This counter is not a long type.");
// }
// }
//
// public void setLongValue(long value) {
// if (this.type == CounterType.LONG) {
// this.longValue = value;
// } else {
// throw new IllegalArgumentException("Invalid counter type. This counter is not a long type.");
// }
// }
//
// public void setDoubleValue(double value) {
// if (this.type == CounterType.DOUBLE) {
// this.doubleValue = value;
// } else {
// throw new IllegalArgumentException("Invalid counter type. This counter is not a double type.");
// }
// }
//
// public long getLong() {
// if (this.type == CounterType.LONG) {
// return this.longValue;
// } else {
// throw new IllegalArgumentException("Invalid counter type. This counter is not a long type.");
// }
// }
//
// public double getDouble() {
// if (this.type == CounterType.DOUBLE) {
// return this.doubleValue;
// } else {
// throw new IllegalArgumentException("Invalid counter type. This counter is not a double type.");
// }
// }
//
//
// public CounterType getType() {
// return this.type;
// }
//
// public String toString() {
// String ret = "{type: ";
// if (this.type == CounterType.DOUBLE) {
// ret += "Double" + ", value: " + this.doubleValue + "}";
// } else {
// ret += "Long" + ", value: " + this.longValue + "}";
// }
// return ret;
// }
//
//
// }
//
// Path: src/main/java/net/floodlightcontroller/counter/ICounter.java
// public interface ICounter {
//
// /**
// * Most commonly used method
// */
// public void increment();
//
// /**
// * Used primarily for flushing thread local updates
// */
// public void increment(Date d, long delta);
//
// /**
// * Counter value setter
// */
// public void setCounter(Date d, CounterValue value);
//
// /**
// * Return the most current value
// */
// public Date getCounterDate();
//
// /**
// * Return the most current value
// */
// public CounterValue getCounterValue();
//
// /**
// * Reset the value
// */
// public void reset(Date d);
//
//
// public static enum DateSpan {
// REALTIME,
// SECONDS,
// MINUTES,
// HOURS,
// DAYS,
// WEEKS
// }
// }
| import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import net.floodlightcontroller.counter.CounterValue;
import net.floodlightcontroller.counter.ICounter;
import org.restlet.resource.Get; | /**
* Copyright 2011, Big Switch Networks, Inc.
* Originally created by David Erickson, Stanford University
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
package net.floodlightcontroller.core.web;
public class CounterResource extends CounterResourceBase {
@Get("json")
public Map<String, Object> retrieve() {
String counterTitle =
(String) getRequestAttributes().get("counterTitle");
Map<String, Object> model = new HashMap<String,Object>();
CounterValue v;
if (counterTitle.equalsIgnoreCase("all")) { | // Path: src/main/java/net/floodlightcontroller/counter/CounterValue.java
// public class CounterValue {
// public enum CounterType {
// LONG,
// DOUBLE
// }
//
// protected CounterType type;
// protected long longValue;
// protected double doubleValue;
//
// public CounterValue(CounterType type) {
// this.type = CounterType.LONG;
// this.longValue = 0;
// this.doubleValue = 0.0;
// }
//
// /**
// * This method is only applicable to type long.
// * Setter() should be used for type double
// */
// public void increment(long delta) {
// if (this.type == CounterType.LONG) {
// this.longValue += delta;
// } else {
// throw new IllegalArgumentException("Invalid counter type. This counter is not a long type.");
// }
// }
//
// public void setLongValue(long value) {
// if (this.type == CounterType.LONG) {
// this.longValue = value;
// } else {
// throw new IllegalArgumentException("Invalid counter type. This counter is not a long type.");
// }
// }
//
// public void setDoubleValue(double value) {
// if (this.type == CounterType.DOUBLE) {
// this.doubleValue = value;
// } else {
// throw new IllegalArgumentException("Invalid counter type. This counter is not a double type.");
// }
// }
//
// public long getLong() {
// if (this.type == CounterType.LONG) {
// return this.longValue;
// } else {
// throw new IllegalArgumentException("Invalid counter type. This counter is not a long type.");
// }
// }
//
// public double getDouble() {
// if (this.type == CounterType.DOUBLE) {
// return this.doubleValue;
// } else {
// throw new IllegalArgumentException("Invalid counter type. This counter is not a double type.");
// }
// }
//
//
// public CounterType getType() {
// return this.type;
// }
//
// public String toString() {
// String ret = "{type: ";
// if (this.type == CounterType.DOUBLE) {
// ret += "Double" + ", value: " + this.doubleValue + "}";
// } else {
// ret += "Long" + ", value: " + this.longValue + "}";
// }
// return ret;
// }
//
//
// }
//
// Path: src/main/java/net/floodlightcontroller/counter/ICounter.java
// public interface ICounter {
//
// /**
// * Most commonly used method
// */
// public void increment();
//
// /**
// * Used primarily for flushing thread local updates
// */
// public void increment(Date d, long delta);
//
// /**
// * Counter value setter
// */
// public void setCounter(Date d, CounterValue value);
//
// /**
// * Return the most current value
// */
// public Date getCounterDate();
//
// /**
// * Return the most current value
// */
// public CounterValue getCounterValue();
//
// /**
// * Reset the value
// */
// public void reset(Date d);
//
//
// public static enum DateSpan {
// REALTIME,
// SECONDS,
// MINUTES,
// HOURS,
// DAYS,
// WEEKS
// }
// }
// Path: src/main/java/net/floodlightcontroller/core/web/CounterResource.java
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import net.floodlightcontroller.counter.CounterValue;
import net.floodlightcontroller.counter.ICounter;
import org.restlet.resource.Get;
/**
* Copyright 2011, Big Switch Networks, Inc.
* Originally created by David Erickson, Stanford University
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
package net.floodlightcontroller.core.web;
public class CounterResource extends CounterResourceBase {
@Get("json")
public Map<String, Object> retrieve() {
String counterTitle =
(String) getRequestAttributes().get("counterTitle");
Map<String, Object> model = new HashMap<String,Object>();
CounterValue v;
if (counterTitle.equalsIgnoreCase("all")) { | Map<String, ICounter> counters = this.counterStore.getAll(); |
xuraylei/floodlight_with_topoguard | src/main/java/net/floodlightcontroller/core/RoleInfo.java | // Path: src/main/java/net/floodlightcontroller/core/IFloodlightProviderService.java
// public static enum Role {
// EQUAL(OFRoleVendorData.NX_ROLE_OTHER),
// MASTER(OFRoleVendorData.NX_ROLE_MASTER),
// SLAVE(OFRoleVendorData.NX_ROLE_SLAVE);
//
// private final int nxRole;
//
// private Role(int nxRole) {
// this.nxRole = nxRole;
// }
//
// private static Map<Integer,Role> nxRoleToEnum
// = new HashMap<Integer,Role>();
// static {
// for(Role r: Role.values())
// nxRoleToEnum.put(r.toNxRole(), r);
// }
// public int toNxRole() {
// return nxRole;
// }
// // Return the enum representing the given nxRole or null if no
// // such role exists
// public static Role fromNxRole(int nxRole) {
// return nxRoleToEnum.get(nxRole);
// }
// };
| import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import net.floodlightcontroller.core.IFloodlightProviderService.Role;
import com.fasterxml.jackson.annotation.JsonProperty; | /**
* Copyright 2013, Big Switch Networks, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
package net.floodlightcontroller.core;
public class RoleInfo {
protected String role;
protected String roleChangeDescription;
protected Date roleChangeDateTime;
public RoleInfo() {
}
public RoleInfo(RoleInfo o) {
role = o.role;
roleChangeDescription = o.roleChangeDescription;
roleChangeDateTime = (Date)o.roleChangeDateTime.clone();
}
public RoleInfo(String role) {
setRole(role);
}
| // Path: src/main/java/net/floodlightcontroller/core/IFloodlightProviderService.java
// public static enum Role {
// EQUAL(OFRoleVendorData.NX_ROLE_OTHER),
// MASTER(OFRoleVendorData.NX_ROLE_MASTER),
// SLAVE(OFRoleVendorData.NX_ROLE_SLAVE);
//
// private final int nxRole;
//
// private Role(int nxRole) {
// this.nxRole = nxRole;
// }
//
// private static Map<Integer,Role> nxRoleToEnum
// = new HashMap<Integer,Role>();
// static {
// for(Role r: Role.values())
// nxRoleToEnum.put(r.toNxRole(), r);
// }
// public int toNxRole() {
// return nxRole;
// }
// // Return the enum representing the given nxRole or null if no
// // such role exists
// public static Role fromNxRole(int nxRole) {
// return nxRoleToEnum.get(nxRole);
// }
// };
// Path: src/main/java/net/floodlightcontroller/core/RoleInfo.java
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import net.floodlightcontroller.core.IFloodlightProviderService.Role;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Copyright 2013, Big Switch Networks, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
package net.floodlightcontroller.core;
public class RoleInfo {
protected String role;
protected String roleChangeDescription;
protected Date roleChangeDateTime;
public RoleInfo() {
}
public RoleInfo(RoleInfo o) {
role = o.role;
roleChangeDescription = o.roleChangeDescription;
roleChangeDateTime = (Date)o.roleChangeDateTime.clone();
}
public RoleInfo(String role) {
setRole(role);
}
| public RoleInfo(Role role, String description) { |
xuraylei/floodlight_with_topoguard | src/main/java/net/floodlightcontroller/routing/RoutingDecision.java | // Path: src/main/java/net/floodlightcontroller/devicemanager/SwitchPort.java
// public class SwitchPort {
// @JsonSerialize(using=ToStringSerializer.class)
// public enum ErrorStatus {
// DUPLICATE_DEVICE("duplicate-device");
//
// private String value;
// ErrorStatus(String v) {
// value = v;
// }
//
// @Override
// public String toString() {
// return value;
// }
//
// public static ErrorStatus fromString(String str) {
// for (ErrorStatus m : ErrorStatus.values()) {
// if (m.value.equals(str)) {
// return m;
// }
// }
// return null;
// }
// }
//
// private final long switchDPID;
// private final int port;
// private final ErrorStatus errorStatus;
//
// /**
// * Simple constructor
// * @param switchDPID the dpid
// * @param port the port
// * @param errorStatus any error status for the switch port
// */
// public SwitchPort(long switchDPID, int port, ErrorStatus errorStatus) {
// super();
// this.switchDPID = switchDPID;
// this.port = port;
// this.errorStatus = errorStatus;
// }
//
// /**
// * Simple constructor
// * @param switchDPID the dpid
// * @param port the port
// */
// public SwitchPort(long switchDPID, int port) {
// super();
// this.switchDPID = switchDPID;
// this.port = port;
// this.errorStatus = null;
// }
//
// // ***************
// // Getters/Setters
// // ***************
//
// @JsonSerialize(using=DPIDSerializer.class)
// public long getSwitchDPID() {
// return switchDPID;
// }
//
// public int getPort() {
// return port;
// }
//
// public ErrorStatus getErrorStatus() {
// return errorStatus;
// }
//
// // ******
// // Object
// // ******
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result
// + ((errorStatus == null)
// ? 0
// : errorStatus.hashCode());
// result = prime * result + port;
// result = prime * result + (int) (switchDPID ^ (switchDPID >>> 32));
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) return true;
// if (obj == null) return false;
// if (getClass() != obj.getClass()) return false;
// SwitchPort other = (SwitchPort) obj;
// if (errorStatus != other.errorStatus) return false;
// if (port != other.port) return false;
// if (switchDPID != other.switchDPID) return false;
// return true;
// }
//
// @Override
// public String toString() {
// return "SwitchPort [switchDPID=" + HexString.toHexString(switchDPID) +
// ", port=" + port + ", errorStatus=" + errorStatus + "]";
// }
//
// }
| import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.floodlightcontroller.core.FloodlightContext;
import net.floodlightcontroller.devicemanager.IDevice;
import net.floodlightcontroller.devicemanager.SwitchPort; | /**
* Copyright 2013, Big Switch Networks, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
package net.floodlightcontroller.routing;
public class RoutingDecision implements IRoutingDecision {
protected RoutingAction action;
protected Integer wildcards;
protected short hardTimeout; | // Path: src/main/java/net/floodlightcontroller/devicemanager/SwitchPort.java
// public class SwitchPort {
// @JsonSerialize(using=ToStringSerializer.class)
// public enum ErrorStatus {
// DUPLICATE_DEVICE("duplicate-device");
//
// private String value;
// ErrorStatus(String v) {
// value = v;
// }
//
// @Override
// public String toString() {
// return value;
// }
//
// public static ErrorStatus fromString(String str) {
// for (ErrorStatus m : ErrorStatus.values()) {
// if (m.value.equals(str)) {
// return m;
// }
// }
// return null;
// }
// }
//
// private final long switchDPID;
// private final int port;
// private final ErrorStatus errorStatus;
//
// /**
// * Simple constructor
// * @param switchDPID the dpid
// * @param port the port
// * @param errorStatus any error status for the switch port
// */
// public SwitchPort(long switchDPID, int port, ErrorStatus errorStatus) {
// super();
// this.switchDPID = switchDPID;
// this.port = port;
// this.errorStatus = errorStatus;
// }
//
// /**
// * Simple constructor
// * @param switchDPID the dpid
// * @param port the port
// */
// public SwitchPort(long switchDPID, int port) {
// super();
// this.switchDPID = switchDPID;
// this.port = port;
// this.errorStatus = null;
// }
//
// // ***************
// // Getters/Setters
// // ***************
//
// @JsonSerialize(using=DPIDSerializer.class)
// public long getSwitchDPID() {
// return switchDPID;
// }
//
// public int getPort() {
// return port;
// }
//
// public ErrorStatus getErrorStatus() {
// return errorStatus;
// }
//
// // ******
// // Object
// // ******
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result
// + ((errorStatus == null)
// ? 0
// : errorStatus.hashCode());
// result = prime * result + port;
// result = prime * result + (int) (switchDPID ^ (switchDPID >>> 32));
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) return true;
// if (obj == null) return false;
// if (getClass() != obj.getClass()) return false;
// SwitchPort other = (SwitchPort) obj;
// if (errorStatus != other.errorStatus) return false;
// if (port != other.port) return false;
// if (switchDPID != other.switchDPID) return false;
// return true;
// }
//
// @Override
// public String toString() {
// return "SwitchPort [switchDPID=" + HexString.toHexString(switchDPID) +
// ", port=" + port + ", errorStatus=" + errorStatus + "]";
// }
//
// }
// Path: src/main/java/net/floodlightcontroller/routing/RoutingDecision.java
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.floodlightcontroller.core.FloodlightContext;
import net.floodlightcontroller.devicemanager.IDevice;
import net.floodlightcontroller.devicemanager.SwitchPort;
/**
* Copyright 2013, Big Switch Networks, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
package net.floodlightcontroller.routing;
public class RoutingDecision implements IRoutingDecision {
protected RoutingAction action;
protected Integer wildcards;
protected short hardTimeout; | protected SwitchPort srcPort; |
xuraylei/floodlight_with_topoguard | src/main/java/net/floodlightcontroller/linkdiscovery/web/LinksResource.java | // Path: src/main/java/net/floodlightcontroller/linkdiscovery/ILinkDiscovery.java
// public enum LinkDirection {
// UNIDIRECTIONAL {
// @Override
// public String toString() {
// return "unidirectional";
// }
// },
// BIDIRECTIONAL {
// @Override
// public String toString() {
// return "bidirectional";
// }
// }
// }
//
// Path: src/main/java/net/floodlightcontroller/linkdiscovery/ILinkDiscovery.java
// public enum LinkType {
// INVALID_LINK {
// @Override
// public String toString() {
// return "invalid";
// }
// },
// DIRECT_LINK{
// @Override
// public String toString() {
// return "internal";
// }
// },
// MULTIHOP_LINK {
// @Override
// public String toString() {
// return "external";
// }
// },
// TUNNEL {
// @Override
// public String toString() {
// return "tunnel";
// }
// }
// };
| import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import net.floodlightcontroller.linkdiscovery.ILinkDiscovery.LinkDirection;
import net.floodlightcontroller.linkdiscovery.ILinkDiscovery.LinkType;
import net.floodlightcontroller.linkdiscovery.ILinkDiscoveryService;
import net.floodlightcontroller.linkdiscovery.LinkInfo;
import net.floodlightcontroller.routing.Link;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource; | /**
* Copyright 2013, Big Switch Networks, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
package net.floodlightcontroller.linkdiscovery.web;
public class LinksResource extends ServerResource {
@Get("json")
public Set<LinkWithType> retrieve() {
ILinkDiscoveryService ld = (ILinkDiscoveryService)getContext().getAttributes().
get(ILinkDiscoveryService.class.getCanonicalName());
Map<Link, LinkInfo> links = new HashMap<Link, LinkInfo>();
Set<LinkWithType> returnLinkSet = new HashSet<LinkWithType>();
if (ld != null) {
links.putAll(ld.getLinks());
for (Link link: links.keySet()) {
LinkInfo info = links.get(link); | // Path: src/main/java/net/floodlightcontroller/linkdiscovery/ILinkDiscovery.java
// public enum LinkDirection {
// UNIDIRECTIONAL {
// @Override
// public String toString() {
// return "unidirectional";
// }
// },
// BIDIRECTIONAL {
// @Override
// public String toString() {
// return "bidirectional";
// }
// }
// }
//
// Path: src/main/java/net/floodlightcontroller/linkdiscovery/ILinkDiscovery.java
// public enum LinkType {
// INVALID_LINK {
// @Override
// public String toString() {
// return "invalid";
// }
// },
// DIRECT_LINK{
// @Override
// public String toString() {
// return "internal";
// }
// },
// MULTIHOP_LINK {
// @Override
// public String toString() {
// return "external";
// }
// },
// TUNNEL {
// @Override
// public String toString() {
// return "tunnel";
// }
// }
// };
// Path: src/main/java/net/floodlightcontroller/linkdiscovery/web/LinksResource.java
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import net.floodlightcontroller.linkdiscovery.ILinkDiscovery.LinkDirection;
import net.floodlightcontroller.linkdiscovery.ILinkDiscovery.LinkType;
import net.floodlightcontroller.linkdiscovery.ILinkDiscoveryService;
import net.floodlightcontroller.linkdiscovery.LinkInfo;
import net.floodlightcontroller.routing.Link;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
/**
* Copyright 2013, Big Switch Networks, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
package net.floodlightcontroller.linkdiscovery.web;
public class LinksResource extends ServerResource {
@Get("json")
public Set<LinkWithType> retrieve() {
ILinkDiscoveryService ld = (ILinkDiscoveryService)getContext().getAttributes().
get(ILinkDiscoveryService.class.getCanonicalName());
Map<Link, LinkInfo> links = new HashMap<Link, LinkInfo>();
Set<LinkWithType> returnLinkSet = new HashSet<LinkWithType>();
if (ld != null) {
links.putAll(ld.getLinks());
for (Link link: links.keySet()) {
LinkInfo info = links.get(link); | LinkType type = ld.getLinkType(link, info); |
xuraylei/floodlight_with_topoguard | src/main/java/net/floodlightcontroller/linkdiscovery/web/LinksResource.java | // Path: src/main/java/net/floodlightcontroller/linkdiscovery/ILinkDiscovery.java
// public enum LinkDirection {
// UNIDIRECTIONAL {
// @Override
// public String toString() {
// return "unidirectional";
// }
// },
// BIDIRECTIONAL {
// @Override
// public String toString() {
// return "bidirectional";
// }
// }
// }
//
// Path: src/main/java/net/floodlightcontroller/linkdiscovery/ILinkDiscovery.java
// public enum LinkType {
// INVALID_LINK {
// @Override
// public String toString() {
// return "invalid";
// }
// },
// DIRECT_LINK{
// @Override
// public String toString() {
// return "internal";
// }
// },
// MULTIHOP_LINK {
// @Override
// public String toString() {
// return "external";
// }
// },
// TUNNEL {
// @Override
// public String toString() {
// return "tunnel";
// }
// }
// };
| import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import net.floodlightcontroller.linkdiscovery.ILinkDiscovery.LinkDirection;
import net.floodlightcontroller.linkdiscovery.ILinkDiscovery.LinkType;
import net.floodlightcontroller.linkdiscovery.ILinkDiscoveryService;
import net.floodlightcontroller.linkdiscovery.LinkInfo;
import net.floodlightcontroller.routing.Link;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource; | /**
* Copyright 2013, Big Switch Networks, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
package net.floodlightcontroller.linkdiscovery.web;
public class LinksResource extends ServerResource {
@Get("json")
public Set<LinkWithType> retrieve() {
ILinkDiscoveryService ld = (ILinkDiscoveryService)getContext().getAttributes().
get(ILinkDiscoveryService.class.getCanonicalName());
Map<Link, LinkInfo> links = new HashMap<Link, LinkInfo>();
Set<LinkWithType> returnLinkSet = new HashSet<LinkWithType>();
if (ld != null) {
links.putAll(ld.getLinks());
for (Link link: links.keySet()) {
LinkInfo info = links.get(link);
LinkType type = ld.getLinkType(link, info);
if (type == LinkType.DIRECT_LINK || type == LinkType.TUNNEL) {
LinkWithType lwt;
long src = link.getSrc();
long dst = link.getDst();
short srcPort = link.getSrcPort();
short dstPort = link.getDstPort();
Link otherLink = new Link(dst, dstPort, src, srcPort);
LinkInfo otherInfo = links.get(otherLink);
LinkType otherType = null;
if (otherInfo != null)
otherType = ld.getLinkType(otherLink, otherInfo);
if (otherType == LinkType.DIRECT_LINK ||
otherType == LinkType.TUNNEL) {
// This is a bi-direcitonal link.
// It is sufficient to add only one side of it.
if ((src < dst) || (src == dst && srcPort < dstPort)) {
lwt = new LinkWithType(link,
type, | // Path: src/main/java/net/floodlightcontroller/linkdiscovery/ILinkDiscovery.java
// public enum LinkDirection {
// UNIDIRECTIONAL {
// @Override
// public String toString() {
// return "unidirectional";
// }
// },
// BIDIRECTIONAL {
// @Override
// public String toString() {
// return "bidirectional";
// }
// }
// }
//
// Path: src/main/java/net/floodlightcontroller/linkdiscovery/ILinkDiscovery.java
// public enum LinkType {
// INVALID_LINK {
// @Override
// public String toString() {
// return "invalid";
// }
// },
// DIRECT_LINK{
// @Override
// public String toString() {
// return "internal";
// }
// },
// MULTIHOP_LINK {
// @Override
// public String toString() {
// return "external";
// }
// },
// TUNNEL {
// @Override
// public String toString() {
// return "tunnel";
// }
// }
// };
// Path: src/main/java/net/floodlightcontroller/linkdiscovery/web/LinksResource.java
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import net.floodlightcontroller.linkdiscovery.ILinkDiscovery.LinkDirection;
import net.floodlightcontroller.linkdiscovery.ILinkDiscovery.LinkType;
import net.floodlightcontroller.linkdiscovery.ILinkDiscoveryService;
import net.floodlightcontroller.linkdiscovery.LinkInfo;
import net.floodlightcontroller.routing.Link;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
/**
* Copyright 2013, Big Switch Networks, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
package net.floodlightcontroller.linkdiscovery.web;
public class LinksResource extends ServerResource {
@Get("json")
public Set<LinkWithType> retrieve() {
ILinkDiscoveryService ld = (ILinkDiscoveryService)getContext().getAttributes().
get(ILinkDiscoveryService.class.getCanonicalName());
Map<Link, LinkInfo> links = new HashMap<Link, LinkInfo>();
Set<LinkWithType> returnLinkSet = new HashSet<LinkWithType>();
if (ld != null) {
links.putAll(ld.getLinks());
for (Link link: links.keySet()) {
LinkInfo info = links.get(link);
LinkType type = ld.getLinkType(link, info);
if (type == LinkType.DIRECT_LINK || type == LinkType.TUNNEL) {
LinkWithType lwt;
long src = link.getSrc();
long dst = link.getDst();
short srcPort = link.getSrcPort();
short dstPort = link.getDstPort();
Link otherLink = new Link(dst, dstPort, src, srcPort);
LinkInfo otherInfo = links.get(otherLink);
LinkType otherType = null;
if (otherInfo != null)
otherType = ld.getLinkType(otherLink, otherInfo);
if (otherType == LinkType.DIRECT_LINK ||
otherType == LinkType.TUNNEL) {
// This is a bi-direcitonal link.
// It is sufficient to add only one side of it.
if ((src < dst) || (src == dst && srcPort < dstPort)) {
lwt = new LinkWithType(link,
type, | LinkDirection.BIDIRECTIONAL); |
xuraylei/floodlight_with_topoguard | src/main/java/org/openflow/vendor/nicira/OFNiciraVendorExtensions.java | // Path: src/main/java/org/openflow/protocol/vendor/OFBasicVendorId.java
// public class OFBasicVendorId extends OFVendorId {
//
// /**
// * The size of the data type value at the beginning of all vendor
// * data associated with this vendor id. The data type size must be
// * either 1, 2, 4 or 8.
// */
// protected int dataTypeSize;
//
// /**
// * Map of the vendor data types that have been registered for this
// * vendor id.
// */
// protected Map<Long, OFBasicVendorDataType> dataTypeMap =
// new HashMap<Long, OFBasicVendorDataType>();
//
// /**
// * Construct an OFVendorId that where the vendor data begins
// * with a data type value whose size is dataTypeSize.
// * @param id the id of the vendor, typically the OUI of a vendor
// * prefixed with 0.
// * @param dataTypeSize the size of the integral data type value
// * at the beginning of the vendor data. The value must be the
// * size of an integeral data type (i.e. either 1,2,4 or 8).
// */
// public OFBasicVendorId(int id, int dataTypeSize) {
// super(id);
// assert (dataTypeSize == 1) || (dataTypeSize == 2) ||
// (dataTypeSize == 4) || (dataTypeSize == 8);
// this.dataTypeSize = dataTypeSize;
// }
//
// /**
// * Get the size of the data type value at the beginning of the vendor
// * data. OFBasicVendorId assumes that this value is common across all of
// * the vendor data formats associated with a given vendor id.
// * @return
// */
// public int getDataTypeSize() {
// return dataTypeSize;
// }
//
// /**
// * Register a vendor data type with this vendor id.
// * @param vendorDataType
// */
// public void registerVendorDataType(OFBasicVendorDataType vendorDataType) {
// dataTypeMap.put(vendorDataType.getTypeValue(), vendorDataType);
// }
//
// /**
// * Lookup the OFVendorDataType instance that has been registered with
// * this vendor id.
// *
// * @param vendorDataType the integer code that was parsed from the
// * @return
// */
// public OFVendorDataType lookupVendorDataType(int vendorDataType) {
// return dataTypeMap.get(Long.valueOf(vendorDataType));
// }
//
// /**
// * This function parses enough of the data from the buffer to be able
// * to determine the appropriate OFVendorDataType for the data. It is meant
// * to be a reasonably generic implementation that will work for most
// * formats of vendor extensions. If the vendor data doesn't fit the
// * assumptions listed below, then this method will need to be overridden
// * to implement custom parsing.
// *
// * This implementation assumes that the vendor data begins with a data
// * type code that is used to distinguish different formats of vendor
// * data associated with a particular vendor ID.
// * The exact format of the data is vendor-defined, so we don't know how
// * how big the code is (or really even if there is a code). This code
// * assumes that the common case will be that the data does include
// * an initial type code (i.e. so that the vendor can have multiple
// * message/data types) and that the size is either 1, 2 or 4 bytes.
// * The size of the initial type code is configured by the subclass of
// * OFVendorId.
// *
// * @param data the channel buffer containing the vendor data.
// * @param length the length to the end of the enclosing message
// * @return the OFVendorDataType that can be used to instantiate the
// * appropriate subclass of OFVendorData.
// */
// public OFVendorDataType parseVendorDataType(ChannelBuffer data, int length) {
// OFVendorDataType vendorDataType = null;
//
// // Parse out the type code from the vendor data.
// long dataTypeValue = 0;
// if ((length == 0) || (length >= dataTypeSize)) {
// switch (dataTypeSize) {
// case 1:
// dataTypeValue = data.readByte();
// break;
// case 2:
// dataTypeValue = data.readShort();
// break;
// case 4:
// dataTypeValue = data.readInt();
// break;
// case 8:
// dataTypeValue = data.readLong();
// break;
// default:
// // This would be indicative of a coding error where the
// // dataTypeSize was specified incorrectly. This should have been
// // caught in the constructor for OFVendorId.
// assert false;
// }
//
// vendorDataType = dataTypeMap.get(dataTypeValue);
// }
//
// // If we weren't able to parse/map the data to a known OFVendorDataType,
// // then map it to a generic vendor data type.
// if (vendorDataType == null) {
// vendorDataType = new OFBasicVendorDataType(dataTypeValue,
// new Instantiable<OFVendorData>() {
// @Override
// public OFVendorData instantiate() {
// return new OFByteArrayVendorData();
// }
// }
// );
// }
//
// return vendorDataType;
// }
//
// }
| import org.openflow.protocol.vendor.OFBasicVendorDataType;
import org.openflow.protocol.vendor.OFBasicVendorId;
import org.openflow.protocol.vendor.OFVendorId; | package org.openflow.vendor.nicira;
public class OFNiciraVendorExtensions {
private static boolean initialized = false;
public static synchronized void initialize() {
if (initialized)
return;
// Configure openflowj to be able to parse the role request/reply
// vendor messages. | // Path: src/main/java/org/openflow/protocol/vendor/OFBasicVendorId.java
// public class OFBasicVendorId extends OFVendorId {
//
// /**
// * The size of the data type value at the beginning of all vendor
// * data associated with this vendor id. The data type size must be
// * either 1, 2, 4 or 8.
// */
// protected int dataTypeSize;
//
// /**
// * Map of the vendor data types that have been registered for this
// * vendor id.
// */
// protected Map<Long, OFBasicVendorDataType> dataTypeMap =
// new HashMap<Long, OFBasicVendorDataType>();
//
// /**
// * Construct an OFVendorId that where the vendor data begins
// * with a data type value whose size is dataTypeSize.
// * @param id the id of the vendor, typically the OUI of a vendor
// * prefixed with 0.
// * @param dataTypeSize the size of the integral data type value
// * at the beginning of the vendor data. The value must be the
// * size of an integeral data type (i.e. either 1,2,4 or 8).
// */
// public OFBasicVendorId(int id, int dataTypeSize) {
// super(id);
// assert (dataTypeSize == 1) || (dataTypeSize == 2) ||
// (dataTypeSize == 4) || (dataTypeSize == 8);
// this.dataTypeSize = dataTypeSize;
// }
//
// /**
// * Get the size of the data type value at the beginning of the vendor
// * data. OFBasicVendorId assumes that this value is common across all of
// * the vendor data formats associated with a given vendor id.
// * @return
// */
// public int getDataTypeSize() {
// return dataTypeSize;
// }
//
// /**
// * Register a vendor data type with this vendor id.
// * @param vendorDataType
// */
// public void registerVendorDataType(OFBasicVendorDataType vendorDataType) {
// dataTypeMap.put(vendorDataType.getTypeValue(), vendorDataType);
// }
//
// /**
// * Lookup the OFVendorDataType instance that has been registered with
// * this vendor id.
// *
// * @param vendorDataType the integer code that was parsed from the
// * @return
// */
// public OFVendorDataType lookupVendorDataType(int vendorDataType) {
// return dataTypeMap.get(Long.valueOf(vendorDataType));
// }
//
// /**
// * This function parses enough of the data from the buffer to be able
// * to determine the appropriate OFVendorDataType for the data. It is meant
// * to be a reasonably generic implementation that will work for most
// * formats of vendor extensions. If the vendor data doesn't fit the
// * assumptions listed below, then this method will need to be overridden
// * to implement custom parsing.
// *
// * This implementation assumes that the vendor data begins with a data
// * type code that is used to distinguish different formats of vendor
// * data associated with a particular vendor ID.
// * The exact format of the data is vendor-defined, so we don't know how
// * how big the code is (or really even if there is a code). This code
// * assumes that the common case will be that the data does include
// * an initial type code (i.e. so that the vendor can have multiple
// * message/data types) and that the size is either 1, 2 or 4 bytes.
// * The size of the initial type code is configured by the subclass of
// * OFVendorId.
// *
// * @param data the channel buffer containing the vendor data.
// * @param length the length to the end of the enclosing message
// * @return the OFVendorDataType that can be used to instantiate the
// * appropriate subclass of OFVendorData.
// */
// public OFVendorDataType parseVendorDataType(ChannelBuffer data, int length) {
// OFVendorDataType vendorDataType = null;
//
// // Parse out the type code from the vendor data.
// long dataTypeValue = 0;
// if ((length == 0) || (length >= dataTypeSize)) {
// switch (dataTypeSize) {
// case 1:
// dataTypeValue = data.readByte();
// break;
// case 2:
// dataTypeValue = data.readShort();
// break;
// case 4:
// dataTypeValue = data.readInt();
// break;
// case 8:
// dataTypeValue = data.readLong();
// break;
// default:
// // This would be indicative of a coding error where the
// // dataTypeSize was specified incorrectly. This should have been
// // caught in the constructor for OFVendorId.
// assert false;
// }
//
// vendorDataType = dataTypeMap.get(dataTypeValue);
// }
//
// // If we weren't able to parse/map the data to a known OFVendorDataType,
// // then map it to a generic vendor data type.
// if (vendorDataType == null) {
// vendorDataType = new OFBasicVendorDataType(dataTypeValue,
// new Instantiable<OFVendorData>() {
// @Override
// public OFVendorData instantiate() {
// return new OFByteArrayVendorData();
// }
// }
// );
// }
//
// return vendorDataType;
// }
//
// }
// Path: src/main/java/org/openflow/vendor/nicira/OFNiciraVendorExtensions.java
import org.openflow.protocol.vendor.OFBasicVendorDataType;
import org.openflow.protocol.vendor.OFBasicVendorId;
import org.openflow.protocol.vendor.OFVendorId;
package org.openflow.vendor.nicira;
public class OFNiciraVendorExtensions {
private static boolean initialized = false;
public static synchronized void initialize() {
if (initialized)
return;
// Configure openflowj to be able to parse the role request/reply
// vendor messages. | OFBasicVendorId niciraVendorId = |
xuraylei/floodlight_with_topoguard | src/main/java/org/sdnplatform/sync/internal/rpc/RPCChannelHandler.java | // Path: src/main/java/net/floodlightcontroller/debugcounter/IDebugCounter.java
// public interface IDebugCounter {
// /**
// * Increments the counter by 1 thread-locally, and immediately flushes to
// * the global counter storage. This method should be used for counters that
// * are updated outside the OF message processing pipeline.
// */
// void updateCounterWithFlush();
//
// /**
// * Increments the counter by 1 thread-locally. Flushing to the global
// * counter storage is delayed (happens with flushCounters() in IDebugCounterService),
// * resulting in higher performance. This method should be used for counters
// * updated in the OF message processing pipeline.
// */
// void updateCounterNoFlush();
//
// /**
// * Increments the counter thread-locally by the 'incr' specified, and immediately
// * flushes to the global counter storage. This method should be used for counters
// * that are updated outside the OF message processing pipeline.
// */
// void updateCounterWithFlush(int incr);
//
// /**
// * Increments the counter thread-locally by the 'incr' specified. Flushing to the global
// * counter storage is delayed (happens with flushCounters() in IDebugCounterService),
// * resulting in higher performance. This method should be used for counters
// * updated in the OF message processing pipeline.
// */
// void updateCounterNoFlush(int incr);
//
// /**
// * Retrieve the value of the counter from the global counter store
// */
// long getCounterValue();
// }
//
// Path: src/main/java/org/sdnplatform/sync/internal/rpc/RPCService.java
// protected static class NodeMessage extends Pair<Short,SyncMessage> {
// private static final long serialVersionUID = -3443080461324647922L;
//
// public NodeMessage(Short first, SyncMessage second) {
// super(first, second);
// }
// }
| import java.nio.ByteBuffer;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.Map.Entry;
import net.floodlightcontroller.core.annotations.LogMessageCategory;
import net.floodlightcontroller.core.annotations.LogMessageDoc;
import net.floodlightcontroller.debugcounter.IDebugCounter;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.channel.MessageEvent;
import org.sdnplatform.sync.IClosableIterator;
import org.sdnplatform.sync.IStoreClient;
import org.sdnplatform.sync.IVersion;
import org.sdnplatform.sync.Versioned;
import org.sdnplatform.sync.ISyncService.Scope;
import org.sdnplatform.sync.error.AuthException;
import org.sdnplatform.sync.error.ObsoleteVersionException;
import org.sdnplatform.sync.error.SyncException;
import org.sdnplatform.sync.internal.Cursor;
import org.sdnplatform.sync.internal.SyncManager;
import org.sdnplatform.sync.internal.config.AuthScheme;
import org.sdnplatform.sync.internal.config.ClusterConfig;
import org.sdnplatform.sync.internal.config.Node;
import org.sdnplatform.sync.internal.config.SyncStoreCCProvider;
import org.sdnplatform.sync.internal.rpc.RPCService.NodeMessage;
import org.sdnplatform.sync.internal.store.IStorageEngine;
import org.sdnplatform.sync.internal.util.ByteArray;
import org.sdnplatform.sync.internal.util.CryptoUtil;
import org.sdnplatform.sync.internal.version.VectorClock;
import org.sdnplatform.sync.thrift.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | @Override
protected void handleSyncRequest(SyncRequestMessage request,
Channel channel) {
rpcService.messageAcked(MessageType.SYNC_OFFER, getRemoteNodeId());
if (!request.isSetKeys()) return;
String storeName = request.getStore().getStoreName();
try {
IStorageEngine<ByteArray, byte[]> store =
syncManager.getRawStore(storeName);
SyncMessage bsm =
TProtocolUtil.getTSyncValueMessage(request.getStore());
SyncValueMessage svm = bsm.getSyncValue();
svm.setResponseTo(request.getHeader().getTransactionId());
svm.getHeader().setTransactionId(rpcService.getTransactionId());
for (ByteBuffer key : request.getKeys()) {
ByteArray keyArray = new ByteArray(key.array());
List<Versioned<byte[]>> values =
store.get(keyArray);
if (values == null || values.size() == 0) continue;
KeyedValues kv =
TProtocolUtil.getTKeyedValues(keyArray, values);
svm.addToValues(kv);
}
if (svm.isSetValues()) {
updateCounter(SyncManager.counterSentValues,
svm.getValuesSize()); | // Path: src/main/java/net/floodlightcontroller/debugcounter/IDebugCounter.java
// public interface IDebugCounter {
// /**
// * Increments the counter by 1 thread-locally, and immediately flushes to
// * the global counter storage. This method should be used for counters that
// * are updated outside the OF message processing pipeline.
// */
// void updateCounterWithFlush();
//
// /**
// * Increments the counter by 1 thread-locally. Flushing to the global
// * counter storage is delayed (happens with flushCounters() in IDebugCounterService),
// * resulting in higher performance. This method should be used for counters
// * updated in the OF message processing pipeline.
// */
// void updateCounterNoFlush();
//
// /**
// * Increments the counter thread-locally by the 'incr' specified, and immediately
// * flushes to the global counter storage. This method should be used for counters
// * that are updated outside the OF message processing pipeline.
// */
// void updateCounterWithFlush(int incr);
//
// /**
// * Increments the counter thread-locally by the 'incr' specified. Flushing to the global
// * counter storage is delayed (happens with flushCounters() in IDebugCounterService),
// * resulting in higher performance. This method should be used for counters
// * updated in the OF message processing pipeline.
// */
// void updateCounterNoFlush(int incr);
//
// /**
// * Retrieve the value of the counter from the global counter store
// */
// long getCounterValue();
// }
//
// Path: src/main/java/org/sdnplatform/sync/internal/rpc/RPCService.java
// protected static class NodeMessage extends Pair<Short,SyncMessage> {
// private static final long serialVersionUID = -3443080461324647922L;
//
// public NodeMessage(Short first, SyncMessage second) {
// super(first, second);
// }
// }
// Path: src/main/java/org/sdnplatform/sync/internal/rpc/RPCChannelHandler.java
import java.nio.ByteBuffer;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.Map.Entry;
import net.floodlightcontroller.core.annotations.LogMessageCategory;
import net.floodlightcontroller.core.annotations.LogMessageDoc;
import net.floodlightcontroller.debugcounter.IDebugCounter;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.channel.MessageEvent;
import org.sdnplatform.sync.IClosableIterator;
import org.sdnplatform.sync.IStoreClient;
import org.sdnplatform.sync.IVersion;
import org.sdnplatform.sync.Versioned;
import org.sdnplatform.sync.ISyncService.Scope;
import org.sdnplatform.sync.error.AuthException;
import org.sdnplatform.sync.error.ObsoleteVersionException;
import org.sdnplatform.sync.error.SyncException;
import org.sdnplatform.sync.internal.Cursor;
import org.sdnplatform.sync.internal.SyncManager;
import org.sdnplatform.sync.internal.config.AuthScheme;
import org.sdnplatform.sync.internal.config.ClusterConfig;
import org.sdnplatform.sync.internal.config.Node;
import org.sdnplatform.sync.internal.config.SyncStoreCCProvider;
import org.sdnplatform.sync.internal.rpc.RPCService.NodeMessage;
import org.sdnplatform.sync.internal.store.IStorageEngine;
import org.sdnplatform.sync.internal.util.ByteArray;
import org.sdnplatform.sync.internal.util.CryptoUtil;
import org.sdnplatform.sync.internal.version.VectorClock;
import org.sdnplatform.sync.thrift.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Override
protected void handleSyncRequest(SyncRequestMessage request,
Channel channel) {
rpcService.messageAcked(MessageType.SYNC_OFFER, getRemoteNodeId());
if (!request.isSetKeys()) return;
String storeName = request.getStore().getStoreName();
try {
IStorageEngine<ByteArray, byte[]> store =
syncManager.getRawStore(storeName);
SyncMessage bsm =
TProtocolUtil.getTSyncValueMessage(request.getStore());
SyncValueMessage svm = bsm.getSyncValue();
svm.setResponseTo(request.getHeader().getTransactionId());
svm.getHeader().setTransactionId(rpcService.getTransactionId());
for (ByteBuffer key : request.getKeys()) {
ByteArray keyArray = new ByteArray(key.array());
List<Versioned<byte[]>> values =
store.get(keyArray);
if (values == null || values.size() == 0) continue;
KeyedValues kv =
TProtocolUtil.getTKeyedValues(keyArray, values);
svm.addToValues(kv);
}
if (svm.isSetValues()) {
updateCounter(SyncManager.counterSentValues,
svm.getValuesSize()); | rpcService.syncQueue.add(new NodeMessage(getRemoteNodeId(), |
xuraylei/floodlight_with_topoguard | src/main/java/org/sdnplatform/sync/internal/rpc/RPCChannelHandler.java | // Path: src/main/java/net/floodlightcontroller/debugcounter/IDebugCounter.java
// public interface IDebugCounter {
// /**
// * Increments the counter by 1 thread-locally, and immediately flushes to
// * the global counter storage. This method should be used for counters that
// * are updated outside the OF message processing pipeline.
// */
// void updateCounterWithFlush();
//
// /**
// * Increments the counter by 1 thread-locally. Flushing to the global
// * counter storage is delayed (happens with flushCounters() in IDebugCounterService),
// * resulting in higher performance. This method should be used for counters
// * updated in the OF message processing pipeline.
// */
// void updateCounterNoFlush();
//
// /**
// * Increments the counter thread-locally by the 'incr' specified, and immediately
// * flushes to the global counter storage. This method should be used for counters
// * that are updated outside the OF message processing pipeline.
// */
// void updateCounterWithFlush(int incr);
//
// /**
// * Increments the counter thread-locally by the 'incr' specified. Flushing to the global
// * counter storage is delayed (happens with flushCounters() in IDebugCounterService),
// * resulting in higher performance. This method should be used for counters
// * updated in the OF message processing pipeline.
// */
// void updateCounterNoFlush(int incr);
//
// /**
// * Retrieve the value of the counter from the global counter store
// */
// long getCounterValue();
// }
//
// Path: src/main/java/org/sdnplatform/sync/internal/rpc/RPCService.java
// protected static class NodeMessage extends Pair<Short,SyncMessage> {
// private static final long serialVersionUID = -3443080461324647922L;
//
// public NodeMessage(Short first, SyncMessage second) {
// super(first, second);
// }
// }
| import java.nio.ByteBuffer;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.Map.Entry;
import net.floodlightcontroller.core.annotations.LogMessageCategory;
import net.floodlightcontroller.core.annotations.LogMessageDoc;
import net.floodlightcontroller.debugcounter.IDebugCounter;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.channel.MessageEvent;
import org.sdnplatform.sync.IClosableIterator;
import org.sdnplatform.sync.IStoreClient;
import org.sdnplatform.sync.IVersion;
import org.sdnplatform.sync.Versioned;
import org.sdnplatform.sync.ISyncService.Scope;
import org.sdnplatform.sync.error.AuthException;
import org.sdnplatform.sync.error.ObsoleteVersionException;
import org.sdnplatform.sync.error.SyncException;
import org.sdnplatform.sync.internal.Cursor;
import org.sdnplatform.sync.internal.SyncManager;
import org.sdnplatform.sync.internal.config.AuthScheme;
import org.sdnplatform.sync.internal.config.ClusterConfig;
import org.sdnplatform.sync.internal.config.Node;
import org.sdnplatform.sync.internal.config.SyncStoreCCProvider;
import org.sdnplatform.sync.internal.rpc.RPCService.NodeMessage;
import org.sdnplatform.sync.internal.store.IStorageEngine;
import org.sdnplatform.sync.internal.util.ByteArray;
import org.sdnplatform.sync.internal.util.CryptoUtil;
import org.sdnplatform.sync.internal.version.VectorClock;
import org.sdnplatform.sync.thrift.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | }
@Override
protected AuthScheme getAuthScheme() {
return syncManager.getClusterConfig().getAuthScheme();
}
@Override
protected byte[] getSharedSecret() throws AuthException {
String path = syncManager.getClusterConfig().getKeyStorePath();
String pass = syncManager.getClusterConfig().getKeyStorePassword();
try {
return CryptoUtil.getSharedSecret(path, pass);
} catch (Exception e) {
throw new AuthException("Could not read challenge/response " +
"shared secret from key store " + path, e);
}
}
@Override
protected SyncMessage getError(int transactionId, Exception error,
MessageType type) {
updateCounter(SyncManager.counterErrorProcessing, 1);
return super.getError(transactionId, error, type);
}
// *****************
// Utility functions
// *****************
| // Path: src/main/java/net/floodlightcontroller/debugcounter/IDebugCounter.java
// public interface IDebugCounter {
// /**
// * Increments the counter by 1 thread-locally, and immediately flushes to
// * the global counter storage. This method should be used for counters that
// * are updated outside the OF message processing pipeline.
// */
// void updateCounterWithFlush();
//
// /**
// * Increments the counter by 1 thread-locally. Flushing to the global
// * counter storage is delayed (happens with flushCounters() in IDebugCounterService),
// * resulting in higher performance. This method should be used for counters
// * updated in the OF message processing pipeline.
// */
// void updateCounterNoFlush();
//
// /**
// * Increments the counter thread-locally by the 'incr' specified, and immediately
// * flushes to the global counter storage. This method should be used for counters
// * that are updated outside the OF message processing pipeline.
// */
// void updateCounterWithFlush(int incr);
//
// /**
// * Increments the counter thread-locally by the 'incr' specified. Flushing to the global
// * counter storage is delayed (happens with flushCounters() in IDebugCounterService),
// * resulting in higher performance. This method should be used for counters
// * updated in the OF message processing pipeline.
// */
// void updateCounterNoFlush(int incr);
//
// /**
// * Retrieve the value of the counter from the global counter store
// */
// long getCounterValue();
// }
//
// Path: src/main/java/org/sdnplatform/sync/internal/rpc/RPCService.java
// protected static class NodeMessage extends Pair<Short,SyncMessage> {
// private static final long serialVersionUID = -3443080461324647922L;
//
// public NodeMessage(Short first, SyncMessage second) {
// super(first, second);
// }
// }
// Path: src/main/java/org/sdnplatform/sync/internal/rpc/RPCChannelHandler.java
import java.nio.ByteBuffer;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.Map.Entry;
import net.floodlightcontroller.core.annotations.LogMessageCategory;
import net.floodlightcontroller.core.annotations.LogMessageDoc;
import net.floodlightcontroller.debugcounter.IDebugCounter;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.channel.MessageEvent;
import org.sdnplatform.sync.IClosableIterator;
import org.sdnplatform.sync.IStoreClient;
import org.sdnplatform.sync.IVersion;
import org.sdnplatform.sync.Versioned;
import org.sdnplatform.sync.ISyncService.Scope;
import org.sdnplatform.sync.error.AuthException;
import org.sdnplatform.sync.error.ObsoleteVersionException;
import org.sdnplatform.sync.error.SyncException;
import org.sdnplatform.sync.internal.Cursor;
import org.sdnplatform.sync.internal.SyncManager;
import org.sdnplatform.sync.internal.config.AuthScheme;
import org.sdnplatform.sync.internal.config.ClusterConfig;
import org.sdnplatform.sync.internal.config.Node;
import org.sdnplatform.sync.internal.config.SyncStoreCCProvider;
import org.sdnplatform.sync.internal.rpc.RPCService.NodeMessage;
import org.sdnplatform.sync.internal.store.IStorageEngine;
import org.sdnplatform.sync.internal.util.ByteArray;
import org.sdnplatform.sync.internal.util.CryptoUtil;
import org.sdnplatform.sync.internal.version.VectorClock;
import org.sdnplatform.sync.thrift.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
@Override
protected AuthScheme getAuthScheme() {
return syncManager.getClusterConfig().getAuthScheme();
}
@Override
protected byte[] getSharedSecret() throws AuthException {
String path = syncManager.getClusterConfig().getKeyStorePath();
String pass = syncManager.getClusterConfig().getKeyStorePassword();
try {
return CryptoUtil.getSharedSecret(path, pass);
} catch (Exception e) {
throw new AuthException("Could not read challenge/response " +
"shared secret from key store " + path, e);
}
}
@Override
protected SyncMessage getError(int transactionId, Exception error,
MessageType type) {
updateCounter(SyncManager.counterErrorProcessing, 1);
return super.getError(transactionId, error, type);
}
// *****************
// Utility functions
// *****************
| protected void updateCounter(IDebugCounter counter, int incr) { |
xuraylei/floodlight_with_topoguard | src/main/java/net/floodlightcontroller/topology/web/RouteResource.java | // Path: src/main/java/net/floodlightcontroller/topology/NodePortTuple.java
// public class NodePortTuple implements Comparable<NodePortTuple> {
// protected long nodeId; // switch DPID
// protected short portId; // switch port id
//
// /**
// * Creates a NodePortTuple
// * @param nodeId The DPID of the switch
// * @param portId The port of the switch
// */
// public NodePortTuple(long nodeId, short portId) {
// this.nodeId = nodeId;
// this.portId = portId;
// }
//
// public NodePortTuple(long nodeId, int portId) {
// this.nodeId = nodeId;
// this.portId = (short) portId;
// }
//
// @JsonProperty("switch")
// @JsonSerialize(using=DPIDSerializer.class)
// public long getNodeId() {
// return nodeId;
// }
// public void setNodeId(long nodeId) {
// this.nodeId = nodeId;
// }
// @JsonProperty("port")
// @JsonSerialize(using=UShortSerializer.class)
// public short getPortId() {
// return portId;
// }
// public void setPortId(short portId) {
// this.portId = portId;
// }
//
// public String toString() {
// return "[id=" + HexString.toHexString(nodeId) + ", port=" + new Short(portId) + "]";
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + (int) (nodeId ^ (nodeId >>> 32));
// result = prime * result + portId;
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// NodePortTuple other = (NodePortTuple) obj;
// if (nodeId != other.nodeId)
// return false;
// if (portId != other.portId)
// return false;
// return true;
// }
//
// /**
// * API to return a String value formed wtih NodeID and PortID
// * The portID is a 16-bit field, so mask it as an integer to get full
// * positive value
// * @return
// */
// public String toKeyString() {
// return (HexString.toHexString(nodeId)+ "|" + (portId & 0xffff));
// }
//
// @Override
// public int compareTo(NodePortTuple obj) {
// final int BEFORE = -1;
// final int EQUAL = 0;
// final int AFTER = 1;
//
// if (this.getNodeId() < obj.getNodeId())
// return BEFORE;
// if (this.getNodeId() > obj.getNodeId())
// return AFTER;
//
// if (this.getPortId() < obj.getPortId())
// return BEFORE;
// if (this.getPortId() > obj.getPortId())
// return AFTER;
//
// return EQUAL;
// }
// }
| import java.util.List;
import net.floodlightcontroller.routing.IRoutingService;
import net.floodlightcontroller.routing.Route;
import net.floodlightcontroller.topology.NodePortTuple;
import org.openflow.util.HexString;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | /**
* Copyright 2013, Big Switch Networks, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
package net.floodlightcontroller.topology.web;
public class RouteResource extends ServerResource {
protected static Logger log = LoggerFactory.getLogger(RouteResource.class);
@Get("json") | // Path: src/main/java/net/floodlightcontroller/topology/NodePortTuple.java
// public class NodePortTuple implements Comparable<NodePortTuple> {
// protected long nodeId; // switch DPID
// protected short portId; // switch port id
//
// /**
// * Creates a NodePortTuple
// * @param nodeId The DPID of the switch
// * @param portId The port of the switch
// */
// public NodePortTuple(long nodeId, short portId) {
// this.nodeId = nodeId;
// this.portId = portId;
// }
//
// public NodePortTuple(long nodeId, int portId) {
// this.nodeId = nodeId;
// this.portId = (short) portId;
// }
//
// @JsonProperty("switch")
// @JsonSerialize(using=DPIDSerializer.class)
// public long getNodeId() {
// return nodeId;
// }
// public void setNodeId(long nodeId) {
// this.nodeId = nodeId;
// }
// @JsonProperty("port")
// @JsonSerialize(using=UShortSerializer.class)
// public short getPortId() {
// return portId;
// }
// public void setPortId(short portId) {
// this.portId = portId;
// }
//
// public String toString() {
// return "[id=" + HexString.toHexString(nodeId) + ", port=" + new Short(portId) + "]";
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + (int) (nodeId ^ (nodeId >>> 32));
// result = prime * result + portId;
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// NodePortTuple other = (NodePortTuple) obj;
// if (nodeId != other.nodeId)
// return false;
// if (portId != other.portId)
// return false;
// return true;
// }
//
// /**
// * API to return a String value formed wtih NodeID and PortID
// * The portID is a 16-bit field, so mask it as an integer to get full
// * positive value
// * @return
// */
// public String toKeyString() {
// return (HexString.toHexString(nodeId)+ "|" + (portId & 0xffff));
// }
//
// @Override
// public int compareTo(NodePortTuple obj) {
// final int BEFORE = -1;
// final int EQUAL = 0;
// final int AFTER = 1;
//
// if (this.getNodeId() < obj.getNodeId())
// return BEFORE;
// if (this.getNodeId() > obj.getNodeId())
// return AFTER;
//
// if (this.getPortId() < obj.getPortId())
// return BEFORE;
// if (this.getPortId() > obj.getPortId())
// return AFTER;
//
// return EQUAL;
// }
// }
// Path: src/main/java/net/floodlightcontroller/topology/web/RouteResource.java
import java.util.List;
import net.floodlightcontroller.routing.IRoutingService;
import net.floodlightcontroller.routing.Route;
import net.floodlightcontroller.topology.NodePortTuple;
import org.openflow.util.HexString;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Copyright 2013, Big Switch Networks, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
package net.floodlightcontroller.topology.web;
public class RouteResource extends ServerResource {
protected static Logger log = LoggerFactory.getLogger(RouteResource.class);
@Get("json") | public List<NodePortTuple> retrieve() { |
xiaolongzuo/xxoo | src/main/java/cn/zxl/xxoo/support/DomConfigurableXmlParser.java | // Path: src/main/java/cn/zxl/xxoo/annotation/DateAnnotationHandler.java
// public class DateAnnotationHandler {
//
// /**
// * 处理构建xml过程中的注解
// * @param field field
// * @param fieldValue fieldValue
// * @return String
// */
// public static String handle(final Field field,final Object fieldValue){
// if (field.getType() != Date.class) {
// return fieldValue.toString();
// }
// Annotation annotation = Annotations.getAnnotation(field, ADate.class);
// if (annotation != null && annotation instanceof ADate) {
// ADate dateAnnotation = (ADate) annotation;
// String format = dateAnnotation.format();
// if (format != null) {
// return new SimpleDateFormat(format).format((Date)fieldValue);
// }
// }
// return fieldValue.toString();
// }
//
// /**
// * 处理解析xml过程中的注解
// * @param field field
// * @param fieldValue fieldValue
// * @return Date
// * @throws ParseException 解析日期字符串异常
// */
// public static Date handle(final Field field,final String fieldValue) throws ParseException{
// if (field.getType() != Date.class) {
// return new SimpleDateFormat().parse(fieldValue);
// }
// Annotation annotation = Annotations.getAnnotation(field, ADate.class);
// if (annotation != null && annotation instanceof ADate) {
// ADate dateAnnotation = (ADate) annotation;
// String format = dateAnnotation.format();
// if (format != null) {
// return new SimpleDateFormat(format).parse(fieldValue);
// }
// }
// return XmlProcessor.DEFAULT_DATE_FORMAT.parse(fieldValue);
// }
// }
| import java.io.ByteArrayInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import cn.zxl.xxoo.annotation.DateAnnotationHandler;
import cn.zxl.xxoo.exception.XmlParseException;
import cn.zxl.xxoo.utils.Commons;
import cn.zxl.xxoo.utils.Reflects;
|
private <T> T parseRecursion(Class<T> clazz,Node root) throws IllegalArgumentException, IllegalAccessException, InstantiationException, ParseException, SecurityException, NoSuchMethodException, InvocationTargetException{
if (Commons.isNull(clazz) || !Reflects.isComplexType(clazz)) {
return null;
}
T object = (T) Reflects.getInstance(clazz);
if (!Reflects.hasField(clazz)) {
return object;
}
NodeList nodeList = root.getChildNodes();
for (int i = 0 ; i < nodeList.getLength() ; i++) {
Node node = nodeList.item(i);
if (node.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
String nodeName = node.getNodeName();
String nodeValue = node.getTextContent();
if (nodeName == null || nodeValue == null) {
continue;
}
Field field = null;
try {
field = clazz.getDeclaredField(nodeName);
}catch (NoSuchFieldException e) {
continue;
}
field.setAccessible(true);
if (!Reflects.isComplexType(field.getType()) && nodeValue.trim().length() > 0 ) {
Constructor constructor = field.getType().getConstructor(String.class);
if (Date.class.isAssignableFrom(field.getType())) {
| // Path: src/main/java/cn/zxl/xxoo/annotation/DateAnnotationHandler.java
// public class DateAnnotationHandler {
//
// /**
// * 处理构建xml过程中的注解
// * @param field field
// * @param fieldValue fieldValue
// * @return String
// */
// public static String handle(final Field field,final Object fieldValue){
// if (field.getType() != Date.class) {
// return fieldValue.toString();
// }
// Annotation annotation = Annotations.getAnnotation(field, ADate.class);
// if (annotation != null && annotation instanceof ADate) {
// ADate dateAnnotation = (ADate) annotation;
// String format = dateAnnotation.format();
// if (format != null) {
// return new SimpleDateFormat(format).format((Date)fieldValue);
// }
// }
// return fieldValue.toString();
// }
//
// /**
// * 处理解析xml过程中的注解
// * @param field field
// * @param fieldValue fieldValue
// * @return Date
// * @throws ParseException 解析日期字符串异常
// */
// public static Date handle(final Field field,final String fieldValue) throws ParseException{
// if (field.getType() != Date.class) {
// return new SimpleDateFormat().parse(fieldValue);
// }
// Annotation annotation = Annotations.getAnnotation(field, ADate.class);
// if (annotation != null && annotation instanceof ADate) {
// ADate dateAnnotation = (ADate) annotation;
// String format = dateAnnotation.format();
// if (format != null) {
// return new SimpleDateFormat(format).parse(fieldValue);
// }
// }
// return XmlProcessor.DEFAULT_DATE_FORMAT.parse(fieldValue);
// }
// }
// Path: src/main/java/cn/zxl/xxoo/support/DomConfigurableXmlParser.java
import java.io.ByteArrayInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import cn.zxl.xxoo.annotation.DateAnnotationHandler;
import cn.zxl.xxoo.exception.XmlParseException;
import cn.zxl.xxoo.utils.Commons;
import cn.zxl.xxoo.utils.Reflects;
private <T> T parseRecursion(Class<T> clazz,Node root) throws IllegalArgumentException, IllegalAccessException, InstantiationException, ParseException, SecurityException, NoSuchMethodException, InvocationTargetException{
if (Commons.isNull(clazz) || !Reflects.isComplexType(clazz)) {
return null;
}
T object = (T) Reflects.getInstance(clazz);
if (!Reflects.hasField(clazz)) {
return object;
}
NodeList nodeList = root.getChildNodes();
for (int i = 0 ; i < nodeList.getLength() ; i++) {
Node node = nodeList.item(i);
if (node.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
String nodeName = node.getNodeName();
String nodeValue = node.getTextContent();
if (nodeName == null || nodeValue == null) {
continue;
}
Field field = null;
try {
field = clazz.getDeclaredField(nodeName);
}catch (NoSuchFieldException e) {
continue;
}
field.setAccessible(true);
if (!Reflects.isComplexType(field.getType()) && nodeValue.trim().length() > 0 ) {
Constructor constructor = field.getType().getConstructor(String.class);
if (Date.class.isAssignableFrom(field.getType())) {
| field.set(object, DateAnnotationHandler.handle(field, nodeValue));
|
xiaolongzuo/xxoo | src/main/java/cn/zxl/xxoo/annotation/DateAnnotationHandler.java | // Path: src/main/java/cn/zxl/xxoo/processor/XmlProcessor.java
// public interface XmlProcessor {
//
// /**
// * 所有处理器统一的默认日期格式
// */
// DateFormat DEFAULT_DATE_FORMAT = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy",Locale.ENGLISH);
//
// }
| import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import cn.zxl.xxoo.processor.XmlProcessor;
import cn.zxl.xxoo.utils.Annotations;
| package cn.zxl.xxoo.annotation;
/**
* 日期注解处理
* @author 左潇龙
* @version 1.0.0
* @since 1.0.0
*/
public class DateAnnotationHandler {
/**
* 处理构建xml过程中的注解
* @param field field
* @param fieldValue fieldValue
* @return String
*/
public static String handle(final Field field,final Object fieldValue){
if (field.getType() != Date.class) {
return fieldValue.toString();
}
Annotation annotation = Annotations.getAnnotation(field, ADate.class);
if (annotation != null && annotation instanceof ADate) {
ADate dateAnnotation = (ADate) annotation;
String format = dateAnnotation.format();
if (format != null) {
return new SimpleDateFormat(format).format((Date)fieldValue);
}
}
return fieldValue.toString();
}
/**
* 处理解析xml过程中的注解
* @param field field
* @param fieldValue fieldValue
* @return Date
* @throws ParseException 解析日期字符串异常
*/
public static Date handle(final Field field,final String fieldValue) throws ParseException{
if (field.getType() != Date.class) {
return new SimpleDateFormat().parse(fieldValue);
}
Annotation annotation = Annotations.getAnnotation(field, ADate.class);
if (annotation != null && annotation instanceof ADate) {
ADate dateAnnotation = (ADate) annotation;
String format = dateAnnotation.format();
if (format != null) {
return new SimpleDateFormat(format).parse(fieldValue);
}
}
| // Path: src/main/java/cn/zxl/xxoo/processor/XmlProcessor.java
// public interface XmlProcessor {
//
// /**
// * 所有处理器统一的默认日期格式
// */
// DateFormat DEFAULT_DATE_FORMAT = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy",Locale.ENGLISH);
//
// }
// Path: src/main/java/cn/zxl/xxoo/annotation/DateAnnotationHandler.java
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import cn.zxl.xxoo.processor.XmlProcessor;
import cn.zxl.xxoo.utils.Annotations;
package cn.zxl.xxoo.annotation;
/**
* 日期注解处理
* @author 左潇龙
* @version 1.0.0
* @since 1.0.0
*/
public class DateAnnotationHandler {
/**
* 处理构建xml过程中的注解
* @param field field
* @param fieldValue fieldValue
* @return String
*/
public static String handle(final Field field,final Object fieldValue){
if (field.getType() != Date.class) {
return fieldValue.toString();
}
Annotation annotation = Annotations.getAnnotation(field, ADate.class);
if (annotation != null && annotation instanceof ADate) {
ADate dateAnnotation = (ADate) annotation;
String format = dateAnnotation.format();
if (format != null) {
return new SimpleDateFormat(format).format((Date)fieldValue);
}
}
return fieldValue.toString();
}
/**
* 处理解析xml过程中的注解
* @param field field
* @param fieldValue fieldValue
* @return Date
* @throws ParseException 解析日期字符串异常
*/
public static Date handle(final Field field,final String fieldValue) throws ParseException{
if (field.getType() != Date.class) {
return new SimpleDateFormat().parse(fieldValue);
}
Annotation annotation = Annotations.getAnnotation(field, ADate.class);
if (annotation != null && annotation instanceof ADate) {
ADate dateAnnotation = (ADate) annotation;
String format = dateAnnotation.format();
if (format != null) {
return new SimpleDateFormat(format).parse(fieldValue);
}
}
| return XmlProcessor.DEFAULT_DATE_FORMAT.parse(fieldValue);
|
punchup/Superuser-UI | app/src/main/java/com/koushikdutta/superuser/util/Util.java | // Path: app/src/main/java/com/koushikdutta/superuser/helper/ImageCache.java
// public final class ImageCache extends SoftReferenceHashTable<String, Drawable> {
//
// private static ImageCache mInstance = new ImageCache();
//
// public static ImageCache getInstance() {
// return mInstance;
// }
//
// private ImageCache() {
// }
// }
| import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.util.TypedValue;
import com.koushikdutta.superuser.helper.ImageCache; | /**
* Superuser
* Copyright (C) 2016 Pierre-Hugues Husson (phhusson)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
package com.koushikdutta.superuser.util;
public class Util {
public static Drawable loadPackageIcon(Context context, String pn) {
try {
PackageManager pm = context.getPackageManager();
PackageInfo pi = context.getPackageManager().getPackageInfo(pn, 0); | // Path: app/src/main/java/com/koushikdutta/superuser/helper/ImageCache.java
// public final class ImageCache extends SoftReferenceHashTable<String, Drawable> {
//
// private static ImageCache mInstance = new ImageCache();
//
// public static ImageCache getInstance() {
// return mInstance;
// }
//
// private ImageCache() {
// }
// }
// Path: app/src/main/java/com/koushikdutta/superuser/util/Util.java
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.util.TypedValue;
import com.koushikdutta.superuser.helper.ImageCache;
/**
* Superuser
* Copyright (C) 2016 Pierre-Hugues Husson (phhusson)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
package com.koushikdutta.superuser.util;
public class Util {
public static Drawable loadPackageIcon(Context context, String pn) {
try {
PackageManager pm = context.getPackageManager();
PackageInfo pi = context.getPackageManager().getPackageInfo(pn, 0); | Drawable ret = ImageCache.getInstance().get(pn); |
punchup/Superuser-UI | libAppThemeHelper/src/main/java/com/kabouzeid/appthemehelper/core/ThemeStore.java | // Path: libAppThemeHelper/src/main/java/com/kabouzeid/appthemehelper/util/ATHUtil.java
// public final class ATHUtil {
//
// public static boolean isWindowBackgroundDark(Context context) {
// return !ColorUtil.isColorLight(ATHUtil.resolveColor(context, android.R.attr.windowBackground));
// }
//
// public static int resolveColor(Context context, @AttrRes int attr) {
// return resolveColor(context, attr, 0);
// }
//
// public static int resolveColor(Context context, @AttrRes int attr, int fallback) {
// TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{attr});
//
// try {
// return a.getColor(0, fallback);
//
// } finally {
// a.recycle();
// }
// }
//
// public static boolean isInClassPath(@NonNull String clsName) {
// try {
// return inClassPath(clsName) != null;
// } catch (Throwable t) {
// return false;
// }
// }
//
// public static Class<?> inClassPath(@NonNull String clsName) {
// try {
// return Class.forName(clsName);
// } catch (Throwable t) {
// throw new IllegalStateException(String.format("%s is not in your class path! You must include the associated library.", clsName));
// }
// }
//
// private ATHUtil() {
// }
// }
//
// Path: libAppThemeHelper/src/main/java/com/kabouzeid/appthemehelper/util/ColorUtil.java
// public final class ColorUtil {
//
// public static int stripAlpha(@ColorInt int color) {
// return 0xff000000 | color;
// }
//
// @ColorInt
// public static int shiftColor(@ColorInt int color, @FloatRange(from = 0.0f, to = 2.0f) float by) {
// if (by == 1f) return color;
// int alpha = Color.alpha(color);
// float[] hsv = new float[3];
// Color.colorToHSV(color, hsv);
// hsv[2] *= by; // value component
// return (alpha << 24) + (0x00ffffff & Color.HSVToColor(hsv));
// }
//
// @ColorInt
// public static int darkenColor(@ColorInt int color) {
// return shiftColor(color, 0.9f);
// }
//
// @ColorInt
// public static int lightenColor(@ColorInt int color) {
// return shiftColor(color, 1.1f);
// }
//
// public static boolean isColorLight(@ColorInt int color) {
// final double darkness = 1 - (0.299 * Color.red(color) + 0.587 * Color.green(color) + 0.114 * Color.blue(color)) / 255;
// return darkness < 0.4;
// }
//
// @ColorInt
// public static int invertColor(@ColorInt int color) {
// final int r = 255 - Color.red(color);
// final int g = 255 - Color.green(color);
// final int b = 255 - Color.blue(color);
// return Color.argb(Color.alpha(color), r, g, b);
// }
//
// @ColorInt
// public static int adjustAlpha(@ColorInt int color, @FloatRange(from = 0.0, to = 1.0) float factor) {
// int alpha = Math.round(Color.alpha(color) * factor);
// int red = Color.red(color);
// int green = Color.green(color);
// int blue = Color.blue(color);
// return Color.argb(alpha, red, green, blue);
// }
//
// @ColorInt
// public static int withAlpha(@ColorInt int baseColor, @FloatRange(from = 0.0, to = 1.0) float alpha) {
// int a = Math.min(255, Math.max(0, (int) (alpha * 255))) << 24;
// int rgb = 0x00ffffff & baseColor;
// return a + rgb;
// }
//
// /**
// * Taken from CollapsingToolbarLayout's CollapsingTextHelper class.
// */
// public static int blendColors(int color1, int color2, @FloatRange(from = 0.0, to = 1.0) float ratio) {
// final float inverseRatio = 1f - ratio;
// float a = (Color.alpha(color1) * inverseRatio) + (Color.alpha(color2) * ratio);
// float r = (Color.red(color1) * inverseRatio) + (Color.red(color2) * ratio);
// float g = (Color.green(color1) * inverseRatio) + (Color.green(color2) * ratio);
// float b = (Color.blue(color1) * inverseRatio) + (Color.blue(color2) * ratio);
// return Color.argb((int) a, (int) r, (int) g, (int) b);
// }
//
// private ColorUtil() {
// }
// }
| import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.preference.PreferenceManager;
import android.support.annotation.AttrRes;
import android.support.annotation.CheckResult;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.annotation.StyleRes;
import android.support.v4.content.ContextCompat;
import com.kabouzeid.appthemehelper.R;
import com.kabouzeid.appthemehelper.util.ATHUtil;
import com.kabouzeid.appthemehelper.util.ColorUtil; | package com.kabouzeid.appthemehelper.core;
/**
* @author Aidan Follestad (afollestad), Karim Abou Zeid (kabouzeid)
*/
public final class ThemeStore implements ThemeStorePrefKeys, ThemeStoreInterface {
private final Context mContext;
private final SharedPreferences.Editor mEditor;
public static ThemeStore editTheme(@NonNull Context context) {
return new ThemeStore(context);
}
@SuppressLint("CommitPrefEdits")
private ThemeStore(@NonNull Context context) {
mContext = context;
mEditor = prefs(context).edit();
}
@Override
public ThemeStore activityTheme(@StyleRes int theme) {
mEditor.putInt(KEY_ACTIVITY_THEME, theme);
return this;
}
@Override
public ThemeStore primaryColor(@ColorInt int color) {
mEditor.putInt(KEY_PRIMARY_COLOR, color); | // Path: libAppThemeHelper/src/main/java/com/kabouzeid/appthemehelper/util/ATHUtil.java
// public final class ATHUtil {
//
// public static boolean isWindowBackgroundDark(Context context) {
// return !ColorUtil.isColorLight(ATHUtil.resolveColor(context, android.R.attr.windowBackground));
// }
//
// public static int resolveColor(Context context, @AttrRes int attr) {
// return resolveColor(context, attr, 0);
// }
//
// public static int resolveColor(Context context, @AttrRes int attr, int fallback) {
// TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{attr});
//
// try {
// return a.getColor(0, fallback);
//
// } finally {
// a.recycle();
// }
// }
//
// public static boolean isInClassPath(@NonNull String clsName) {
// try {
// return inClassPath(clsName) != null;
// } catch (Throwable t) {
// return false;
// }
// }
//
// public static Class<?> inClassPath(@NonNull String clsName) {
// try {
// return Class.forName(clsName);
// } catch (Throwable t) {
// throw new IllegalStateException(String.format("%s is not in your class path! You must include the associated library.", clsName));
// }
// }
//
// private ATHUtil() {
// }
// }
//
// Path: libAppThemeHelper/src/main/java/com/kabouzeid/appthemehelper/util/ColorUtil.java
// public final class ColorUtil {
//
// public static int stripAlpha(@ColorInt int color) {
// return 0xff000000 | color;
// }
//
// @ColorInt
// public static int shiftColor(@ColorInt int color, @FloatRange(from = 0.0f, to = 2.0f) float by) {
// if (by == 1f) return color;
// int alpha = Color.alpha(color);
// float[] hsv = new float[3];
// Color.colorToHSV(color, hsv);
// hsv[2] *= by; // value component
// return (alpha << 24) + (0x00ffffff & Color.HSVToColor(hsv));
// }
//
// @ColorInt
// public static int darkenColor(@ColorInt int color) {
// return shiftColor(color, 0.9f);
// }
//
// @ColorInt
// public static int lightenColor(@ColorInt int color) {
// return shiftColor(color, 1.1f);
// }
//
// public static boolean isColorLight(@ColorInt int color) {
// final double darkness = 1 - (0.299 * Color.red(color) + 0.587 * Color.green(color) + 0.114 * Color.blue(color)) / 255;
// return darkness < 0.4;
// }
//
// @ColorInt
// public static int invertColor(@ColorInt int color) {
// final int r = 255 - Color.red(color);
// final int g = 255 - Color.green(color);
// final int b = 255 - Color.blue(color);
// return Color.argb(Color.alpha(color), r, g, b);
// }
//
// @ColorInt
// public static int adjustAlpha(@ColorInt int color, @FloatRange(from = 0.0, to = 1.0) float factor) {
// int alpha = Math.round(Color.alpha(color) * factor);
// int red = Color.red(color);
// int green = Color.green(color);
// int blue = Color.blue(color);
// return Color.argb(alpha, red, green, blue);
// }
//
// @ColorInt
// public static int withAlpha(@ColorInt int baseColor, @FloatRange(from = 0.0, to = 1.0) float alpha) {
// int a = Math.min(255, Math.max(0, (int) (alpha * 255))) << 24;
// int rgb = 0x00ffffff & baseColor;
// return a + rgb;
// }
//
// /**
// * Taken from CollapsingToolbarLayout's CollapsingTextHelper class.
// */
// public static int blendColors(int color1, int color2, @FloatRange(from = 0.0, to = 1.0) float ratio) {
// final float inverseRatio = 1f - ratio;
// float a = (Color.alpha(color1) * inverseRatio) + (Color.alpha(color2) * ratio);
// float r = (Color.red(color1) * inverseRatio) + (Color.red(color2) * ratio);
// float g = (Color.green(color1) * inverseRatio) + (Color.green(color2) * ratio);
// float b = (Color.blue(color1) * inverseRatio) + (Color.blue(color2) * ratio);
// return Color.argb((int) a, (int) r, (int) g, (int) b);
// }
//
// private ColorUtil() {
// }
// }
// Path: libAppThemeHelper/src/main/java/com/kabouzeid/appthemehelper/core/ThemeStore.java
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.preference.PreferenceManager;
import android.support.annotation.AttrRes;
import android.support.annotation.CheckResult;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.annotation.StyleRes;
import android.support.v4.content.ContextCompat;
import com.kabouzeid.appthemehelper.R;
import com.kabouzeid.appthemehelper.util.ATHUtil;
import com.kabouzeid.appthemehelper.util.ColorUtil;
package com.kabouzeid.appthemehelper.core;
/**
* @author Aidan Follestad (afollestad), Karim Abou Zeid (kabouzeid)
*/
public final class ThemeStore implements ThemeStorePrefKeys, ThemeStoreInterface {
private final Context mContext;
private final SharedPreferences.Editor mEditor;
public static ThemeStore editTheme(@NonNull Context context) {
return new ThemeStore(context);
}
@SuppressLint("CommitPrefEdits")
private ThemeStore(@NonNull Context context) {
mContext = context;
mEditor = prefs(context).edit();
}
@Override
public ThemeStore activityTheme(@StyleRes int theme) {
mEditor.putInt(KEY_ACTIVITY_THEME, theme);
return this;
}
@Override
public ThemeStore primaryColor(@ColorInt int color) {
mEditor.putInt(KEY_PRIMARY_COLOR, color); | if (autoGeneratePrimaryDark(mContext)) primaryColorDark(ColorUtil.darkenColor(color)); |
punchup/Superuser-UI | app/src/main/java/com/koushikdutta/superuser/NotifyActivity.java | // Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_BLACK_THEME = "black_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_DARK_THEME = "dark_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_LIGHT_THEME = "light_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_THEME = "theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MultitaskSuRequestActivity.java
// public static int height(Context context, int h1, int h2) {
//
// int height;
//
// if (context.getResources().getConfiguration().screenWidthDp < 400)
// height = Util.toPx(context, h1);
//
// else
// height = Util.toPx(context, h2);
//
// return height;
// }
//
// Path: app/src/main/java/com/koushikdutta/superuser/MultitaskSuRequestActivity.java
// public static int width(Context context, int w) {
//
// int width;
//
// if (context.getResources().getConfiguration().screenWidthDp < 400)
// width = context.getResources().getDisplayMetrics().widthPixels;
//
// else
// width = Util.toPx(context, w);
//
// return width;
// }
| import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.preference.PreferenceManager;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import static com.koushikdutta.superuser.MainActivity.PREF_BLACK_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_DARK_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_LIGHT_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_THEME;
import static com.koushikdutta.superuser.MultitaskSuRequestActivity.height;
import static com.koushikdutta.superuser.MultitaskSuRequestActivity.width; | /**
* Superuser
* Copyright (C) 2016 Pierre-Hugues Husson (phhusson)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
package com.koushikdutta.superuser;
public class NotifyActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
| // Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_BLACK_THEME = "black_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_DARK_THEME = "dark_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_LIGHT_THEME = "light_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_THEME = "theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MultitaskSuRequestActivity.java
// public static int height(Context context, int h1, int h2) {
//
// int height;
//
// if (context.getResources().getConfiguration().screenWidthDp < 400)
// height = Util.toPx(context, h1);
//
// else
// height = Util.toPx(context, h2);
//
// return height;
// }
//
// Path: app/src/main/java/com/koushikdutta/superuser/MultitaskSuRequestActivity.java
// public static int width(Context context, int w) {
//
// int width;
//
// if (context.getResources().getConfiguration().screenWidthDp < 400)
// width = context.getResources().getDisplayMetrics().widthPixels;
//
// else
// width = Util.toPx(context, w);
//
// return width;
// }
// Path: app/src/main/java/com/koushikdutta/superuser/NotifyActivity.java
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.preference.PreferenceManager;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import static com.koushikdutta.superuser.MainActivity.PREF_BLACK_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_DARK_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_LIGHT_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_THEME;
import static com.koushikdutta.superuser.MultitaskSuRequestActivity.height;
import static com.koushikdutta.superuser.MultitaskSuRequestActivity.width;
/**
* Superuser
* Copyright (C) 2016 Pierre-Hugues Husson (phhusson)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
package com.koushikdutta.superuser;
public class NotifyActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
| switch (pref.getString(PREF_THEME, PREF_DARK_THEME)) { |
punchup/Superuser-UI | app/src/main/java/com/koushikdutta/superuser/NotifyActivity.java | // Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_BLACK_THEME = "black_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_DARK_THEME = "dark_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_LIGHT_THEME = "light_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_THEME = "theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MultitaskSuRequestActivity.java
// public static int height(Context context, int h1, int h2) {
//
// int height;
//
// if (context.getResources().getConfiguration().screenWidthDp < 400)
// height = Util.toPx(context, h1);
//
// else
// height = Util.toPx(context, h2);
//
// return height;
// }
//
// Path: app/src/main/java/com/koushikdutta/superuser/MultitaskSuRequestActivity.java
// public static int width(Context context, int w) {
//
// int width;
//
// if (context.getResources().getConfiguration().screenWidthDp < 400)
// width = context.getResources().getDisplayMetrics().widthPixels;
//
// else
// width = Util.toPx(context, w);
//
// return width;
// }
| import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.preference.PreferenceManager;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import static com.koushikdutta.superuser.MainActivity.PREF_BLACK_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_DARK_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_LIGHT_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_THEME;
import static com.koushikdutta.superuser.MultitaskSuRequestActivity.height;
import static com.koushikdutta.superuser.MultitaskSuRequestActivity.width; | /**
* Superuser
* Copyright (C) 2016 Pierre-Hugues Husson (phhusson)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
package com.koushikdutta.superuser;
public class NotifyActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
| // Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_BLACK_THEME = "black_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_DARK_THEME = "dark_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_LIGHT_THEME = "light_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_THEME = "theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MultitaskSuRequestActivity.java
// public static int height(Context context, int h1, int h2) {
//
// int height;
//
// if (context.getResources().getConfiguration().screenWidthDp < 400)
// height = Util.toPx(context, h1);
//
// else
// height = Util.toPx(context, h2);
//
// return height;
// }
//
// Path: app/src/main/java/com/koushikdutta/superuser/MultitaskSuRequestActivity.java
// public static int width(Context context, int w) {
//
// int width;
//
// if (context.getResources().getConfiguration().screenWidthDp < 400)
// width = context.getResources().getDisplayMetrics().widthPixels;
//
// else
// width = Util.toPx(context, w);
//
// return width;
// }
// Path: app/src/main/java/com/koushikdutta/superuser/NotifyActivity.java
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.preference.PreferenceManager;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import static com.koushikdutta.superuser.MainActivity.PREF_BLACK_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_DARK_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_LIGHT_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_THEME;
import static com.koushikdutta.superuser.MultitaskSuRequestActivity.height;
import static com.koushikdutta.superuser.MultitaskSuRequestActivity.width;
/**
* Superuser
* Copyright (C) 2016 Pierre-Hugues Husson (phhusson)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
package com.koushikdutta.superuser;
public class NotifyActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
| switch (pref.getString(PREF_THEME, PREF_DARK_THEME)) { |
punchup/Superuser-UI | app/src/main/java/com/koushikdutta/superuser/NotifyActivity.java | // Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_BLACK_THEME = "black_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_DARK_THEME = "dark_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_LIGHT_THEME = "light_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_THEME = "theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MultitaskSuRequestActivity.java
// public static int height(Context context, int h1, int h2) {
//
// int height;
//
// if (context.getResources().getConfiguration().screenWidthDp < 400)
// height = Util.toPx(context, h1);
//
// else
// height = Util.toPx(context, h2);
//
// return height;
// }
//
// Path: app/src/main/java/com/koushikdutta/superuser/MultitaskSuRequestActivity.java
// public static int width(Context context, int w) {
//
// int width;
//
// if (context.getResources().getConfiguration().screenWidthDp < 400)
// width = context.getResources().getDisplayMetrics().widthPixels;
//
// else
// width = Util.toPx(context, w);
//
// return width;
// }
| import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.preference.PreferenceManager;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import static com.koushikdutta.superuser.MainActivity.PREF_BLACK_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_DARK_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_LIGHT_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_THEME;
import static com.koushikdutta.superuser.MultitaskSuRequestActivity.height;
import static com.koushikdutta.superuser.MultitaskSuRequestActivity.width; | /**
* Superuser
* Copyright (C) 2016 Pierre-Hugues Husson (phhusson)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
package com.koushikdutta.superuser;
public class NotifyActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
switch (pref.getString(PREF_THEME, PREF_DARK_THEME)) { | // Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_BLACK_THEME = "black_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_DARK_THEME = "dark_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_LIGHT_THEME = "light_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_THEME = "theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MultitaskSuRequestActivity.java
// public static int height(Context context, int h1, int h2) {
//
// int height;
//
// if (context.getResources().getConfiguration().screenWidthDp < 400)
// height = Util.toPx(context, h1);
//
// else
// height = Util.toPx(context, h2);
//
// return height;
// }
//
// Path: app/src/main/java/com/koushikdutta/superuser/MultitaskSuRequestActivity.java
// public static int width(Context context, int w) {
//
// int width;
//
// if (context.getResources().getConfiguration().screenWidthDp < 400)
// width = context.getResources().getDisplayMetrics().widthPixels;
//
// else
// width = Util.toPx(context, w);
//
// return width;
// }
// Path: app/src/main/java/com/koushikdutta/superuser/NotifyActivity.java
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.preference.PreferenceManager;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import static com.koushikdutta.superuser.MainActivity.PREF_BLACK_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_DARK_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_LIGHT_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_THEME;
import static com.koushikdutta.superuser.MultitaskSuRequestActivity.height;
import static com.koushikdutta.superuser.MultitaskSuRequestActivity.width;
/**
* Superuser
* Copyright (C) 2016 Pierre-Hugues Husson (phhusson)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
package com.koushikdutta.superuser;
public class NotifyActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
switch (pref.getString(PREF_THEME, PREF_DARK_THEME)) { | case PREF_BLACK_THEME: |
punchup/Superuser-UI | app/src/main/java/com/koushikdutta/superuser/NotifyActivity.java | // Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_BLACK_THEME = "black_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_DARK_THEME = "dark_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_LIGHT_THEME = "light_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_THEME = "theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MultitaskSuRequestActivity.java
// public static int height(Context context, int h1, int h2) {
//
// int height;
//
// if (context.getResources().getConfiguration().screenWidthDp < 400)
// height = Util.toPx(context, h1);
//
// else
// height = Util.toPx(context, h2);
//
// return height;
// }
//
// Path: app/src/main/java/com/koushikdutta/superuser/MultitaskSuRequestActivity.java
// public static int width(Context context, int w) {
//
// int width;
//
// if (context.getResources().getConfiguration().screenWidthDp < 400)
// width = context.getResources().getDisplayMetrics().widthPixels;
//
// else
// width = Util.toPx(context, w);
//
// return width;
// }
| import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.preference.PreferenceManager;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import static com.koushikdutta.superuser.MainActivity.PREF_BLACK_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_DARK_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_LIGHT_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_THEME;
import static com.koushikdutta.superuser.MultitaskSuRequestActivity.height;
import static com.koushikdutta.superuser.MultitaskSuRequestActivity.width; | /**
* Superuser
* Copyright (C) 2016 Pierre-Hugues Husson (phhusson)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
package com.koushikdutta.superuser;
public class NotifyActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
switch (pref.getString(PREF_THEME, PREF_DARK_THEME)) {
case PREF_BLACK_THEME:
case PREF_DARK_THEME:
setTheme(R.style.PopupTheme);
break;
| // Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_BLACK_THEME = "black_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_DARK_THEME = "dark_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_LIGHT_THEME = "light_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_THEME = "theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MultitaskSuRequestActivity.java
// public static int height(Context context, int h1, int h2) {
//
// int height;
//
// if (context.getResources().getConfiguration().screenWidthDp < 400)
// height = Util.toPx(context, h1);
//
// else
// height = Util.toPx(context, h2);
//
// return height;
// }
//
// Path: app/src/main/java/com/koushikdutta/superuser/MultitaskSuRequestActivity.java
// public static int width(Context context, int w) {
//
// int width;
//
// if (context.getResources().getConfiguration().screenWidthDp < 400)
// width = context.getResources().getDisplayMetrics().widthPixels;
//
// else
// width = Util.toPx(context, w);
//
// return width;
// }
// Path: app/src/main/java/com/koushikdutta/superuser/NotifyActivity.java
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.preference.PreferenceManager;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import static com.koushikdutta.superuser.MainActivity.PREF_BLACK_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_DARK_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_LIGHT_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_THEME;
import static com.koushikdutta.superuser.MultitaskSuRequestActivity.height;
import static com.koushikdutta.superuser.MultitaskSuRequestActivity.width;
/**
* Superuser
* Copyright (C) 2016 Pierre-Hugues Husson (phhusson)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
package com.koushikdutta.superuser;
public class NotifyActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
switch (pref.getString(PREF_THEME, PREF_DARK_THEME)) {
case PREF_BLACK_THEME:
case PREF_DARK_THEME:
setTheme(R.style.PopupTheme);
break;
| case PREF_LIGHT_THEME: |
punchup/Superuser-UI | app/src/main/java/com/koushikdutta/superuser/NotifyActivity.java | // Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_BLACK_THEME = "black_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_DARK_THEME = "dark_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_LIGHT_THEME = "light_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_THEME = "theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MultitaskSuRequestActivity.java
// public static int height(Context context, int h1, int h2) {
//
// int height;
//
// if (context.getResources().getConfiguration().screenWidthDp < 400)
// height = Util.toPx(context, h1);
//
// else
// height = Util.toPx(context, h2);
//
// return height;
// }
//
// Path: app/src/main/java/com/koushikdutta/superuser/MultitaskSuRequestActivity.java
// public static int width(Context context, int w) {
//
// int width;
//
// if (context.getResources().getConfiguration().screenWidthDp < 400)
// width = context.getResources().getDisplayMetrics().widthPixels;
//
// else
// width = Util.toPx(context, w);
//
// return width;
// }
| import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.preference.PreferenceManager;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import static com.koushikdutta.superuser.MainActivity.PREF_BLACK_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_DARK_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_LIGHT_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_THEME;
import static com.koushikdutta.superuser.MultitaskSuRequestActivity.height;
import static com.koushikdutta.superuser.MultitaskSuRequestActivity.width; | /**
* Superuser
* Copyright (C) 2016 Pierre-Hugues Husson (phhusson)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
package com.koushikdutta.superuser;
public class NotifyActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
switch (pref.getString(PREF_THEME, PREF_DARK_THEME)) {
case PREF_BLACK_THEME:
case PREF_DARK_THEME:
setTheme(R.style.PopupTheme);
break;
case PREF_LIGHT_THEME:
setTheme(R.style.PopupTheme_Light);
break;
}
//Settings.applyDarkThemeSetting(this, R.style.RequestThemeDark);
super.onCreate(savedInstanceState);
overridePendingTransition(R.anim.abc_slide_in_bottom, 0);
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setBackgroundDrawableResource(android.R.color.background_light);
getWindow().setGravity(Gravity.BOTTOM);
View root = LayoutInflater.from(this).inflate(R.layout.activity_notify, null);
| // Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_BLACK_THEME = "black_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_DARK_THEME = "dark_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_LIGHT_THEME = "light_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_THEME = "theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MultitaskSuRequestActivity.java
// public static int height(Context context, int h1, int h2) {
//
// int height;
//
// if (context.getResources().getConfiguration().screenWidthDp < 400)
// height = Util.toPx(context, h1);
//
// else
// height = Util.toPx(context, h2);
//
// return height;
// }
//
// Path: app/src/main/java/com/koushikdutta/superuser/MultitaskSuRequestActivity.java
// public static int width(Context context, int w) {
//
// int width;
//
// if (context.getResources().getConfiguration().screenWidthDp < 400)
// width = context.getResources().getDisplayMetrics().widthPixels;
//
// else
// width = Util.toPx(context, w);
//
// return width;
// }
// Path: app/src/main/java/com/koushikdutta/superuser/NotifyActivity.java
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.preference.PreferenceManager;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import static com.koushikdutta.superuser.MainActivity.PREF_BLACK_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_DARK_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_LIGHT_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_THEME;
import static com.koushikdutta.superuser.MultitaskSuRequestActivity.height;
import static com.koushikdutta.superuser.MultitaskSuRequestActivity.width;
/**
* Superuser
* Copyright (C) 2016 Pierre-Hugues Husson (phhusson)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
package com.koushikdutta.superuser;
public class NotifyActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
switch (pref.getString(PREF_THEME, PREF_DARK_THEME)) {
case PREF_BLACK_THEME:
case PREF_DARK_THEME:
setTheme(R.style.PopupTheme);
break;
case PREF_LIGHT_THEME:
setTheme(R.style.PopupTheme_Light);
break;
}
//Settings.applyDarkThemeSetting(this, R.style.RequestThemeDark);
super.onCreate(savedInstanceState);
overridePendingTransition(R.anim.abc_slide_in_bottom, 0);
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setBackgroundDrawableResource(android.R.color.background_light);
getWindow().setGravity(Gravity.BOTTOM);
View root = LayoutInflater.from(this).inflate(R.layout.activity_notify, null);
| setContentView(root, new LinearLayout.LayoutParams(width(this, 375), height(this, 180, 180))); |
punchup/Superuser-UI | app/src/main/java/com/koushikdutta/superuser/NotifyActivity.java | // Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_BLACK_THEME = "black_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_DARK_THEME = "dark_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_LIGHT_THEME = "light_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_THEME = "theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MultitaskSuRequestActivity.java
// public static int height(Context context, int h1, int h2) {
//
// int height;
//
// if (context.getResources().getConfiguration().screenWidthDp < 400)
// height = Util.toPx(context, h1);
//
// else
// height = Util.toPx(context, h2);
//
// return height;
// }
//
// Path: app/src/main/java/com/koushikdutta/superuser/MultitaskSuRequestActivity.java
// public static int width(Context context, int w) {
//
// int width;
//
// if (context.getResources().getConfiguration().screenWidthDp < 400)
// width = context.getResources().getDisplayMetrics().widthPixels;
//
// else
// width = Util.toPx(context, w);
//
// return width;
// }
| import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.preference.PreferenceManager;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import static com.koushikdutta.superuser.MainActivity.PREF_BLACK_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_DARK_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_LIGHT_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_THEME;
import static com.koushikdutta.superuser.MultitaskSuRequestActivity.height;
import static com.koushikdutta.superuser.MultitaskSuRequestActivity.width; | /**
* Superuser
* Copyright (C) 2016 Pierre-Hugues Husson (phhusson)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
package com.koushikdutta.superuser;
public class NotifyActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
switch (pref.getString(PREF_THEME, PREF_DARK_THEME)) {
case PREF_BLACK_THEME:
case PREF_DARK_THEME:
setTheme(R.style.PopupTheme);
break;
case PREF_LIGHT_THEME:
setTheme(R.style.PopupTheme_Light);
break;
}
//Settings.applyDarkThemeSetting(this, R.style.RequestThemeDark);
super.onCreate(savedInstanceState);
overridePendingTransition(R.anim.abc_slide_in_bottom, 0);
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setBackgroundDrawableResource(android.R.color.background_light);
getWindow().setGravity(Gravity.BOTTOM);
View root = LayoutInflater.from(this).inflate(R.layout.activity_notify, null);
| // Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_BLACK_THEME = "black_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_DARK_THEME = "dark_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_LIGHT_THEME = "light_theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MainActivity.java
// public static final String PREF_THEME = "theme";
//
// Path: app/src/main/java/com/koushikdutta/superuser/MultitaskSuRequestActivity.java
// public static int height(Context context, int h1, int h2) {
//
// int height;
//
// if (context.getResources().getConfiguration().screenWidthDp < 400)
// height = Util.toPx(context, h1);
//
// else
// height = Util.toPx(context, h2);
//
// return height;
// }
//
// Path: app/src/main/java/com/koushikdutta/superuser/MultitaskSuRequestActivity.java
// public static int width(Context context, int w) {
//
// int width;
//
// if (context.getResources().getConfiguration().screenWidthDp < 400)
// width = context.getResources().getDisplayMetrics().widthPixels;
//
// else
// width = Util.toPx(context, w);
//
// return width;
// }
// Path: app/src/main/java/com/koushikdutta/superuser/NotifyActivity.java
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.preference.PreferenceManager;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import static com.koushikdutta.superuser.MainActivity.PREF_BLACK_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_DARK_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_LIGHT_THEME;
import static com.koushikdutta.superuser.MainActivity.PREF_THEME;
import static com.koushikdutta.superuser.MultitaskSuRequestActivity.height;
import static com.koushikdutta.superuser.MultitaskSuRequestActivity.width;
/**
* Superuser
* Copyright (C) 2016 Pierre-Hugues Husson (phhusson)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
package com.koushikdutta.superuser;
public class NotifyActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
switch (pref.getString(PREF_THEME, PREF_DARK_THEME)) {
case PREF_BLACK_THEME:
case PREF_DARK_THEME:
setTheme(R.style.PopupTheme);
break;
case PREF_LIGHT_THEME:
setTheme(R.style.PopupTheme_Light);
break;
}
//Settings.applyDarkThemeSetting(this, R.style.RequestThemeDark);
super.onCreate(savedInstanceState);
overridePendingTransition(R.anim.abc_slide_in_bottom, 0);
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setBackgroundDrawableResource(android.R.color.background_light);
getWindow().setGravity(Gravity.BOTTOM);
View root = LayoutInflater.from(this).inflate(R.layout.activity_notify, null);
| setContentView(root, new LinearLayout.LayoutParams(width(this, 375), height(this, 180, 180))); |
punchup/Superuser-UI | app/src/main/java/com/koushikdutta/superuser/ListItem.java | // Path: app/src/main/java/com/koushikdutta/superuser/db/UidPolicy.java
// public class UidPolicy extends UidCommand {
// public static final String ALLOW = "allow";
// public static final String DENY = "deny";
// public static final String INTERACTIVE = "interactive";
//
// public String policy;
// public int until;
// public boolean logging = true;
// public boolean notification = true;
//
// public String getPolicy() {
// return policy;
// }
//
// public void setPolicy(String policy){
// this.policy = policy;
// }
//
// public Date getUntilDate() {
// return new Date((long)until * 1000);
// }
//
// public int getPolicyResource() {
// if (ALLOW.equals(policy))
// return R.string.allow;
//
// else if (INTERACTIVE.equals(policy))
// return R.string.interactive;
//
// return R.string.deny;
// }
//
// @Override
// public boolean equals(Object o) {
//
// if (o instanceof UidPolicy) {
//
// UidPolicy policy = (UidPolicy) o;
//
// return (policy.getPolicy() == null ? this.policy == null : policy.getPolicy().equals(this.policy)) &&
// policy.until == this.until &&
// policy.logging == this.logging &&
// policy.notification == this.notification;
// }
//
// return false;
// }
//
// @Override
// public int hashCode() {
//
// int prime = 11;
//
// int result = 1;
//
// result = prime * result + (policy == null ? 0 : policy.hashCode());
//
// result = prime * result + until;
//
// result = prime * result + (logging ? 1 : 0);
//
// result = prime + result + (notification ? 1 : 0);
//
// return result;
// }
// }
| import android.graphics.drawable.Drawable;
import com.koushikdutta.superuser.db.UidPolicy; | /**
* Superuser
* Copyright (C) 2016 Pierre-Hugues Husson (phhusson)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
package com.koushikdutta.superuser;
class ListItem {
private String item1, item2, item3;
private Drawable icon;
| // Path: app/src/main/java/com/koushikdutta/superuser/db/UidPolicy.java
// public class UidPolicy extends UidCommand {
// public static final String ALLOW = "allow";
// public static final String DENY = "deny";
// public static final String INTERACTIVE = "interactive";
//
// public String policy;
// public int until;
// public boolean logging = true;
// public boolean notification = true;
//
// public String getPolicy() {
// return policy;
// }
//
// public void setPolicy(String policy){
// this.policy = policy;
// }
//
// public Date getUntilDate() {
// return new Date((long)until * 1000);
// }
//
// public int getPolicyResource() {
// if (ALLOW.equals(policy))
// return R.string.allow;
//
// else if (INTERACTIVE.equals(policy))
// return R.string.interactive;
//
// return R.string.deny;
// }
//
// @Override
// public boolean equals(Object o) {
//
// if (o instanceof UidPolicy) {
//
// UidPolicy policy = (UidPolicy) o;
//
// return (policy.getPolicy() == null ? this.policy == null : policy.getPolicy().equals(this.policy)) &&
// policy.until == this.until &&
// policy.logging == this.logging &&
// policy.notification == this.notification;
// }
//
// return false;
// }
//
// @Override
// public int hashCode() {
//
// int prime = 11;
//
// int result = 1;
//
// result = prime * result + (policy == null ? 0 : policy.hashCode());
//
// result = prime * result + until;
//
// result = prime * result + (logging ? 1 : 0);
//
// result = prime + result + (notification ? 1 : 0);
//
// return result;
// }
// }
// Path: app/src/main/java/com/koushikdutta/superuser/ListItem.java
import android.graphics.drawable.Drawable;
import com.koushikdutta.superuser.db.UidPolicy;
/**
* Superuser
* Copyright (C) 2016 Pierre-Hugues Husson (phhusson)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
package com.koushikdutta.superuser;
class ListItem {
private String item1, item2, item3;
private Drawable icon;
| private UidPolicy policy; |
adamin1990/MaterialWpp | wpp/app/src/main/java/adamin90/com/wpp/service/TabListService.java | // Path: wpp/app/src/main/java/adamin90/com/wpp/model/tablist/TabList.java
// @Generated("org.jsonschema2pojo")
// public class TabList {
//
// @SerializedName("data")
// @Expose
// private List<adamin90.com.wpp.model.tablist.Datum> data = new ArrayList<adamin90.com.wpp.model.tablist.Datum>();
// @SerializedName("total_count")
// @Expose
// private Integer totalCount;
// @SerializedName("code")
// @Expose
// private Integer code;
//
// /**
// *
// * @return
// * The data
// */
// public List<adamin90.com.wpp.model.tablist.Datum> getData() {
// return data;
// }
//
// /**
// *
// * @param data
// * The data
// */
// public void setData(List<adamin90.com.wpp.model.tablist.Datum> data) {
// this.data = data;
// }
//
// /**
// *
// * @return
// * The totalCount
// */
// public Integer getTotalCount() {
// return totalCount;
// }
//
// /**
// *
// * @param totalCount
// * The total_count
// */
// public void setTotalCount(Integer totalCount) {
// this.totalCount = totalCount;
// }
//
// /**
// *
// * @return
// * The code
// */
// public Integer getCode() {
// return code;
// }
//
// /**
// *
// * @param code
// * The code
// */
// public void setCode(Integer code) {
// this.code = code;
// }
//
// }
| import adamin90.com.wpp.model.tablist.TabList;
import retrofit.http.GET;
import retrofit.http.Path;
import rx.Observable; | package adamin90.com.wpp.service;
/**
* Created by LiTao on 2015-11-20-13:09.
* Company: QD24so
* Email: [email protected]
* WebSite: http://lixiaopeng.top
* 动态获取tab列表
*/
public interface TabListService {
@GET("index.php/3/Wallpaper/subPiccates/pid/{pid}/") | // Path: wpp/app/src/main/java/adamin90/com/wpp/model/tablist/TabList.java
// @Generated("org.jsonschema2pojo")
// public class TabList {
//
// @SerializedName("data")
// @Expose
// private List<adamin90.com.wpp.model.tablist.Datum> data = new ArrayList<adamin90.com.wpp.model.tablist.Datum>();
// @SerializedName("total_count")
// @Expose
// private Integer totalCount;
// @SerializedName("code")
// @Expose
// private Integer code;
//
// /**
// *
// * @return
// * The data
// */
// public List<adamin90.com.wpp.model.tablist.Datum> getData() {
// return data;
// }
//
// /**
// *
// * @param data
// * The data
// */
// public void setData(List<adamin90.com.wpp.model.tablist.Datum> data) {
// this.data = data;
// }
//
// /**
// *
// * @return
// * The totalCount
// */
// public Integer getTotalCount() {
// return totalCount;
// }
//
// /**
// *
// * @param totalCount
// * The total_count
// */
// public void setTotalCount(Integer totalCount) {
// this.totalCount = totalCount;
// }
//
// /**
// *
// * @return
// * The code
// */
// public Integer getCode() {
// return code;
// }
//
// /**
// *
// * @param code
// * The code
// */
// public void setCode(Integer code) {
// this.code = code;
// }
//
// }
// Path: wpp/app/src/main/java/adamin90/com/wpp/service/TabListService.java
import adamin90.com.wpp.model.tablist.TabList;
import retrofit.http.GET;
import retrofit.http.Path;
import rx.Observable;
package adamin90.com.wpp.service;
/**
* Created by LiTao on 2015-11-20-13:09.
* Company: QD24so
* Email: [email protected]
* WebSite: http://lixiaopeng.top
* 动态获取tab列表
*/
public interface TabListService {
@GET("index.php/3/Wallpaper/subPiccates/pid/{pid}/") | Observable<TabList> getTabList(@Path("pid") int pid); |
adamin1990/MaterialWpp | wpp/app/src/main/java/adamin90/com/wpp/fragment/ZhuanTiFragment.java | // Path: wpp/app/src/main/java/adamin90/com/wpp/fragment/dummy/DummyContent.java
// public class DummyContent {
//
// /**
// * An array of sample (dummy) items.
// */
// public static final List<DummyItem> ITEMS = new ArrayList<DummyItem>();
//
// /**
// * A map of sample (dummy) items, by ID.
// */
// public static final Map<String, DummyItem> ITEM_MAP = new HashMap<String, DummyItem>();
//
// private static final int COUNT = 25;
//
// static {
// // Add some sample items.
// for (int i = 1; i <= COUNT; i++) {
// addItem(createDummyItem(i));
// }
// }
//
// private static void addItem(DummyItem item) {
// ITEMS.add(item);
// ITEM_MAP.put(item.id, item);
// }
//
// private static DummyItem createDummyItem(int position) {
// return new DummyItem(String.valueOf(position), "Item " + position, makeDetails(position));
// }
//
// private static String makeDetails(int position) {
// StringBuilder builder = new StringBuilder();
// builder.append("Details about Item: ").append(position);
// for (int i = 0; i < position; i++) {
// builder.append("\nMore details information here.");
// }
// return builder.toString();
// }
//
// /**
// * A dummy item representing a piece of content.
// */
// public static class DummyItem {
// public final String id;
// public final String content;
// public final String details;
//
// public DummyItem(String id, String content, String details) {
// this.id = id;
// this.content = content;
// this.details = details;
// }
//
// @Override
// public String toString() {
// return content;
// }
// }
// }
//
// Path: wpp/app/src/main/java/adamin90/com/wpp/fragment/dummy/DummyContent.java
// public static class DummyItem {
// public final String id;
// public final String content;
// public final String details;
//
// public DummyItem(String id, String content, String details) {
// this.id = id;
// this.content = content;
// this.details = details;
// }
//
// @Override
// public String toString() {
// return content;
// }
// }
| import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import adamin90.com.wpp.R;
import adamin90.com.wpp.fragment.dummy.DummyContent;
import adamin90.com.wpp.fragment.dummy.DummyContent.DummyItem;
import java.util.List; | package adamin90.com.wpp.fragment;
/**
* A fragment representing a list of Items.
* <p/>
* Activities containing this fragment MUST implement the {@link OnListFragmentInteractionListener}
* interface.
*/
public class ZhuanTiFragment extends Fragment {
// TODO: Customize parameter argument names
private static final String ARG_COLUMN_COUNT = "column-count";
// TODO: Customize parameters
private int mColumnCount = 1;
private OnListFragmentInteractionListener mListener;
/**
* Mandatory empty constructor for the fragment manager to instantiate the
* fragment (e.g. upon screen orientation changes).
*/
public ZhuanTiFragment() {
}
// TODO: Customize parameter initialization
@SuppressWarnings("unused")
public static ZhuanTiFragment newInstance(int columnCount) {
ZhuanTiFragment fragment = new ZhuanTiFragment();
Bundle args = new Bundle();
args.putInt(ARG_COLUMN_COUNT, columnCount);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mColumnCount = getArguments().getInt(ARG_COLUMN_COUNT);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_item_list, container, false);
// Set the adapter
if (view instanceof RecyclerView) {
Context context = view.getContext();
RecyclerView recyclerView = (RecyclerView) view;
// if (mColumnCount <= 1) {
recyclerView.setLayoutManager(new LinearLayoutManager(context));
// } else {
// recyclerView.setLayoutManager(new GridLayoutManager(context, mColumnCount));
// } | // Path: wpp/app/src/main/java/adamin90/com/wpp/fragment/dummy/DummyContent.java
// public class DummyContent {
//
// /**
// * An array of sample (dummy) items.
// */
// public static final List<DummyItem> ITEMS = new ArrayList<DummyItem>();
//
// /**
// * A map of sample (dummy) items, by ID.
// */
// public static final Map<String, DummyItem> ITEM_MAP = new HashMap<String, DummyItem>();
//
// private static final int COUNT = 25;
//
// static {
// // Add some sample items.
// for (int i = 1; i <= COUNT; i++) {
// addItem(createDummyItem(i));
// }
// }
//
// private static void addItem(DummyItem item) {
// ITEMS.add(item);
// ITEM_MAP.put(item.id, item);
// }
//
// private static DummyItem createDummyItem(int position) {
// return new DummyItem(String.valueOf(position), "Item " + position, makeDetails(position));
// }
//
// private static String makeDetails(int position) {
// StringBuilder builder = new StringBuilder();
// builder.append("Details about Item: ").append(position);
// for (int i = 0; i < position; i++) {
// builder.append("\nMore details information here.");
// }
// return builder.toString();
// }
//
// /**
// * A dummy item representing a piece of content.
// */
// public static class DummyItem {
// public final String id;
// public final String content;
// public final String details;
//
// public DummyItem(String id, String content, String details) {
// this.id = id;
// this.content = content;
// this.details = details;
// }
//
// @Override
// public String toString() {
// return content;
// }
// }
// }
//
// Path: wpp/app/src/main/java/adamin90/com/wpp/fragment/dummy/DummyContent.java
// public static class DummyItem {
// public final String id;
// public final String content;
// public final String details;
//
// public DummyItem(String id, String content, String details) {
// this.id = id;
// this.content = content;
// this.details = details;
// }
//
// @Override
// public String toString() {
// return content;
// }
// }
// Path: wpp/app/src/main/java/adamin90/com/wpp/fragment/ZhuanTiFragment.java
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import adamin90.com.wpp.R;
import adamin90.com.wpp.fragment.dummy.DummyContent;
import adamin90.com.wpp.fragment.dummy.DummyContent.DummyItem;
import java.util.List;
package adamin90.com.wpp.fragment;
/**
* A fragment representing a list of Items.
* <p/>
* Activities containing this fragment MUST implement the {@link OnListFragmentInteractionListener}
* interface.
*/
public class ZhuanTiFragment extends Fragment {
// TODO: Customize parameter argument names
private static final String ARG_COLUMN_COUNT = "column-count";
// TODO: Customize parameters
private int mColumnCount = 1;
private OnListFragmentInteractionListener mListener;
/**
* Mandatory empty constructor for the fragment manager to instantiate the
* fragment (e.g. upon screen orientation changes).
*/
public ZhuanTiFragment() {
}
// TODO: Customize parameter initialization
@SuppressWarnings("unused")
public static ZhuanTiFragment newInstance(int columnCount) {
ZhuanTiFragment fragment = new ZhuanTiFragment();
Bundle args = new Bundle();
args.putInt(ARG_COLUMN_COUNT, columnCount);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mColumnCount = getArguments().getInt(ARG_COLUMN_COUNT);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_item_list, container, false);
// Set the adapter
if (view instanceof RecyclerView) {
Context context = view.getContext();
RecyclerView recyclerView = (RecyclerView) view;
// if (mColumnCount <= 1) {
recyclerView.setLayoutManager(new LinearLayoutManager(context));
// } else {
// recyclerView.setLayoutManager(new GridLayoutManager(context, mColumnCount));
// } | recyclerView.setAdapter(new MyItemRecyclerViewAdapter(DummyContent.ITEMS, mListener)); |
adamin1990/MaterialWpp | wpp/app/src/main/java/adamin90/com/wpp/fragment/ZhuanTiFragment.java | // Path: wpp/app/src/main/java/adamin90/com/wpp/fragment/dummy/DummyContent.java
// public class DummyContent {
//
// /**
// * An array of sample (dummy) items.
// */
// public static final List<DummyItem> ITEMS = new ArrayList<DummyItem>();
//
// /**
// * A map of sample (dummy) items, by ID.
// */
// public static final Map<String, DummyItem> ITEM_MAP = new HashMap<String, DummyItem>();
//
// private static final int COUNT = 25;
//
// static {
// // Add some sample items.
// for (int i = 1; i <= COUNT; i++) {
// addItem(createDummyItem(i));
// }
// }
//
// private static void addItem(DummyItem item) {
// ITEMS.add(item);
// ITEM_MAP.put(item.id, item);
// }
//
// private static DummyItem createDummyItem(int position) {
// return new DummyItem(String.valueOf(position), "Item " + position, makeDetails(position));
// }
//
// private static String makeDetails(int position) {
// StringBuilder builder = new StringBuilder();
// builder.append("Details about Item: ").append(position);
// for (int i = 0; i < position; i++) {
// builder.append("\nMore details information here.");
// }
// return builder.toString();
// }
//
// /**
// * A dummy item representing a piece of content.
// */
// public static class DummyItem {
// public final String id;
// public final String content;
// public final String details;
//
// public DummyItem(String id, String content, String details) {
// this.id = id;
// this.content = content;
// this.details = details;
// }
//
// @Override
// public String toString() {
// return content;
// }
// }
// }
//
// Path: wpp/app/src/main/java/adamin90/com/wpp/fragment/dummy/DummyContent.java
// public static class DummyItem {
// public final String id;
// public final String content;
// public final String details;
//
// public DummyItem(String id, String content, String details) {
// this.id = id;
// this.content = content;
// this.details = details;
// }
//
// @Override
// public String toString() {
// return content;
// }
// }
| import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import adamin90.com.wpp.R;
import adamin90.com.wpp.fragment.dummy.DummyContent;
import adamin90.com.wpp.fragment.dummy.DummyContent.DummyItem;
import java.util.List; |
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnListFragmentInteractionListener) {
mListener = (OnListFragmentInteractionListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnListFragmentInteractionListener");
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
* <p/>
* See the Android Training lesson <a href=
* "http://developer.android.com/training/basics/fragments/communicating.html"
* >Communicating with Other Fragments</a> for more information.
*/
public interface OnListFragmentInteractionListener {
// TODO: Update argument type and name | // Path: wpp/app/src/main/java/adamin90/com/wpp/fragment/dummy/DummyContent.java
// public class DummyContent {
//
// /**
// * An array of sample (dummy) items.
// */
// public static final List<DummyItem> ITEMS = new ArrayList<DummyItem>();
//
// /**
// * A map of sample (dummy) items, by ID.
// */
// public static final Map<String, DummyItem> ITEM_MAP = new HashMap<String, DummyItem>();
//
// private static final int COUNT = 25;
//
// static {
// // Add some sample items.
// for (int i = 1; i <= COUNT; i++) {
// addItem(createDummyItem(i));
// }
// }
//
// private static void addItem(DummyItem item) {
// ITEMS.add(item);
// ITEM_MAP.put(item.id, item);
// }
//
// private static DummyItem createDummyItem(int position) {
// return new DummyItem(String.valueOf(position), "Item " + position, makeDetails(position));
// }
//
// private static String makeDetails(int position) {
// StringBuilder builder = new StringBuilder();
// builder.append("Details about Item: ").append(position);
// for (int i = 0; i < position; i++) {
// builder.append("\nMore details information here.");
// }
// return builder.toString();
// }
//
// /**
// * A dummy item representing a piece of content.
// */
// public static class DummyItem {
// public final String id;
// public final String content;
// public final String details;
//
// public DummyItem(String id, String content, String details) {
// this.id = id;
// this.content = content;
// this.details = details;
// }
//
// @Override
// public String toString() {
// return content;
// }
// }
// }
//
// Path: wpp/app/src/main/java/adamin90/com/wpp/fragment/dummy/DummyContent.java
// public static class DummyItem {
// public final String id;
// public final String content;
// public final String details;
//
// public DummyItem(String id, String content, String details) {
// this.id = id;
// this.content = content;
// this.details = details;
// }
//
// @Override
// public String toString() {
// return content;
// }
// }
// Path: wpp/app/src/main/java/adamin90/com/wpp/fragment/ZhuanTiFragment.java
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import adamin90.com.wpp.R;
import adamin90.com.wpp.fragment.dummy.DummyContent;
import adamin90.com.wpp.fragment.dummy.DummyContent.DummyItem;
import java.util.List;
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnListFragmentInteractionListener) {
mListener = (OnListFragmentInteractionListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnListFragmentInteractionListener");
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
* <p/>
* See the Android Training lesson <a href=
* "http://developer.android.com/training/basics/fragments/communicating.html"
* >Communicating with Other Fragments</a> for more information.
*/
public interface OnListFragmentInteractionListener {
// TODO: Update argument type and name | void onListFragmentInteraction(DummyItem item); |
adamin1990/MaterialWpp | wpp/app/src/main/java/adamin90/com/wpp/service/FetchDetailService.java | // Path: wpp/app/src/main/java/adamin90/com/wpp/model/detail/DetailData.java
// @Generated("org.jsonschema2pojo")
// public class DetailData {
//
// @SerializedName("data")
// @Expose
// private Data data;
// @SerializedName("code")
// @Expose
// private Integer code;
//
// /**
// *
// * @return
// * The data
// */
// public Data getData() {
// return data;
// }
//
// /**
// *
// * @param data
// * The data
// */
// public void setData(Data data) {
// this.data = data;
// }
//
// /**
// *
// * @return
// * The code
// */
// public Integer getCode() {
// return code;
// }
//
// /**
// *
// * @param code
// * The code
// */
// public void setCode(Integer code) {
// this.code = code;
// }
//
// }
| import adamin90.com.wpp.model.detail.DetailData;
import retrofit.http.GET;
import retrofit.http.Path;
import rx.Observable; | package adamin90.com.wpp.service;
/**
* Created by LiTao on 2015-11-23-14:25.
* Company: QD24so
* Email: [email protected]
* WebSite: http://lixiaopeng.top
* 获取图片列表详情
*/
public interface FetchDetailService {
@GET("index.php/3/Wallpaper/picList/order/{order}/source_type/{sourcetype}/source_id/{sourceid}/update/{update}/index/{index}/limit/{limit}/pixel/1080*1920/") | // Path: wpp/app/src/main/java/adamin90/com/wpp/model/detail/DetailData.java
// @Generated("org.jsonschema2pojo")
// public class DetailData {
//
// @SerializedName("data")
// @Expose
// private Data data;
// @SerializedName("code")
// @Expose
// private Integer code;
//
// /**
// *
// * @return
// * The data
// */
// public Data getData() {
// return data;
// }
//
// /**
// *
// * @param data
// * The data
// */
// public void setData(Data data) {
// this.data = data;
// }
//
// /**
// *
// * @return
// * The code
// */
// public Integer getCode() {
// return code;
// }
//
// /**
// *
// * @param code
// * The code
// */
// public void setCode(Integer code) {
// this.code = code;
// }
//
// }
// Path: wpp/app/src/main/java/adamin90/com/wpp/service/FetchDetailService.java
import adamin90.com.wpp.model.detail.DetailData;
import retrofit.http.GET;
import retrofit.http.Path;
import rx.Observable;
package adamin90.com.wpp.service;
/**
* Created by LiTao on 2015-11-23-14:25.
* Company: QD24so
* Email: [email protected]
* WebSite: http://lixiaopeng.top
* 获取图片列表详情
*/
public interface FetchDetailService {
@GET("index.php/3/Wallpaper/picList/order/{order}/source_type/{sourcetype}/source_id/{sourceid}/update/{update}/index/{index}/limit/{limit}/pixel/1080*1920/") | Observable<DetailData> fetchDetails(@Path("order") String order,@Path("sourcetype") int sourcetype,@Path("sourceid") int sourceid,@Path("index")int index, @Path("limit") int limit,@Path("update") int update); |
adamin1990/MaterialWpp | wpp/app/src/main/java/adamin90/com/wpp/service/FetchNewest.java | // Path: wpp/app/src/main/java/adamin90/com/wpp/model/newest/NewestData.java
// @Generated("org.jsonschema2pojo")
// public class NewestData {
//
// @SerializedName("data")
// @Expose
// private List<Datum> data = new ArrayList<Datum>();
// @SerializedName("total_count")
// @Expose
// private String totalCount;
// @SerializedName("source_type")
// @Expose
// private Integer sourceType;
// @SerializedName("code")
// @Expose
// private Integer code;
//
// /**
// *
// * @return
// * The data
// */
// public List<Datum> getData() {
// return data;
// }
//
// /**
// *
// * @param data
// * The data
// */
// public void setData(List<Datum> data) {
// this.data = data;
// }
//
// /**
// *
// * @return
// * The totalCount
// */
// public String getTotalCount() {
// return totalCount;
// }
//
// /**
// *
// * @param totalCount
// * The total_count
// */
// public void setTotalCount(String totalCount) {
// this.totalCount = totalCount;
// }
//
// /**
// *
// * @return
// * The sourceType
// */
// public Integer getSourceType() {
// return sourceType;
// }
//
// /**
// *
// * @param sourceType
// * The source_type
// */
// public void setSourceType(Integer sourceType) {
// this.sourceType = sourceType;
// }
//
// /**
// *
// * @return
// * The code
// */
// public Integer getCode() {
// return code;
// }
//
// /**
// *
// * @param code
// * The code
// */
// public void setCode(Integer code) {
// this.code = code;
// }
//
// }
| import android.database.Observable;
import adamin90.com.wpp.model.newest.NewestData;
import retrofit.http.GET;
import retrofit.http.Path; | package adamin90.com.wpp.service;
/**
* Created by LiTao on 2015-11-20-18:13.
* Company: QD24so
* Email: [email protected]
* WebSite: http://lixiaopeng.top
* 获取最新数据
*/
public interface FetchNewest {
@GET("index.php/3/Wallpaper/picLatest/start/{start}/limit/{limit}/") | // Path: wpp/app/src/main/java/adamin90/com/wpp/model/newest/NewestData.java
// @Generated("org.jsonschema2pojo")
// public class NewestData {
//
// @SerializedName("data")
// @Expose
// private List<Datum> data = new ArrayList<Datum>();
// @SerializedName("total_count")
// @Expose
// private String totalCount;
// @SerializedName("source_type")
// @Expose
// private Integer sourceType;
// @SerializedName("code")
// @Expose
// private Integer code;
//
// /**
// *
// * @return
// * The data
// */
// public List<Datum> getData() {
// return data;
// }
//
// /**
// *
// * @param data
// * The data
// */
// public void setData(List<Datum> data) {
// this.data = data;
// }
//
// /**
// *
// * @return
// * The totalCount
// */
// public String getTotalCount() {
// return totalCount;
// }
//
// /**
// *
// * @param totalCount
// * The total_count
// */
// public void setTotalCount(String totalCount) {
// this.totalCount = totalCount;
// }
//
// /**
// *
// * @return
// * The sourceType
// */
// public Integer getSourceType() {
// return sourceType;
// }
//
// /**
// *
// * @param sourceType
// * The source_type
// */
// public void setSourceType(Integer sourceType) {
// this.sourceType = sourceType;
// }
//
// /**
// *
// * @return
// * The code
// */
// public Integer getCode() {
// return code;
// }
//
// /**
// *
// * @param code
// * The code
// */
// public void setCode(Integer code) {
// this.code = code;
// }
//
// }
// Path: wpp/app/src/main/java/adamin90/com/wpp/service/FetchNewest.java
import android.database.Observable;
import adamin90.com.wpp.model.newest.NewestData;
import retrofit.http.GET;
import retrofit.http.Path;
package adamin90.com.wpp.service;
/**
* Created by LiTao on 2015-11-20-18:13.
* Company: QD24so
* Email: [email protected]
* WebSite: http://lixiaopeng.top
* 获取最新数据
*/
public interface FetchNewest {
@GET("index.php/3/Wallpaper/picLatest/start/{start}/limit/{limit}/") | Observable<NewestData> fetchNewestData(@Path("start") int start,@Path("limit") int limit); |
adamin1990/MaterialWpp | wpp/app/src/main/java/adamin90/com/wpp/service/FetchAlbum.java | // Path: wpp/app/src/main/java/adamin90/com/wpp/model/Album.java
// @Generated("org.jsonschema2pojo")
// public class Album {
//
// @SerializedName("data")
// @Expose
// private List<Datum> data = new ArrayList<Datum>();
// @SerializedName("total_count")
// @Expose
// private String totalCount;
// @SerializedName("source_type")
// @Expose
// private Integer sourceType;
// @SerializedName("code")
// @Expose
// private Integer code;
//
// /**
// *
// * @return
// * The data
// */
// public List<Datum> getData() {
// return data;
// }
//
// /**
// *
// * @param data
// * The data
// */
// public void setData(List<Datum> data) {
// this.data = data;
// }
//
// /**
// *
// * @return
// * The totalCount
// */
// public String getTotalCount() {
// return totalCount;
// }
//
// /**
// *
// * @param totalCount
// * The total_count
// */
// public void setTotalCount(String totalCount) {
// this.totalCount = totalCount;
// }
//
// /**
// *
// * @return
// * The sourceType
// */
// public Integer getSourceType() {
// return sourceType;
// }
//
// /**
// *
// * @param sourceType
// * The source_type
// */
// public void setSourceType(Integer sourceType) {
// this.sourceType = sourceType;
// }
//
// /**
// *
// * @return
// * The code
// */
// public Integer getCode() {
// return code;
// }
//
// /**
// *
// * @param code
// * The code
// */
// public void setCode(Integer code) {
// this.code = code;
// }
//
// }
| import java.util.List;
import adamin90.com.wpp.model.Album;
import retrofit.http.GET;
import retrofit.http.Path;
import rx.Observable; | package adamin90.com.wpp.service;
/**
* Created by LiTao on 2015-11-17-9:58.
* Company: QD24so
* Email: [email protected]
* WebSite: http://lixiaopeng.top
* 首页每日精选专辑
*/
public interface FetchAlbum {
@GET("3/Wallpaper/album/start/{star}/limit/{end}/") | // Path: wpp/app/src/main/java/adamin90/com/wpp/model/Album.java
// @Generated("org.jsonschema2pojo")
// public class Album {
//
// @SerializedName("data")
// @Expose
// private List<Datum> data = new ArrayList<Datum>();
// @SerializedName("total_count")
// @Expose
// private String totalCount;
// @SerializedName("source_type")
// @Expose
// private Integer sourceType;
// @SerializedName("code")
// @Expose
// private Integer code;
//
// /**
// *
// * @return
// * The data
// */
// public List<Datum> getData() {
// return data;
// }
//
// /**
// *
// * @param data
// * The data
// */
// public void setData(List<Datum> data) {
// this.data = data;
// }
//
// /**
// *
// * @return
// * The totalCount
// */
// public String getTotalCount() {
// return totalCount;
// }
//
// /**
// *
// * @param totalCount
// * The total_count
// */
// public void setTotalCount(String totalCount) {
// this.totalCount = totalCount;
// }
//
// /**
// *
// * @return
// * The sourceType
// */
// public Integer getSourceType() {
// return sourceType;
// }
//
// /**
// *
// * @param sourceType
// * The source_type
// */
// public void setSourceType(Integer sourceType) {
// this.sourceType = sourceType;
// }
//
// /**
// *
// * @return
// * The code
// */
// public Integer getCode() {
// return code;
// }
//
// /**
// *
// * @param code
// * The code
// */
// public void setCode(Integer code) {
// this.code = code;
// }
//
// }
// Path: wpp/app/src/main/java/adamin90/com/wpp/service/FetchAlbum.java
import java.util.List;
import adamin90.com.wpp.model.Album;
import retrofit.http.GET;
import retrofit.http.Path;
import rx.Observable;
package adamin90.com.wpp.service;
/**
* Created by LiTao on 2015-11-17-9:58.
* Company: QD24so
* Email: [email protected]
* WebSite: http://lixiaopeng.top
* 首页每日精选专辑
*/
public interface FetchAlbum {
@GET("3/Wallpaper/album/start/{star}/limit/{end}/") | Observable<Album> getAlbum(@Path("star") int star,@Path("end") int end); |
adamin1990/MaterialWpp | wpp/app/src/main/java/adamin90/com/wpp/service/TopicChoice.java | // Path: wpp/app/src/main/java/adamin90/com/wpp/model/topicchoice/TopicModel.java
// @Generated("org.jsonschema2pojo")
// public class TopicModel {
//
// @SerializedName("data")
// @Expose
// private List<Datum> data = new ArrayList<Datum>();
// @SerializedName("total_count")
// @Expose
// private String totalCount;
// @SerializedName("source_type")
// @Expose
// private Integer sourceType;
// @SerializedName("code")
// @Expose
// private Integer code;
//
// /**
// *
// * @return
// * The data
// */
// public List<Datum> getData() {
// return data;
// }
//
// /**
// *
// * @param data
// * The data
// */
// public void setData(List<Datum> data) {
// this.data = data;
// }
//
// /**
// *
// * @return
// * The totalCount
// */
// public String getTotalCount() {
// return totalCount;
// }
//
// /**
// *
// * @param totalCount
// * The total_count
// */
// public void setTotalCount(String totalCount) {
// this.totalCount = totalCount;
// }
//
// /**
// *
// * @return
// * The sourceType
// */
// public Integer getSourceType() {
// return sourceType;
// }
//
// /**
// *
// * @param sourceType
// * The source_type
// */
// public void setSourceType(Integer sourceType) {
// this.sourceType = sourceType;
// }
//
// /**
// *
// * @return
// * The code
// */
// public Integer getCode() {
// return code;
// }
//
// /**
// *
// * @param code
// * The code
// */
// public void setCode(Integer code) {
// this.code = code;
// }
//
// }
| import adamin90.com.wpp.model.topicchoice.TopicModel;
import retrofit.http.GET;
import retrofit.http.Path;
import rx.Observable; | package adamin90.com.wpp.service;
/**
* Created by LiTao on 2015-11-20-10:37.
* Company: QD24so
* Email: [email protected]
* WebSite: http://lixiaopeng.top
* 专题精选
* /index.php/3/Wallpaper/banner/cate/2226/start/0/limit/20/
*/
public interface TopicChoice {
@GET("index.php/3/Wallpaper/banner/cate/{cate}/start/{start}/limit/{limit}/") | // Path: wpp/app/src/main/java/adamin90/com/wpp/model/topicchoice/TopicModel.java
// @Generated("org.jsonschema2pojo")
// public class TopicModel {
//
// @SerializedName("data")
// @Expose
// private List<Datum> data = new ArrayList<Datum>();
// @SerializedName("total_count")
// @Expose
// private String totalCount;
// @SerializedName("source_type")
// @Expose
// private Integer sourceType;
// @SerializedName("code")
// @Expose
// private Integer code;
//
// /**
// *
// * @return
// * The data
// */
// public List<Datum> getData() {
// return data;
// }
//
// /**
// *
// * @param data
// * The data
// */
// public void setData(List<Datum> data) {
// this.data = data;
// }
//
// /**
// *
// * @return
// * The totalCount
// */
// public String getTotalCount() {
// return totalCount;
// }
//
// /**
// *
// * @param totalCount
// * The total_count
// */
// public void setTotalCount(String totalCount) {
// this.totalCount = totalCount;
// }
//
// /**
// *
// * @return
// * The sourceType
// */
// public Integer getSourceType() {
// return sourceType;
// }
//
// /**
// *
// * @param sourceType
// * The source_type
// */
// public void setSourceType(Integer sourceType) {
// this.sourceType = sourceType;
// }
//
// /**
// *
// * @return
// * The code
// */
// public Integer getCode() {
// return code;
// }
//
// /**
// *
// * @param code
// * The code
// */
// public void setCode(Integer code) {
// this.code = code;
// }
//
// }
// Path: wpp/app/src/main/java/adamin90/com/wpp/service/TopicChoice.java
import adamin90.com.wpp.model.topicchoice.TopicModel;
import retrofit.http.GET;
import retrofit.http.Path;
import rx.Observable;
package adamin90.com.wpp.service;
/**
* Created by LiTao on 2015-11-20-10:37.
* Company: QD24so
* Email: [email protected]
* WebSite: http://lixiaopeng.top
* 专题精选
* /index.php/3/Wallpaper/banner/cate/2226/start/0/limit/20/
*/
public interface TopicChoice {
@GET("index.php/3/Wallpaper/banner/cate/{cate}/start/{start}/limit/{limit}/") | Observable<TopicModel> getTopicChoice(@Path("cate") int cate,@Path("start") int start,@Path("limit") int limit); |
adamin1990/MaterialWpp | wpp/app/src/main/java/adamin90/com/wpp/service/FecthSearch.java | // Path: wpp/app/src/main/java/adamin90/com/wpp/model/mostsearch/MostSearchData.java
// @Generated("org.jsonschema2pojo")
// public class MostSearchData {
//
// @SerializedName("data")
// @Expose
// private List<Datum> data = new ArrayList<Datum>();
// @SerializedName("code")
// @Expose
// private Integer code;
//
// /**
// *
// * @return
// * The data
// */
// public List<Datum> getData() {
// return data;
// }
//
// /**
// *
// * @param data
// * The data
// */
// public void setData(List<Datum> data) {
// this.data = data;
// }
//
// /**
// *
// * @return
// * The code
// */
// public Integer getCode() {
// return code;
// }
//
// /**
// *
// * @param code
// * The code
// */
// public void setCode(Integer code) {
// this.code = code;
// }
//
// }
//
// Path: wpp/app/src/main/java/adamin90/com/wpp/model/search/SearchData.java
// @Generated("org.jsonschema2pojo")
// public class SearchData {
//
// @SerializedName("data")
// @Expose
// private List<Datum> data = new ArrayList<Datum>();
// @SerializedName("total_count")
// @Expose
// private String totalCount;
// @SerializedName("code")
// @Expose
// private Integer code;
//
// /**
// *
// * @return
// * The data
// */
// public List<Datum> getData() {
// return data;
// }
//
// /**
// *
// * @param data
// * The data
// */
// public void setData(List<Datum> data) {
// this.data = data;
// }
//
// /**
// *
// * @return
// * The totalCount
// */
// public String getTotalCount() {
// return totalCount;
// }
//
// /**
// *
// * @param totalCount
// * The total_count
// */
// public void setTotalCount(String totalCount) {
// this.totalCount = totalCount;
// }
//
// /**
// *
// * @return
// * The code
// */
// public Integer getCode() {
// return code;
// }
//
// /**
// *
// * @param code
// * The code
// */
// public void setCode(Integer code) {
// this.code = code;
// }
//
// }
| import adamin90.com.wpp.model.mostsearch.MostSearchData;
import adamin90.com.wpp.model.search.SearchData;
import retrofit.http.GET;
import retrofit.http.Path;
import rx.Observable;
import rx.Observer; | package adamin90.com.wpp.service;
/**
* Created by LiTao on 2015-11-20-22:01.
* Company: QD24so
* Email: [email protected]
* WebSite: http://lixiaopeng.top
* 搜索标签
*/
public interface FecthSearch {
/**
* 大家都在搜
* @return
*/
@GET("/index.php/3/Keyword/HotKeyword/type/0/start/0/limit/15/") | // Path: wpp/app/src/main/java/adamin90/com/wpp/model/mostsearch/MostSearchData.java
// @Generated("org.jsonschema2pojo")
// public class MostSearchData {
//
// @SerializedName("data")
// @Expose
// private List<Datum> data = new ArrayList<Datum>();
// @SerializedName("code")
// @Expose
// private Integer code;
//
// /**
// *
// * @return
// * The data
// */
// public List<Datum> getData() {
// return data;
// }
//
// /**
// *
// * @param data
// * The data
// */
// public void setData(List<Datum> data) {
// this.data = data;
// }
//
// /**
// *
// * @return
// * The code
// */
// public Integer getCode() {
// return code;
// }
//
// /**
// *
// * @param code
// * The code
// */
// public void setCode(Integer code) {
// this.code = code;
// }
//
// }
//
// Path: wpp/app/src/main/java/adamin90/com/wpp/model/search/SearchData.java
// @Generated("org.jsonschema2pojo")
// public class SearchData {
//
// @SerializedName("data")
// @Expose
// private List<Datum> data = new ArrayList<Datum>();
// @SerializedName("total_count")
// @Expose
// private String totalCount;
// @SerializedName("code")
// @Expose
// private Integer code;
//
// /**
// *
// * @return
// * The data
// */
// public List<Datum> getData() {
// return data;
// }
//
// /**
// *
// * @param data
// * The data
// */
// public void setData(List<Datum> data) {
// this.data = data;
// }
//
// /**
// *
// * @return
// * The totalCount
// */
// public String getTotalCount() {
// return totalCount;
// }
//
// /**
// *
// * @param totalCount
// * The total_count
// */
// public void setTotalCount(String totalCount) {
// this.totalCount = totalCount;
// }
//
// /**
// *
// * @return
// * The code
// */
// public Integer getCode() {
// return code;
// }
//
// /**
// *
// * @param code
// * The code
// */
// public void setCode(Integer code) {
// this.code = code;
// }
//
// }
// Path: wpp/app/src/main/java/adamin90/com/wpp/service/FecthSearch.java
import adamin90.com.wpp.model.mostsearch.MostSearchData;
import adamin90.com.wpp.model.search.SearchData;
import retrofit.http.GET;
import retrofit.http.Path;
import rx.Observable;
import rx.Observer;
package adamin90.com.wpp.service;
/**
* Created by LiTao on 2015-11-20-22:01.
* Company: QD24so
* Email: [email protected]
* WebSite: http://lixiaopeng.top
* 搜索标签
*/
public interface FecthSearch {
/**
* 大家都在搜
* @return
*/
@GET("/index.php/3/Keyword/HotKeyword/type/0/start/0/limit/15/") | Observable<MostSearchData> fetchMostSeach(); |
adamin1990/MaterialWpp | wpp/app/src/main/java/adamin90/com/wpp/service/FecthSearch.java | // Path: wpp/app/src/main/java/adamin90/com/wpp/model/mostsearch/MostSearchData.java
// @Generated("org.jsonschema2pojo")
// public class MostSearchData {
//
// @SerializedName("data")
// @Expose
// private List<Datum> data = new ArrayList<Datum>();
// @SerializedName("code")
// @Expose
// private Integer code;
//
// /**
// *
// * @return
// * The data
// */
// public List<Datum> getData() {
// return data;
// }
//
// /**
// *
// * @param data
// * The data
// */
// public void setData(List<Datum> data) {
// this.data = data;
// }
//
// /**
// *
// * @return
// * The code
// */
// public Integer getCode() {
// return code;
// }
//
// /**
// *
// * @param code
// * The code
// */
// public void setCode(Integer code) {
// this.code = code;
// }
//
// }
//
// Path: wpp/app/src/main/java/adamin90/com/wpp/model/search/SearchData.java
// @Generated("org.jsonschema2pojo")
// public class SearchData {
//
// @SerializedName("data")
// @Expose
// private List<Datum> data = new ArrayList<Datum>();
// @SerializedName("total_count")
// @Expose
// private String totalCount;
// @SerializedName("code")
// @Expose
// private Integer code;
//
// /**
// *
// * @return
// * The data
// */
// public List<Datum> getData() {
// return data;
// }
//
// /**
// *
// * @param data
// * The data
// */
// public void setData(List<Datum> data) {
// this.data = data;
// }
//
// /**
// *
// * @return
// * The totalCount
// */
// public String getTotalCount() {
// return totalCount;
// }
//
// /**
// *
// * @param totalCount
// * The total_count
// */
// public void setTotalCount(String totalCount) {
// this.totalCount = totalCount;
// }
//
// /**
// *
// * @return
// * The code
// */
// public Integer getCode() {
// return code;
// }
//
// /**
// *
// * @param code
// * The code
// */
// public void setCode(Integer code) {
// this.code = code;
// }
//
// }
| import adamin90.com.wpp.model.mostsearch.MostSearchData;
import adamin90.com.wpp.model.search.SearchData;
import retrofit.http.GET;
import retrofit.http.Path;
import rx.Observable;
import rx.Observer; | package adamin90.com.wpp.service;
/**
* Created by LiTao on 2015-11-20-22:01.
* Company: QD24so
* Email: [email protected]
* WebSite: http://lixiaopeng.top
* 搜索标签
*/
public interface FecthSearch {
/**
* 大家都在搜
* @return
*/
@GET("/index.php/3/Keyword/HotKeyword/type/0/start/0/limit/15/")
Observable<MostSearchData> fetchMostSeach();
/**
*用户壁纸查询
* @return
*/
@GET("/index.php/3/Keyword/HotKeyword/type/1/start/0/limit/6/")
Observable<MostSearchData> fetchMemberSearch();
/**
* 用户查询接口
* @return
*/
@GET("/index.php/3/Wallpaper/picByKeyword/word/{keyword}/start/{start}/limit/{limit}/") | // Path: wpp/app/src/main/java/adamin90/com/wpp/model/mostsearch/MostSearchData.java
// @Generated("org.jsonschema2pojo")
// public class MostSearchData {
//
// @SerializedName("data")
// @Expose
// private List<Datum> data = new ArrayList<Datum>();
// @SerializedName("code")
// @Expose
// private Integer code;
//
// /**
// *
// * @return
// * The data
// */
// public List<Datum> getData() {
// return data;
// }
//
// /**
// *
// * @param data
// * The data
// */
// public void setData(List<Datum> data) {
// this.data = data;
// }
//
// /**
// *
// * @return
// * The code
// */
// public Integer getCode() {
// return code;
// }
//
// /**
// *
// * @param code
// * The code
// */
// public void setCode(Integer code) {
// this.code = code;
// }
//
// }
//
// Path: wpp/app/src/main/java/adamin90/com/wpp/model/search/SearchData.java
// @Generated("org.jsonschema2pojo")
// public class SearchData {
//
// @SerializedName("data")
// @Expose
// private List<Datum> data = new ArrayList<Datum>();
// @SerializedName("total_count")
// @Expose
// private String totalCount;
// @SerializedName("code")
// @Expose
// private Integer code;
//
// /**
// *
// * @return
// * The data
// */
// public List<Datum> getData() {
// return data;
// }
//
// /**
// *
// * @param data
// * The data
// */
// public void setData(List<Datum> data) {
// this.data = data;
// }
//
// /**
// *
// * @return
// * The totalCount
// */
// public String getTotalCount() {
// return totalCount;
// }
//
// /**
// *
// * @param totalCount
// * The total_count
// */
// public void setTotalCount(String totalCount) {
// this.totalCount = totalCount;
// }
//
// /**
// *
// * @return
// * The code
// */
// public Integer getCode() {
// return code;
// }
//
// /**
// *
// * @param code
// * The code
// */
// public void setCode(Integer code) {
// this.code = code;
// }
//
// }
// Path: wpp/app/src/main/java/adamin90/com/wpp/service/FecthSearch.java
import adamin90.com.wpp.model.mostsearch.MostSearchData;
import adamin90.com.wpp.model.search.SearchData;
import retrofit.http.GET;
import retrofit.http.Path;
import rx.Observable;
import rx.Observer;
package adamin90.com.wpp.service;
/**
* Created by LiTao on 2015-11-20-22:01.
* Company: QD24so
* Email: [email protected]
* WebSite: http://lixiaopeng.top
* 搜索标签
*/
public interface FecthSearch {
/**
* 大家都在搜
* @return
*/
@GET("/index.php/3/Keyword/HotKeyword/type/0/start/0/limit/15/")
Observable<MostSearchData> fetchMostSeach();
/**
*用户壁纸查询
* @return
*/
@GET("/index.php/3/Keyword/HotKeyword/type/1/start/0/limit/6/")
Observable<MostSearchData> fetchMemberSearch();
/**
* 用户查询接口
* @return
*/
@GET("/index.php/3/Wallpaper/picByKeyword/word/{keyword}/start/{start}/limit/{limit}/") | Observable<SearchData> fetchSearchData(@Path("keyword") String keyword,@Path("start") int start, |
adamin1990/MaterialWpp | wpp/app/src/main/java/adamin90/com/wpp/service/FetchHot.java | // Path: wpp/app/src/main/java/adamin90/com/wpp/model/hot/HotData.java
// @Generated("org.jsonschema2pojo")
// public class HotData {
//
// @SerializedName("data")
// @Expose
// private List<Datum> data = new ArrayList<Datum>();
// @SerializedName("total_count")
// @Expose
// private String totalCount;
// @SerializedName("source_type")
// @Expose
// private Integer sourceType;
// @SerializedName("code")
// @Expose
// private Integer code;
//
// /**
// *
// * @return
// * The data
// */
// public List<Datum> getData() {
// return data;
// }
//
// /**
// *
// * @param data
// * The data
// */
// public void setData(List<Datum> data) {
// this.data = data;
// }
//
// /**
// *
// * @return
// * The totalCount
// */
// public String getTotalCount() {
// return totalCount;
// }
//
// /**
// *
// * @param totalCount
// * The total_count
// */
// public void setTotalCount(String totalCount) {
// this.totalCount = totalCount;
// }
//
// /**
// *
// * @return
// * The sourceType
// */
// public Integer getSourceType() {
// return sourceType;
// }
//
// /**
// *
// * @param sourceType
// * The source_type
// */
// public void setSourceType(Integer sourceType) {
// this.sourceType = sourceType;
// }
//
// /**
// *
// * @return
// * The code
// */
// public Integer getCode() {
// return code;
// }
//
// /**
// *
// * @param code
// * The code
// */
// public void setCode(Integer code) {
// this.code = code;
// }
//
// }
| import adamin90.com.wpp.model.hot.HotData;
import retrofit.http.GET;
import retrofit.http.Path;
import rx.Observable; | package adamin90.com.wpp.service;
/**
* Created by LiTao on 2015-11-20-21:55.
* Company: QD24so
* Email: [email protected]
* WebSite: http://lixiaopeng.top
* 热门数据
*/
public interface FetchHot {
@GET("/index.php/3/Wallpaper/picByselection/order/1/start/{start}/limit/{limit}/") | // Path: wpp/app/src/main/java/adamin90/com/wpp/model/hot/HotData.java
// @Generated("org.jsonschema2pojo")
// public class HotData {
//
// @SerializedName("data")
// @Expose
// private List<Datum> data = new ArrayList<Datum>();
// @SerializedName("total_count")
// @Expose
// private String totalCount;
// @SerializedName("source_type")
// @Expose
// private Integer sourceType;
// @SerializedName("code")
// @Expose
// private Integer code;
//
// /**
// *
// * @return
// * The data
// */
// public List<Datum> getData() {
// return data;
// }
//
// /**
// *
// * @param data
// * The data
// */
// public void setData(List<Datum> data) {
// this.data = data;
// }
//
// /**
// *
// * @return
// * The totalCount
// */
// public String getTotalCount() {
// return totalCount;
// }
//
// /**
// *
// * @param totalCount
// * The total_count
// */
// public void setTotalCount(String totalCount) {
// this.totalCount = totalCount;
// }
//
// /**
// *
// * @return
// * The sourceType
// */
// public Integer getSourceType() {
// return sourceType;
// }
//
// /**
// *
// * @param sourceType
// * The source_type
// */
// public void setSourceType(Integer sourceType) {
// this.sourceType = sourceType;
// }
//
// /**
// *
// * @return
// * The code
// */
// public Integer getCode() {
// return code;
// }
//
// /**
// *
// * @param code
// * The code
// */
// public void setCode(Integer code) {
// this.code = code;
// }
//
// }
// Path: wpp/app/src/main/java/adamin90/com/wpp/service/FetchHot.java
import adamin90.com.wpp.model.hot.HotData;
import retrofit.http.GET;
import retrofit.http.Path;
import rx.Observable;
package adamin90.com.wpp.service;
/**
* Created by LiTao on 2015-11-20-21:55.
* Company: QD24so
* Email: [email protected]
* WebSite: http://lixiaopeng.top
* 热门数据
*/
public interface FetchHot {
@GET("/index.php/3/Wallpaper/picByselection/order/1/start/{start}/limit/{limit}/") | Observable<HotData> fetchHot(@Path("start") int start,@Path("limit") int limit); |
adamin1990/MaterialWpp | wpp/app/src/main/java/adamin90/com/wpp/fragment/MyItemRecyclerViewAdapter.java | // Path: wpp/app/src/main/java/adamin90/com/wpp/fragment/ZhuanTiFragment.java
// public interface OnListFragmentInteractionListener {
// // TODO: Update argument type and name
// void onListFragmentInteraction(DummyItem item);
// }
//
// Path: wpp/app/src/main/java/adamin90/com/wpp/fragment/dummy/DummyContent.java
// public static class DummyItem {
// public final String id;
// public final String content;
// public final String details;
//
// public DummyItem(String id, String content, String details) {
// this.id = id;
// this.content = content;
// this.details = details;
// }
//
// @Override
// public String toString() {
// return content;
// }
// }
| import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import adamin90.com.wpp.R;
import adamin90.com.wpp.fragment.ZhuanTiFragment.OnListFragmentInteractionListener;
import adamin90.com.wpp.fragment.dummy.DummyContent.DummyItem;
import java.util.List; | package adamin90.com.wpp.fragment;
/**
* {@link RecyclerView.Adapter} that can display a {@link DummyItem} and makes a call to the
* specified {@link OnListFragmentInteractionListener}.
* TODO: Replace the implementation with code for your data type.
*/
public class MyItemRecyclerViewAdapter extends RecyclerView.Adapter<MyItemRecyclerViewAdapter.ViewHolder> {
private final List<DummyItem> mValues; | // Path: wpp/app/src/main/java/adamin90/com/wpp/fragment/ZhuanTiFragment.java
// public interface OnListFragmentInteractionListener {
// // TODO: Update argument type and name
// void onListFragmentInteraction(DummyItem item);
// }
//
// Path: wpp/app/src/main/java/adamin90/com/wpp/fragment/dummy/DummyContent.java
// public static class DummyItem {
// public final String id;
// public final String content;
// public final String details;
//
// public DummyItem(String id, String content, String details) {
// this.id = id;
// this.content = content;
// this.details = details;
// }
//
// @Override
// public String toString() {
// return content;
// }
// }
// Path: wpp/app/src/main/java/adamin90/com/wpp/fragment/MyItemRecyclerViewAdapter.java
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import adamin90.com.wpp.R;
import adamin90.com.wpp.fragment.ZhuanTiFragment.OnListFragmentInteractionListener;
import adamin90.com.wpp.fragment.dummy.DummyContent.DummyItem;
import java.util.List;
package adamin90.com.wpp.fragment;
/**
* {@link RecyclerView.Adapter} that can display a {@link DummyItem} and makes a call to the
* specified {@link OnListFragmentInteractionListener}.
* TODO: Replace the implementation with code for your data type.
*/
public class MyItemRecyclerViewAdapter extends RecyclerView.Adapter<MyItemRecyclerViewAdapter.ViewHolder> {
private final List<DummyItem> mValues; | private final OnListFragmentInteractionListener mListener; |
adamin1990/MaterialWpp | wpp/app/src/main/java/adamin90/com/wpp/model/newest/NewestData.java | // Path: wpp/app/src/main/java/adamin90/com/wpp/model/Datum.java
// @Generated("org.jsonschema2pojo")
// public class Datum {
//
// @SerializedName("title")
// @Expose
// private String title;
// @SerializedName("id")
// @Expose
// private String id;
// @SerializedName("datetime")
// @Expose
// private String datetime;
// @SerializedName("list")
// @Expose
// private java.util.List<List> list = new ArrayList<List>();
//
// /**
// *
// * @return
// * The title
// */
// public String getTitle() {
// return title;
// }
//
// /**
// *
// * @param title
// * The title
// */
// public void setTitle(String title) {
// this.title = title;
// }
//
// /**
// *
// * @return
// * The id
// */
// public String getId() {
// return id;
// }
//
// /**
// *
// * @param id
// * The id
// */
// public void setId(String id) {
// this.id = id;
// }
//
// /**
// *
// * @return
// * The datetime
// */
// public String getDatetime() {
// return datetime;
// }
//
// /**
// *
// * @param datetime
// * The datetime
// */
// public void setDatetime(String datetime) {
// this.datetime = datetime;
// }
//
// /**
// *
// * @return
// * The list
// */
// public java.util.List<List> getList() {
// return list;
// }
//
// /**
// *
// * @param list
// * The list
// */
// public void setList(java.util.List<List> list) {
// this.list = list;
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import javax.annotation.Generated;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import adamin90.com.wpp.model.Datum; |
package adamin90.com.wpp.model.newest;
@Generated("org.jsonschema2pojo")
public class NewestData {
@SerializedName("data")
@Expose | // Path: wpp/app/src/main/java/adamin90/com/wpp/model/Datum.java
// @Generated("org.jsonschema2pojo")
// public class Datum {
//
// @SerializedName("title")
// @Expose
// private String title;
// @SerializedName("id")
// @Expose
// private String id;
// @SerializedName("datetime")
// @Expose
// private String datetime;
// @SerializedName("list")
// @Expose
// private java.util.List<List> list = new ArrayList<List>();
//
// /**
// *
// * @return
// * The title
// */
// public String getTitle() {
// return title;
// }
//
// /**
// *
// * @param title
// * The title
// */
// public void setTitle(String title) {
// this.title = title;
// }
//
// /**
// *
// * @return
// * The id
// */
// public String getId() {
// return id;
// }
//
// /**
// *
// * @param id
// * The id
// */
// public void setId(String id) {
// this.id = id;
// }
//
// /**
// *
// * @return
// * The datetime
// */
// public String getDatetime() {
// return datetime;
// }
//
// /**
// *
// * @param datetime
// * The datetime
// */
// public void setDatetime(String datetime) {
// this.datetime = datetime;
// }
//
// /**
// *
// * @return
// * The list
// */
// public java.util.List<List> getList() {
// return list;
// }
//
// /**
// *
// * @param list
// * The list
// */
// public void setList(java.util.List<List> list) {
// this.list = list;
// }
//
// }
// Path: wpp/app/src/main/java/adamin90/com/wpp/model/newest/NewestData.java
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Generated;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import adamin90.com.wpp.model.Datum;
package adamin90.com.wpp.model.newest;
@Generated("org.jsonschema2pojo")
public class NewestData {
@SerializedName("data")
@Expose | private List<Datum> data = new ArrayList<Datum>(); |
adamin1990/MaterialWpp | wpp/app/src/main/java/adamin90/com/wpp/service/OtherService.java | // Path: wpp/app/src/main/java/adamin90/com/wpp/model/other/OtherModel.java
// @Generated("org.jsonschema2pojo")
// public class OtherModel {
//
// @SerializedName("data")
// @Expose
// private List<Datum> data = new ArrayList<Datum>();
// @SerializedName("total_count")
// @Expose
// private String totalCount;
// @SerializedName("source_type")
// @Expose
// private Integer sourceType;
// @SerializedName("code")
// @Expose
// private Integer code;
//
// /**
// *
// * @return
// * The data
// */
// public List<Datum> getData() {
// return data;
// }
//
// /**
// *
// * @param data
// * The data
// */
// public void setData(List<Datum> data) {
// this.data = data;
// }
//
// /**
// *
// * @return
// * The totalCount
// */
// public String getTotalCount() {
// return totalCount;
// }
//
// /**
// *
// * @param totalCount
// * The total_count
// */
// public void setTotalCount(String totalCount) {
// this.totalCount = totalCount;
// }
//
// /**
// *
// * @return
// * The sourceType
// */
// public Integer getSourceType() {
// return sourceType;
// }
//
// /**
// *
// * @param sourceType
// * The source_type
// */
// public void setSourceType(Integer sourceType) {
// this.sourceType = sourceType;
// }
//
// /**
// *
// * @return
// * The code
// */
// public Integer getCode() {
// return code;
// }
//
// /**
// *
// * @param code
// * The code
// */
// public void setCode(Integer code) {
// this.code = code;
// }
//
// }
| import adamin90.com.wpp.model.other.OtherModel;
import retrofit.http.GET;
import retrofit.http.Path;
import rx.Observable; | package adamin90.com.wpp.service;
/**
* Created by LiTao on 2015-11-21-15:31.
* Company: QD24so
* Email: [email protected]
* WebSite: http://lixiaopeng.top
* "其他"通用接口
*/
public interface OtherService {
@GET("index.php/3/Wallpaper/PicByCate/cate/{cate}/order/1/start/{start}/limit/{limit}/") | // Path: wpp/app/src/main/java/adamin90/com/wpp/model/other/OtherModel.java
// @Generated("org.jsonschema2pojo")
// public class OtherModel {
//
// @SerializedName("data")
// @Expose
// private List<Datum> data = new ArrayList<Datum>();
// @SerializedName("total_count")
// @Expose
// private String totalCount;
// @SerializedName("source_type")
// @Expose
// private Integer sourceType;
// @SerializedName("code")
// @Expose
// private Integer code;
//
// /**
// *
// * @return
// * The data
// */
// public List<Datum> getData() {
// return data;
// }
//
// /**
// *
// * @param data
// * The data
// */
// public void setData(List<Datum> data) {
// this.data = data;
// }
//
// /**
// *
// * @return
// * The totalCount
// */
// public String getTotalCount() {
// return totalCount;
// }
//
// /**
// *
// * @param totalCount
// * The total_count
// */
// public void setTotalCount(String totalCount) {
// this.totalCount = totalCount;
// }
//
// /**
// *
// * @return
// * The sourceType
// */
// public Integer getSourceType() {
// return sourceType;
// }
//
// /**
// *
// * @param sourceType
// * The source_type
// */
// public void setSourceType(Integer sourceType) {
// this.sourceType = sourceType;
// }
//
// /**
// *
// * @return
// * The code
// */
// public Integer getCode() {
// return code;
// }
//
// /**
// *
// * @param code
// * The code
// */
// public void setCode(Integer code) {
// this.code = code;
// }
//
// }
// Path: wpp/app/src/main/java/adamin90/com/wpp/service/OtherService.java
import adamin90.com.wpp.model.other.OtherModel;
import retrofit.http.GET;
import retrofit.http.Path;
import rx.Observable;
package adamin90.com.wpp.service;
/**
* Created by LiTao on 2015-11-21-15:31.
* Company: QD24so
* Email: [email protected]
* WebSite: http://lixiaopeng.top
* "其他"通用接口
*/
public interface OtherService {
@GET("index.php/3/Wallpaper/PicByCate/cate/{cate}/order/1/start/{start}/limit/{limit}/") | Observable<OtherModel> fetchOther(@Path("cate") int cate ,@Path("start") int start,@Path("limit")int limit); |
adamin1990/MaterialWpp | wpp/app/src/main/java/adamin90/com/wpp/service/PictureList.java | // Path: wpp/app/src/main/java/adamin90/com/wpp/model/piclist/PicList.java
// @Generated("org.jsonschema2pojo")
// public class PicList {
//
// @SerializedName("data")
// @Expose
// private Data data;
// @SerializedName("code")
// @Expose
// private Integer code;
//
// /**
// *
// * @return
// * The data
// */
// public Data getData() {
// return data;
// }
//
// /**
// *
// * @param data
// * The data
// */
// public void setData(Data data) {
// this.data = data;
// }
//
// /**
// *
// * @return
// * The code
// */
// public Integer getCode() {
// return code;
// }
//
// /**
// *
// * @param code
// * The code
// */
// public void setCode(Integer code) {
// this.code = code;
// }
//
// }
| import adamin90.com.wpp.model.piclist.PicList;
import retrofit.http.GET;
import retrofit.http.Path;
import rx.Observable; | package adamin90.com.wpp.service;
/**
* Created by LiTao on 2015-11-17-10:45.
* Company: QD24so
* Email: [email protected]
* WebSite: http://lixiaopeng.top
*/
public interface PictureList {
@GET("3/Wallpaper/picList/order/-1/source_type/1/source_id/{sourceid}/update/0/index/{index}/limit/{limit}/pixel/1080*1920/") | // Path: wpp/app/src/main/java/adamin90/com/wpp/model/piclist/PicList.java
// @Generated("org.jsonschema2pojo")
// public class PicList {
//
// @SerializedName("data")
// @Expose
// private Data data;
// @SerializedName("code")
// @Expose
// private Integer code;
//
// /**
// *
// * @return
// * The data
// */
// public Data getData() {
// return data;
// }
//
// /**
// *
// * @param data
// * The data
// */
// public void setData(Data data) {
// this.data = data;
// }
//
// /**
// *
// * @return
// * The code
// */
// public Integer getCode() {
// return code;
// }
//
// /**
// *
// * @param code
// * The code
// */
// public void setCode(Integer code) {
// this.code = code;
// }
//
// }
// Path: wpp/app/src/main/java/adamin90/com/wpp/service/PictureList.java
import adamin90.com.wpp.model.piclist.PicList;
import retrofit.http.GET;
import retrofit.http.Path;
import rx.Observable;
package adamin90.com.wpp.service;
/**
* Created by LiTao on 2015-11-17-10:45.
* Company: QD24so
* Email: [email protected]
* WebSite: http://lixiaopeng.top
*/
public interface PictureList {
@GET("3/Wallpaper/picList/order/-1/source_type/1/source_id/{sourceid}/update/0/index/{index}/limit/{limit}/pixel/1080*1920/") | Observable<PicList> getPicList(@Path("sourceid") int id,@Path("index") int index,@Path("limit") int limit); |
adamin1990/MaterialWpp | wpp/app/src/main/java/adamin90/com/wpp/service/FetchNormalService.java | // Path: wpp/app/src/main/java/adamin90/com/wpp/model/normal/NormalModel.java
// @Generated("org.jsonschema2pojo")
// public class NormalModel {
//
// @SerializedName("data")
// @Expose
// private List<Datum> data = new ArrayList<Datum>();
// @SerializedName("total_count")
// @Expose
// private String totalCount;
// @SerializedName("source_type")
// @Expose
// private Integer sourceType;
// @SerializedName("code")
// @Expose
// private Integer code;
//
// /**
// *
// * @return
// * The data
// */
// public List<Datum> getData() {
// return data;
// }
//
// /**
// *
// * @param data
// * The data
// */
// public void setData(List<Datum> data) {
// this.data = data;
// }
//
// /**
// *
// * @return
// * The totalCount
// */
// public String getTotalCount() {
// return totalCount;
// }
//
// /**
// *
// * @param totalCount
// * The total_count
// */
// public void setTotalCount(String totalCount) {
// this.totalCount = totalCount;
// }
//
// /**
// *
// * @return
// * The sourceType
// */
// public Integer getSourceType() {
// return sourceType;
// }
//
// /**
// *
// * @param sourceType
// * The source_type
// */
// public void setSourceType(Integer sourceType) {
// this.sourceType = sourceType;
// }
//
// /**
// *
// * @return
// * The code
// */
// public Integer getCode() {
// return code;
// }
//
// /**
// *
// * @param code
// * The code
// */
// public void setCode(Integer code) {
// this.code = code;
// }
//
// }
| import adamin90.com.wpp.model.normal.NormalModel;
import retrofit.http.GET;
import retrofit.http.Path;
import rx.Observable; | package adamin90.com.wpp.service;
/**
* Created by LiTao on 2015-11-21-17:21.
* Company: QD24so
* Email: [email protected]
* WebSite: http://lixiaopeng.top
* 正常tab接口
*/
public interface FetchNormalService {
@GET("index.php/3/Wallpaper/PicByCate/cate/{cate}/order/1/start/{start}/limit/{limit}/") | // Path: wpp/app/src/main/java/adamin90/com/wpp/model/normal/NormalModel.java
// @Generated("org.jsonschema2pojo")
// public class NormalModel {
//
// @SerializedName("data")
// @Expose
// private List<Datum> data = new ArrayList<Datum>();
// @SerializedName("total_count")
// @Expose
// private String totalCount;
// @SerializedName("source_type")
// @Expose
// private Integer sourceType;
// @SerializedName("code")
// @Expose
// private Integer code;
//
// /**
// *
// * @return
// * The data
// */
// public List<Datum> getData() {
// return data;
// }
//
// /**
// *
// * @param data
// * The data
// */
// public void setData(List<Datum> data) {
// this.data = data;
// }
//
// /**
// *
// * @return
// * The totalCount
// */
// public String getTotalCount() {
// return totalCount;
// }
//
// /**
// *
// * @param totalCount
// * The total_count
// */
// public void setTotalCount(String totalCount) {
// this.totalCount = totalCount;
// }
//
// /**
// *
// * @return
// * The sourceType
// */
// public Integer getSourceType() {
// return sourceType;
// }
//
// /**
// *
// * @param sourceType
// * The source_type
// */
// public void setSourceType(Integer sourceType) {
// this.sourceType = sourceType;
// }
//
// /**
// *
// * @return
// * The code
// */
// public Integer getCode() {
// return code;
// }
//
// /**
// *
// * @param code
// * The code
// */
// public void setCode(Integer code) {
// this.code = code;
// }
//
// }
// Path: wpp/app/src/main/java/adamin90/com/wpp/service/FetchNormalService.java
import adamin90.com.wpp.model.normal.NormalModel;
import retrofit.http.GET;
import retrofit.http.Path;
import rx.Observable;
package adamin90.com.wpp.service;
/**
* Created by LiTao on 2015-11-21-17:21.
* Company: QD24so
* Email: [email protected]
* WebSite: http://lixiaopeng.top
* 正常tab接口
*/
public interface FetchNormalService {
@GET("index.php/3/Wallpaper/PicByCate/cate/{cate}/order/1/start/{start}/limit/{limit}/") | Observable<NormalModel> fetchNormal(@Path("cate") int cate,@Path("start") int start,@Path("limit") int limit); |
camac/BuildXPages | com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/ant/GenerateSiteXmlTask.java | // Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/task/GenerateSiteXml.java
// public class GenerateSiteXml {
//
// private String eclipseFolder = null;
// private List<String> features = new ArrayList<String>();
//
// public GenerateSiteXml(String eclipseFolder) {
// this.eclipseFolder = eclipseFolder;
// }
//
// public void execute() throws FileNotFoundException, TransformerException,
// ParserConfigurationException {
//
// File eclipseDirFile = new File(this.eclipseFolder);
// if (!eclipseDirFile.exists()) {
// throw new FileNotFoundException(
// "Can't find Eclipse Directory, does not exists");
// }
// if (!eclipseDirFile.isDirectory()) {
// throw new IllegalArgumentException(
// "Supplied argument must be a directory");
// }
// String featuresDir = this.eclipseFolder + File.separator + "features";
//
// File featuresDirFile = new File(featuresDir);
// if (!featuresDirFile.exists()) {
// throw new FileNotFoundException("features sub directory not found");
// }
// if (!featuresDirFile.isDirectory()) {
// throw new IllegalArgumentException(
// "Directory must have sub-directory called features");
// }
// String[] featureJars = featuresDirFile.list();
// for (String subfile : featureJars) {
// if (subfile.endsWith(".jar")) {
// this.features.add(subfile);
// }
// }
// DocumentBuilderFactory docFactory = DocumentBuilderFactory
// .newInstance();
// DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
//
// Document doc = docBuilder.newDocument();
// Element rootElement = doc.createElement("site");
// doc.appendChild(rootElement);
// for (String featureName : this.features) {
// if (featureName.endsWith(".jar") && featureName.contains("_")) {
// String[] bits = featureName.split("_");
//
// String id = bits[0];
// String version = bits[1].substring(0, bits[1].lastIndexOf('.'));
// String url = "features/" + featureName;
//
// Element feature = doc.createElement("feature");
// rootElement.appendChild(feature);
//
// feature.setAttribute("url", url);
// feature.setAttribute("id", id);
// feature.setAttribute("version", version);
// }
// }
// TransformerFactory transformerFactory = TransformerFactory
// .newInstance();
// Transformer transformer = transformerFactory.newTransformer();
// DOMSource source = new DOMSource(doc);
// StreamResult result = new StreamResult(new File(eclipseDirFile,
// "site.xml"));
//
// transformer.setOutputProperty("indent", "yes");
// transformer.setOutputProperty(
// "{http://xml.apache.org/xslt}indent-amount", "2");
//
// transformer.transform(source, result);
//
// System.out.println("File saved!");
// }
//
// public static void main(String[] args) throws FileNotFoundException,
// TransformerException, ParserConfigurationException {
// if (args.length != 1) {
// System.out.println("Wrong number of arguments");
// System.out
// .println("expects update site root directory containing features directory");
// }
// String updateSiteFolder = args[0];
//
// System.out.println("Running on " + updateSiteFolder);
//
// GenerateSiteXml gen = new GenerateSiteXml(updateSiteFolder);
// gen.execute();
// }
// }
| import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import com.gregorbyte.buildxpages.task.GenerateSiteXml; | package com.gregorbyte.buildxpages.ant;
public class GenerateSiteXmlTask extends Task {
private String eclipseDir;
public void setEclipseDir(String eclipseDir) {
this.eclipseDir = eclipseDir;
}
@Override
public void execute() throws BuildException {
if (this.eclipseDir == null || this.eclipseDir.isEmpty())
throw new BuildException("eclipseDir not Specified");
File file = new File(eclipseDir);
if (!file.exists())
throw new BuildException("specified eclipseDir does not exists");
if (!file.isDirectory())
throw new BuildException("eclipseDir must be a directory");
try {
| // Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/task/GenerateSiteXml.java
// public class GenerateSiteXml {
//
// private String eclipseFolder = null;
// private List<String> features = new ArrayList<String>();
//
// public GenerateSiteXml(String eclipseFolder) {
// this.eclipseFolder = eclipseFolder;
// }
//
// public void execute() throws FileNotFoundException, TransformerException,
// ParserConfigurationException {
//
// File eclipseDirFile = new File(this.eclipseFolder);
// if (!eclipseDirFile.exists()) {
// throw new FileNotFoundException(
// "Can't find Eclipse Directory, does not exists");
// }
// if (!eclipseDirFile.isDirectory()) {
// throw new IllegalArgumentException(
// "Supplied argument must be a directory");
// }
// String featuresDir = this.eclipseFolder + File.separator + "features";
//
// File featuresDirFile = new File(featuresDir);
// if (!featuresDirFile.exists()) {
// throw new FileNotFoundException("features sub directory not found");
// }
// if (!featuresDirFile.isDirectory()) {
// throw new IllegalArgumentException(
// "Directory must have sub-directory called features");
// }
// String[] featureJars = featuresDirFile.list();
// for (String subfile : featureJars) {
// if (subfile.endsWith(".jar")) {
// this.features.add(subfile);
// }
// }
// DocumentBuilderFactory docFactory = DocumentBuilderFactory
// .newInstance();
// DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
//
// Document doc = docBuilder.newDocument();
// Element rootElement = doc.createElement("site");
// doc.appendChild(rootElement);
// for (String featureName : this.features) {
// if (featureName.endsWith(".jar") && featureName.contains("_")) {
// String[] bits = featureName.split("_");
//
// String id = bits[0];
// String version = bits[1].substring(0, bits[1].lastIndexOf('.'));
// String url = "features/" + featureName;
//
// Element feature = doc.createElement("feature");
// rootElement.appendChild(feature);
//
// feature.setAttribute("url", url);
// feature.setAttribute("id", id);
// feature.setAttribute("version", version);
// }
// }
// TransformerFactory transformerFactory = TransformerFactory
// .newInstance();
// Transformer transformer = transformerFactory.newTransformer();
// DOMSource source = new DOMSource(doc);
// StreamResult result = new StreamResult(new File(eclipseDirFile,
// "site.xml"));
//
// transformer.setOutputProperty("indent", "yes");
// transformer.setOutputProperty(
// "{http://xml.apache.org/xslt}indent-amount", "2");
//
// transformer.transform(source, result);
//
// System.out.println("File saved!");
// }
//
// public static void main(String[] args) throws FileNotFoundException,
// TransformerException, ParserConfigurationException {
// if (args.length != 1) {
// System.out.println("Wrong number of arguments");
// System.out
// .println("expects update site root directory containing features directory");
// }
// String updateSiteFolder = args[0];
//
// System.out.println("Running on " + updateSiteFolder);
//
// GenerateSiteXml gen = new GenerateSiteXml(updateSiteFolder);
// gen.execute();
// }
// }
// Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/ant/GenerateSiteXmlTask.java
import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import com.gregorbyte.buildxpages.task.GenerateSiteXml;
package com.gregorbyte.buildxpages.ant;
public class GenerateSiteXmlTask extends Task {
private String eclipseDir;
public void setEclipseDir(String eclipseDir) {
this.eclipseDir = eclipseDir;
}
@Override
public void execute() throws BuildException {
if (this.eclipseDir == null || this.eclipseDir.isEmpty())
throw new BuildException("eclipseDir not Specified");
File file = new File(eclipseDir);
if (!file.exists())
throw new BuildException("specified eclipseDir does not exists");
if (!file.isDirectory())
throw new BuildException("eclipseDir must be a directory");
try {
| GenerateSiteXml gen = new GenerateSiteXml(this.eclipseDir); |
camac/BuildXPages | com.gregorbyte.designer.headless/src/com/gregorbyte/designer/headless/actions/StopServerAction.java | // Path: com.gregorbyte.designer.headless/src/com/gregorbyte/designer/headless/HeadlessServerActivator.java
// public class HeadlessServerActivator extends AbstractUIPlugin {
//
// // The plug-in ID
// public static final String PLUGIN_ID = "com.gregorbyte.designer.headless"; //$NON-NLS-1$
//
// public static HeadlessServerActivator INSTANCE = null;
//
// private Thread serverThread;
// private HeadlessServerRunnable headlessServer;
//
// // The shared instance
// private static HeadlessServerActivator plugin;
//
// /**
// * The constructor
// */
// public HeadlessServerActivator() {
// }
//
// public void startServer() {
// if (!isServerRunning()) {
// headlessServer = new HeadlessServerRunnable();
// serverThread = new Thread(headlessServer);
// serverThread.setName("Headless Nsf Server");
// serverThread.start();
// }
// }
//
// public void stopServer() {
// if (isServerRunning())
// headlessServer.stopThread();
// }
//
// public boolean isServerRunning() {
//
// if (serverThread == null)
// return false;
// return serverThread.isAlive();
//
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.
// * BundleContext)
// */
// public void start(BundleContext context) throws Exception {
//
// INSTANCE = this;
//
// super.start(context);
//
// plugin = this;
//
// try {
// Boolean autoStart = getDefault().getPreferenceStore().getBoolean(PreferenceConstants.P_START);
//
// if (autoStart) {
// System.out.println("Attempting to Auto Start Gregorbyte Headless Server");
// startServer();
// }
//
// } catch (Exception e) {
// System.err.println("Error attempting to auto start GregorbyteHeadless Server");
// }
//
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.
// * BundleContext)
// */
// public void stop(BundleContext context) throws Exception {
//
// System.out.println("Stopping Headless Bundle");
//
// stopServer();
//
// plugin = null;
// super.stop(context);
// }
//
// /**
// * Returns the shared instance
// *
// * @return the shared instance
// */
// public static HeadlessServerActivator getDefault() {
// return plugin;
// }
//
// }
| import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import com.gregorbyte.designer.headless.HeadlessServerActivator; | package com.gregorbyte.designer.headless.actions;
public class StopServerAction implements IWorkbenchWindowActionDelegate {
private IWorkbenchWindow window;
public StopServerAction() {
super();
}
@Override
public void run(IAction action) {
String msg = "";
| // Path: com.gregorbyte.designer.headless/src/com/gregorbyte/designer/headless/HeadlessServerActivator.java
// public class HeadlessServerActivator extends AbstractUIPlugin {
//
// // The plug-in ID
// public static final String PLUGIN_ID = "com.gregorbyte.designer.headless"; //$NON-NLS-1$
//
// public static HeadlessServerActivator INSTANCE = null;
//
// private Thread serverThread;
// private HeadlessServerRunnable headlessServer;
//
// // The shared instance
// private static HeadlessServerActivator plugin;
//
// /**
// * The constructor
// */
// public HeadlessServerActivator() {
// }
//
// public void startServer() {
// if (!isServerRunning()) {
// headlessServer = new HeadlessServerRunnable();
// serverThread = new Thread(headlessServer);
// serverThread.setName("Headless Nsf Server");
// serverThread.start();
// }
// }
//
// public void stopServer() {
// if (isServerRunning())
// headlessServer.stopThread();
// }
//
// public boolean isServerRunning() {
//
// if (serverThread == null)
// return false;
// return serverThread.isAlive();
//
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.
// * BundleContext)
// */
// public void start(BundleContext context) throws Exception {
//
// INSTANCE = this;
//
// super.start(context);
//
// plugin = this;
//
// try {
// Boolean autoStart = getDefault().getPreferenceStore().getBoolean(PreferenceConstants.P_START);
//
// if (autoStart) {
// System.out.println("Attempting to Auto Start Gregorbyte Headless Server");
// startServer();
// }
//
// } catch (Exception e) {
// System.err.println("Error attempting to auto start GregorbyteHeadless Server");
// }
//
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.
// * BundleContext)
// */
// public void stop(BundleContext context) throws Exception {
//
// System.out.println("Stopping Headless Bundle");
//
// stopServer();
//
// plugin = null;
// super.stop(context);
// }
//
// /**
// * Returns the shared instance
// *
// * @return the shared instance
// */
// public static HeadlessServerActivator getDefault() {
// return plugin;
// }
//
// }
// Path: com.gregorbyte.designer.headless/src/com/gregorbyte/designer/headless/actions/StopServerAction.java
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import com.gregorbyte.designer.headless.HeadlessServerActivator;
package com.gregorbyte.designer.headless.actions;
public class StopServerAction implements IWorkbenchWindowActionDelegate {
private IWorkbenchWindow window;
public StopServerAction() {
super();
}
@Override
public void run(IAction action) {
String msg = "";
| if (HeadlessServerActivator.INSTANCE.isServerRunning()) { |
camac/BuildXPages | com.gregorbyte.designer.headless/src/com/gregorbyte/designer/headless/actions/StartServerAction.java | // Path: com.gregorbyte.designer.headless/src/com/gregorbyte/designer/headless/HeadlessServerActivator.java
// public class HeadlessServerActivator extends AbstractUIPlugin {
//
// // The plug-in ID
// public static final String PLUGIN_ID = "com.gregorbyte.designer.headless"; //$NON-NLS-1$
//
// public static HeadlessServerActivator INSTANCE = null;
//
// private Thread serverThread;
// private HeadlessServerRunnable headlessServer;
//
// // The shared instance
// private static HeadlessServerActivator plugin;
//
// /**
// * The constructor
// */
// public HeadlessServerActivator() {
// }
//
// public void startServer() {
// if (!isServerRunning()) {
// headlessServer = new HeadlessServerRunnable();
// serverThread = new Thread(headlessServer);
// serverThread.setName("Headless Nsf Server");
// serverThread.start();
// }
// }
//
// public void stopServer() {
// if (isServerRunning())
// headlessServer.stopThread();
// }
//
// public boolean isServerRunning() {
//
// if (serverThread == null)
// return false;
// return serverThread.isAlive();
//
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.
// * BundleContext)
// */
// public void start(BundleContext context) throws Exception {
//
// INSTANCE = this;
//
// super.start(context);
//
// plugin = this;
//
// try {
// Boolean autoStart = getDefault().getPreferenceStore().getBoolean(PreferenceConstants.P_START);
//
// if (autoStart) {
// System.out.println("Attempting to Auto Start Gregorbyte Headless Server");
// startServer();
// }
//
// } catch (Exception e) {
// System.err.println("Error attempting to auto start GregorbyteHeadless Server");
// }
//
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.
// * BundleContext)
// */
// public void stop(BundleContext context) throws Exception {
//
// System.out.println("Stopping Headless Bundle");
//
// stopServer();
//
// plugin = null;
// super.stop(context);
// }
//
// /**
// * Returns the shared instance
// *
// * @return the shared instance
// */
// public static HeadlessServerActivator getDefault() {
// return plugin;
// }
//
// }
| import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import com.gregorbyte.designer.headless.HeadlessServerActivator; | package com.gregorbyte.designer.headless.actions;
public class StartServerAction implements IWorkbenchWindowActionDelegate {
private IWorkbenchWindow window;
@Override
public void run(IAction action) {
String msg = "";
| // Path: com.gregorbyte.designer.headless/src/com/gregorbyte/designer/headless/HeadlessServerActivator.java
// public class HeadlessServerActivator extends AbstractUIPlugin {
//
// // The plug-in ID
// public static final String PLUGIN_ID = "com.gregorbyte.designer.headless"; //$NON-NLS-1$
//
// public static HeadlessServerActivator INSTANCE = null;
//
// private Thread serverThread;
// private HeadlessServerRunnable headlessServer;
//
// // The shared instance
// private static HeadlessServerActivator plugin;
//
// /**
// * The constructor
// */
// public HeadlessServerActivator() {
// }
//
// public void startServer() {
// if (!isServerRunning()) {
// headlessServer = new HeadlessServerRunnable();
// serverThread = new Thread(headlessServer);
// serverThread.setName("Headless Nsf Server");
// serverThread.start();
// }
// }
//
// public void stopServer() {
// if (isServerRunning())
// headlessServer.stopThread();
// }
//
// public boolean isServerRunning() {
//
// if (serverThread == null)
// return false;
// return serverThread.isAlive();
//
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.
// * BundleContext)
// */
// public void start(BundleContext context) throws Exception {
//
// INSTANCE = this;
//
// super.start(context);
//
// plugin = this;
//
// try {
// Boolean autoStart = getDefault().getPreferenceStore().getBoolean(PreferenceConstants.P_START);
//
// if (autoStart) {
// System.out.println("Attempting to Auto Start Gregorbyte Headless Server");
// startServer();
// }
//
// } catch (Exception e) {
// System.err.println("Error attempting to auto start GregorbyteHeadless Server");
// }
//
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.
// * BundleContext)
// */
// public void stop(BundleContext context) throws Exception {
//
// System.out.println("Stopping Headless Bundle");
//
// stopServer();
//
// plugin = null;
// super.stop(context);
// }
//
// /**
// * Returns the shared instance
// *
// * @return the shared instance
// */
// public static HeadlessServerActivator getDefault() {
// return plugin;
// }
//
// }
// Path: com.gregorbyte.designer.headless/src/com/gregorbyte/designer/headless/actions/StartServerAction.java
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import com.gregorbyte.designer.headless.HeadlessServerActivator;
package com.gregorbyte.designer.headless.actions;
public class StartServerAction implements IWorkbenchWindowActionDelegate {
private IWorkbenchWindow window;
@Override
public void run(IAction action) {
String msg = "";
| if (HeadlessServerActivator.INSTANCE.isServerRunning()) { |
camac/BuildXPages | com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/ant/RefreshDbDesign.java | // Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/DesignRefreshMessageCallback.java
// public interface DesignRefreshMessageCallback extends StdCallLibrary.StdCallCallback {
//
// void proc(StringByReference message, short mType);
//
// }
//
// Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/StringByReference.java
// public class StringByReference extends ByReference {
//
// public StringByReference() {
// this(0);
// }
//
// public StringByReference(int size) {
// super(size < 4 ? 4 : size);
// getPointer().clear(size < 4 ? 4 : size);
// }
//
// public StringByReference(String str) {
// super(str.length() < 4 ? 4 : str.length() + 1);
// setValue(str);
// }
//
// private void setValue(String str) {
// getPointer().setString(0, str);
// }
//
// public String getValue() {
// return getPointer().getString(0);
// }
// }
| import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import com.gregorbyte.buildxpages.DesignRefreshMessageCallback;
import com.gregorbyte.buildxpages.StringByReference; | String dbpath = null;
String servername = null;
if (this.server == null) {
dbpath = "local!!" + this.database;
} else {
dbpath = this.server + "!!" + this.database;
}
if (this.templateserver == null) {
servername = "local";
} else {
servername = this.templateserver;
}
log("Refreshing Design of Db : " + dbpath);
log("Refreshing From Server : " + servername);
com.gregorbyte.buildxpages.task.RefreshDbDesign task = new com.gregorbyte.buildxpages.task.RefreshDbDesign(
this.database);
task.setServer(this.server);
task.setTemplateServer(this.templateserver);
task.setCallback(getCallback());
task.execute();
}
| // Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/DesignRefreshMessageCallback.java
// public interface DesignRefreshMessageCallback extends StdCallLibrary.StdCallCallback {
//
// void proc(StringByReference message, short mType);
//
// }
//
// Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/StringByReference.java
// public class StringByReference extends ByReference {
//
// public StringByReference() {
// this(0);
// }
//
// public StringByReference(int size) {
// super(size < 4 ? 4 : size);
// getPointer().clear(size < 4 ? 4 : size);
// }
//
// public StringByReference(String str) {
// super(str.length() < 4 ? 4 : str.length() + 1);
// setValue(str);
// }
//
// private void setValue(String str) {
// getPointer().setString(0, str);
// }
//
// public String getValue() {
// return getPointer().getString(0);
// }
// }
// Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/ant/RefreshDbDesign.java
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import com.gregorbyte.buildxpages.DesignRefreshMessageCallback;
import com.gregorbyte.buildxpages.StringByReference;
String dbpath = null;
String servername = null;
if (this.server == null) {
dbpath = "local!!" + this.database;
} else {
dbpath = this.server + "!!" + this.database;
}
if (this.templateserver == null) {
servername = "local";
} else {
servername = this.templateserver;
}
log("Refreshing Design of Db : " + dbpath);
log("Refreshing From Server : " + servername);
com.gregorbyte.buildxpages.task.RefreshDbDesign task = new com.gregorbyte.buildxpages.task.RefreshDbDesign(
this.database);
task.setServer(this.server);
task.setTemplateServer(this.templateserver);
task.setCallback(getCallback());
task.execute();
}
| public DesignRefreshMessageCallback getCallback() { |
camac/BuildXPages | com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/ant/RefreshDbDesign.java | // Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/DesignRefreshMessageCallback.java
// public interface DesignRefreshMessageCallback extends StdCallLibrary.StdCallCallback {
//
// void proc(StringByReference message, short mType);
//
// }
//
// Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/StringByReference.java
// public class StringByReference extends ByReference {
//
// public StringByReference() {
// this(0);
// }
//
// public StringByReference(int size) {
// super(size < 4 ? 4 : size);
// getPointer().clear(size < 4 ? 4 : size);
// }
//
// public StringByReference(String str) {
// super(str.length() < 4 ? 4 : str.length() + 1);
// setValue(str);
// }
//
// private void setValue(String str) {
// getPointer().setString(0, str);
// }
//
// public String getValue() {
// return getPointer().getString(0);
// }
// }
| import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import com.gregorbyte.buildxpages.DesignRefreshMessageCallback;
import com.gregorbyte.buildxpages.StringByReference; | dbpath = this.server + "!!" + this.database;
}
if (this.templateserver == null) {
servername = "local";
} else {
servername = this.templateserver;
}
log("Refreshing Design of Db : " + dbpath);
log("Refreshing From Server : " + servername);
com.gregorbyte.buildxpages.task.RefreshDbDesign task = new com.gregorbyte.buildxpages.task.RefreshDbDesign(
this.database);
task.setServer(this.server);
task.setTemplateServer(this.templateserver);
task.setCallback(getCallback());
task.execute();
}
public DesignRefreshMessageCallback getCallback() {
return new DesignRefreshMessageCallback() {
@Override | // Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/DesignRefreshMessageCallback.java
// public interface DesignRefreshMessageCallback extends StdCallLibrary.StdCallCallback {
//
// void proc(StringByReference message, short mType);
//
// }
//
// Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/StringByReference.java
// public class StringByReference extends ByReference {
//
// public StringByReference() {
// this(0);
// }
//
// public StringByReference(int size) {
// super(size < 4 ? 4 : size);
// getPointer().clear(size < 4 ? 4 : size);
// }
//
// public StringByReference(String str) {
// super(str.length() < 4 ? 4 : str.length() + 1);
// setValue(str);
// }
//
// private void setValue(String str) {
// getPointer().setString(0, str);
// }
//
// public String getValue() {
// return getPointer().getString(0);
// }
// }
// Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/ant/RefreshDbDesign.java
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import com.gregorbyte.buildxpages.DesignRefreshMessageCallback;
import com.gregorbyte.buildxpages.StringByReference;
dbpath = this.server + "!!" + this.database;
}
if (this.templateserver == null) {
servername = "local";
} else {
servername = this.templateserver;
}
log("Refreshing Design of Db : " + dbpath);
log("Refreshing From Server : " + servername);
com.gregorbyte.buildxpages.task.RefreshDbDesign task = new com.gregorbyte.buildxpages.task.RefreshDbDesign(
this.database);
task.setServer(this.server);
task.setTemplateServer(this.templateserver);
task.setCallback(getCallback());
task.execute();
}
public DesignRefreshMessageCallback getCallback() {
return new DesignRefreshMessageCallback() {
@Override | public void proc(StringByReference message, short mType) { |
camac/BuildXPages | com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/ant/ControlHttpTask.java | // Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/task/ControlHttpBxpTask.java
// public class ControlHttpBxpTask extends AbstractBxTask {
//
// private static final String ACTION_START = "start";
// private static final String ACTION_STOP = "stop";
// private static final String ACTION_RESTART = "restart";
//
// private static final String CMD_START = "load http";
// private static final String CMD_STOP = "tell http quit";
// private static final String CMD_RESTART = "restart task http";
//
// private String server;
// private String action;
//
// public ControlHttpBxpTask(String server, String action) {
// this.server = server;
// this.action = action;
// }
//
// public String getConsoleCommand() {
//
// if (action == null)
// return null;
//
// if (action.equalsIgnoreCase(ACTION_START)) {
// return CMD_START;
// } else if (action.equalsIgnoreCase(ACTION_STOP)) {
// return CMD_STOP;
// } else if (action.equalsIgnoreCase(ACTION_RESTART)) {
// return CMD_RESTART;
// }
//
// return null;
// }
//
// @Override
// protected void doTask() {
//
// String command = getConsoleCommand();
//
// if (command == null)
// throw new RuntimeException(
// "Could not determine action: must be start, stop or restart");
//
// NotesNativeLibrary notes = NotesNativeLibrary.SYNC_INSTANCE;
//
// IntByReference retInfo = new IntByReference();
// notes.NSFRemoteConsole(server, command, retInfo);
//
// }
//
// }
| import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import com.gregorbyte.buildxpages.task.ControlHttpBxpTask; | package com.gregorbyte.buildxpages.ant;
public class ControlHttpTask extends Task {
private String server;
private String action;
public void setServer(String server) {
this.server = server;
}
public void setAction(String action) {
this.action = action;
}
@Override
public void execute() throws BuildException {
| // Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/task/ControlHttpBxpTask.java
// public class ControlHttpBxpTask extends AbstractBxTask {
//
// private static final String ACTION_START = "start";
// private static final String ACTION_STOP = "stop";
// private static final String ACTION_RESTART = "restart";
//
// private static final String CMD_START = "load http";
// private static final String CMD_STOP = "tell http quit";
// private static final String CMD_RESTART = "restart task http";
//
// private String server;
// private String action;
//
// public ControlHttpBxpTask(String server, String action) {
// this.server = server;
// this.action = action;
// }
//
// public String getConsoleCommand() {
//
// if (action == null)
// return null;
//
// if (action.equalsIgnoreCase(ACTION_START)) {
// return CMD_START;
// } else if (action.equalsIgnoreCase(ACTION_STOP)) {
// return CMD_STOP;
// } else if (action.equalsIgnoreCase(ACTION_RESTART)) {
// return CMD_RESTART;
// }
//
// return null;
// }
//
// @Override
// protected void doTask() {
//
// String command = getConsoleCommand();
//
// if (command == null)
// throw new RuntimeException(
// "Could not determine action: must be start, stop or restart");
//
// NotesNativeLibrary notes = NotesNativeLibrary.SYNC_INSTANCE;
//
// IntByReference retInfo = new IntByReference();
// notes.NSFRemoteConsole(server, command, retInfo);
//
// }
//
// }
// Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/ant/ControlHttpTask.java
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import com.gregorbyte.buildxpages.task.ControlHttpBxpTask;
package com.gregorbyte.buildxpages.ant;
public class ControlHttpTask extends Task {
private String server;
private String action;
public void setServer(String server) {
this.server = server;
}
public void setAction(String action) {
this.action = action;
}
@Override
public void execute() throws BuildException {
| ControlHttpBxpTask task = new ControlHttpBxpTask(server, action); |
camac/BuildXPages | com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/ant/MaintenanceWarningTask.java | // Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/task/MaintenanceWarningBxpTask.java
// public class MaintenanceWarningBxpTask extends AbstractBxTask {
//
// private String server;
// private String minutes;
//
// private boolean cancelWarning = false;
//
// public MaintenanceWarningBxpTask(String server) {
// this.server = server;
// }
//
// public String getServer() {
// return server;
// }
//
// public void setServer(String server) {
// this.server = server;
// }
//
// public String getMinutes() {
// return minutes;
// }
//
// public void setMinutes(String minutes) {
// this.minutes = minutes;
// }
//
// public boolean isCancelWarning() {
// return cancelWarning;
// }
//
// public void setCancelWarning(boolean cancelWarning) {
// this.cancelWarning = cancelWarning;
// }
//
// public String getConsoleCommand() {
//
// StringBuilder sb = new StringBuilder("tell http osgi ");
//
// if (cancelWarning) {
// sb.append(" goingdowncancel");
// } else {
// sb.append(" goingdown " + getMinutes());
// }
//
// return sb.toString();
//
// }
//
// @Override
// protected void doTask() {
//
// NotesNativeLibrary notes = NotesNativeLibrary.SYNC_INSTANCE;
//
// String command = getConsoleCommand();
//
// if (command == null || command.equals("")) {
// throw new RuntimeException("No Console Command");
// }
//
// IntByReference retInfo = new IntByReference();
// notes.NSFRemoteConsole(server, command, retInfo);
//
// }
//
// }
| import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import com.gregorbyte.buildxpages.task.MaintenanceWarningBxpTask; | package com.gregorbyte.buildxpages.ant;
public class MaintenanceWarningTask extends Task {
private String server;
private String minutes;
private boolean cancelwarning;
public void setServer(String server) {
this.server = server;
}
public void setMinutes(String minutes) {
this.minutes = minutes;
}
public void setCancelwarning(boolean cancelwarning) {
this.cancelwarning = cancelwarning;
}
@Override
public void execute() throws BuildException {
| // Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/task/MaintenanceWarningBxpTask.java
// public class MaintenanceWarningBxpTask extends AbstractBxTask {
//
// private String server;
// private String minutes;
//
// private boolean cancelWarning = false;
//
// public MaintenanceWarningBxpTask(String server) {
// this.server = server;
// }
//
// public String getServer() {
// return server;
// }
//
// public void setServer(String server) {
// this.server = server;
// }
//
// public String getMinutes() {
// return minutes;
// }
//
// public void setMinutes(String minutes) {
// this.minutes = minutes;
// }
//
// public boolean isCancelWarning() {
// return cancelWarning;
// }
//
// public void setCancelWarning(boolean cancelWarning) {
// this.cancelWarning = cancelWarning;
// }
//
// public String getConsoleCommand() {
//
// StringBuilder sb = new StringBuilder("tell http osgi ");
//
// if (cancelWarning) {
// sb.append(" goingdowncancel");
// } else {
// sb.append(" goingdown " + getMinutes());
// }
//
// return sb.toString();
//
// }
//
// @Override
// protected void doTask() {
//
// NotesNativeLibrary notes = NotesNativeLibrary.SYNC_INSTANCE;
//
// String command = getConsoleCommand();
//
// if (command == null || command.equals("")) {
// throw new RuntimeException("No Console Command");
// }
//
// IntByReference retInfo = new IntByReference();
// notes.NSFRemoteConsole(server, command, retInfo);
//
// }
//
// }
// Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/ant/MaintenanceWarningTask.java
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import com.gregorbyte.buildxpages.task.MaintenanceWarningBxpTask;
package com.gregorbyte.buildxpages.ant;
public class MaintenanceWarningTask extends Task {
private String server;
private String minutes;
private boolean cancelwarning;
public void setServer(String server) {
this.server = server;
}
public void setMinutes(String minutes) {
this.minutes = minutes;
}
public void setCancelwarning(boolean cancelwarning) {
this.cancelwarning = cancelwarning;
}
@Override
public void execute() throws BuildException {
| MaintenanceWarningBxpTask task = new MaintenanceWarningBxpTask(server); |
camac/BuildXPages | com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/ThreadTest.java | // Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/task/ShowSpaceUsageTask.java
// public class ShowSpaceUsageTask extends AbstractBxTask {
//
// private String dbpath;
//
// public ShowSpaceUsageTask(String dbpath) {
// this.dbpath = dbpath;
// }
//
//
//
// @Override
// protected void doTask() {
//
// IntByReference dbHandle = new IntByReference();
// IntByReference retAllocatedBytes = new IntByReference();
// IntByReference retFreeBytes = new IntByReference();
// boolean dbOpen = false;
// short errorint = 0;
//
// NotesNativeLibrary notes = NotesNativeLibrary.SYNC_INSTANCE;
//
// try {
//
// errorint = notes.NSFDbOpen(this.dbpath, dbHandle);
// checkError(errorint);
// dbOpen = true;
//
// errorint = notes.NSFDbSpaceUsage(dbHandle.getValue(),
// retAllocatedBytes, retFreeBytes);
// checkError(errorint);
//
// errorint = notes.NSFDbClose(dbHandle.getValue());
// checkError(errorint);
// dbOpen = false;
//
// float percentused = 100 * (float) retAllocatedBytes.getValue()
// / retFreeBytes.getValue() + retAllocatedBytes.getValue();
//
// System.out.println(Float.toString(percentused));
//
// } finally {
//
// if (dbOpen) {
// errorint = notes.NSFDbClose(dbHandle.getValue());
// checkError(errorint);
// }
//
// }
//
// }
//
// }
| import com.gregorbyte.buildxpages.task.ShowSpaceUsageTask; | package com.gregorbyte.buildxpages;
public class ThreadTest {
private static final String TEST_DB = "domino02!!Cameron\\plugindev.nsf";
private static final String TEST_DB2 = "domino02!!temp\\SetTemplate.nsf";
private static class MyRunnable implements Runnable {
@Override
public void run() {
| // Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/task/ShowSpaceUsageTask.java
// public class ShowSpaceUsageTask extends AbstractBxTask {
//
// private String dbpath;
//
// public ShowSpaceUsageTask(String dbpath) {
// this.dbpath = dbpath;
// }
//
//
//
// @Override
// protected void doTask() {
//
// IntByReference dbHandle = new IntByReference();
// IntByReference retAllocatedBytes = new IntByReference();
// IntByReference retFreeBytes = new IntByReference();
// boolean dbOpen = false;
// short errorint = 0;
//
// NotesNativeLibrary notes = NotesNativeLibrary.SYNC_INSTANCE;
//
// try {
//
// errorint = notes.NSFDbOpen(this.dbpath, dbHandle);
// checkError(errorint);
// dbOpen = true;
//
// errorint = notes.NSFDbSpaceUsage(dbHandle.getValue(),
// retAllocatedBytes, retFreeBytes);
// checkError(errorint);
//
// errorint = notes.NSFDbClose(dbHandle.getValue());
// checkError(errorint);
// dbOpen = false;
//
// float percentused = 100 * (float) retAllocatedBytes.getValue()
// / retFreeBytes.getValue() + retAllocatedBytes.getValue();
//
// System.out.println(Float.toString(percentused));
//
// } finally {
//
// if (dbOpen) {
// errorint = notes.NSFDbClose(dbHandle.getValue());
// checkError(errorint);
// }
//
// }
//
// }
//
// }
// Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/ThreadTest.java
import com.gregorbyte.buildxpages.task.ShowSpaceUsageTask;
package com.gregorbyte.buildxpages;
public class ThreadTest {
private static final String TEST_DB = "domino02!!Cameron\\plugindev.nsf";
private static final String TEST_DB2 = "domino02!!temp\\SetTemplate.nsf";
private static class MyRunnable implements Runnable {
@Override
public void run() {
| ShowSpaceUsageTask task = new ShowSpaceUsageTask(TEST_DB); |
camac/BuildXPages | com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/ant/LoadDesignTask.java | // Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/task/LoadDesignBxpTask.java
// public class LoadDesignBxpTask extends AbstractBxTask {
//
// private String server;
// private String directory;
//
// public LoadDesignBxpTask(String server, String directory) {
// this.server = server;
// this.directory = directory;
// }
//
// public String getConsoleCommand() {
//
// if (directory == null || "".equals(directory)) {
// return null;
// }
//
// StringBuilder sb = new StringBuilder("load design -d ");
//
// sb.append(directory);
//
// return sb.toString();
// }
//
// @Override
// protected void doTask() {
//
// String command = getConsoleCommand();
//
// if (command == null)
// throw new RuntimeException(
// "Could not determine directory to refresh");
//
// NotesNativeLibrary notes = NotesNativeLibrary.SYNC_INSTANCE;
//
// IntByReference retInfo = new IntByReference();
// notes.NSFRemoteConsole(server, command, retInfo);
//
// }
//
// }
| import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import com.gregorbyte.buildxpages.task.LoadDesignBxpTask; | package com.gregorbyte.buildxpages.ant;
public class LoadDesignTask extends Task {
private String server;
private String directory;
public void setServer(String server) {
this.server = server;
}
public void setDirectory(String directory) {
this.directory = directory;
}
@Override
public void execute() throws BuildException {
| // Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/task/LoadDesignBxpTask.java
// public class LoadDesignBxpTask extends AbstractBxTask {
//
// private String server;
// private String directory;
//
// public LoadDesignBxpTask(String server, String directory) {
// this.server = server;
// this.directory = directory;
// }
//
// public String getConsoleCommand() {
//
// if (directory == null || "".equals(directory)) {
// return null;
// }
//
// StringBuilder sb = new StringBuilder("load design -d ");
//
// sb.append(directory);
//
// return sb.toString();
// }
//
// @Override
// protected void doTask() {
//
// String command = getConsoleCommand();
//
// if (command == null)
// throw new RuntimeException(
// "Could not determine directory to refresh");
//
// NotesNativeLibrary notes = NotesNativeLibrary.SYNC_INSTANCE;
//
// IntByReference retInfo = new IntByReference();
// notes.NSFRemoteConsole(server, command, retInfo);
//
// }
//
// }
// Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/ant/LoadDesignTask.java
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import com.gregorbyte.buildxpages.task.LoadDesignBxpTask;
package com.gregorbyte.buildxpages.ant;
public class LoadDesignTask extends Task {
private String server;
private String directory;
public void setServer(String server) {
this.server = server;
}
public void setDirectory(String directory) {
this.directory = directory;
}
@Override
public void execute() throws BuildException {
| LoadDesignBxpTask task = new LoadDesignBxpTask(server, directory); |
camac/BuildXPages | com.gregorbyte.designer.headless/src/com/gregorbyte/designer/headless/preferences/PreferenceInitializer.java | // Path: com.gregorbyte.designer.headless/src/com/gregorbyte/designer/headless/HeadlessServerActivator.java
// public class HeadlessServerActivator extends AbstractUIPlugin {
//
// // The plug-in ID
// public static final String PLUGIN_ID = "com.gregorbyte.designer.headless"; //$NON-NLS-1$
//
// public static HeadlessServerActivator INSTANCE = null;
//
// private Thread serverThread;
// private HeadlessServerRunnable headlessServer;
//
// // The shared instance
// private static HeadlessServerActivator plugin;
//
// /**
// * The constructor
// */
// public HeadlessServerActivator() {
// }
//
// public void startServer() {
// if (!isServerRunning()) {
// headlessServer = new HeadlessServerRunnable();
// serverThread = new Thread(headlessServer);
// serverThread.setName("Headless Nsf Server");
// serverThread.start();
// }
// }
//
// public void stopServer() {
// if (isServerRunning())
// headlessServer.stopThread();
// }
//
// public boolean isServerRunning() {
//
// if (serverThread == null)
// return false;
// return serverThread.isAlive();
//
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.
// * BundleContext)
// */
// public void start(BundleContext context) throws Exception {
//
// INSTANCE = this;
//
// super.start(context);
//
// plugin = this;
//
// try {
// Boolean autoStart = getDefault().getPreferenceStore().getBoolean(PreferenceConstants.P_START);
//
// if (autoStart) {
// System.out.println("Attempting to Auto Start Gregorbyte Headless Server");
// startServer();
// }
//
// } catch (Exception e) {
// System.err.println("Error attempting to auto start GregorbyteHeadless Server");
// }
//
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.
// * BundleContext)
// */
// public void stop(BundleContext context) throws Exception {
//
// System.out.println("Stopping Headless Bundle");
//
// stopServer();
//
// plugin = null;
// super.stop(context);
// }
//
// /**
// * Returns the shared instance
// *
// * @return the shared instance
// */
// public static HeadlessServerActivator getDefault() {
// return plugin;
// }
//
// }
| import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
import com.gregorbyte.designer.headless.HeadlessServerActivator; | package com.gregorbyte.designer.headless.preferences;
/**
* Class used to initialize default preference values.
*/
public class PreferenceInitializer extends AbstractPreferenceInitializer {
/*
* (non-Javadoc)
*
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
*/
public void initializeDefaultPreferences() { | // Path: com.gregorbyte.designer.headless/src/com/gregorbyte/designer/headless/HeadlessServerActivator.java
// public class HeadlessServerActivator extends AbstractUIPlugin {
//
// // The plug-in ID
// public static final String PLUGIN_ID = "com.gregorbyte.designer.headless"; //$NON-NLS-1$
//
// public static HeadlessServerActivator INSTANCE = null;
//
// private Thread serverThread;
// private HeadlessServerRunnable headlessServer;
//
// // The shared instance
// private static HeadlessServerActivator plugin;
//
// /**
// * The constructor
// */
// public HeadlessServerActivator() {
// }
//
// public void startServer() {
// if (!isServerRunning()) {
// headlessServer = new HeadlessServerRunnable();
// serverThread = new Thread(headlessServer);
// serverThread.setName("Headless Nsf Server");
// serverThread.start();
// }
// }
//
// public void stopServer() {
// if (isServerRunning())
// headlessServer.stopThread();
// }
//
// public boolean isServerRunning() {
//
// if (serverThread == null)
// return false;
// return serverThread.isAlive();
//
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.
// * BundleContext)
// */
// public void start(BundleContext context) throws Exception {
//
// INSTANCE = this;
//
// super.start(context);
//
// plugin = this;
//
// try {
// Boolean autoStart = getDefault().getPreferenceStore().getBoolean(PreferenceConstants.P_START);
//
// if (autoStart) {
// System.out.println("Attempting to Auto Start Gregorbyte Headless Server");
// startServer();
// }
//
// } catch (Exception e) {
// System.err.println("Error attempting to auto start GregorbyteHeadless Server");
// }
//
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.
// * BundleContext)
// */
// public void stop(BundleContext context) throws Exception {
//
// System.out.println("Stopping Headless Bundle");
//
// stopServer();
//
// plugin = null;
// super.stop(context);
// }
//
// /**
// * Returns the shared instance
// *
// * @return the shared instance
// */
// public static HeadlessServerActivator getDefault() {
// return plugin;
// }
//
// }
// Path: com.gregorbyte.designer.headless/src/com/gregorbyte/designer/headless/preferences/PreferenceInitializer.java
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
import com.gregorbyte.designer.headless.HeadlessServerActivator;
package com.gregorbyte.designer.headless.preferences;
/**
* Class used to initialize default preference values.
*/
public class PreferenceInitializer extends AbstractPreferenceInitializer {
/*
* (non-Javadoc)
*
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
*/
public void initializeDefaultPreferences() { | IPreferenceStore store = HeadlessServerActivator.getDefault().getPreferenceStore(); |
camac/BuildXPages | com.gregorbyte.designer.headless/src/com/gregorbyte/designer/headless/preferences/HeadlessServerPreferencePage.java | // Path: com.gregorbyte.designer.headless/src/com/gregorbyte/designer/headless/HeadlessServerActivator.java
// public class HeadlessServerActivator extends AbstractUIPlugin {
//
// // The plug-in ID
// public static final String PLUGIN_ID = "com.gregorbyte.designer.headless"; //$NON-NLS-1$
//
// public static HeadlessServerActivator INSTANCE = null;
//
// private Thread serverThread;
// private HeadlessServerRunnable headlessServer;
//
// // The shared instance
// private static HeadlessServerActivator plugin;
//
// /**
// * The constructor
// */
// public HeadlessServerActivator() {
// }
//
// public void startServer() {
// if (!isServerRunning()) {
// headlessServer = new HeadlessServerRunnable();
// serverThread = new Thread(headlessServer);
// serverThread.setName("Headless Nsf Server");
// serverThread.start();
// }
// }
//
// public void stopServer() {
// if (isServerRunning())
// headlessServer.stopThread();
// }
//
// public boolean isServerRunning() {
//
// if (serverThread == null)
// return false;
// return serverThread.isAlive();
//
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.
// * BundleContext)
// */
// public void start(BundleContext context) throws Exception {
//
// INSTANCE = this;
//
// super.start(context);
//
// plugin = this;
//
// try {
// Boolean autoStart = getDefault().getPreferenceStore().getBoolean(PreferenceConstants.P_START);
//
// if (autoStart) {
// System.out.println("Attempting to Auto Start Gregorbyte Headless Server");
// startServer();
// }
//
// } catch (Exception e) {
// System.err.println("Error attempting to auto start GregorbyteHeadless Server");
// }
//
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.
// * BundleContext)
// */
// public void stop(BundleContext context) throws Exception {
//
// System.out.println("Stopping Headless Bundle");
//
// stopServer();
//
// plugin = null;
// super.stop(context);
// }
//
// /**
// * Returns the shared instance
// *
// * @return the shared instance
// */
// public static HeadlessServerActivator getDefault() {
// return plugin;
// }
//
// }
| import org.eclipse.jface.preference.*;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.IWorkbench;
import com.gregorbyte.designer.headless.HeadlessServerActivator; | package com.gregorbyte.designer.headless.preferences;
/**
* This class represents a preference page that is contributed to the
* Preferences dialog. By subclassing <samp>FieldEditorPreferencePage</samp>, we
* can use the field support built into JFace that allows us to create a page
* that is small and knows how to save, restore and apply itself.
* <p>
* This page is used to modify preferences only. They are stored in the
* preference store that belongs to the main plug-in class. That way,
* preferences can be accessed directly via the preference store.
*/
public class HeadlessServerPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
public HeadlessServerPreferencePage() {
super(GRID); | // Path: com.gregorbyte.designer.headless/src/com/gregorbyte/designer/headless/HeadlessServerActivator.java
// public class HeadlessServerActivator extends AbstractUIPlugin {
//
// // The plug-in ID
// public static final String PLUGIN_ID = "com.gregorbyte.designer.headless"; //$NON-NLS-1$
//
// public static HeadlessServerActivator INSTANCE = null;
//
// private Thread serverThread;
// private HeadlessServerRunnable headlessServer;
//
// // The shared instance
// private static HeadlessServerActivator plugin;
//
// /**
// * The constructor
// */
// public HeadlessServerActivator() {
// }
//
// public void startServer() {
// if (!isServerRunning()) {
// headlessServer = new HeadlessServerRunnable();
// serverThread = new Thread(headlessServer);
// serverThread.setName("Headless Nsf Server");
// serverThread.start();
// }
// }
//
// public void stopServer() {
// if (isServerRunning())
// headlessServer.stopThread();
// }
//
// public boolean isServerRunning() {
//
// if (serverThread == null)
// return false;
// return serverThread.isAlive();
//
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.
// * BundleContext)
// */
// public void start(BundleContext context) throws Exception {
//
// INSTANCE = this;
//
// super.start(context);
//
// plugin = this;
//
// try {
// Boolean autoStart = getDefault().getPreferenceStore().getBoolean(PreferenceConstants.P_START);
//
// if (autoStart) {
// System.out.println("Attempting to Auto Start Gregorbyte Headless Server");
// startServer();
// }
//
// } catch (Exception e) {
// System.err.println("Error attempting to auto start GregorbyteHeadless Server");
// }
//
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.
// * BundleContext)
// */
// public void stop(BundleContext context) throws Exception {
//
// System.out.println("Stopping Headless Bundle");
//
// stopServer();
//
// plugin = null;
// super.stop(context);
// }
//
// /**
// * Returns the shared instance
// *
// * @return the shared instance
// */
// public static HeadlessServerActivator getDefault() {
// return plugin;
// }
//
// }
// Path: com.gregorbyte.designer.headless/src/com/gregorbyte/designer/headless/preferences/HeadlessServerPreferencePage.java
import org.eclipse.jface.preference.*;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.IWorkbench;
import com.gregorbyte.designer.headless.HeadlessServerActivator;
package com.gregorbyte.designer.headless.preferences;
/**
* This class represents a preference page that is contributed to the
* Preferences dialog. By subclassing <samp>FieldEditorPreferencePage</samp>, we
* can use the field support built into JFace that allows us to create a page
* that is small and knows how to save, restore and apply itself.
* <p>
* This page is used to modify preferences only. They are stored in the
* preference store that belongs to the main plug-in class. That way,
* preferences can be accessed directly via the preference store.
*/
public class HeadlessServerPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
public HeadlessServerPreferencePage() {
super(GRID); | setPreferenceStore(HeadlessServerActivator.getDefault().getPreferenceStore()); |
camac/BuildXPages | com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/ant/CopyNsfTask.java | // Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/task/CreateAndCopyDatabase.java
// public class CreateAndCopyDatabase extends AbstractBxTask {
//
// private String srcServer;
// private String srcFilename;
//
// private String dstServer;
// private String dstFilename;
//
// public CreateAndCopyDatabase() {
//
// }
//
// public CreateAndCopyDatabase(String srcServer, String srcFilename,
// String dstServer, String dstFilename) {
//
// this.srcServer = srcServer;
// this.srcFilename = srcFilename;
//
// this.dstServer = dstServer;
// this.dstFilename = dstFilename;
//
// }
//
// public String getSrcServer() {
// return srcServer;
// }
//
// public void setSrcServer(String srcServer) {
// this.srcServer = srcServer;
// }
//
// public String getSrcFilename() {
// return srcFilename;
// }
//
// public void setSrcFilename(String srcFilename) {
// this.srcFilename = srcFilename;
// }
//
// public String getDstServer() {
// return dstServer;
// }
//
// public void setDstServer(String dstServer) {
// this.dstServer = dstServer;
// }
//
// public String getDstFilename() {
// return dstFilename;
// }
//
// public void setDstFilename(String dstFilename) {
// this.dstFilename = dstFilename;
// }
//
// @Override
// protected void doTask() {
//
// NotesNativeLibrary notes = NotesNativeLibrary.SYNC_INSTANCE;
//
// String srcPath = pathNetConstruct(srcServer, srcFilename);
// String dstPath = pathNetConstruct(dstServer, dstFilename);
//
// System.out.println(srcPath);
// System.out.println(dstPath);
//
// IntByReference retHandle = new IntByReference();
// short zero = 0;
//
// short error = notes.NSFDbCreateAndCopy(srcPath, dstPath,
// (short) NOTE_CLASS_ALLNONDATA, zero, 0, retHandle);
// checkError(error);
//
// error = notes.NSFDbClose(retHandle.getValue());
// checkError(error);
//
// }
// }
| import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import com.gregorbyte.buildxpages.task.CreateAndCopyDatabase; | this.srcserver = srcserver;
}
public String getSrcfilepath() {
return srcfilepath;
}
public void setSrcfilepath(String srcfilepath) {
this.srcfilepath = srcfilepath;
}
public String getDstserver() {
return dstserver;
}
public void setDstserver(String dstserver) {
this.dstserver = dstserver;
}
public String getDstfilepath() {
return dstfilepath;
}
public void setDstfilepath(String dstfilepath) {
this.dstfilepath = dstfilepath;
}
@Override
public void execute() throws BuildException {
| // Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/task/CreateAndCopyDatabase.java
// public class CreateAndCopyDatabase extends AbstractBxTask {
//
// private String srcServer;
// private String srcFilename;
//
// private String dstServer;
// private String dstFilename;
//
// public CreateAndCopyDatabase() {
//
// }
//
// public CreateAndCopyDatabase(String srcServer, String srcFilename,
// String dstServer, String dstFilename) {
//
// this.srcServer = srcServer;
// this.srcFilename = srcFilename;
//
// this.dstServer = dstServer;
// this.dstFilename = dstFilename;
//
// }
//
// public String getSrcServer() {
// return srcServer;
// }
//
// public void setSrcServer(String srcServer) {
// this.srcServer = srcServer;
// }
//
// public String getSrcFilename() {
// return srcFilename;
// }
//
// public void setSrcFilename(String srcFilename) {
// this.srcFilename = srcFilename;
// }
//
// public String getDstServer() {
// return dstServer;
// }
//
// public void setDstServer(String dstServer) {
// this.dstServer = dstServer;
// }
//
// public String getDstFilename() {
// return dstFilename;
// }
//
// public void setDstFilename(String dstFilename) {
// this.dstFilename = dstFilename;
// }
//
// @Override
// protected void doTask() {
//
// NotesNativeLibrary notes = NotesNativeLibrary.SYNC_INSTANCE;
//
// String srcPath = pathNetConstruct(srcServer, srcFilename);
// String dstPath = pathNetConstruct(dstServer, dstFilename);
//
// System.out.println(srcPath);
// System.out.println(dstPath);
//
// IntByReference retHandle = new IntByReference();
// short zero = 0;
//
// short error = notes.NSFDbCreateAndCopy(srcPath, dstPath,
// (short) NOTE_CLASS_ALLNONDATA, zero, 0, retHandle);
// checkError(error);
//
// error = notes.NSFDbClose(retHandle.getValue());
// checkError(error);
//
// }
// }
// Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/ant/CopyNsfTask.java
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import com.gregorbyte.buildxpages.task.CreateAndCopyDatabase;
this.srcserver = srcserver;
}
public String getSrcfilepath() {
return srcfilepath;
}
public void setSrcfilepath(String srcfilepath) {
this.srcfilepath = srcfilepath;
}
public String getDstserver() {
return dstserver;
}
public void setDstserver(String dstserver) {
this.dstserver = dstserver;
}
public String getDstfilepath() {
return dstfilepath;
}
public void setDstfilepath(String dstfilepath) {
this.dstfilepath = dstfilepath;
}
@Override
public void execute() throws BuildException {
| CreateAndCopyDatabase task = new CreateAndCopyDatabase(); |
camac/BuildXPages | com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/NotesLibrary.java | // Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/task/DeleteDatabase.java
// public class DeleteDatabase extends AbstractBxTask {
//
// private String server;
// private String filename;
//
// public DeleteDatabase(String server, String filename) {
//
// this.server = server;
// this.filename = filename;
//
// }
//
// @Override
// protected void doTask() {
//
// NotesNativeLibrary notes = NotesNativeLibrary.SYNC_INSTANCE;
//
// String path = pathNetConstruct(server, filename);
//
// short error = notes.NSFDbDelete(path);
// checkError(error);
//
// }
//
// }
| import com.gregorbyte.buildxpages.task.DeleteDatabase;
import com.sun.jna.Native;
import com.sun.jna.ptr.IntByReference; | @Deprecated
public static void deinit() {
if (initialised) {
NotesNativeLibrary notes = NotesNativeLibrary.SYNC_INSTANCE;
notes.NotesTerm();
initialised = false;
}
}
@SuppressWarnings("unused")
public static void main(String[] args) {
NotesNativeLibrary notes = NotesNativeLibrary.SYNC_INSTANCE;
short error = 0;
boolean notesInitialised = false;
Native.setProtected(true);
try {
error = notes.NotesInitExtended(0, null);
checkError(error);
notesInitialised = true;
String srcFilename = "demo\\GitTest.nsf";
String dstFilename = "demo\\DidItwork.nsf";
//CreateAndCopyDatabase task = new CreateAndCopyDatabase(null, srcFilename, null, dstFilename); | // Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/task/DeleteDatabase.java
// public class DeleteDatabase extends AbstractBxTask {
//
// private String server;
// private String filename;
//
// public DeleteDatabase(String server, String filename) {
//
// this.server = server;
// this.filename = filename;
//
// }
//
// @Override
// protected void doTask() {
//
// NotesNativeLibrary notes = NotesNativeLibrary.SYNC_INSTANCE;
//
// String path = pathNetConstruct(server, filename);
//
// short error = notes.NSFDbDelete(path);
// checkError(error);
//
// }
//
// }
// Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/NotesLibrary.java
import com.gregorbyte.buildxpages.task.DeleteDatabase;
import com.sun.jna.Native;
import com.sun.jna.ptr.IntByReference;
@Deprecated
public static void deinit() {
if (initialised) {
NotesNativeLibrary notes = NotesNativeLibrary.SYNC_INSTANCE;
notes.NotesTerm();
initialised = false;
}
}
@SuppressWarnings("unused")
public static void main(String[] args) {
NotesNativeLibrary notes = NotesNativeLibrary.SYNC_INSTANCE;
short error = 0;
boolean notesInitialised = false;
Native.setProtected(true);
try {
error = notes.NotesInitExtended(0, null);
checkError(error);
notesInitialised = true;
String srcFilename = "demo\\GitTest.nsf";
String dstFilename = "demo\\DidItwork.nsf";
//CreateAndCopyDatabase task = new CreateAndCopyDatabase(null, srcFilename, null, dstFilename); | DeleteDatabase task = new DeleteDatabase(null, dstFilename); |
camac/BuildXPages | com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/ant/DeleteNsfTask.java | // Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/task/DeleteDatabase.java
// public class DeleteDatabase extends AbstractBxTask {
//
// private String server;
// private String filename;
//
// public DeleteDatabase(String server, String filename) {
//
// this.server = server;
// this.filename = filename;
//
// }
//
// @Override
// protected void doTask() {
//
// NotesNativeLibrary notes = NotesNativeLibrary.SYNC_INSTANCE;
//
// String path = pathNetConstruct(server, filename);
//
// short error = notes.NSFDbDelete(path);
// checkError(error);
//
// }
//
// }
| import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import com.gregorbyte.buildxpages.task.DeleteDatabase; | package com.gregorbyte.buildxpages.ant;
public class DeleteNsfTask extends Task {
private String server;
private String filename;
public String getServer() {
return server;
}
public void setServer(String server) {
this.server = server;
}
public String getFilename() {
return filename;
}
public void setFilename(String filename) {
this.filename = filename;
}
@Override
public void execute() throws BuildException {
| // Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/task/DeleteDatabase.java
// public class DeleteDatabase extends AbstractBxTask {
//
// private String server;
// private String filename;
//
// public DeleteDatabase(String server, String filename) {
//
// this.server = server;
// this.filename = filename;
//
// }
//
// @Override
// protected void doTask() {
//
// NotesNativeLibrary notes = NotesNativeLibrary.SYNC_INSTANCE;
//
// String path = pathNetConstruct(server, filename);
//
// short error = notes.NSFDbDelete(path);
// checkError(error);
//
// }
//
// }
// Path: com.gregorbyte.buildxpages.ant/src/com/gregorbyte/buildxpages/ant/DeleteNsfTask.java
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import com.gregorbyte.buildxpages.task.DeleteDatabase;
package com.gregorbyte.buildxpages.ant;
public class DeleteNsfTask extends Task {
private String server;
private String filename;
public String getServer() {
return server;
}
public void setServer(String server) {
this.server = server;
}
public String getFilename() {
return filename;
}
public void setFilename(String filename) {
this.filename = filename;
}
@Override
public void execute() throws BuildException {
| DeleteDatabase task = new DeleteDatabase(server, filename); |
HubSpot/jackson-datatype-protobuf | src/test/java/com/hubspot/jackson/datatype/protobuf/ReadUnknownEnumValuesAsNullTest.java | // Path: src/test/java/com/hubspot/jackson/datatype/protobuf/util/ObjectMapperHelper.java
// public static ObjectMapper camelCase() {
// return DEFAULT;
// }
| import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.hubspot.jackson.datatype.protobuf.util.TestProtobuf.AllFields;
import org.junit.Test;
import static com.hubspot.jackson.datatype.protobuf.util.ObjectMapperHelper.camelCase;
import static org.assertj.core.api.Assertions.assertThat; | package com.hubspot.jackson.datatype.protobuf;
public class ReadUnknownEnumValuesAsNullTest {
@Test
public void testStringEnabled() throws JsonProcessingException {
ObjectMapper mapper = objectMapper(true);
AllFields parsed = mapper.treeToValue(buildNode("fakeValue"), AllFields.class);
assertThat(parsed.hasEnum()).isFalse();
}
@Test(expected = JsonMappingException.class)
public void testStringDisabled() throws JsonProcessingException {
ObjectMapper mapper = objectMapper(false);
mapper.treeToValue(buildNode("fakeValue"), AllFields.class);
}
@Test
public void testIntEnabled() throws JsonProcessingException {
ObjectMapper mapper = objectMapper(true);
AllFields parsed = mapper.treeToValue(buildNode(999999), AllFields.class);
assertThat(parsed.hasEnum()).isFalse();
}
@Test(expected = JsonMappingException.class)
public void testIntDisabled() throws JsonProcessingException {
ObjectMapper mapper = objectMapper(false);
mapper.treeToValue(buildNode(999999), AllFields.class);
}
private static JsonNode buildNode(String value) { | // Path: src/test/java/com/hubspot/jackson/datatype/protobuf/util/ObjectMapperHelper.java
// public static ObjectMapper camelCase() {
// return DEFAULT;
// }
// Path: src/test/java/com/hubspot/jackson/datatype/protobuf/ReadUnknownEnumValuesAsNullTest.java
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.hubspot.jackson.datatype.protobuf.util.TestProtobuf.AllFields;
import org.junit.Test;
import static com.hubspot.jackson.datatype.protobuf.util.ObjectMapperHelper.camelCase;
import static org.assertj.core.api.Assertions.assertThat;
package com.hubspot.jackson.datatype.protobuf;
public class ReadUnknownEnumValuesAsNullTest {
@Test
public void testStringEnabled() throws JsonProcessingException {
ObjectMapper mapper = objectMapper(true);
AllFields parsed = mapper.treeToValue(buildNode("fakeValue"), AllFields.class);
assertThat(parsed.hasEnum()).isFalse();
}
@Test(expected = JsonMappingException.class)
public void testStringDisabled() throws JsonProcessingException {
ObjectMapper mapper = objectMapper(false);
mapper.treeToValue(buildNode("fakeValue"), AllFields.class);
}
@Test
public void testIntEnabled() throws JsonProcessingException {
ObjectMapper mapper = objectMapper(true);
AllFields parsed = mapper.treeToValue(buildNode(999999), AllFields.class);
assertThat(parsed.hasEnum()).isFalse();
}
@Test(expected = JsonMappingException.class)
public void testIntDisabled() throws JsonProcessingException {
ObjectMapper mapper = objectMapper(false);
mapper.treeToValue(buildNode(999999), AllFields.class);
}
private static JsonNode buildNode(String value) { | return camelCase().createObjectNode().put("enum", value); |
HubSpot/jackson-datatype-protobuf | src/test/java/com/hubspot/jackson/datatype/protobuf/AcceptSingleValueAsArrayTest.java | // Path: src/test/java/com/hubspot/jackson/datatype/protobuf/util/ObjectMapperHelper.java
// public static ObjectMapper camelCase() {
// return DEFAULT;
// }
| import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.hubspot.jackson.datatype.protobuf.util.TestProtobuf.RepeatedFields;
import org.junit.Test;
import static com.hubspot.jackson.datatype.protobuf.util.ObjectMapperHelper.camelCase;
import static org.assertj.core.api.Assertions.assertThat; | package com.hubspot.jackson.datatype.protobuf;
public class AcceptSingleValueAsArrayTest {
@Test
public void testEnabled() throws JsonProcessingException {
ObjectMapper mapper = objectMapper(true);
RepeatedFields parsed = mapper.treeToValue(buildNode(), RepeatedFields.class);
assertThat(parsed.getBoolCount()).isEqualTo(1);
assertThat(parsed.getBoolList()).containsExactly(true);
}
@Test(expected = JsonMappingException.class)
public void testDisabled() throws JsonProcessingException {
ObjectMapper mapper = objectMapper(false);
mapper.treeToValue(buildNode(), RepeatedFields.class);
}
private static JsonNode buildNode() { | // Path: src/test/java/com/hubspot/jackson/datatype/protobuf/util/ObjectMapperHelper.java
// public static ObjectMapper camelCase() {
// return DEFAULT;
// }
// Path: src/test/java/com/hubspot/jackson/datatype/protobuf/AcceptSingleValueAsArrayTest.java
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.hubspot.jackson.datatype.protobuf.util.TestProtobuf.RepeatedFields;
import org.junit.Test;
import static com.hubspot.jackson.datatype.protobuf.util.ObjectMapperHelper.camelCase;
import static org.assertj.core.api.Assertions.assertThat;
package com.hubspot.jackson.datatype.protobuf;
public class AcceptSingleValueAsArrayTest {
@Test
public void testEnabled() throws JsonProcessingException {
ObjectMapper mapper = objectMapper(true);
RepeatedFields parsed = mapper.treeToValue(buildNode(), RepeatedFields.class);
assertThat(parsed.getBoolCount()).isEqualTo(1);
assertThat(parsed.getBoolList()).containsExactly(true);
}
@Test(expected = JsonMappingException.class)
public void testDisabled() throws JsonProcessingException {
ObjectMapper mapper = objectMapper(false);
mapper.treeToValue(buildNode(), RepeatedFields.class);
}
private static JsonNode buildNode() { | return camelCase().createObjectNode().put("bool", true); |
HubSpot/jackson-datatype-protobuf | src/test/java/com/hubspot/jackson/datatype/protobuf/builtin/RepeatedListValueTest.java | // Path: src/test/java/com/hubspot/jackson/datatype/protobuf/util/ObjectMapperHelper.java
// public static ObjectMapper camelCase() {
// return DEFAULT;
// }
| import static com.hubspot.jackson.datatype.protobuf.util.ObjectMapperHelper.camelCase;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
import org.junit.Test;
import com.google.protobuf.ListValue;
import com.google.protobuf.Value;
import com.hubspot.jackson.datatype.protobuf.util.BuiltInProtobufs.RepeatedListValue; | package com.hubspot.jackson.datatype.protobuf.builtin;
public class RepeatedListValueTest {
private static final Value NESTED = Value.newBuilder().setStringValue("nested").build();
private static final ListValue LIST = ListValue
.newBuilder()
.addValues(NESTED)
.build();
@Test
public void itReadsNestedListValues() throws IOException {
String json = "{\"listValues\":[[\"nested\"]]}"; | // Path: src/test/java/com/hubspot/jackson/datatype/protobuf/util/ObjectMapperHelper.java
// public static ObjectMapper camelCase() {
// return DEFAULT;
// }
// Path: src/test/java/com/hubspot/jackson/datatype/protobuf/builtin/RepeatedListValueTest.java
import static com.hubspot.jackson.datatype.protobuf.util.ObjectMapperHelper.camelCase;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
import org.junit.Test;
import com.google.protobuf.ListValue;
import com.google.protobuf.Value;
import com.hubspot.jackson.datatype.protobuf.util.BuiltInProtobufs.RepeatedListValue;
package com.hubspot.jackson.datatype.protobuf.builtin;
public class RepeatedListValueTest {
private static final Value NESTED = Value.newBuilder().setStringValue("nested").build();
private static final ListValue LIST = ListValue
.newBuilder()
.addValues(NESTED)
.build();
@Test
public void itReadsNestedListValues() throws IOException {
String json = "{\"listValues\":[[\"nested\"]]}"; | RepeatedListValue message = camelCase().readValue(json, RepeatedListValue.class); |
HubSpot/jackson-datatype-protobuf | src/test/java/com/hubspot/jackson/datatype/protobuf/builtin/RepeatedValueTest.java | // Path: src/test/java/com/hubspot/jackson/datatype/protobuf/util/ObjectMapperHelper.java
// public static ObjectMapper camelCase() {
// return DEFAULT;
// }
| import static com.hubspot.jackson.datatype.protobuf.util.ObjectMapperHelper.camelCase;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
import org.junit.Test;
import com.google.protobuf.ListValue;
import com.google.protobuf.NullValue;
import com.google.protobuf.Struct;
import com.google.protobuf.Value;
import com.hubspot.jackson.datatype.protobuf.util.BuiltInProtobufs.RepeatedValue; | package com.hubspot.jackson.datatype.protobuf.builtin;
public class RepeatedValueTest {
private static final Value NESTED = Value.newBuilder().setStringValue("nested").build();
private static final Value LIST = Value
.newBuilder()
.setListValue(ListValue.newBuilder().addValues(NESTED).build())
.build();
private static final Struct STRUCT = Struct
.newBuilder()
.putFields("key", Value.newBuilder().setStringValue("value").build())
.build();
@Test
public void itReadsListValues() throws IOException {
String json = "{\"values\":[\"nested\"]}"; | // Path: src/test/java/com/hubspot/jackson/datatype/protobuf/util/ObjectMapperHelper.java
// public static ObjectMapper camelCase() {
// return DEFAULT;
// }
// Path: src/test/java/com/hubspot/jackson/datatype/protobuf/builtin/RepeatedValueTest.java
import static com.hubspot.jackson.datatype.protobuf.util.ObjectMapperHelper.camelCase;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
import org.junit.Test;
import com.google.protobuf.ListValue;
import com.google.protobuf.NullValue;
import com.google.protobuf.Struct;
import com.google.protobuf.Value;
import com.hubspot.jackson.datatype.protobuf.util.BuiltInProtobufs.RepeatedValue;
package com.hubspot.jackson.datatype.protobuf.builtin;
public class RepeatedValueTest {
private static final Value NESTED = Value.newBuilder().setStringValue("nested").build();
private static final Value LIST = Value
.newBuilder()
.setListValue(ListValue.newBuilder().addValues(NESTED).build())
.build();
private static final Struct STRUCT = Struct
.newBuilder()
.putFields("key", Value.newBuilder().setStringValue("value").build())
.build();
@Test
public void itReadsListValues() throws IOException {
String json = "{\"values\":[\"nested\"]}"; | RepeatedValue message = camelCase().readValue(json, RepeatedValue.class); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.