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
wutongke/AndroidSkinAnimator
skin-support/src/main/java/skin/support/animator/SingleAnimator/hide/TranslationHideAnimator2.java
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorImpl.java // public abstract class ViewAnimatorImpl implements SkinAnimator { // @Override // public abstract SkinAnimator apply(@NonNull View view, @Nullable Action action); // // @Override // public SkinAnimator setPreDuration() { // return this; // } // // @Override // public SkinAnimator setAfterDuration() { // return this; // } // // @Override // public SkinAnimator setDuration() { // return this; // } // // @Override // public abstract void start(); // // protected void resetView(View view) { // view.setAlpha(1); // view.setScaleY(1); // view.setScaleX(1); // view.setRotation(0); // view.setTranslationX(0); // view.setTranslationY(0); // view.setPivotX(view.getWidth() / 2); // view.setPivotY(view.getHeight() / 2); // } // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // }
import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import android.view.animation.AccelerateInterpolator; import skin.support.animator.Action; import skin.support.animator.SingleAnimator.ViewAnimatorImpl; import skin.support.animator.SkinAnimator;
package skin.support.animator.SingleAnimator.hide; /** * Created by erfli on 2/25/17. */ public class TranslationHideAnimator2 extends ViewAnimatorImpl { private ObjectAnimator animator; private TranslationHideAnimator2() { } public static TranslationHideAnimator2 getInstance() { return new TranslationHideAnimator2(); } @Override
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorImpl.java // public abstract class ViewAnimatorImpl implements SkinAnimator { // @Override // public abstract SkinAnimator apply(@NonNull View view, @Nullable Action action); // // @Override // public SkinAnimator setPreDuration() { // return this; // } // // @Override // public SkinAnimator setAfterDuration() { // return this; // } // // @Override // public SkinAnimator setDuration() { // return this; // } // // @Override // public abstract void start(); // // protected void resetView(View view) { // view.setAlpha(1); // view.setScaleY(1); // view.setScaleX(1); // view.setRotation(0); // view.setTranslationX(0); // view.setTranslationY(0); // view.setPivotX(view.getWidth() / 2); // view.setPivotY(view.getHeight() / 2); // } // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // } // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/hide/TranslationHideAnimator2.java import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import android.view.animation.AccelerateInterpolator; import skin.support.animator.Action; import skin.support.animator.SingleAnimator.ViewAnimatorImpl; import skin.support.animator.SkinAnimator; package skin.support.animator.SingleAnimator.hide; /** * Created by erfli on 2/25/17. */ public class TranslationHideAnimator2 extends ViewAnimatorImpl { private ObjectAnimator animator; private TranslationHideAnimator2() { } public static TranslationHideAnimator2 getInstance() { return new TranslationHideAnimator2(); } @Override
public SkinAnimator apply(@NonNull final View view, @Nullable final Action action) {
wutongke/AndroidSkinAnimator
skin-support/src/main/java/skin/support/animator/activityAnimator/ScaleAnimator2.java
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // }
import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import android.view.animation.LinearInterpolator; import skin.support.animator.Action; import skin.support.animator.SkinAnimator;
package skin.support.animator.activityAnimator; /** * Created by erfli on 2/25/17. */ public class ScaleAnimator2 implements SkinAnimator { protected ObjectAnimator preAnimator; protected ObjectAnimator afterAnimator; protected View targetView; private ScaleAnimator2() { } public static ScaleAnimator2 getInstance() { ScaleAnimator2 skinAlphaAnimator = new ScaleAnimator2(); return skinAlphaAnimator; } @Override
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // } // Path: skin-support/src/main/java/skin/support/animator/activityAnimator/ScaleAnimator2.java import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import android.view.animation.LinearInterpolator; import skin.support.animator.Action; import skin.support.animator.SkinAnimator; package skin.support.animator.activityAnimator; /** * Created by erfli on 2/25/17. */ public class ScaleAnimator2 implements SkinAnimator { protected ObjectAnimator preAnimator; protected ObjectAnimator afterAnimator; protected View targetView; private ScaleAnimator2() { } public static ScaleAnimator2 getInstance() { ScaleAnimator2 skinAlphaAnimator = new ScaleAnimator2(); return skinAlphaAnimator; } @Override
public SkinAnimator apply(@NonNull View view, @Nullable final Action action) {
wutongke/AndroidSkinAnimator
skin-support/src/main/java/skin/support/widget/SkinCompatTextHelper.java
// Path: skin-support/src/main/java/skin/support/content/res/SkinCompatResources.java // public class SkinCompatResources { // private static volatile SkinCompatResources sInstance; // private final Context mAppContext; // private Resources mResources; // private String mSkinPkgName; // private boolean isDefaultSkin; // // private SkinCompatResources(Context context) { // mAppContext = context.getApplicationContext(); // setSkinResource(mAppContext.getResources(), mAppContext.getPackageName()); // } // // public static void init(Context context) { // if (sInstance == null) { // synchronized (SkinCompatResources.class) { // if (sInstance == null) { // sInstance = new SkinCompatResources(context); // } // } // } // } // // public static SkinCompatResources getInstance() { // return sInstance; // } // // public void setSkinResource(Resources resources, String pkgName) { // mResources = resources; // mSkinPkgName = pkgName; // isDefaultSkin = mAppContext.getPackageName().equals(pkgName); // } // // public int getColor(int resId) { // int originColor = ContextCompat.getColor(mAppContext, resId); // if (isDefaultSkin) { // return originColor; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? originColor : mResources.getColor(targetResId); // } // // public Drawable getDrawable(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "drawable", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public Drawable getMipmap(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "mipmap", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public ColorStateList getColorStateList(int resId) { // ColorStateList colorStateList = ContextCompat.getColorStateList(mAppContext, resId); // if (isDefaultSkin) { // return colorStateList; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? colorStateList : mResources.getColorStateList(targetResId); // } // } // // Path: skin-support/src/main/java/skin/support/utils/SkinLog.java // public class SkinLog { // private static boolean DEBUG = BuildConfig.DEBUG; // private static final String TAG = "Skin-support"; // // public static void v(String msg) { // v(TAG, msg); // } // // public static void d(String msg) { // d(TAG, msg); // } // // public static void i(String msg) { // i(TAG, msg); // } // // public static void w(String msg) { // w(TAG, msg); // } // // public static void e(String msg) { // e(TAG, msg); // } // // public static void v(String tag, String msg) { // if (DEBUG) { // Log.v(tag, msg); // } // } // // public static void d(String tag, String msg) { // if (DEBUG) { // Log.d(tag, msg); // } // } // // public static void i(String tag, String msg) { // if (DEBUG) { // Log.i(tag, msg); // } // } // // public static void w(String tag, String msg) { // if (DEBUG) { // Log.w(tag, msg); // } // } // // public static void e(String tag, String msg) { // if (DEBUG) { // Log.e(tag, msg); // } // } // }
import android.content.Context; import android.content.res.ColorStateList; import android.support.v7.widget.TintTypedArray; import android.util.AttributeSet; import android.widget.TextView; import skin.support.R; import skin.support.content.res.SkinCompatResources; import skin.support.utils.SkinLog;
package skin.support.widget; /** * Created by ximsfei on 2017/1/10. */ public class SkinCompatTextHelper extends SkinCompatHelper { private static final String TAG = SkinCompatTextHelper.class.getSimpleName(); private final TextView mView; private int mTextColorResId = INVALID_ID; private int mTextColorHintResId = INVALID_ID; public SkinCompatTextHelper(TextView view) { mView = view; } public void loadFromAttributes(AttributeSet attrs, int defStyleAttr) { final Context context = mView.getContext(); // First read the TextAppearance style id TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs, R.styleable.SkinCompatTextHelper, defStyleAttr, 0); final int ap = a.getResourceId(R.styleable.SkinCompatTextHelper_android_textAppearance, INVALID_ID);
// Path: skin-support/src/main/java/skin/support/content/res/SkinCompatResources.java // public class SkinCompatResources { // private static volatile SkinCompatResources sInstance; // private final Context mAppContext; // private Resources mResources; // private String mSkinPkgName; // private boolean isDefaultSkin; // // private SkinCompatResources(Context context) { // mAppContext = context.getApplicationContext(); // setSkinResource(mAppContext.getResources(), mAppContext.getPackageName()); // } // // public static void init(Context context) { // if (sInstance == null) { // synchronized (SkinCompatResources.class) { // if (sInstance == null) { // sInstance = new SkinCompatResources(context); // } // } // } // } // // public static SkinCompatResources getInstance() { // return sInstance; // } // // public void setSkinResource(Resources resources, String pkgName) { // mResources = resources; // mSkinPkgName = pkgName; // isDefaultSkin = mAppContext.getPackageName().equals(pkgName); // } // // public int getColor(int resId) { // int originColor = ContextCompat.getColor(mAppContext, resId); // if (isDefaultSkin) { // return originColor; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? originColor : mResources.getColor(targetResId); // } // // public Drawable getDrawable(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "drawable", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public Drawable getMipmap(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "mipmap", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public ColorStateList getColorStateList(int resId) { // ColorStateList colorStateList = ContextCompat.getColorStateList(mAppContext, resId); // if (isDefaultSkin) { // return colorStateList; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? colorStateList : mResources.getColorStateList(targetResId); // } // } // // Path: skin-support/src/main/java/skin/support/utils/SkinLog.java // public class SkinLog { // private static boolean DEBUG = BuildConfig.DEBUG; // private static final String TAG = "Skin-support"; // // public static void v(String msg) { // v(TAG, msg); // } // // public static void d(String msg) { // d(TAG, msg); // } // // public static void i(String msg) { // i(TAG, msg); // } // // public static void w(String msg) { // w(TAG, msg); // } // // public static void e(String msg) { // e(TAG, msg); // } // // public static void v(String tag, String msg) { // if (DEBUG) { // Log.v(tag, msg); // } // } // // public static void d(String tag, String msg) { // if (DEBUG) { // Log.d(tag, msg); // } // } // // public static void i(String tag, String msg) { // if (DEBUG) { // Log.i(tag, msg); // } // } // // public static void w(String tag, String msg) { // if (DEBUG) { // Log.w(tag, msg); // } // } // // public static void e(String tag, String msg) { // if (DEBUG) { // Log.e(tag, msg); // } // } // } // Path: skin-support/src/main/java/skin/support/widget/SkinCompatTextHelper.java import android.content.Context; import android.content.res.ColorStateList; import android.support.v7.widget.TintTypedArray; import android.util.AttributeSet; import android.widget.TextView; import skin.support.R; import skin.support.content.res.SkinCompatResources; import skin.support.utils.SkinLog; package skin.support.widget; /** * Created by ximsfei on 2017/1/10. */ public class SkinCompatTextHelper extends SkinCompatHelper { private static final String TAG = SkinCompatTextHelper.class.getSimpleName(); private final TextView mView; private int mTextColorResId = INVALID_ID; private int mTextColorHintResId = INVALID_ID; public SkinCompatTextHelper(TextView view) { mView = view; } public void loadFromAttributes(AttributeSet attrs, int defStyleAttr) { final Context context = mView.getContext(); // First read the TextAppearance style id TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs, R.styleable.SkinCompatTextHelper, defStyleAttr, 0); final int ap = a.getResourceId(R.styleable.SkinCompatTextHelper_android_textAppearance, INVALID_ID);
SkinLog.d(TAG, "ap = " + ap);
wutongke/AndroidSkinAnimator
skin-support/src/main/java/skin/support/widget/SkinCompatTextHelper.java
// Path: skin-support/src/main/java/skin/support/content/res/SkinCompatResources.java // public class SkinCompatResources { // private static volatile SkinCompatResources sInstance; // private final Context mAppContext; // private Resources mResources; // private String mSkinPkgName; // private boolean isDefaultSkin; // // private SkinCompatResources(Context context) { // mAppContext = context.getApplicationContext(); // setSkinResource(mAppContext.getResources(), mAppContext.getPackageName()); // } // // public static void init(Context context) { // if (sInstance == null) { // synchronized (SkinCompatResources.class) { // if (sInstance == null) { // sInstance = new SkinCompatResources(context); // } // } // } // } // // public static SkinCompatResources getInstance() { // return sInstance; // } // // public void setSkinResource(Resources resources, String pkgName) { // mResources = resources; // mSkinPkgName = pkgName; // isDefaultSkin = mAppContext.getPackageName().equals(pkgName); // } // // public int getColor(int resId) { // int originColor = ContextCompat.getColor(mAppContext, resId); // if (isDefaultSkin) { // return originColor; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? originColor : mResources.getColor(targetResId); // } // // public Drawable getDrawable(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "drawable", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public Drawable getMipmap(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "mipmap", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public ColorStateList getColorStateList(int resId) { // ColorStateList colorStateList = ContextCompat.getColorStateList(mAppContext, resId); // if (isDefaultSkin) { // return colorStateList; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? colorStateList : mResources.getColorStateList(targetResId); // } // } // // Path: skin-support/src/main/java/skin/support/utils/SkinLog.java // public class SkinLog { // private static boolean DEBUG = BuildConfig.DEBUG; // private static final String TAG = "Skin-support"; // // public static void v(String msg) { // v(TAG, msg); // } // // public static void d(String msg) { // d(TAG, msg); // } // // public static void i(String msg) { // i(TAG, msg); // } // // public static void w(String msg) { // w(TAG, msg); // } // // public static void e(String msg) { // e(TAG, msg); // } // // public static void v(String tag, String msg) { // if (DEBUG) { // Log.v(tag, msg); // } // } // // public static void d(String tag, String msg) { // if (DEBUG) { // Log.d(tag, msg); // } // } // // public static void i(String tag, String msg) { // if (DEBUG) { // Log.i(tag, msg); // } // } // // public static void w(String tag, String msg) { // if (DEBUG) { // Log.w(tag, msg); // } // } // // public static void e(String tag, String msg) { // if (DEBUG) { // Log.e(tag, msg); // } // } // }
import android.content.Context; import android.content.res.ColorStateList; import android.support.v7.widget.TintTypedArray; import android.util.AttributeSet; import android.widget.TextView; import skin.support.R; import skin.support.content.res.SkinCompatResources; import skin.support.utils.SkinLog;
mTextColorResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID); SkinLog.d(TAG, "mTextColorResId = " + mTextColorResId); } if (a.hasValue(R.styleable.SkinTextAppearance_android_textColorHint)) { mTextColorHintResId = a.getResourceId( R.styleable.SkinTextAppearance_android_textColorHint, INVALID_ID); SkinLog.d(TAG, "mTextColorHintResId = " + mTextColorHintResId); } a.recycle(); applySkin(); } public void onSetTextAppearance(Context context, int resId) { final TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, resId, R.styleable.SkinTextAppearance); if (a.hasValue(R.styleable.SkinTextAppearance_android_textColor)) { mTextColorResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID); SkinLog.d(TAG, "mTextColorResId = " + mTextColorResId); } if (a.hasValue(R.styleable.SkinTextAppearance_android_textColorHint)) { mTextColorHintResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColorHint, INVALID_ID); SkinLog.d(TAG, "mTextColorHintResId = " + mTextColorHintResId); } a.recycle(); applySkin(); } public void applySkin() { mTextColorResId = checkResourceId(mTextColorResId); if (mTextColorResId != INVALID_ID) {
// Path: skin-support/src/main/java/skin/support/content/res/SkinCompatResources.java // public class SkinCompatResources { // private static volatile SkinCompatResources sInstance; // private final Context mAppContext; // private Resources mResources; // private String mSkinPkgName; // private boolean isDefaultSkin; // // private SkinCompatResources(Context context) { // mAppContext = context.getApplicationContext(); // setSkinResource(mAppContext.getResources(), mAppContext.getPackageName()); // } // // public static void init(Context context) { // if (sInstance == null) { // synchronized (SkinCompatResources.class) { // if (sInstance == null) { // sInstance = new SkinCompatResources(context); // } // } // } // } // // public static SkinCompatResources getInstance() { // return sInstance; // } // // public void setSkinResource(Resources resources, String pkgName) { // mResources = resources; // mSkinPkgName = pkgName; // isDefaultSkin = mAppContext.getPackageName().equals(pkgName); // } // // public int getColor(int resId) { // int originColor = ContextCompat.getColor(mAppContext, resId); // if (isDefaultSkin) { // return originColor; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? originColor : mResources.getColor(targetResId); // } // // public Drawable getDrawable(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "drawable", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public Drawable getMipmap(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "mipmap", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public ColorStateList getColorStateList(int resId) { // ColorStateList colorStateList = ContextCompat.getColorStateList(mAppContext, resId); // if (isDefaultSkin) { // return colorStateList; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? colorStateList : mResources.getColorStateList(targetResId); // } // } // // Path: skin-support/src/main/java/skin/support/utils/SkinLog.java // public class SkinLog { // private static boolean DEBUG = BuildConfig.DEBUG; // private static final String TAG = "Skin-support"; // // public static void v(String msg) { // v(TAG, msg); // } // // public static void d(String msg) { // d(TAG, msg); // } // // public static void i(String msg) { // i(TAG, msg); // } // // public static void w(String msg) { // w(TAG, msg); // } // // public static void e(String msg) { // e(TAG, msg); // } // // public static void v(String tag, String msg) { // if (DEBUG) { // Log.v(tag, msg); // } // } // // public static void d(String tag, String msg) { // if (DEBUG) { // Log.d(tag, msg); // } // } // // public static void i(String tag, String msg) { // if (DEBUG) { // Log.i(tag, msg); // } // } // // public static void w(String tag, String msg) { // if (DEBUG) { // Log.w(tag, msg); // } // } // // public static void e(String tag, String msg) { // if (DEBUG) { // Log.e(tag, msg); // } // } // } // Path: skin-support/src/main/java/skin/support/widget/SkinCompatTextHelper.java import android.content.Context; import android.content.res.ColorStateList; import android.support.v7.widget.TintTypedArray; import android.util.AttributeSet; import android.widget.TextView; import skin.support.R; import skin.support.content.res.SkinCompatResources; import skin.support.utils.SkinLog; mTextColorResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID); SkinLog.d(TAG, "mTextColorResId = " + mTextColorResId); } if (a.hasValue(R.styleable.SkinTextAppearance_android_textColorHint)) { mTextColorHintResId = a.getResourceId( R.styleable.SkinTextAppearance_android_textColorHint, INVALID_ID); SkinLog.d(TAG, "mTextColorHintResId = " + mTextColorHintResId); } a.recycle(); applySkin(); } public void onSetTextAppearance(Context context, int resId) { final TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, resId, R.styleable.SkinTextAppearance); if (a.hasValue(R.styleable.SkinTextAppearance_android_textColor)) { mTextColorResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID); SkinLog.d(TAG, "mTextColorResId = " + mTextColorResId); } if (a.hasValue(R.styleable.SkinTextAppearance_android_textColorHint)) { mTextColorHintResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColorHint, INVALID_ID); SkinLog.d(TAG, "mTextColorHintResId = " + mTextColorHintResId); } a.recycle(); applySkin(); } public void applySkin() { mTextColorResId = checkResourceId(mTextColorResId); if (mTextColorResId != INVALID_ID) {
ColorStateList color = SkinCompatResources.getInstance().getColorStateList(mTextColorResId);
wutongke/AndroidSkinAnimator
skin-support/src/main/java/skin/support/animator/SingleAnimator/hide/TranslationAlphaHideAnimator.java
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorImpl.java // public abstract class ViewAnimatorImpl implements SkinAnimator { // @Override // public abstract SkinAnimator apply(@NonNull View view, @Nullable Action action); // // @Override // public SkinAnimator setPreDuration() { // return this; // } // // @Override // public SkinAnimator setAfterDuration() { // return this; // } // // @Override // public SkinAnimator setDuration() { // return this; // } // // @Override // public abstract void start(); // // protected void resetView(View view) { // view.setAlpha(1); // view.setScaleY(1); // view.setScaleX(1); // view.setRotation(0); // view.setTranslationX(0); // view.setTranslationY(0); // view.setPivotX(view.getWidth() / 2); // view.setPivotY(view.getHeight() / 2); // } // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // }
import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import android.view.animation.LinearInterpolator; import skin.support.animator.Action; import skin.support.animator.SingleAnimator.ViewAnimatorImpl; import skin.support.animator.SkinAnimator;
package skin.support.animator.SingleAnimator.hide; /** * Created by erfli on 2/25/17. */ public class TranslationAlphaHideAnimator extends ViewAnimatorImpl { private ObjectAnimator animator; private TranslationAlphaHideAnimator() { } public static TranslationAlphaHideAnimator getInstance() { return new TranslationAlphaHideAnimator(); } @Override
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorImpl.java // public abstract class ViewAnimatorImpl implements SkinAnimator { // @Override // public abstract SkinAnimator apply(@NonNull View view, @Nullable Action action); // // @Override // public SkinAnimator setPreDuration() { // return this; // } // // @Override // public SkinAnimator setAfterDuration() { // return this; // } // // @Override // public SkinAnimator setDuration() { // return this; // } // // @Override // public abstract void start(); // // protected void resetView(View view) { // view.setAlpha(1); // view.setScaleY(1); // view.setScaleX(1); // view.setRotation(0); // view.setTranslationX(0); // view.setTranslationY(0); // view.setPivotX(view.getWidth() / 2); // view.setPivotY(view.getHeight() / 2); // } // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // } // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/hide/TranslationAlphaHideAnimator.java import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import android.view.animation.LinearInterpolator; import skin.support.animator.Action; import skin.support.animator.SingleAnimator.ViewAnimatorImpl; import skin.support.animator.SkinAnimator; package skin.support.animator.SingleAnimator.hide; /** * Created by erfli on 2/25/17. */ public class TranslationAlphaHideAnimator extends ViewAnimatorImpl { private ObjectAnimator animator; private TranslationAlphaHideAnimator() { } public static TranslationAlphaHideAnimator getInstance() { return new TranslationAlphaHideAnimator(); } @Override
public SkinAnimator apply(@NonNull final View view, @Nullable final Action action) {
wutongke/AndroidSkinAnimator
skin-support/src/main/java/skin/support/animator/SingleAnimator/hide/TranslationAlphaHideAnimator.java
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorImpl.java // public abstract class ViewAnimatorImpl implements SkinAnimator { // @Override // public abstract SkinAnimator apply(@NonNull View view, @Nullable Action action); // // @Override // public SkinAnimator setPreDuration() { // return this; // } // // @Override // public SkinAnimator setAfterDuration() { // return this; // } // // @Override // public SkinAnimator setDuration() { // return this; // } // // @Override // public abstract void start(); // // protected void resetView(View view) { // view.setAlpha(1); // view.setScaleY(1); // view.setScaleX(1); // view.setRotation(0); // view.setTranslationX(0); // view.setTranslationY(0); // view.setPivotX(view.getWidth() / 2); // view.setPivotY(view.getHeight() / 2); // } // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // }
import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import android.view.animation.LinearInterpolator; import skin.support.animator.Action; import skin.support.animator.SingleAnimator.ViewAnimatorImpl; import skin.support.animator.SkinAnimator;
package skin.support.animator.SingleAnimator.hide; /** * Created by erfli on 2/25/17. */ public class TranslationAlphaHideAnimator extends ViewAnimatorImpl { private ObjectAnimator animator; private TranslationAlphaHideAnimator() { } public static TranslationAlphaHideAnimator getInstance() { return new TranslationAlphaHideAnimator(); } @Override
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorImpl.java // public abstract class ViewAnimatorImpl implements SkinAnimator { // @Override // public abstract SkinAnimator apply(@NonNull View view, @Nullable Action action); // // @Override // public SkinAnimator setPreDuration() { // return this; // } // // @Override // public SkinAnimator setAfterDuration() { // return this; // } // // @Override // public SkinAnimator setDuration() { // return this; // } // // @Override // public abstract void start(); // // protected void resetView(View view) { // view.setAlpha(1); // view.setScaleY(1); // view.setScaleX(1); // view.setRotation(0); // view.setTranslationX(0); // view.setTranslationY(0); // view.setPivotX(view.getWidth() / 2); // view.setPivotY(view.getHeight() / 2); // } // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // } // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/hide/TranslationAlphaHideAnimator.java import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import android.view.animation.LinearInterpolator; import skin.support.animator.Action; import skin.support.animator.SingleAnimator.ViewAnimatorImpl; import skin.support.animator.SkinAnimator; package skin.support.animator.SingleAnimator.hide; /** * Created by erfli on 2/25/17. */ public class TranslationAlphaHideAnimator extends ViewAnimatorImpl { private ObjectAnimator animator; private TranslationAlphaHideAnimator() { } public static TranslationAlphaHideAnimator getInstance() { return new TranslationAlphaHideAnimator(); } @Override
public SkinAnimator apply(@NonNull final View view, @Nullable final Action action) {
wutongke/AndroidSkinAnimator
app/src/main/java/com/ximsfei/skindemo/ui/discover/SongMenuFragment.java
// Path: app/src/main/java/com/ximsfei/skindemo/ui/adapter/SongMenuAdapter.java // public class SongMenuAdapter extends BaseRecyclerViewAdapter { // public SongMenuAdapter(Context context) { // } // // @Override // public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { // return null; // } // // @Override // public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { // // } // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/base/BaseFragment.java // public abstract class BaseFragment<VDB extends ViewDataBinding> extends Fragment { // protected VDB mDataBinding; // // @LayoutRes // protected abstract int getLayoutId(); // // @Override // public void onActivityCreated(@Nullable Bundle savedInstanceState) { // super.onActivityCreated(savedInstanceState); // loadData(); // } // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // View view = inflater.inflate(getLayoutId(), null); // mDataBinding = DataBindingUtil.bind(view); // onCreateVew(inflater, savedInstanceState); // return view; // } // // protected void onCreateVew(LayoutInflater inflater, Bundle savedInstanceState) { // // } // // protected abstract void loadData(); // }
import android.databinding.DataBindingUtil; import android.os.Bundle; import android.support.v7.widget.DefaultItemAnimator; import android.support.v7.widget.LinearLayoutManager; import android.view.LayoutInflater; import com.ximsfei.skindemo.R; import com.ximsfei.skindemo.databinding.FragmentSongBinding; import com.ximsfei.skindemo.databinding.HeaderSongItemBinding; import com.ximsfei.skindemo.ui.adapter.SongMenuAdapter; import com.ximsfei.skindemo.ui.base.BaseFragment;
package com.ximsfei.skindemo.ui.discover; /** * Created by ximsfei on 17-1-8. */ public class SongMenuFragment extends BaseFragment<FragmentSongBinding> { private HeaderSongItemBinding mHeaderBinding;
// Path: app/src/main/java/com/ximsfei/skindemo/ui/adapter/SongMenuAdapter.java // public class SongMenuAdapter extends BaseRecyclerViewAdapter { // public SongMenuAdapter(Context context) { // } // // @Override // public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { // return null; // } // // @Override // public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { // // } // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/base/BaseFragment.java // public abstract class BaseFragment<VDB extends ViewDataBinding> extends Fragment { // protected VDB mDataBinding; // // @LayoutRes // protected abstract int getLayoutId(); // // @Override // public void onActivityCreated(@Nullable Bundle savedInstanceState) { // super.onActivityCreated(savedInstanceState); // loadData(); // } // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // View view = inflater.inflate(getLayoutId(), null); // mDataBinding = DataBindingUtil.bind(view); // onCreateVew(inflater, savedInstanceState); // return view; // } // // protected void onCreateVew(LayoutInflater inflater, Bundle savedInstanceState) { // // } // // protected abstract void loadData(); // } // Path: app/src/main/java/com/ximsfei/skindemo/ui/discover/SongMenuFragment.java import android.databinding.DataBindingUtil; import android.os.Bundle; import android.support.v7.widget.DefaultItemAnimator; import android.support.v7.widget.LinearLayoutManager; import android.view.LayoutInflater; import com.ximsfei.skindemo.R; import com.ximsfei.skindemo.databinding.FragmentSongBinding; import com.ximsfei.skindemo.databinding.HeaderSongItemBinding; import com.ximsfei.skindemo.ui.adapter.SongMenuAdapter; import com.ximsfei.skindemo.ui.base.BaseFragment; package com.ximsfei.skindemo.ui.discover; /** * Created by ximsfei on 17-1-8. */ public class SongMenuFragment extends BaseFragment<FragmentSongBinding> { private HeaderSongItemBinding mHeaderBinding;
private SongMenuAdapter mAdapter;
wutongke/AndroidSkinAnimator
skin-support/src/main/java/skin/support/widget/SkinCompatAutoCompleteTextView.java
// Path: skin-support/src/main/java/skin/support/content/res/SkinCompatResources.java // public class SkinCompatResources { // private static volatile SkinCompatResources sInstance; // private final Context mAppContext; // private Resources mResources; // private String mSkinPkgName; // private boolean isDefaultSkin; // // private SkinCompatResources(Context context) { // mAppContext = context.getApplicationContext(); // setSkinResource(mAppContext.getResources(), mAppContext.getPackageName()); // } // // public static void init(Context context) { // if (sInstance == null) { // synchronized (SkinCompatResources.class) { // if (sInstance == null) { // sInstance = new SkinCompatResources(context); // } // } // } // } // // public static SkinCompatResources getInstance() { // return sInstance; // } // // public void setSkinResource(Resources resources, String pkgName) { // mResources = resources; // mSkinPkgName = pkgName; // isDefaultSkin = mAppContext.getPackageName().equals(pkgName); // } // // public int getColor(int resId) { // int originColor = ContextCompat.getColor(mAppContext, resId); // if (isDefaultSkin) { // return originColor; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? originColor : mResources.getColor(targetResId); // } // // public Drawable getDrawable(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "drawable", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public Drawable getMipmap(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "mipmap", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public ColorStateList getColorStateList(int resId) { // ColorStateList colorStateList = ContextCompat.getColorStateList(mAppContext, resId); // if (isDefaultSkin) { // return colorStateList; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? colorStateList : mResources.getColorStateList(targetResId); // } // } // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // public static final int INVALID_ID = -1;
import android.content.Context; import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; import android.os.Build; import android.support.annotation.DrawableRes; import android.support.v4.graphics.drawable.DrawableCompat; import android.support.v7.widget.AppCompatAutoCompleteTextView; import android.support.v7.widget.TintTypedArray; import android.util.AttributeSet; import skin.support.R; import skin.support.content.res.SkinCompatResources; import static skin.support.widget.SkinCompatHelper.INVALID_ID;
package skin.support.widget; /** * Created by ximsfei on 2017/1/13. */ public class SkinCompatAutoCompleteTextView extends AppCompatAutoCompleteTextView implements SkinCompatSupportable { private static final int[] TINT_ATTRS = { android.R.attr.popupBackground };
// Path: skin-support/src/main/java/skin/support/content/res/SkinCompatResources.java // public class SkinCompatResources { // private static volatile SkinCompatResources sInstance; // private final Context mAppContext; // private Resources mResources; // private String mSkinPkgName; // private boolean isDefaultSkin; // // private SkinCompatResources(Context context) { // mAppContext = context.getApplicationContext(); // setSkinResource(mAppContext.getResources(), mAppContext.getPackageName()); // } // // public static void init(Context context) { // if (sInstance == null) { // synchronized (SkinCompatResources.class) { // if (sInstance == null) { // sInstance = new SkinCompatResources(context); // } // } // } // } // // public static SkinCompatResources getInstance() { // return sInstance; // } // // public void setSkinResource(Resources resources, String pkgName) { // mResources = resources; // mSkinPkgName = pkgName; // isDefaultSkin = mAppContext.getPackageName().equals(pkgName); // } // // public int getColor(int resId) { // int originColor = ContextCompat.getColor(mAppContext, resId); // if (isDefaultSkin) { // return originColor; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? originColor : mResources.getColor(targetResId); // } // // public Drawable getDrawable(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "drawable", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public Drawable getMipmap(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "mipmap", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public ColorStateList getColorStateList(int resId) { // ColorStateList colorStateList = ContextCompat.getColorStateList(mAppContext, resId); // if (isDefaultSkin) { // return colorStateList; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? colorStateList : mResources.getColorStateList(targetResId); // } // } // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // public static final int INVALID_ID = -1; // Path: skin-support/src/main/java/skin/support/widget/SkinCompatAutoCompleteTextView.java import android.content.Context; import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; import android.os.Build; import android.support.annotation.DrawableRes; import android.support.v4.graphics.drawable.DrawableCompat; import android.support.v7.widget.AppCompatAutoCompleteTextView; import android.support.v7.widget.TintTypedArray; import android.util.AttributeSet; import skin.support.R; import skin.support.content.res.SkinCompatResources; import static skin.support.widget.SkinCompatHelper.INVALID_ID; package skin.support.widget; /** * Created by ximsfei on 2017/1/13. */ public class SkinCompatAutoCompleteTextView extends AppCompatAutoCompleteTextView implements SkinCompatSupportable { private static final int[] TINT_ATTRS = { android.R.attr.popupBackground };
private int mDropDownBackgroundResId = INVALID_ID;
wutongke/AndroidSkinAnimator
skin-support/src/main/java/skin/support/widget/SkinCompatAutoCompleteTextView.java
// Path: skin-support/src/main/java/skin/support/content/res/SkinCompatResources.java // public class SkinCompatResources { // private static volatile SkinCompatResources sInstance; // private final Context mAppContext; // private Resources mResources; // private String mSkinPkgName; // private boolean isDefaultSkin; // // private SkinCompatResources(Context context) { // mAppContext = context.getApplicationContext(); // setSkinResource(mAppContext.getResources(), mAppContext.getPackageName()); // } // // public static void init(Context context) { // if (sInstance == null) { // synchronized (SkinCompatResources.class) { // if (sInstance == null) { // sInstance = new SkinCompatResources(context); // } // } // } // } // // public static SkinCompatResources getInstance() { // return sInstance; // } // // public void setSkinResource(Resources resources, String pkgName) { // mResources = resources; // mSkinPkgName = pkgName; // isDefaultSkin = mAppContext.getPackageName().equals(pkgName); // } // // public int getColor(int resId) { // int originColor = ContextCompat.getColor(mAppContext, resId); // if (isDefaultSkin) { // return originColor; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? originColor : mResources.getColor(targetResId); // } // // public Drawable getDrawable(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "drawable", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public Drawable getMipmap(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "mipmap", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public ColorStateList getColorStateList(int resId) { // ColorStateList colorStateList = ContextCompat.getColorStateList(mAppContext, resId); // if (isDefaultSkin) { // return colorStateList; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? colorStateList : mResources.getColorStateList(targetResId); // } // } // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // public static final int INVALID_ID = -1;
import android.content.Context; import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; import android.os.Build; import android.support.annotation.DrawableRes; import android.support.v4.graphics.drawable.DrawableCompat; import android.support.v7.widget.AppCompatAutoCompleteTextView; import android.support.v7.widget.TintTypedArray; import android.util.AttributeSet; import skin.support.R; import skin.support.content.res.SkinCompatResources; import static skin.support.widget.SkinCompatHelper.INVALID_ID;
} public SkinCompatAutoCompleteTextView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), attrs, TINT_ATTRS, defStyleAttr, 0); if (a.hasValue(0)) { mDropDownBackgroundResId = a.getResourceId(0, INVALID_ID); } a.recycle(); applyDropDownBackgroundResource(); mBackgroundTintHelper = new SkinCompatBackgroundHelper(this); mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr); mTextHelper = new SkinCompatTextHelper(this); mTextHelper.loadFromAttributes(attrs, defStyleAttr); } @Override public void setDropDownBackgroundResource(@DrawableRes int resId) { super.setDropDownBackgroundResource(resId); mDropDownBackgroundResId = resId; applyDropDownBackgroundResource(); } private void applyDropDownBackgroundResource() { mDropDownBackgroundResId = SkinCompatHelper.checkResourceId(mDropDownBackgroundResId); if (mDropDownBackgroundResId != INVALID_ID) { String typeName = getResources().getResourceTypeName(mDropDownBackgroundResId); if ("color".equals(typeName)) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
// Path: skin-support/src/main/java/skin/support/content/res/SkinCompatResources.java // public class SkinCompatResources { // private static volatile SkinCompatResources sInstance; // private final Context mAppContext; // private Resources mResources; // private String mSkinPkgName; // private boolean isDefaultSkin; // // private SkinCompatResources(Context context) { // mAppContext = context.getApplicationContext(); // setSkinResource(mAppContext.getResources(), mAppContext.getPackageName()); // } // // public static void init(Context context) { // if (sInstance == null) { // synchronized (SkinCompatResources.class) { // if (sInstance == null) { // sInstance = new SkinCompatResources(context); // } // } // } // } // // public static SkinCompatResources getInstance() { // return sInstance; // } // // public void setSkinResource(Resources resources, String pkgName) { // mResources = resources; // mSkinPkgName = pkgName; // isDefaultSkin = mAppContext.getPackageName().equals(pkgName); // } // // public int getColor(int resId) { // int originColor = ContextCompat.getColor(mAppContext, resId); // if (isDefaultSkin) { // return originColor; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? originColor : mResources.getColor(targetResId); // } // // public Drawable getDrawable(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "drawable", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public Drawable getMipmap(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "mipmap", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public ColorStateList getColorStateList(int resId) { // ColorStateList colorStateList = ContextCompat.getColorStateList(mAppContext, resId); // if (isDefaultSkin) { // return colorStateList; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? colorStateList : mResources.getColorStateList(targetResId); // } // } // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // public static final int INVALID_ID = -1; // Path: skin-support/src/main/java/skin/support/widget/SkinCompatAutoCompleteTextView.java import android.content.Context; import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; import android.os.Build; import android.support.annotation.DrawableRes; import android.support.v4.graphics.drawable.DrawableCompat; import android.support.v7.widget.AppCompatAutoCompleteTextView; import android.support.v7.widget.TintTypedArray; import android.util.AttributeSet; import skin.support.R; import skin.support.content.res.SkinCompatResources; import static skin.support.widget.SkinCompatHelper.INVALID_ID; } public SkinCompatAutoCompleteTextView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), attrs, TINT_ATTRS, defStyleAttr, 0); if (a.hasValue(0)) { mDropDownBackgroundResId = a.getResourceId(0, INVALID_ID); } a.recycle(); applyDropDownBackgroundResource(); mBackgroundTintHelper = new SkinCompatBackgroundHelper(this); mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr); mTextHelper = new SkinCompatTextHelper(this); mTextHelper.loadFromAttributes(attrs, defStyleAttr); } @Override public void setDropDownBackgroundResource(@DrawableRes int resId) { super.setDropDownBackgroundResource(resId); mDropDownBackgroundResId = resId; applyDropDownBackgroundResource(); } private void applyDropDownBackgroundResource() { mDropDownBackgroundResId = SkinCompatHelper.checkResourceId(mDropDownBackgroundResId); if (mDropDownBackgroundResId != INVALID_ID) { String typeName = getResources().getResourceTypeName(mDropDownBackgroundResId); if ("color".equals(typeName)) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
int color = SkinCompatResources.getInstance().getColor(mDropDownBackgroundResId);
wutongke/AndroidSkinAnimator
skin-support/src/main/java/skin/support/animator/SingleAnimator/update/AlphaAnimator.java
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorImpl.java // public abstract class ViewAnimatorImpl implements SkinAnimator { // @Override // public abstract SkinAnimator apply(@NonNull View view, @Nullable Action action); // // @Override // public SkinAnimator setPreDuration() { // return this; // } // // @Override // public SkinAnimator setAfterDuration() { // return this; // } // // @Override // public SkinAnimator setDuration() { // return this; // } // // @Override // public abstract void start(); // // protected void resetView(View view) { // view.setAlpha(1); // view.setScaleY(1); // view.setScaleX(1); // view.setRotation(0); // view.setTranslationX(0); // view.setTranslationY(0); // view.setPivotX(view.getWidth() / 2); // view.setPivotY(view.getHeight() / 2); // } // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // }
import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import android.view.animation.LinearInterpolator; import skin.support.animator.Action; import skin.support.animator.SingleAnimator.ViewAnimatorImpl; import skin.support.animator.SkinAnimator;
package skin.support.animator.SingleAnimator.update; /** * Created by erfli on 2/25/17. */ public class AlphaAnimator extends ViewAnimatorImpl { protected ObjectAnimator preAnimator; protected ObjectAnimator afterAnimator; protected View targetView; private AlphaAnimator() { } public static AlphaAnimator getInstance() { AlphaAnimator skinAlphaAnimator = new AlphaAnimator(); return skinAlphaAnimator; } @Override
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorImpl.java // public abstract class ViewAnimatorImpl implements SkinAnimator { // @Override // public abstract SkinAnimator apply(@NonNull View view, @Nullable Action action); // // @Override // public SkinAnimator setPreDuration() { // return this; // } // // @Override // public SkinAnimator setAfterDuration() { // return this; // } // // @Override // public SkinAnimator setDuration() { // return this; // } // // @Override // public abstract void start(); // // protected void resetView(View view) { // view.setAlpha(1); // view.setScaleY(1); // view.setScaleX(1); // view.setRotation(0); // view.setTranslationX(0); // view.setTranslationY(0); // view.setPivotX(view.getWidth() / 2); // view.setPivotY(view.getHeight() / 2); // } // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // } // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/update/AlphaAnimator.java import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import android.view.animation.LinearInterpolator; import skin.support.animator.Action; import skin.support.animator.SingleAnimator.ViewAnimatorImpl; import skin.support.animator.SkinAnimator; package skin.support.animator.SingleAnimator.update; /** * Created by erfli on 2/25/17. */ public class AlphaAnimator extends ViewAnimatorImpl { protected ObjectAnimator preAnimator; protected ObjectAnimator afterAnimator; protected View targetView; private AlphaAnimator() { } public static AlphaAnimator getInstance() { AlphaAnimator skinAlphaAnimator = new AlphaAnimator(); return skinAlphaAnimator; } @Override
public SkinAnimator apply(@NonNull View view, @Nullable final Action action) {
wutongke/AndroidSkinAnimator
skin-support/src/main/java/skin/support/animator/SingleAnimator/update/AlphaAnimator.java
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorImpl.java // public abstract class ViewAnimatorImpl implements SkinAnimator { // @Override // public abstract SkinAnimator apply(@NonNull View view, @Nullable Action action); // // @Override // public SkinAnimator setPreDuration() { // return this; // } // // @Override // public SkinAnimator setAfterDuration() { // return this; // } // // @Override // public SkinAnimator setDuration() { // return this; // } // // @Override // public abstract void start(); // // protected void resetView(View view) { // view.setAlpha(1); // view.setScaleY(1); // view.setScaleX(1); // view.setRotation(0); // view.setTranslationX(0); // view.setTranslationY(0); // view.setPivotX(view.getWidth() / 2); // view.setPivotY(view.getHeight() / 2); // } // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // }
import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import android.view.animation.LinearInterpolator; import skin.support.animator.Action; import skin.support.animator.SingleAnimator.ViewAnimatorImpl; import skin.support.animator.SkinAnimator;
package skin.support.animator.SingleAnimator.update; /** * Created by erfli on 2/25/17. */ public class AlphaAnimator extends ViewAnimatorImpl { protected ObjectAnimator preAnimator; protected ObjectAnimator afterAnimator; protected View targetView; private AlphaAnimator() { } public static AlphaAnimator getInstance() { AlphaAnimator skinAlphaAnimator = new AlphaAnimator(); return skinAlphaAnimator; } @Override
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorImpl.java // public abstract class ViewAnimatorImpl implements SkinAnimator { // @Override // public abstract SkinAnimator apply(@NonNull View view, @Nullable Action action); // // @Override // public SkinAnimator setPreDuration() { // return this; // } // // @Override // public SkinAnimator setAfterDuration() { // return this; // } // // @Override // public SkinAnimator setDuration() { // return this; // } // // @Override // public abstract void start(); // // protected void resetView(View view) { // view.setAlpha(1); // view.setScaleY(1); // view.setScaleX(1); // view.setRotation(0); // view.setTranslationX(0); // view.setTranslationY(0); // view.setPivotX(view.getWidth() / 2); // view.setPivotY(view.getHeight() / 2); // } // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // } // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/update/AlphaAnimator.java import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import android.view.animation.LinearInterpolator; import skin.support.animator.Action; import skin.support.animator.SingleAnimator.ViewAnimatorImpl; import skin.support.animator.SkinAnimator; package skin.support.animator.SingleAnimator.update; /** * Created by erfli on 2/25/17. */ public class AlphaAnimator extends ViewAnimatorImpl { protected ObjectAnimator preAnimator; protected ObjectAnimator afterAnimator; protected View targetView; private AlphaAnimator() { } public static AlphaAnimator getInstance() { AlphaAnimator skinAlphaAnimator = new AlphaAnimator(); return skinAlphaAnimator; } @Override
public SkinAnimator apply(@NonNull View view, @Nullable final Action action) {
wutongke/AndroidSkinAnimator
skin-support/src/main/java/skin/support/animator/activityAnimator/SkinRotateHintAnimator.java
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // }
import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import android.view.animation.AccelerateInterpolator; import android.view.animation.LinearInterpolator; import skin.support.animator.Action; import skin.support.animator.SkinAnimator;
package skin.support.animator.activityAnimator; /** * Created by erfli on 2/25/17. */ public class SkinRotateHintAnimator implements SkinAnimator { protected ObjectAnimator preAnimator; protected ObjectAnimator middleAnimator; protected ObjectAnimator afterAnimator; protected View targetView; private SkinRotateHintAnimator() { } public static SkinRotateHintAnimator getInstance() { SkinRotateHintAnimator skinAlphaAnimator = new SkinRotateHintAnimator(); return skinAlphaAnimator; } @Override
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // } // Path: skin-support/src/main/java/skin/support/animator/activityAnimator/SkinRotateHintAnimator.java import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import android.view.animation.AccelerateInterpolator; import android.view.animation.LinearInterpolator; import skin.support.animator.Action; import skin.support.animator.SkinAnimator; package skin.support.animator.activityAnimator; /** * Created by erfli on 2/25/17. */ public class SkinRotateHintAnimator implements SkinAnimator { protected ObjectAnimator preAnimator; protected ObjectAnimator middleAnimator; protected ObjectAnimator afterAnimator; protected View targetView; private SkinRotateHintAnimator() { } public static SkinRotateHintAnimator getInstance() { SkinRotateHintAnimator skinAlphaAnimator = new SkinRotateHintAnimator(); return skinAlphaAnimator; } @Override
public SkinAnimator apply(@NonNull View view, @Nullable final Action action) {
wutongke/AndroidSkinAnimator
skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorImpl.java
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // }
import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import skin.support.animator.Action; import skin.support.animator.SkinAnimator;
package skin.support.animator.SingleAnimator; /** * Created by erfli on 2/25/17. */ public abstract class ViewAnimatorImpl implements SkinAnimator { @Override
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // } // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorImpl.java import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import skin.support.animator.Action; import skin.support.animator.SkinAnimator; package skin.support.animator.SingleAnimator; /** * Created by erfli on 2/25/17. */ public abstract class ViewAnimatorImpl implements SkinAnimator { @Override
public abstract SkinAnimator apply(@NonNull View view, @Nullable Action action);
wutongke/AndroidSkinAnimator
skin-support/src/main/java/skin/support/animator/SingleAnimator/hide/ScaleHideAnimator.java
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorImpl.java // public abstract class ViewAnimatorImpl implements SkinAnimator { // @Override // public abstract SkinAnimator apply(@NonNull View view, @Nullable Action action); // // @Override // public SkinAnimator setPreDuration() { // return this; // } // // @Override // public SkinAnimator setAfterDuration() { // return this; // } // // @Override // public SkinAnimator setDuration() { // return this; // } // // @Override // public abstract void start(); // // protected void resetView(View view) { // view.setAlpha(1); // view.setScaleY(1); // view.setScaleX(1); // view.setRotation(0); // view.setTranslationX(0); // view.setTranslationY(0); // view.setPivotX(view.getWidth() / 2); // view.setPivotY(view.getHeight() / 2); // } // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // }
import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import android.view.animation.AnticipateInterpolator; import skin.support.animator.Action; import skin.support.animator.SingleAnimator.ViewAnimatorImpl; import skin.support.animator.SkinAnimator;
package skin.support.animator.SingleAnimator.hide; /** * Created by erfli on 2/25/17. */ public class ScaleHideAnimator extends ViewAnimatorImpl { private ObjectAnimator animator; private ScaleHideAnimator() { } public static ScaleHideAnimator getInstance() { return new ScaleHideAnimator(); } @Override
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorImpl.java // public abstract class ViewAnimatorImpl implements SkinAnimator { // @Override // public abstract SkinAnimator apply(@NonNull View view, @Nullable Action action); // // @Override // public SkinAnimator setPreDuration() { // return this; // } // // @Override // public SkinAnimator setAfterDuration() { // return this; // } // // @Override // public SkinAnimator setDuration() { // return this; // } // // @Override // public abstract void start(); // // protected void resetView(View view) { // view.setAlpha(1); // view.setScaleY(1); // view.setScaleX(1); // view.setRotation(0); // view.setTranslationX(0); // view.setTranslationY(0); // view.setPivotX(view.getWidth() / 2); // view.setPivotY(view.getHeight() / 2); // } // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // } // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/hide/ScaleHideAnimator.java import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import android.view.animation.AnticipateInterpolator; import skin.support.animator.Action; import skin.support.animator.SingleAnimator.ViewAnimatorImpl; import skin.support.animator.SkinAnimator; package skin.support.animator.SingleAnimator.hide; /** * Created by erfli on 2/25/17. */ public class ScaleHideAnimator extends ViewAnimatorImpl { private ObjectAnimator animator; private ScaleHideAnimator() { } public static ScaleHideAnimator getInstance() { return new ScaleHideAnimator(); } @Override
public SkinAnimator apply(@NonNull final View view, @Nullable final Action action) {
wutongke/AndroidSkinAnimator
skin-support/src/main/java/skin/support/animator/SingleAnimator/hide/ScaleHideAnimator.java
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorImpl.java // public abstract class ViewAnimatorImpl implements SkinAnimator { // @Override // public abstract SkinAnimator apply(@NonNull View view, @Nullable Action action); // // @Override // public SkinAnimator setPreDuration() { // return this; // } // // @Override // public SkinAnimator setAfterDuration() { // return this; // } // // @Override // public SkinAnimator setDuration() { // return this; // } // // @Override // public abstract void start(); // // protected void resetView(View view) { // view.setAlpha(1); // view.setScaleY(1); // view.setScaleX(1); // view.setRotation(0); // view.setTranslationX(0); // view.setTranslationY(0); // view.setPivotX(view.getWidth() / 2); // view.setPivotY(view.getHeight() / 2); // } // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // }
import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import android.view.animation.AnticipateInterpolator; import skin.support.animator.Action; import skin.support.animator.SingleAnimator.ViewAnimatorImpl; import skin.support.animator.SkinAnimator;
package skin.support.animator.SingleAnimator.hide; /** * Created by erfli on 2/25/17. */ public class ScaleHideAnimator extends ViewAnimatorImpl { private ObjectAnimator animator; private ScaleHideAnimator() { } public static ScaleHideAnimator getInstance() { return new ScaleHideAnimator(); } @Override
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorImpl.java // public abstract class ViewAnimatorImpl implements SkinAnimator { // @Override // public abstract SkinAnimator apply(@NonNull View view, @Nullable Action action); // // @Override // public SkinAnimator setPreDuration() { // return this; // } // // @Override // public SkinAnimator setAfterDuration() { // return this; // } // // @Override // public SkinAnimator setDuration() { // return this; // } // // @Override // public abstract void start(); // // protected void resetView(View view) { // view.setAlpha(1); // view.setScaleY(1); // view.setScaleX(1); // view.setRotation(0); // view.setTranslationX(0); // view.setTranslationY(0); // view.setPivotX(view.getWidth() / 2); // view.setPivotY(view.getHeight() / 2); // } // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // } // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/hide/ScaleHideAnimator.java import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import android.view.animation.AnticipateInterpolator; import skin.support.animator.Action; import skin.support.animator.SingleAnimator.ViewAnimatorImpl; import skin.support.animator.SkinAnimator; package skin.support.animator.SingleAnimator.hide; /** * Created by erfli on 2/25/17. */ public class ScaleHideAnimator extends ViewAnimatorImpl { private ObjectAnimator animator; private ScaleHideAnimator() { } public static ScaleHideAnimator getInstance() { return new ScaleHideAnimator(); } @Override
public SkinAnimator apply(@NonNull final View view, @Nullable final Action action) {
wutongke/AndroidSkinAnimator
skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorType.java
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/update/AlphaAnimator.java // public class AlphaAnimator extends ViewAnimatorImpl { // protected ObjectAnimator preAnimator; // protected ObjectAnimator afterAnimator; // protected View targetView; // // private AlphaAnimator() { // } // // public static AlphaAnimator getInstance() { // AlphaAnimator skinAlphaAnimator = new AlphaAnimator(); // return skinAlphaAnimator; // } // // @Override // public SkinAnimator apply(@NonNull View view, @Nullable final Action action) { // this.targetView = view; // preAnimator = ObjectAnimator.ofFloat(targetView, "alpha", 1, 0) // .setDuration(2 * PRE_DURATION); // preAnimator.setInterpolator(new LinearInterpolator()); // afterAnimator = ObjectAnimator.ofFloat(targetView, "alpha", 0, 1) // .setDuration(AFTER_DURATION); // afterAnimator.setInterpolator(new LinearInterpolator()); // // preAnimator.addListener(new AnimatorListenerAdapter() { // @Override // public void onAnimationEnd(Animator animation) { // super.onAnimationEnd(animation); // if (action != null) { // action.action(); // } // afterAnimator.start(); // } // }); // return this; // } // // @Override // public void start() { // preAnimator.start(); // } // }
import android.view.View; import skin.support.animator.Action; import skin.support.animator.SingleAnimator.update.AlphaAnimator;
package skin.support.animator.SingleAnimator; /** * Created by erfli on 2/28/17. */ public enum ViewAnimatorType { //Visible //Update AlphaUpdateAnimator() { @Override
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/update/AlphaAnimator.java // public class AlphaAnimator extends ViewAnimatorImpl { // protected ObjectAnimator preAnimator; // protected ObjectAnimator afterAnimator; // protected View targetView; // // private AlphaAnimator() { // } // // public static AlphaAnimator getInstance() { // AlphaAnimator skinAlphaAnimator = new AlphaAnimator(); // return skinAlphaAnimator; // } // // @Override // public SkinAnimator apply(@NonNull View view, @Nullable final Action action) { // this.targetView = view; // preAnimator = ObjectAnimator.ofFloat(targetView, "alpha", 1, 0) // .setDuration(2 * PRE_DURATION); // preAnimator.setInterpolator(new LinearInterpolator()); // afterAnimator = ObjectAnimator.ofFloat(targetView, "alpha", 0, 1) // .setDuration(AFTER_DURATION); // afterAnimator.setInterpolator(new LinearInterpolator()); // // preAnimator.addListener(new AnimatorListenerAdapter() { // @Override // public void onAnimationEnd(Animator animation) { // super.onAnimationEnd(animation); // if (action != null) { // action.action(); // } // afterAnimator.start(); // } // }); // return this; // } // // @Override // public void start() { // preAnimator.start(); // } // } // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorType.java import android.view.View; import skin.support.animator.Action; import skin.support.animator.SingleAnimator.update.AlphaAnimator; package skin.support.animator.SingleAnimator; /** * Created by erfli on 2/28/17. */ public enum ViewAnimatorType { //Visible //Update AlphaUpdateAnimator() { @Override
public void apply(View view, Action action) {
wutongke/AndroidSkinAnimator
skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorType.java
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/update/AlphaAnimator.java // public class AlphaAnimator extends ViewAnimatorImpl { // protected ObjectAnimator preAnimator; // protected ObjectAnimator afterAnimator; // protected View targetView; // // private AlphaAnimator() { // } // // public static AlphaAnimator getInstance() { // AlphaAnimator skinAlphaAnimator = new AlphaAnimator(); // return skinAlphaAnimator; // } // // @Override // public SkinAnimator apply(@NonNull View view, @Nullable final Action action) { // this.targetView = view; // preAnimator = ObjectAnimator.ofFloat(targetView, "alpha", 1, 0) // .setDuration(2 * PRE_DURATION); // preAnimator.setInterpolator(new LinearInterpolator()); // afterAnimator = ObjectAnimator.ofFloat(targetView, "alpha", 0, 1) // .setDuration(AFTER_DURATION); // afterAnimator.setInterpolator(new LinearInterpolator()); // // preAnimator.addListener(new AnimatorListenerAdapter() { // @Override // public void onAnimationEnd(Animator animation) { // super.onAnimationEnd(animation); // if (action != null) { // action.action(); // } // afterAnimator.start(); // } // }); // return this; // } // // @Override // public void start() { // preAnimator.start(); // } // }
import android.view.View; import skin.support.animator.Action; import skin.support.animator.SingleAnimator.update.AlphaAnimator;
package skin.support.animator.SingleAnimator; /** * Created by erfli on 2/28/17. */ public enum ViewAnimatorType { //Visible //Update AlphaUpdateAnimator() { @Override public void apply(View view, Action action) {
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/update/AlphaAnimator.java // public class AlphaAnimator extends ViewAnimatorImpl { // protected ObjectAnimator preAnimator; // protected ObjectAnimator afterAnimator; // protected View targetView; // // private AlphaAnimator() { // } // // public static AlphaAnimator getInstance() { // AlphaAnimator skinAlphaAnimator = new AlphaAnimator(); // return skinAlphaAnimator; // } // // @Override // public SkinAnimator apply(@NonNull View view, @Nullable final Action action) { // this.targetView = view; // preAnimator = ObjectAnimator.ofFloat(targetView, "alpha", 1, 0) // .setDuration(2 * PRE_DURATION); // preAnimator.setInterpolator(new LinearInterpolator()); // afterAnimator = ObjectAnimator.ofFloat(targetView, "alpha", 0, 1) // .setDuration(AFTER_DURATION); // afterAnimator.setInterpolator(new LinearInterpolator()); // // preAnimator.addListener(new AnimatorListenerAdapter() { // @Override // public void onAnimationEnd(Animator animation) { // super.onAnimationEnd(animation); // if (action != null) { // action.action(); // } // afterAnimator.start(); // } // }); // return this; // } // // @Override // public void start() { // preAnimator.start(); // } // } // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorType.java import android.view.View; import skin.support.animator.Action; import skin.support.animator.SingleAnimator.update.AlphaAnimator; package skin.support.animator.SingleAnimator; /** * Created by erfli on 2/28/17. */ public enum ViewAnimatorType { //Visible //Update AlphaUpdateAnimator() { @Override public void apply(View view, Action action) {
AlphaAnimator.getInstance().apply(view, action).start();
wutongke/AndroidSkinAnimator
skin-support-design/src/main/java/skin/support/design/app/SkinMaterialViewInflater.java
// Path: skin-support/src/main/java/skin/support/app/SkinLayoutInflater.java // public interface SkinLayoutInflater { // View createView(@NonNull Context context, final String name, @NonNull AttributeSet attrs); // } // // Path: skin-support-design/src/main/java/skin/support/design/widget/SkinCompatAppBarLayout.java // public class SkinCompatAppBarLayout extends AppBarLayout implements SkinCompatSupportable { // private final SkinCompatBackgroundHelper mBackgroundTintHelper; // // public SkinCompatAppBarLayout(Context context) { // this(context, null); // } // // public SkinCompatAppBarLayout(Context context, AttributeSet attrs) { // super(context, attrs); // mBackgroundTintHelper = new SkinCompatBackgroundHelper(this); // mBackgroundTintHelper.loadFromAttributes(attrs, 0); // } // // @Override // public void applySkin() { // if (mBackgroundTintHelper != null) { // mBackgroundTintHelper.applySkin(); // } // } // } // // Path: skin-support-design/src/main/java/skin/support/design/widget/SkinCompatNavigationView.java // public class SkinCompatNavigationView extends NavigationView implements SkinCompatSupportable { // private final SkinCompatBackgroundHelper mBackgroundTintHelper; // // private int mBackgroundResId = INVALID_ID; // // public SkinCompatNavigationView(Context context) { // this(context, null); // } // // public SkinCompatNavigationView(Context context, AttributeSet attrs) { // this(context, attrs, 0); // } // // public SkinCompatNavigationView(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // mBackgroundTintHelper = new SkinCompatBackgroundHelper(this); // mBackgroundTintHelper.loadFromAttributes(attrs, 0); // applySkin(); // } // // @Override // public void applySkin() { // if (mBackgroundTintHelper != null) { // mBackgroundTintHelper.applySkin(); // } // } // } // // Path: skin-support-design/src/main/java/skin/support/design/widget/SkinCompatTabLayout.java // public class SkinCompatTabLayout extends TabLayout implements SkinCompatSupportable { // private int mTabIndicatorColorResId = INVALID_ID; // private int mTabTextColorsResId = INVALID_ID; // private int mTabSelectedTextColorResId = INVALID_ID; // // public SkinCompatTabLayout(Context context) { // this(context, null); // } // // public SkinCompatTabLayout(Context context, AttributeSet attrs) { // this(context, attrs, 0); // } // // public SkinCompatTabLayout(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TabLayout, // defStyleAttr, 0); // // mTabIndicatorColorResId = a.getResourceId(R.styleable.TabLayout_tabIndicatorColor, INVALID_ID); // // int tabTextAppearance = a.getResourceId(R.styleable.TabLayout_tabTextAppearance, R.style.TextAppearance_Design_Tab); // // // Text colors/sizes come from the text appearance first // final TypedArray ta = context.obtainStyledAttributes(tabTextAppearance, R.styleable.SkinTextAppearance); // try { // mTabTextColorsResId = ta.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID); // } finally { // ta.recycle(); // } // // if (a.hasValue(R.styleable.TabLayout_tabTextColor)) { // // If we have an explicit text color set, use it instead // mTabTextColorsResId = a.getResourceId(R.styleable.TabLayout_tabTextColor, INVALID_ID); // } // // if (a.hasValue(R.styleable.TabLayout_tabSelectedTextColor)) { // // We have an explicit selected text color set, so we need to make merge it with the // // current colors. This is exposed so that developers can use theme attributes to set // // this (theme attrs in ColorStateLists are Lollipop+) // mTabSelectedTextColorResId = a.getResourceId(R.styleable.TabLayout_tabSelectedTextColor, INVALID_ID); // } // a.recycle(); // applySkin(); // } // // @Override // public void applySkin() { // int tabTextColor = INVALID_ID; // mTabIndicatorColorResId = SkinCompatHelper.checkResourceId(mTabIndicatorColorResId); // if (mTabIndicatorColorResId != INVALID_ID) { // setSelectedTabIndicatorColor(SkinCompatResources.getInstance().getColor(mTabIndicatorColorResId)); // } // mTabTextColorsResId = SkinCompatHelper.checkResourceId(mTabTextColorsResId); // if (mTabTextColorsResId != INVALID_ID) { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // setTabTextColors(SkinCompatResources.getInstance().getColorStateList(mTabTextColorsResId)); // } else { // tabTextColor = SkinCompatResources.getInstance().getColor(mTabTextColorsResId); // } // } // mTabSelectedTextColorResId = SkinCompatHelper.checkResourceId(mTabSelectedTextColorResId); // if (mTabSelectedTextColorResId != INVALID_ID) { // int selected = SkinCompatResources.getInstance().getColor(mTabSelectedTextColorResId); // if (getTabTextColors() != null) { // setTabTextColors(getTabTextColors().getDefaultColor(), selected); // } else { // setTabTextColors(tabTextColor, selected); // } // } else if (tabTextColor != INVALID_ID) { // setTabTextColors(tabTextColor, tabTextColor); // } // } // }
import android.content.Context; import android.support.annotation.NonNull; import android.util.AttributeSet; import android.view.View; import skin.support.app.SkinLayoutInflater; import skin.support.design.widget.SkinCompatAppBarLayout; import skin.support.design.widget.SkinCompatNavigationView; import skin.support.design.widget.SkinCompatTabLayout;
package skin.support.design.app; /** * Created by ximsfei on 2017/1/13. */ public class SkinMaterialViewInflater implements SkinLayoutInflater { @Override public View createView(@NonNull Context context, final String name, @NonNull AttributeSet attrs) { View view = null; switch (name) { case "android.support.design.widget.AppBarLayout":
// Path: skin-support/src/main/java/skin/support/app/SkinLayoutInflater.java // public interface SkinLayoutInflater { // View createView(@NonNull Context context, final String name, @NonNull AttributeSet attrs); // } // // Path: skin-support-design/src/main/java/skin/support/design/widget/SkinCompatAppBarLayout.java // public class SkinCompatAppBarLayout extends AppBarLayout implements SkinCompatSupportable { // private final SkinCompatBackgroundHelper mBackgroundTintHelper; // // public SkinCompatAppBarLayout(Context context) { // this(context, null); // } // // public SkinCompatAppBarLayout(Context context, AttributeSet attrs) { // super(context, attrs); // mBackgroundTintHelper = new SkinCompatBackgroundHelper(this); // mBackgroundTintHelper.loadFromAttributes(attrs, 0); // } // // @Override // public void applySkin() { // if (mBackgroundTintHelper != null) { // mBackgroundTintHelper.applySkin(); // } // } // } // // Path: skin-support-design/src/main/java/skin/support/design/widget/SkinCompatNavigationView.java // public class SkinCompatNavigationView extends NavigationView implements SkinCompatSupportable { // private final SkinCompatBackgroundHelper mBackgroundTintHelper; // // private int mBackgroundResId = INVALID_ID; // // public SkinCompatNavigationView(Context context) { // this(context, null); // } // // public SkinCompatNavigationView(Context context, AttributeSet attrs) { // this(context, attrs, 0); // } // // public SkinCompatNavigationView(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // mBackgroundTintHelper = new SkinCompatBackgroundHelper(this); // mBackgroundTintHelper.loadFromAttributes(attrs, 0); // applySkin(); // } // // @Override // public void applySkin() { // if (mBackgroundTintHelper != null) { // mBackgroundTintHelper.applySkin(); // } // } // } // // Path: skin-support-design/src/main/java/skin/support/design/widget/SkinCompatTabLayout.java // public class SkinCompatTabLayout extends TabLayout implements SkinCompatSupportable { // private int mTabIndicatorColorResId = INVALID_ID; // private int mTabTextColorsResId = INVALID_ID; // private int mTabSelectedTextColorResId = INVALID_ID; // // public SkinCompatTabLayout(Context context) { // this(context, null); // } // // public SkinCompatTabLayout(Context context, AttributeSet attrs) { // this(context, attrs, 0); // } // // public SkinCompatTabLayout(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TabLayout, // defStyleAttr, 0); // // mTabIndicatorColorResId = a.getResourceId(R.styleable.TabLayout_tabIndicatorColor, INVALID_ID); // // int tabTextAppearance = a.getResourceId(R.styleable.TabLayout_tabTextAppearance, R.style.TextAppearance_Design_Tab); // // // Text colors/sizes come from the text appearance first // final TypedArray ta = context.obtainStyledAttributes(tabTextAppearance, R.styleable.SkinTextAppearance); // try { // mTabTextColorsResId = ta.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID); // } finally { // ta.recycle(); // } // // if (a.hasValue(R.styleable.TabLayout_tabTextColor)) { // // If we have an explicit text color set, use it instead // mTabTextColorsResId = a.getResourceId(R.styleable.TabLayout_tabTextColor, INVALID_ID); // } // // if (a.hasValue(R.styleable.TabLayout_tabSelectedTextColor)) { // // We have an explicit selected text color set, so we need to make merge it with the // // current colors. This is exposed so that developers can use theme attributes to set // // this (theme attrs in ColorStateLists are Lollipop+) // mTabSelectedTextColorResId = a.getResourceId(R.styleable.TabLayout_tabSelectedTextColor, INVALID_ID); // } // a.recycle(); // applySkin(); // } // // @Override // public void applySkin() { // int tabTextColor = INVALID_ID; // mTabIndicatorColorResId = SkinCompatHelper.checkResourceId(mTabIndicatorColorResId); // if (mTabIndicatorColorResId != INVALID_ID) { // setSelectedTabIndicatorColor(SkinCompatResources.getInstance().getColor(mTabIndicatorColorResId)); // } // mTabTextColorsResId = SkinCompatHelper.checkResourceId(mTabTextColorsResId); // if (mTabTextColorsResId != INVALID_ID) { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // setTabTextColors(SkinCompatResources.getInstance().getColorStateList(mTabTextColorsResId)); // } else { // tabTextColor = SkinCompatResources.getInstance().getColor(mTabTextColorsResId); // } // } // mTabSelectedTextColorResId = SkinCompatHelper.checkResourceId(mTabSelectedTextColorResId); // if (mTabSelectedTextColorResId != INVALID_ID) { // int selected = SkinCompatResources.getInstance().getColor(mTabSelectedTextColorResId); // if (getTabTextColors() != null) { // setTabTextColors(getTabTextColors().getDefaultColor(), selected); // } else { // setTabTextColors(tabTextColor, selected); // } // } else if (tabTextColor != INVALID_ID) { // setTabTextColors(tabTextColor, tabTextColor); // } // } // } // Path: skin-support-design/src/main/java/skin/support/design/app/SkinMaterialViewInflater.java import android.content.Context; import android.support.annotation.NonNull; import android.util.AttributeSet; import android.view.View; import skin.support.app.SkinLayoutInflater; import skin.support.design.widget.SkinCompatAppBarLayout; import skin.support.design.widget.SkinCompatNavigationView; import skin.support.design.widget.SkinCompatTabLayout; package skin.support.design.app; /** * Created by ximsfei on 2017/1/13. */ public class SkinMaterialViewInflater implements SkinLayoutInflater { @Override public View createView(@NonNull Context context, final String name, @NonNull AttributeSet attrs) { View view = null; switch (name) { case "android.support.design.widget.AppBarLayout":
view = new SkinCompatAppBarLayout(context, attrs);
wutongke/AndroidSkinAnimator
skin-support/src/main/java/skin/support/widget/SkinCompatSpinner.java
// Path: skin-support/src/main/java/skin/support/content/res/SkinCompatResources.java // public class SkinCompatResources { // private static volatile SkinCompatResources sInstance; // private final Context mAppContext; // private Resources mResources; // private String mSkinPkgName; // private boolean isDefaultSkin; // // private SkinCompatResources(Context context) { // mAppContext = context.getApplicationContext(); // setSkinResource(mAppContext.getResources(), mAppContext.getPackageName()); // } // // public static void init(Context context) { // if (sInstance == null) { // synchronized (SkinCompatResources.class) { // if (sInstance == null) { // sInstance = new SkinCompatResources(context); // } // } // } // } // // public static SkinCompatResources getInstance() { // return sInstance; // } // // public void setSkinResource(Resources resources, String pkgName) { // mResources = resources; // mSkinPkgName = pkgName; // isDefaultSkin = mAppContext.getPackageName().equals(pkgName); // } // // public int getColor(int resId) { // int originColor = ContextCompat.getColor(mAppContext, resId); // if (isDefaultSkin) { // return originColor; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? originColor : mResources.getColor(targetResId); // } // // public Drawable getDrawable(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "drawable", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public Drawable getMipmap(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "mipmap", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public ColorStateList getColorStateList(int resId) { // ColorStateList colorStateList = ContextCompat.getColorStateList(mAppContext, resId); // if (isDefaultSkin) { // return colorStateList; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? colorStateList : mResources.getColorStateList(targetResId); // } // } // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // public static final int INVALID_ID = -1; // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // final static public int checkResourceId(int resId) { // String hexResId = Integer.toHexString(resId); // SkinLog.d(TAG, "hexResId = " + hexResId); // return hexResId.startsWith(SYSTEM_ID_PREFIX) ? INVALID_ID : resId; // }
import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.os.Build; import android.support.annotation.DrawableRes; import android.support.v7.widget.AppCompatSpinner; import android.support.v7.widget.TintTypedArray; import android.util.AttributeSet; import android.util.Log; import skin.support.R; import skin.support.content.res.SkinCompatResources; import static skin.support.widget.SkinCompatHelper.INVALID_ID; import static skin.support.widget.SkinCompatHelper.checkResourceId;
package skin.support.widget; /** * Created by ximsfei on 17-1-21. */ public class SkinCompatSpinner extends AppCompatSpinner implements SkinCompatSupportable { private static final String TAG = SkinCompatSpinner.class.getSimpleName(); private static final int[] ATTRS_ANDROID_SPINNERMODE = {android.R.attr.spinnerMode}; private static final int MODE_DIALOG = 0; private static final int MODE_DROPDOWN = 1; private static final int MODE_THEME = -1; private final SkinCompatBackgroundHelper mBackgroundTintHelper;
// Path: skin-support/src/main/java/skin/support/content/res/SkinCompatResources.java // public class SkinCompatResources { // private static volatile SkinCompatResources sInstance; // private final Context mAppContext; // private Resources mResources; // private String mSkinPkgName; // private boolean isDefaultSkin; // // private SkinCompatResources(Context context) { // mAppContext = context.getApplicationContext(); // setSkinResource(mAppContext.getResources(), mAppContext.getPackageName()); // } // // public static void init(Context context) { // if (sInstance == null) { // synchronized (SkinCompatResources.class) { // if (sInstance == null) { // sInstance = new SkinCompatResources(context); // } // } // } // } // // public static SkinCompatResources getInstance() { // return sInstance; // } // // public void setSkinResource(Resources resources, String pkgName) { // mResources = resources; // mSkinPkgName = pkgName; // isDefaultSkin = mAppContext.getPackageName().equals(pkgName); // } // // public int getColor(int resId) { // int originColor = ContextCompat.getColor(mAppContext, resId); // if (isDefaultSkin) { // return originColor; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? originColor : mResources.getColor(targetResId); // } // // public Drawable getDrawable(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "drawable", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public Drawable getMipmap(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "mipmap", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public ColorStateList getColorStateList(int resId) { // ColorStateList colorStateList = ContextCompat.getColorStateList(mAppContext, resId); // if (isDefaultSkin) { // return colorStateList; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? colorStateList : mResources.getColorStateList(targetResId); // } // } // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // public static final int INVALID_ID = -1; // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // final static public int checkResourceId(int resId) { // String hexResId = Integer.toHexString(resId); // SkinLog.d(TAG, "hexResId = " + hexResId); // return hexResId.startsWith(SYSTEM_ID_PREFIX) ? INVALID_ID : resId; // } // Path: skin-support/src/main/java/skin/support/widget/SkinCompatSpinner.java import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.os.Build; import android.support.annotation.DrawableRes; import android.support.v7.widget.AppCompatSpinner; import android.support.v7.widget.TintTypedArray; import android.util.AttributeSet; import android.util.Log; import skin.support.R; import skin.support.content.res.SkinCompatResources; import static skin.support.widget.SkinCompatHelper.INVALID_ID; import static skin.support.widget.SkinCompatHelper.checkResourceId; package skin.support.widget; /** * Created by ximsfei on 17-1-21. */ public class SkinCompatSpinner extends AppCompatSpinner implements SkinCompatSupportable { private static final String TAG = SkinCompatSpinner.class.getSimpleName(); private static final int[] ATTRS_ANDROID_SPINNERMODE = {android.R.attr.spinnerMode}; private static final int MODE_DIALOG = 0; private static final int MODE_DROPDOWN = 1; private static final int MODE_THEME = -1; private final SkinCompatBackgroundHelper mBackgroundTintHelper;
private int mPopupBackgroundResId = INVALID_ID;
wutongke/AndroidSkinAnimator
skin-support/src/main/java/skin/support/widget/SkinCompatSpinner.java
// Path: skin-support/src/main/java/skin/support/content/res/SkinCompatResources.java // public class SkinCompatResources { // private static volatile SkinCompatResources sInstance; // private final Context mAppContext; // private Resources mResources; // private String mSkinPkgName; // private boolean isDefaultSkin; // // private SkinCompatResources(Context context) { // mAppContext = context.getApplicationContext(); // setSkinResource(mAppContext.getResources(), mAppContext.getPackageName()); // } // // public static void init(Context context) { // if (sInstance == null) { // synchronized (SkinCompatResources.class) { // if (sInstance == null) { // sInstance = new SkinCompatResources(context); // } // } // } // } // // public static SkinCompatResources getInstance() { // return sInstance; // } // // public void setSkinResource(Resources resources, String pkgName) { // mResources = resources; // mSkinPkgName = pkgName; // isDefaultSkin = mAppContext.getPackageName().equals(pkgName); // } // // public int getColor(int resId) { // int originColor = ContextCompat.getColor(mAppContext, resId); // if (isDefaultSkin) { // return originColor; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? originColor : mResources.getColor(targetResId); // } // // public Drawable getDrawable(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "drawable", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public Drawable getMipmap(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "mipmap", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public ColorStateList getColorStateList(int resId) { // ColorStateList colorStateList = ContextCompat.getColorStateList(mAppContext, resId); // if (isDefaultSkin) { // return colorStateList; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? colorStateList : mResources.getColorStateList(targetResId); // } // } // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // public static final int INVALID_ID = -1; // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // final static public int checkResourceId(int resId) { // String hexResId = Integer.toHexString(resId); // SkinLog.d(TAG, "hexResId = " + hexResId); // return hexResId.startsWith(SYSTEM_ID_PREFIX) ? INVALID_ID : resId; // }
import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.os.Build; import android.support.annotation.DrawableRes; import android.support.v7.widget.AppCompatSpinner; import android.support.v7.widget.TintTypedArray; import android.util.AttributeSet; import android.util.Log; import skin.support.R; import skin.support.content.res.SkinCompatResources; import static skin.support.widget.SkinCompatHelper.INVALID_ID; import static skin.support.widget.SkinCompatHelper.checkResourceId;
aa.recycle(); } } } else { // Else, we use a default mode of dropdown mode = MODE_DROPDOWN; } } if (mode == MODE_DROPDOWN) { final TintTypedArray pa = TintTypedArray.obtainStyledAttributes( getPopupContext(), attrs, R.styleable.Spinner, defStyleAttr, 0); mPopupBackgroundResId = pa.getResourceId(R.styleable.Spinner_android_popupBackground, INVALID_ID); pa.recycle(); } } a.recycle(); mBackgroundTintHelper = new SkinCompatBackgroundHelper(this); mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr); } @Override public void setPopupBackgroundResource(@DrawableRes int resId) { super.setPopupBackgroundResource(resId); mPopupBackgroundResId = resId; applyPopupBackground(); } private void applyPopupBackground() {
// Path: skin-support/src/main/java/skin/support/content/res/SkinCompatResources.java // public class SkinCompatResources { // private static volatile SkinCompatResources sInstance; // private final Context mAppContext; // private Resources mResources; // private String mSkinPkgName; // private boolean isDefaultSkin; // // private SkinCompatResources(Context context) { // mAppContext = context.getApplicationContext(); // setSkinResource(mAppContext.getResources(), mAppContext.getPackageName()); // } // // public static void init(Context context) { // if (sInstance == null) { // synchronized (SkinCompatResources.class) { // if (sInstance == null) { // sInstance = new SkinCompatResources(context); // } // } // } // } // // public static SkinCompatResources getInstance() { // return sInstance; // } // // public void setSkinResource(Resources resources, String pkgName) { // mResources = resources; // mSkinPkgName = pkgName; // isDefaultSkin = mAppContext.getPackageName().equals(pkgName); // } // // public int getColor(int resId) { // int originColor = ContextCompat.getColor(mAppContext, resId); // if (isDefaultSkin) { // return originColor; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? originColor : mResources.getColor(targetResId); // } // // public Drawable getDrawable(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "drawable", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public Drawable getMipmap(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "mipmap", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public ColorStateList getColorStateList(int resId) { // ColorStateList colorStateList = ContextCompat.getColorStateList(mAppContext, resId); // if (isDefaultSkin) { // return colorStateList; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? colorStateList : mResources.getColorStateList(targetResId); // } // } // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // public static final int INVALID_ID = -1; // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // final static public int checkResourceId(int resId) { // String hexResId = Integer.toHexString(resId); // SkinLog.d(TAG, "hexResId = " + hexResId); // return hexResId.startsWith(SYSTEM_ID_PREFIX) ? INVALID_ID : resId; // } // Path: skin-support/src/main/java/skin/support/widget/SkinCompatSpinner.java import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.os.Build; import android.support.annotation.DrawableRes; import android.support.v7.widget.AppCompatSpinner; import android.support.v7.widget.TintTypedArray; import android.util.AttributeSet; import android.util.Log; import skin.support.R; import skin.support.content.res.SkinCompatResources; import static skin.support.widget.SkinCompatHelper.INVALID_ID; import static skin.support.widget.SkinCompatHelper.checkResourceId; aa.recycle(); } } } else { // Else, we use a default mode of dropdown mode = MODE_DROPDOWN; } } if (mode == MODE_DROPDOWN) { final TintTypedArray pa = TintTypedArray.obtainStyledAttributes( getPopupContext(), attrs, R.styleable.Spinner, defStyleAttr, 0); mPopupBackgroundResId = pa.getResourceId(R.styleable.Spinner_android_popupBackground, INVALID_ID); pa.recycle(); } } a.recycle(); mBackgroundTintHelper = new SkinCompatBackgroundHelper(this); mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr); } @Override public void setPopupBackgroundResource(@DrawableRes int resId) { super.setPopupBackgroundResource(resId); mPopupBackgroundResId = resId; applyPopupBackground(); } private void applyPopupBackground() {
mPopupBackgroundResId = checkResourceId(mPopupBackgroundResId);
wutongke/AndroidSkinAnimator
skin-support/src/main/java/skin/support/widget/SkinCompatSpinner.java
// Path: skin-support/src/main/java/skin/support/content/res/SkinCompatResources.java // public class SkinCompatResources { // private static volatile SkinCompatResources sInstance; // private final Context mAppContext; // private Resources mResources; // private String mSkinPkgName; // private boolean isDefaultSkin; // // private SkinCompatResources(Context context) { // mAppContext = context.getApplicationContext(); // setSkinResource(mAppContext.getResources(), mAppContext.getPackageName()); // } // // public static void init(Context context) { // if (sInstance == null) { // synchronized (SkinCompatResources.class) { // if (sInstance == null) { // sInstance = new SkinCompatResources(context); // } // } // } // } // // public static SkinCompatResources getInstance() { // return sInstance; // } // // public void setSkinResource(Resources resources, String pkgName) { // mResources = resources; // mSkinPkgName = pkgName; // isDefaultSkin = mAppContext.getPackageName().equals(pkgName); // } // // public int getColor(int resId) { // int originColor = ContextCompat.getColor(mAppContext, resId); // if (isDefaultSkin) { // return originColor; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? originColor : mResources.getColor(targetResId); // } // // public Drawable getDrawable(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "drawable", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public Drawable getMipmap(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "mipmap", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public ColorStateList getColorStateList(int resId) { // ColorStateList colorStateList = ContextCompat.getColorStateList(mAppContext, resId); // if (isDefaultSkin) { // return colorStateList; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? colorStateList : mResources.getColorStateList(targetResId); // } // } // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // public static final int INVALID_ID = -1; // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // final static public int checkResourceId(int resId) { // String hexResId = Integer.toHexString(resId); // SkinLog.d(TAG, "hexResId = " + hexResId); // return hexResId.startsWith(SYSTEM_ID_PREFIX) ? INVALID_ID : resId; // }
import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.os.Build; import android.support.annotation.DrawableRes; import android.support.v7.widget.AppCompatSpinner; import android.support.v7.widget.TintTypedArray; import android.util.AttributeSet; import android.util.Log; import skin.support.R; import skin.support.content.res.SkinCompatResources; import static skin.support.widget.SkinCompatHelper.INVALID_ID; import static skin.support.widget.SkinCompatHelper.checkResourceId;
} } else { // Else, we use a default mode of dropdown mode = MODE_DROPDOWN; } } if (mode == MODE_DROPDOWN) { final TintTypedArray pa = TintTypedArray.obtainStyledAttributes( getPopupContext(), attrs, R.styleable.Spinner, defStyleAttr, 0); mPopupBackgroundResId = pa.getResourceId(R.styleable.Spinner_android_popupBackground, INVALID_ID); pa.recycle(); } } a.recycle(); mBackgroundTintHelper = new SkinCompatBackgroundHelper(this); mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr); } @Override public void setPopupBackgroundResource(@DrawableRes int resId) { super.setPopupBackgroundResource(resId); mPopupBackgroundResId = resId; applyPopupBackground(); } private void applyPopupBackground() { mPopupBackgroundResId = checkResourceId(mPopupBackgroundResId); if (mPopupBackgroundResId != INVALID_ID) {
// Path: skin-support/src/main/java/skin/support/content/res/SkinCompatResources.java // public class SkinCompatResources { // private static volatile SkinCompatResources sInstance; // private final Context mAppContext; // private Resources mResources; // private String mSkinPkgName; // private boolean isDefaultSkin; // // private SkinCompatResources(Context context) { // mAppContext = context.getApplicationContext(); // setSkinResource(mAppContext.getResources(), mAppContext.getPackageName()); // } // // public static void init(Context context) { // if (sInstance == null) { // synchronized (SkinCompatResources.class) { // if (sInstance == null) { // sInstance = new SkinCompatResources(context); // } // } // } // } // // public static SkinCompatResources getInstance() { // return sInstance; // } // // public void setSkinResource(Resources resources, String pkgName) { // mResources = resources; // mSkinPkgName = pkgName; // isDefaultSkin = mAppContext.getPackageName().equals(pkgName); // } // // public int getColor(int resId) { // int originColor = ContextCompat.getColor(mAppContext, resId); // if (isDefaultSkin) { // return originColor; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? originColor : mResources.getColor(targetResId); // } // // public Drawable getDrawable(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "drawable", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public Drawable getMipmap(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "mipmap", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public ColorStateList getColorStateList(int resId) { // ColorStateList colorStateList = ContextCompat.getColorStateList(mAppContext, resId); // if (isDefaultSkin) { // return colorStateList; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? colorStateList : mResources.getColorStateList(targetResId); // } // } // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // public static final int INVALID_ID = -1; // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // final static public int checkResourceId(int resId) { // String hexResId = Integer.toHexString(resId); // SkinLog.d(TAG, "hexResId = " + hexResId); // return hexResId.startsWith(SYSTEM_ID_PREFIX) ? INVALID_ID : resId; // } // Path: skin-support/src/main/java/skin/support/widget/SkinCompatSpinner.java import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.os.Build; import android.support.annotation.DrawableRes; import android.support.v7.widget.AppCompatSpinner; import android.support.v7.widget.TintTypedArray; import android.util.AttributeSet; import android.util.Log; import skin.support.R; import skin.support.content.res.SkinCompatResources; import static skin.support.widget.SkinCompatHelper.INVALID_ID; import static skin.support.widget.SkinCompatHelper.checkResourceId; } } else { // Else, we use a default mode of dropdown mode = MODE_DROPDOWN; } } if (mode == MODE_DROPDOWN) { final TintTypedArray pa = TintTypedArray.obtainStyledAttributes( getPopupContext(), attrs, R.styleable.Spinner, defStyleAttr, 0); mPopupBackgroundResId = pa.getResourceId(R.styleable.Spinner_android_popupBackground, INVALID_ID); pa.recycle(); } } a.recycle(); mBackgroundTintHelper = new SkinCompatBackgroundHelper(this); mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr); } @Override public void setPopupBackgroundResource(@DrawableRes int resId) { super.setPopupBackgroundResource(resId); mPopupBackgroundResId = resId; applyPopupBackground(); } private void applyPopupBackground() { mPopupBackgroundResId = checkResourceId(mPopupBackgroundResId); if (mPopupBackgroundResId != INVALID_ID) {
setPopupBackgroundDrawable(SkinCompatResources.getInstance().getDrawable(mPopupBackgroundResId));
wutongke/AndroidSkinAnimator
skin-support/src/main/java/skin/support/widget/SkinCompatCheckedTextView.java
// Path: skin-support/src/main/java/skin/support/content/res/SkinCompatResources.java // public class SkinCompatResources { // private static volatile SkinCompatResources sInstance; // private final Context mAppContext; // private Resources mResources; // private String mSkinPkgName; // private boolean isDefaultSkin; // // private SkinCompatResources(Context context) { // mAppContext = context.getApplicationContext(); // setSkinResource(mAppContext.getResources(), mAppContext.getPackageName()); // } // // public static void init(Context context) { // if (sInstance == null) { // synchronized (SkinCompatResources.class) { // if (sInstance == null) { // sInstance = new SkinCompatResources(context); // } // } // } // } // // public static SkinCompatResources getInstance() { // return sInstance; // } // // public void setSkinResource(Resources resources, String pkgName) { // mResources = resources; // mSkinPkgName = pkgName; // isDefaultSkin = mAppContext.getPackageName().equals(pkgName); // } // // public int getColor(int resId) { // int originColor = ContextCompat.getColor(mAppContext, resId); // if (isDefaultSkin) { // return originColor; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? originColor : mResources.getColor(targetResId); // } // // public Drawable getDrawable(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "drawable", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public Drawable getMipmap(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "mipmap", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public ColorStateList getColorStateList(int resId) { // ColorStateList colorStateList = ContextCompat.getColorStateList(mAppContext, resId); // if (isDefaultSkin) { // return colorStateList; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? colorStateList : mResources.getColorStateList(targetResId); // } // } // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // public static final int INVALID_ID = -1;
import android.content.Context; import android.support.annotation.DrawableRes; import android.support.v7.widget.AppCompatCheckedTextView; import android.support.v7.widget.TintTypedArray; import android.util.AttributeSet; import skin.support.content.res.SkinCompatResources; import static skin.support.widget.SkinCompatHelper.INVALID_ID;
package skin.support.widget; /** * Created by ximsfei on 17-1-14. */ public class SkinCompatCheckedTextView extends AppCompatCheckedTextView implements SkinCompatSupportable { private static final int[] TINT_ATTRS = { android.R.attr.checkMark };
// Path: skin-support/src/main/java/skin/support/content/res/SkinCompatResources.java // public class SkinCompatResources { // private static volatile SkinCompatResources sInstance; // private final Context mAppContext; // private Resources mResources; // private String mSkinPkgName; // private boolean isDefaultSkin; // // private SkinCompatResources(Context context) { // mAppContext = context.getApplicationContext(); // setSkinResource(mAppContext.getResources(), mAppContext.getPackageName()); // } // // public static void init(Context context) { // if (sInstance == null) { // synchronized (SkinCompatResources.class) { // if (sInstance == null) { // sInstance = new SkinCompatResources(context); // } // } // } // } // // public static SkinCompatResources getInstance() { // return sInstance; // } // // public void setSkinResource(Resources resources, String pkgName) { // mResources = resources; // mSkinPkgName = pkgName; // isDefaultSkin = mAppContext.getPackageName().equals(pkgName); // } // // public int getColor(int resId) { // int originColor = ContextCompat.getColor(mAppContext, resId); // if (isDefaultSkin) { // return originColor; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? originColor : mResources.getColor(targetResId); // } // // public Drawable getDrawable(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "drawable", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public Drawable getMipmap(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "mipmap", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public ColorStateList getColorStateList(int resId) { // ColorStateList colorStateList = ContextCompat.getColorStateList(mAppContext, resId); // if (isDefaultSkin) { // return colorStateList; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? colorStateList : mResources.getColorStateList(targetResId); // } // } // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // public static final int INVALID_ID = -1; // Path: skin-support/src/main/java/skin/support/widget/SkinCompatCheckedTextView.java import android.content.Context; import android.support.annotation.DrawableRes; import android.support.v7.widget.AppCompatCheckedTextView; import android.support.v7.widget.TintTypedArray; import android.util.AttributeSet; import skin.support.content.res.SkinCompatResources; import static skin.support.widget.SkinCompatHelper.INVALID_ID; package skin.support.widget; /** * Created by ximsfei on 17-1-14. */ public class SkinCompatCheckedTextView extends AppCompatCheckedTextView implements SkinCompatSupportable { private static final int[] TINT_ATTRS = { android.R.attr.checkMark };
private int mCheckMarkResId = INVALID_ID;
wutongke/AndroidSkinAnimator
skin-support/src/main/java/skin/support/widget/SkinCompatCheckedTextView.java
// Path: skin-support/src/main/java/skin/support/content/res/SkinCompatResources.java // public class SkinCompatResources { // private static volatile SkinCompatResources sInstance; // private final Context mAppContext; // private Resources mResources; // private String mSkinPkgName; // private boolean isDefaultSkin; // // private SkinCompatResources(Context context) { // mAppContext = context.getApplicationContext(); // setSkinResource(mAppContext.getResources(), mAppContext.getPackageName()); // } // // public static void init(Context context) { // if (sInstance == null) { // synchronized (SkinCompatResources.class) { // if (sInstance == null) { // sInstance = new SkinCompatResources(context); // } // } // } // } // // public static SkinCompatResources getInstance() { // return sInstance; // } // // public void setSkinResource(Resources resources, String pkgName) { // mResources = resources; // mSkinPkgName = pkgName; // isDefaultSkin = mAppContext.getPackageName().equals(pkgName); // } // // public int getColor(int resId) { // int originColor = ContextCompat.getColor(mAppContext, resId); // if (isDefaultSkin) { // return originColor; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? originColor : mResources.getColor(targetResId); // } // // public Drawable getDrawable(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "drawable", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public Drawable getMipmap(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "mipmap", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public ColorStateList getColorStateList(int resId) { // ColorStateList colorStateList = ContextCompat.getColorStateList(mAppContext, resId); // if (isDefaultSkin) { // return colorStateList; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? colorStateList : mResources.getColorStateList(targetResId); // } // } // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // public static final int INVALID_ID = -1;
import android.content.Context; import android.support.annotation.DrawableRes; import android.support.v7.widget.AppCompatCheckedTextView; import android.support.v7.widget.TintTypedArray; import android.util.AttributeSet; import skin.support.content.res.SkinCompatResources; import static skin.support.widget.SkinCompatHelper.INVALID_ID;
@Override public void setBackgroundResource(@DrawableRes int resId) { super.setBackgroundResource(resId); if (mBackgroundTintHelper != null) { mBackgroundTintHelper.onSetBackgroundResource(resId); } } @Override public void setTextAppearance(Context context, int resId) { super.setTextAppearance(context, resId); if (mTextHelper != null) { mTextHelper.onSetTextAppearance(context, resId); } } @Override public void applySkin() { if (mBackgroundTintHelper != null) { mBackgroundTintHelper.applySkin(); } if (mTextHelper != null) { mTextHelper.applySkin(); } applyCheckMark(); } private void applyCheckMark() { mCheckMarkResId = SkinCompatHelper.checkResourceId(mCheckMarkResId); if (mCheckMarkResId != INVALID_ID) {
// Path: skin-support/src/main/java/skin/support/content/res/SkinCompatResources.java // public class SkinCompatResources { // private static volatile SkinCompatResources sInstance; // private final Context mAppContext; // private Resources mResources; // private String mSkinPkgName; // private boolean isDefaultSkin; // // private SkinCompatResources(Context context) { // mAppContext = context.getApplicationContext(); // setSkinResource(mAppContext.getResources(), mAppContext.getPackageName()); // } // // public static void init(Context context) { // if (sInstance == null) { // synchronized (SkinCompatResources.class) { // if (sInstance == null) { // sInstance = new SkinCompatResources(context); // } // } // } // } // // public static SkinCompatResources getInstance() { // return sInstance; // } // // public void setSkinResource(Resources resources, String pkgName) { // mResources = resources; // mSkinPkgName = pkgName; // isDefaultSkin = mAppContext.getPackageName().equals(pkgName); // } // // public int getColor(int resId) { // int originColor = ContextCompat.getColor(mAppContext, resId); // if (isDefaultSkin) { // return originColor; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? originColor : mResources.getColor(targetResId); // } // // public Drawable getDrawable(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "drawable", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public Drawable getMipmap(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "mipmap", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public ColorStateList getColorStateList(int resId) { // ColorStateList colorStateList = ContextCompat.getColorStateList(mAppContext, resId); // if (isDefaultSkin) { // return colorStateList; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? colorStateList : mResources.getColorStateList(targetResId); // } // } // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // public static final int INVALID_ID = -1; // Path: skin-support/src/main/java/skin/support/widget/SkinCompatCheckedTextView.java import android.content.Context; import android.support.annotation.DrawableRes; import android.support.v7.widget.AppCompatCheckedTextView; import android.support.v7.widget.TintTypedArray; import android.util.AttributeSet; import skin.support.content.res.SkinCompatResources; import static skin.support.widget.SkinCompatHelper.INVALID_ID; @Override public void setBackgroundResource(@DrawableRes int resId) { super.setBackgroundResource(resId); if (mBackgroundTintHelper != null) { mBackgroundTintHelper.onSetBackgroundResource(resId); } } @Override public void setTextAppearance(Context context, int resId) { super.setTextAppearance(context, resId); if (mTextHelper != null) { mTextHelper.onSetTextAppearance(context, resId); } } @Override public void applySkin() { if (mBackgroundTintHelper != null) { mBackgroundTintHelper.applySkin(); } if (mTextHelper != null) { mTextHelper.applySkin(); } applyCheckMark(); } private void applyCheckMark() { mCheckMarkResId = SkinCompatHelper.checkResourceId(mCheckMarkResId); if (mCheckMarkResId != INVALID_ID) {
setCheckMarkDrawable(SkinCompatResources.getInstance().getDrawable(mCheckMarkResId));
wutongke/AndroidSkinAnimator
app/src/main/java/com/ximsfei/skindemo/ui/FriendsFragment.java
// Path: app/src/main/java/com/ximsfei/skindemo/ui/adapter/TabFragmentPagerAdapter.java // public class TabFragmentPagerAdapter extends FragmentPagerAdapter { // // private List<Fragment> mFragments; // private List<String> mTitles; // // public TabFragmentPagerAdapter(FragmentManager fragmentManager, List<Fragment> fragments) { // super(fragmentManager); // mFragments = fragments; // } // // public TabFragmentPagerAdapter(FragmentManager fragmentManager, List<Fragment> fragments, List<String> titles) { // super(fragmentManager); // mFragments = fragments; // mTitles = titles; // } // // @Override // public Fragment getItem(int position) { // return mFragments.get(position); // } // // @Override // public int getCount() { // return mFragments.size(); // } // // @Override // public CharSequence getPageTitle(int position) { // return mTitles != null ? mTitles.get(position) : ""; // } // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/base/BaseFragment.java // public abstract class BaseFragment<VDB extends ViewDataBinding> extends Fragment { // protected VDB mDataBinding; // // @LayoutRes // protected abstract int getLayoutId(); // // @Override // public void onActivityCreated(@Nullable Bundle savedInstanceState) { // super.onActivityCreated(savedInstanceState); // loadData(); // } // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // View view = inflater.inflate(getLayoutId(), null); // mDataBinding = DataBindingUtil.bind(view); // onCreateVew(inflater, savedInstanceState); // return view; // } // // protected void onCreateVew(LayoutInflater inflater, Bundle savedInstanceState) { // // } // // protected abstract void loadData(); // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/friends/ContactsFragment.java // public class ContactsFragment extends BaseFragment { // @Override // protected int getLayoutId() { // return R.layout.fragment_contacts; // } // // @Override // protected void loadData() { // // } // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/friends/FeedsFragment.java // public class FeedsFragment extends BaseFragment { // @Override // protected int getLayoutId() { // return R.layout.fragment_feeds; // } // // @Override // protected void loadData() { // // } // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/friends/NearbyFragment.java // public class NearbyFragment extends BaseFragment { // @Override // protected int getLayoutId() { // return R.layout.fragment_nearby; // } // // @Override // protected void loadData() { // // } // }
import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import com.ximsfei.skindemo.R; import com.ximsfei.skindemo.databinding.FragmentFriendsBinding; import com.ximsfei.skindemo.ui.adapter.TabFragmentPagerAdapter; import com.ximsfei.skindemo.ui.base.BaseFragment; import com.ximsfei.skindemo.ui.friends.ContactsFragment; import com.ximsfei.skindemo.ui.friends.FeedsFragment; import com.ximsfei.skindemo.ui.friends.NearbyFragment; import java.util.ArrayList; import java.util.List;
package com.ximsfei.skindemo.ui; /** * Created by ximsfei on 17-1-7. */ public class FriendsFragment extends BaseFragment<FragmentFriendsBinding> { private TabFragmentPagerAdapter mTabFragmentPagerAdapter; @Override protected int getLayoutId() { return R.layout.fragment_friends; } @Override protected void onCreateVew(LayoutInflater inflater, Bundle savedInstanceState) { super.onCreateVew(inflater, savedInstanceState); configFragments(); } @Override protected void loadData() { } private void configFragments() { List<Fragment> list = new ArrayList<>();
// Path: app/src/main/java/com/ximsfei/skindemo/ui/adapter/TabFragmentPagerAdapter.java // public class TabFragmentPagerAdapter extends FragmentPagerAdapter { // // private List<Fragment> mFragments; // private List<String> mTitles; // // public TabFragmentPagerAdapter(FragmentManager fragmentManager, List<Fragment> fragments) { // super(fragmentManager); // mFragments = fragments; // } // // public TabFragmentPagerAdapter(FragmentManager fragmentManager, List<Fragment> fragments, List<String> titles) { // super(fragmentManager); // mFragments = fragments; // mTitles = titles; // } // // @Override // public Fragment getItem(int position) { // return mFragments.get(position); // } // // @Override // public int getCount() { // return mFragments.size(); // } // // @Override // public CharSequence getPageTitle(int position) { // return mTitles != null ? mTitles.get(position) : ""; // } // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/base/BaseFragment.java // public abstract class BaseFragment<VDB extends ViewDataBinding> extends Fragment { // protected VDB mDataBinding; // // @LayoutRes // protected abstract int getLayoutId(); // // @Override // public void onActivityCreated(@Nullable Bundle savedInstanceState) { // super.onActivityCreated(savedInstanceState); // loadData(); // } // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // View view = inflater.inflate(getLayoutId(), null); // mDataBinding = DataBindingUtil.bind(view); // onCreateVew(inflater, savedInstanceState); // return view; // } // // protected void onCreateVew(LayoutInflater inflater, Bundle savedInstanceState) { // // } // // protected abstract void loadData(); // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/friends/ContactsFragment.java // public class ContactsFragment extends BaseFragment { // @Override // protected int getLayoutId() { // return R.layout.fragment_contacts; // } // // @Override // protected void loadData() { // // } // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/friends/FeedsFragment.java // public class FeedsFragment extends BaseFragment { // @Override // protected int getLayoutId() { // return R.layout.fragment_feeds; // } // // @Override // protected void loadData() { // // } // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/friends/NearbyFragment.java // public class NearbyFragment extends BaseFragment { // @Override // protected int getLayoutId() { // return R.layout.fragment_nearby; // } // // @Override // protected void loadData() { // // } // } // Path: app/src/main/java/com/ximsfei/skindemo/ui/FriendsFragment.java import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import com.ximsfei.skindemo.R; import com.ximsfei.skindemo.databinding.FragmentFriendsBinding; import com.ximsfei.skindemo.ui.adapter.TabFragmentPagerAdapter; import com.ximsfei.skindemo.ui.base.BaseFragment; import com.ximsfei.skindemo.ui.friends.ContactsFragment; import com.ximsfei.skindemo.ui.friends.FeedsFragment; import com.ximsfei.skindemo.ui.friends.NearbyFragment; import java.util.ArrayList; import java.util.List; package com.ximsfei.skindemo.ui; /** * Created by ximsfei on 17-1-7. */ public class FriendsFragment extends BaseFragment<FragmentFriendsBinding> { private TabFragmentPagerAdapter mTabFragmentPagerAdapter; @Override protected int getLayoutId() { return R.layout.fragment_friends; } @Override protected void onCreateVew(LayoutInflater inflater, Bundle savedInstanceState) { super.onCreateVew(inflater, savedInstanceState); configFragments(); } @Override protected void loadData() { } private void configFragments() { List<Fragment> list = new ArrayList<>();
list.add(new FeedsFragment());
wutongke/AndroidSkinAnimator
app/src/main/java/com/ximsfei/skindemo/ui/FriendsFragment.java
// Path: app/src/main/java/com/ximsfei/skindemo/ui/adapter/TabFragmentPagerAdapter.java // public class TabFragmentPagerAdapter extends FragmentPagerAdapter { // // private List<Fragment> mFragments; // private List<String> mTitles; // // public TabFragmentPagerAdapter(FragmentManager fragmentManager, List<Fragment> fragments) { // super(fragmentManager); // mFragments = fragments; // } // // public TabFragmentPagerAdapter(FragmentManager fragmentManager, List<Fragment> fragments, List<String> titles) { // super(fragmentManager); // mFragments = fragments; // mTitles = titles; // } // // @Override // public Fragment getItem(int position) { // return mFragments.get(position); // } // // @Override // public int getCount() { // return mFragments.size(); // } // // @Override // public CharSequence getPageTitle(int position) { // return mTitles != null ? mTitles.get(position) : ""; // } // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/base/BaseFragment.java // public abstract class BaseFragment<VDB extends ViewDataBinding> extends Fragment { // protected VDB mDataBinding; // // @LayoutRes // protected abstract int getLayoutId(); // // @Override // public void onActivityCreated(@Nullable Bundle savedInstanceState) { // super.onActivityCreated(savedInstanceState); // loadData(); // } // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // View view = inflater.inflate(getLayoutId(), null); // mDataBinding = DataBindingUtil.bind(view); // onCreateVew(inflater, savedInstanceState); // return view; // } // // protected void onCreateVew(LayoutInflater inflater, Bundle savedInstanceState) { // // } // // protected abstract void loadData(); // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/friends/ContactsFragment.java // public class ContactsFragment extends BaseFragment { // @Override // protected int getLayoutId() { // return R.layout.fragment_contacts; // } // // @Override // protected void loadData() { // // } // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/friends/FeedsFragment.java // public class FeedsFragment extends BaseFragment { // @Override // protected int getLayoutId() { // return R.layout.fragment_feeds; // } // // @Override // protected void loadData() { // // } // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/friends/NearbyFragment.java // public class NearbyFragment extends BaseFragment { // @Override // protected int getLayoutId() { // return R.layout.fragment_nearby; // } // // @Override // protected void loadData() { // // } // }
import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import com.ximsfei.skindemo.R; import com.ximsfei.skindemo.databinding.FragmentFriendsBinding; import com.ximsfei.skindemo.ui.adapter.TabFragmentPagerAdapter; import com.ximsfei.skindemo.ui.base.BaseFragment; import com.ximsfei.skindemo.ui.friends.ContactsFragment; import com.ximsfei.skindemo.ui.friends.FeedsFragment; import com.ximsfei.skindemo.ui.friends.NearbyFragment; import java.util.ArrayList; import java.util.List;
package com.ximsfei.skindemo.ui; /** * Created by ximsfei on 17-1-7. */ public class FriendsFragment extends BaseFragment<FragmentFriendsBinding> { private TabFragmentPagerAdapter mTabFragmentPagerAdapter; @Override protected int getLayoutId() { return R.layout.fragment_friends; } @Override protected void onCreateVew(LayoutInflater inflater, Bundle savedInstanceState) { super.onCreateVew(inflater, savedInstanceState); configFragments(); } @Override protected void loadData() { } private void configFragments() { List<Fragment> list = new ArrayList<>(); list.add(new FeedsFragment());
// Path: app/src/main/java/com/ximsfei/skindemo/ui/adapter/TabFragmentPagerAdapter.java // public class TabFragmentPagerAdapter extends FragmentPagerAdapter { // // private List<Fragment> mFragments; // private List<String> mTitles; // // public TabFragmentPagerAdapter(FragmentManager fragmentManager, List<Fragment> fragments) { // super(fragmentManager); // mFragments = fragments; // } // // public TabFragmentPagerAdapter(FragmentManager fragmentManager, List<Fragment> fragments, List<String> titles) { // super(fragmentManager); // mFragments = fragments; // mTitles = titles; // } // // @Override // public Fragment getItem(int position) { // return mFragments.get(position); // } // // @Override // public int getCount() { // return mFragments.size(); // } // // @Override // public CharSequence getPageTitle(int position) { // return mTitles != null ? mTitles.get(position) : ""; // } // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/base/BaseFragment.java // public abstract class BaseFragment<VDB extends ViewDataBinding> extends Fragment { // protected VDB mDataBinding; // // @LayoutRes // protected abstract int getLayoutId(); // // @Override // public void onActivityCreated(@Nullable Bundle savedInstanceState) { // super.onActivityCreated(savedInstanceState); // loadData(); // } // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // View view = inflater.inflate(getLayoutId(), null); // mDataBinding = DataBindingUtil.bind(view); // onCreateVew(inflater, savedInstanceState); // return view; // } // // protected void onCreateVew(LayoutInflater inflater, Bundle savedInstanceState) { // // } // // protected abstract void loadData(); // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/friends/ContactsFragment.java // public class ContactsFragment extends BaseFragment { // @Override // protected int getLayoutId() { // return R.layout.fragment_contacts; // } // // @Override // protected void loadData() { // // } // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/friends/FeedsFragment.java // public class FeedsFragment extends BaseFragment { // @Override // protected int getLayoutId() { // return R.layout.fragment_feeds; // } // // @Override // protected void loadData() { // // } // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/friends/NearbyFragment.java // public class NearbyFragment extends BaseFragment { // @Override // protected int getLayoutId() { // return R.layout.fragment_nearby; // } // // @Override // protected void loadData() { // // } // } // Path: app/src/main/java/com/ximsfei/skindemo/ui/FriendsFragment.java import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import com.ximsfei.skindemo.R; import com.ximsfei.skindemo.databinding.FragmentFriendsBinding; import com.ximsfei.skindemo.ui.adapter.TabFragmentPagerAdapter; import com.ximsfei.skindemo.ui.base.BaseFragment; import com.ximsfei.skindemo.ui.friends.ContactsFragment; import com.ximsfei.skindemo.ui.friends.FeedsFragment; import com.ximsfei.skindemo.ui.friends.NearbyFragment; import java.util.ArrayList; import java.util.List; package com.ximsfei.skindemo.ui; /** * Created by ximsfei on 17-1-7. */ public class FriendsFragment extends BaseFragment<FragmentFriendsBinding> { private TabFragmentPagerAdapter mTabFragmentPagerAdapter; @Override protected int getLayoutId() { return R.layout.fragment_friends; } @Override protected void onCreateVew(LayoutInflater inflater, Bundle savedInstanceState) { super.onCreateVew(inflater, savedInstanceState); configFragments(); } @Override protected void loadData() { } private void configFragments() { List<Fragment> list = new ArrayList<>(); list.add(new FeedsFragment());
list.add(new NearbyFragment());
wutongke/AndroidSkinAnimator
app/src/main/java/com/ximsfei/skindemo/ui/FriendsFragment.java
// Path: app/src/main/java/com/ximsfei/skindemo/ui/adapter/TabFragmentPagerAdapter.java // public class TabFragmentPagerAdapter extends FragmentPagerAdapter { // // private List<Fragment> mFragments; // private List<String> mTitles; // // public TabFragmentPagerAdapter(FragmentManager fragmentManager, List<Fragment> fragments) { // super(fragmentManager); // mFragments = fragments; // } // // public TabFragmentPagerAdapter(FragmentManager fragmentManager, List<Fragment> fragments, List<String> titles) { // super(fragmentManager); // mFragments = fragments; // mTitles = titles; // } // // @Override // public Fragment getItem(int position) { // return mFragments.get(position); // } // // @Override // public int getCount() { // return mFragments.size(); // } // // @Override // public CharSequence getPageTitle(int position) { // return mTitles != null ? mTitles.get(position) : ""; // } // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/base/BaseFragment.java // public abstract class BaseFragment<VDB extends ViewDataBinding> extends Fragment { // protected VDB mDataBinding; // // @LayoutRes // protected abstract int getLayoutId(); // // @Override // public void onActivityCreated(@Nullable Bundle savedInstanceState) { // super.onActivityCreated(savedInstanceState); // loadData(); // } // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // View view = inflater.inflate(getLayoutId(), null); // mDataBinding = DataBindingUtil.bind(view); // onCreateVew(inflater, savedInstanceState); // return view; // } // // protected void onCreateVew(LayoutInflater inflater, Bundle savedInstanceState) { // // } // // protected abstract void loadData(); // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/friends/ContactsFragment.java // public class ContactsFragment extends BaseFragment { // @Override // protected int getLayoutId() { // return R.layout.fragment_contacts; // } // // @Override // protected void loadData() { // // } // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/friends/FeedsFragment.java // public class FeedsFragment extends BaseFragment { // @Override // protected int getLayoutId() { // return R.layout.fragment_feeds; // } // // @Override // protected void loadData() { // // } // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/friends/NearbyFragment.java // public class NearbyFragment extends BaseFragment { // @Override // protected int getLayoutId() { // return R.layout.fragment_nearby; // } // // @Override // protected void loadData() { // // } // }
import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import com.ximsfei.skindemo.R; import com.ximsfei.skindemo.databinding.FragmentFriendsBinding; import com.ximsfei.skindemo.ui.adapter.TabFragmentPagerAdapter; import com.ximsfei.skindemo.ui.base.BaseFragment; import com.ximsfei.skindemo.ui.friends.ContactsFragment; import com.ximsfei.skindemo.ui.friends.FeedsFragment; import com.ximsfei.skindemo.ui.friends.NearbyFragment; import java.util.ArrayList; import java.util.List;
package com.ximsfei.skindemo.ui; /** * Created by ximsfei on 17-1-7. */ public class FriendsFragment extends BaseFragment<FragmentFriendsBinding> { private TabFragmentPagerAdapter mTabFragmentPagerAdapter; @Override protected int getLayoutId() { return R.layout.fragment_friends; } @Override protected void onCreateVew(LayoutInflater inflater, Bundle savedInstanceState) { super.onCreateVew(inflater, savedInstanceState); configFragments(); } @Override protected void loadData() { } private void configFragments() { List<Fragment> list = new ArrayList<>(); list.add(new FeedsFragment()); list.add(new NearbyFragment());
// Path: app/src/main/java/com/ximsfei/skindemo/ui/adapter/TabFragmentPagerAdapter.java // public class TabFragmentPagerAdapter extends FragmentPagerAdapter { // // private List<Fragment> mFragments; // private List<String> mTitles; // // public TabFragmentPagerAdapter(FragmentManager fragmentManager, List<Fragment> fragments) { // super(fragmentManager); // mFragments = fragments; // } // // public TabFragmentPagerAdapter(FragmentManager fragmentManager, List<Fragment> fragments, List<String> titles) { // super(fragmentManager); // mFragments = fragments; // mTitles = titles; // } // // @Override // public Fragment getItem(int position) { // return mFragments.get(position); // } // // @Override // public int getCount() { // return mFragments.size(); // } // // @Override // public CharSequence getPageTitle(int position) { // return mTitles != null ? mTitles.get(position) : ""; // } // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/base/BaseFragment.java // public abstract class BaseFragment<VDB extends ViewDataBinding> extends Fragment { // protected VDB mDataBinding; // // @LayoutRes // protected abstract int getLayoutId(); // // @Override // public void onActivityCreated(@Nullable Bundle savedInstanceState) { // super.onActivityCreated(savedInstanceState); // loadData(); // } // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // View view = inflater.inflate(getLayoutId(), null); // mDataBinding = DataBindingUtil.bind(view); // onCreateVew(inflater, savedInstanceState); // return view; // } // // protected void onCreateVew(LayoutInflater inflater, Bundle savedInstanceState) { // // } // // protected abstract void loadData(); // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/friends/ContactsFragment.java // public class ContactsFragment extends BaseFragment { // @Override // protected int getLayoutId() { // return R.layout.fragment_contacts; // } // // @Override // protected void loadData() { // // } // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/friends/FeedsFragment.java // public class FeedsFragment extends BaseFragment { // @Override // protected int getLayoutId() { // return R.layout.fragment_feeds; // } // // @Override // protected void loadData() { // // } // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/friends/NearbyFragment.java // public class NearbyFragment extends BaseFragment { // @Override // protected int getLayoutId() { // return R.layout.fragment_nearby; // } // // @Override // protected void loadData() { // // } // } // Path: app/src/main/java/com/ximsfei/skindemo/ui/FriendsFragment.java import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import com.ximsfei.skindemo.R; import com.ximsfei.skindemo.databinding.FragmentFriendsBinding; import com.ximsfei.skindemo.ui.adapter.TabFragmentPagerAdapter; import com.ximsfei.skindemo.ui.base.BaseFragment; import com.ximsfei.skindemo.ui.friends.ContactsFragment; import com.ximsfei.skindemo.ui.friends.FeedsFragment; import com.ximsfei.skindemo.ui.friends.NearbyFragment; import java.util.ArrayList; import java.util.List; package com.ximsfei.skindemo.ui; /** * Created by ximsfei on 17-1-7. */ public class FriendsFragment extends BaseFragment<FragmentFriendsBinding> { private TabFragmentPagerAdapter mTabFragmentPagerAdapter; @Override protected int getLayoutId() { return R.layout.fragment_friends; } @Override protected void onCreateVew(LayoutInflater inflater, Bundle savedInstanceState) { super.onCreateVew(inflater, savedInstanceState); configFragments(); } @Override protected void loadData() { } private void configFragments() { List<Fragment> list = new ArrayList<>(); list.add(new FeedsFragment()); list.add(new NearbyFragment());
list.add(new ContactsFragment());
wutongke/AndroidSkinAnimator
skin-support/src/main/java/skin/support/animator/SingleAnimator/hide/AlphaHideAnimator.java
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorImpl.java // public abstract class ViewAnimatorImpl implements SkinAnimator { // @Override // public abstract SkinAnimator apply(@NonNull View view, @Nullable Action action); // // @Override // public SkinAnimator setPreDuration() { // return this; // } // // @Override // public SkinAnimator setAfterDuration() { // return this; // } // // @Override // public SkinAnimator setDuration() { // return this; // } // // @Override // public abstract void start(); // // protected void resetView(View view) { // view.setAlpha(1); // view.setScaleY(1); // view.setScaleX(1); // view.setRotation(0); // view.setTranslationX(0); // view.setTranslationY(0); // view.setPivotX(view.getWidth() / 2); // view.setPivotY(view.getHeight() / 2); // } // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // }
import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import android.view.animation.LinearInterpolator; import skin.support.animator.Action; import skin.support.animator.SingleAnimator.ViewAnimatorImpl; import skin.support.animator.SkinAnimator;
package skin.support.animator.SingleAnimator.hide; /** * Created by erfli on 2/25/17. */ public class AlphaHideAnimator extends ViewAnimatorImpl { private ObjectAnimator animator; private AlphaHideAnimator() { } public static AlphaHideAnimator getInstance() { return new AlphaHideAnimator(); } @Override
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorImpl.java // public abstract class ViewAnimatorImpl implements SkinAnimator { // @Override // public abstract SkinAnimator apply(@NonNull View view, @Nullable Action action); // // @Override // public SkinAnimator setPreDuration() { // return this; // } // // @Override // public SkinAnimator setAfterDuration() { // return this; // } // // @Override // public SkinAnimator setDuration() { // return this; // } // // @Override // public abstract void start(); // // protected void resetView(View view) { // view.setAlpha(1); // view.setScaleY(1); // view.setScaleX(1); // view.setRotation(0); // view.setTranslationX(0); // view.setTranslationY(0); // view.setPivotX(view.getWidth() / 2); // view.setPivotY(view.getHeight() / 2); // } // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // } // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/hide/AlphaHideAnimator.java import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import android.view.animation.LinearInterpolator; import skin.support.animator.Action; import skin.support.animator.SingleAnimator.ViewAnimatorImpl; import skin.support.animator.SkinAnimator; package skin.support.animator.SingleAnimator.hide; /** * Created by erfli on 2/25/17. */ public class AlphaHideAnimator extends ViewAnimatorImpl { private ObjectAnimator animator; private AlphaHideAnimator() { } public static AlphaHideAnimator getInstance() { return new AlphaHideAnimator(); } @Override
public SkinAnimator apply(@NonNull final View view, @Nullable final Action action) {
wutongke/AndroidSkinAnimator
skin-support/src/main/java/skin/support/animator/SingleAnimator/hide/AlphaHideAnimator.java
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorImpl.java // public abstract class ViewAnimatorImpl implements SkinAnimator { // @Override // public abstract SkinAnimator apply(@NonNull View view, @Nullable Action action); // // @Override // public SkinAnimator setPreDuration() { // return this; // } // // @Override // public SkinAnimator setAfterDuration() { // return this; // } // // @Override // public SkinAnimator setDuration() { // return this; // } // // @Override // public abstract void start(); // // protected void resetView(View view) { // view.setAlpha(1); // view.setScaleY(1); // view.setScaleX(1); // view.setRotation(0); // view.setTranslationX(0); // view.setTranslationY(0); // view.setPivotX(view.getWidth() / 2); // view.setPivotY(view.getHeight() / 2); // } // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // }
import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import android.view.animation.LinearInterpolator; import skin.support.animator.Action; import skin.support.animator.SingleAnimator.ViewAnimatorImpl; import skin.support.animator.SkinAnimator;
package skin.support.animator.SingleAnimator.hide; /** * Created by erfli on 2/25/17. */ public class AlphaHideAnimator extends ViewAnimatorImpl { private ObjectAnimator animator; private AlphaHideAnimator() { } public static AlphaHideAnimator getInstance() { return new AlphaHideAnimator(); } @Override
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorImpl.java // public abstract class ViewAnimatorImpl implements SkinAnimator { // @Override // public abstract SkinAnimator apply(@NonNull View view, @Nullable Action action); // // @Override // public SkinAnimator setPreDuration() { // return this; // } // // @Override // public SkinAnimator setAfterDuration() { // return this; // } // // @Override // public SkinAnimator setDuration() { // return this; // } // // @Override // public abstract void start(); // // protected void resetView(View view) { // view.setAlpha(1); // view.setScaleY(1); // view.setScaleX(1); // view.setRotation(0); // view.setTranslationX(0); // view.setTranslationY(0); // view.setPivotX(view.getWidth() / 2); // view.setPivotY(view.getHeight() / 2); // } // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // } // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/hide/AlphaHideAnimator.java import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import android.view.animation.LinearInterpolator; import skin.support.animator.Action; import skin.support.animator.SingleAnimator.ViewAnimatorImpl; import skin.support.animator.SkinAnimator; package skin.support.animator.SingleAnimator.hide; /** * Created by erfli on 2/25/17. */ public class AlphaHideAnimator extends ViewAnimatorImpl { private ObjectAnimator animator; private AlphaHideAnimator() { } public static AlphaHideAnimator getInstance() { return new AlphaHideAnimator(); } @Override
public SkinAnimator apply(@NonNull final View view, @Nullable final Action action) {
wutongke/AndroidSkinAnimator
app/src/main/java/com/ximsfei/skindemo/ui/adapter/RecommendAdapter.java
// Path: app/src/main/java/com/ximsfei/skindemo/bean/RecommendItem.java // public class RecommendItem { // public String title; // public int indicator; // // public ImageItem item0; // public ImageItem item1; // public ImageItem item2; // public ImageItem item3; // public ImageItem item4; // public ImageItem item5; // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/adapter/baseadapter/BaseRecyclerViewAdapter.java // public abstract class BaseRecyclerViewAdapter<T> extends RecyclerView.Adapter<BaseRecyclerViewHolder> { // // protected List<T> data = new ArrayList<>(); // protected OnItemClickListener<T> listener; // // @Override // public void onBindViewHolder(BaseRecyclerViewHolder holder, final int position) { // holder.onBaseBindViewHolder(data.get(position), position); // } // // @Override // public int getItemCount() { // return data.size(); // } // // public void addAll(List<T> data) { // this.data.addAll(data); // } // // public void add(T object) { // data.add(object); // } // // public void clear() { // data.clear(); // } // // public void remove(T object) { // data.remove(object); // } // // public void remove(int position) { // data.remove(position); // } // // public void removeAll(List<T> data) { // this.data.retainAll(data); // } // // public void setOnItemClickListener(OnItemClickListener<T> listener) { // this.listener = listener; // } // // public List<T> getData() { // return data; // } // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/adapter/baseadapter/BaseRecyclerViewHolder.java // public abstract class BaseRecyclerViewHolder<T, D extends ViewDataBinding> extends RecyclerView.ViewHolder { // // public D mBinding; // // public BaseRecyclerViewHolder(ViewGroup viewGroup, int layoutId) { // super(DataBindingUtil.inflate(LayoutInflater.from(viewGroup.getContext()), layoutId, viewGroup, false).getRoot()); // mBinding = DataBindingUtil.getBinding(this.itemView); // } // // /** // * @param bean the data of bind // * @param position the item position of recyclerView // */ // public abstract void onBindViewHolder(T bean, final int position); // // /** // * 当数据改变时,binding会在下一帧去改变数据,如果我们需要立即改变,就去调用executePendingBindings方法。 // */ // void onBaseBindViewHolder(T object, final int position) { // onBindViewHolder(object, position); // mBinding.executePendingBindings(); // } // }
import android.content.Context; import android.view.LayoutInflater; import android.view.ViewGroup; import com.bumptech.glide.Glide; import com.ximsfei.skindemo.R; import com.ximsfei.skindemo.bean.RecommendItem; import com.ximsfei.skindemo.databinding.RecommendItemBinding; import com.ximsfei.skindemo.ui.adapter.baseadapter.BaseRecyclerViewAdapter; import com.ximsfei.skindemo.ui.adapter.baseadapter.BaseRecyclerViewHolder;
package com.ximsfei.skindemo.ui.adapter; /** * Created by ximsfei on 2017/1/15. */ public class RecommendAdapter extends BaseRecyclerViewAdapter<RecommendItem> { public static final int TYPE_SONG_MENU = 1; public static final int TYPE_UNIQUE = 2; public static final int TYPE_LASTEST = 3; public static final int TYPE_MV = 4; public static final int TYPE_RADIO = 5; public RecommendAdapter(Context context) { } @Override
// Path: app/src/main/java/com/ximsfei/skindemo/bean/RecommendItem.java // public class RecommendItem { // public String title; // public int indicator; // // public ImageItem item0; // public ImageItem item1; // public ImageItem item2; // public ImageItem item3; // public ImageItem item4; // public ImageItem item5; // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/adapter/baseadapter/BaseRecyclerViewAdapter.java // public abstract class BaseRecyclerViewAdapter<T> extends RecyclerView.Adapter<BaseRecyclerViewHolder> { // // protected List<T> data = new ArrayList<>(); // protected OnItemClickListener<T> listener; // // @Override // public void onBindViewHolder(BaseRecyclerViewHolder holder, final int position) { // holder.onBaseBindViewHolder(data.get(position), position); // } // // @Override // public int getItemCount() { // return data.size(); // } // // public void addAll(List<T> data) { // this.data.addAll(data); // } // // public void add(T object) { // data.add(object); // } // // public void clear() { // data.clear(); // } // // public void remove(T object) { // data.remove(object); // } // // public void remove(int position) { // data.remove(position); // } // // public void removeAll(List<T> data) { // this.data.retainAll(data); // } // // public void setOnItemClickListener(OnItemClickListener<T> listener) { // this.listener = listener; // } // // public List<T> getData() { // return data; // } // } // // Path: app/src/main/java/com/ximsfei/skindemo/ui/adapter/baseadapter/BaseRecyclerViewHolder.java // public abstract class BaseRecyclerViewHolder<T, D extends ViewDataBinding> extends RecyclerView.ViewHolder { // // public D mBinding; // // public BaseRecyclerViewHolder(ViewGroup viewGroup, int layoutId) { // super(DataBindingUtil.inflate(LayoutInflater.from(viewGroup.getContext()), layoutId, viewGroup, false).getRoot()); // mBinding = DataBindingUtil.getBinding(this.itemView); // } // // /** // * @param bean the data of bind // * @param position the item position of recyclerView // */ // public abstract void onBindViewHolder(T bean, final int position); // // /** // * 当数据改变时,binding会在下一帧去改变数据,如果我们需要立即改变,就去调用executePendingBindings方法。 // */ // void onBaseBindViewHolder(T object, final int position) { // onBindViewHolder(object, position); // mBinding.executePendingBindings(); // } // } // Path: app/src/main/java/com/ximsfei/skindemo/ui/adapter/RecommendAdapter.java import android.content.Context; import android.view.LayoutInflater; import android.view.ViewGroup; import com.bumptech.glide.Glide; import com.ximsfei.skindemo.R; import com.ximsfei.skindemo.bean.RecommendItem; import com.ximsfei.skindemo.databinding.RecommendItemBinding; import com.ximsfei.skindemo.ui.adapter.baseadapter.BaseRecyclerViewAdapter; import com.ximsfei.skindemo.ui.adapter.baseadapter.BaseRecyclerViewHolder; package com.ximsfei.skindemo.ui.adapter; /** * Created by ximsfei on 2017/1/15. */ public class RecommendAdapter extends BaseRecyclerViewAdapter<RecommendItem> { public static final int TYPE_SONG_MENU = 1; public static final int TYPE_UNIQUE = 2; public static final int TYPE_LASTEST = 3; public static final int TYPE_MV = 4; public static final int TYPE_RADIO = 5; public RecommendAdapter(Context context) { } @Override
public BaseRecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
wutongke/AndroidSkinAnimator
skin-support/src/main/java/skin/support/animator/activityAnimator/SkinRotateAnimator3.java
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // }
import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.LinearInterpolator; import skin.support.animator.Action; import skin.support.animator.SkinAnimator;
package skin.support.animator.activityAnimator; /** * Created by erfli on 2/25/17. */ public class SkinRotateAnimator3 implements SkinAnimator { protected ObjectAnimator preAnimator; protected View targetView; private SkinRotateAnimator3() { } public static SkinRotateAnimator3 getInstance() { SkinRotateAnimator3 skinAlphaAnimator = new SkinRotateAnimator3(); return skinAlphaAnimator; } @Override
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // } // Path: skin-support/src/main/java/skin/support/animator/activityAnimator/SkinRotateAnimator3.java import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.LinearInterpolator; import skin.support.animator.Action; import skin.support.animator.SkinAnimator; package skin.support.animator.activityAnimator; /** * Created by erfli on 2/25/17. */ public class SkinRotateAnimator3 implements SkinAnimator { protected ObjectAnimator preAnimator; protected View targetView; private SkinRotateAnimator3() { } public static SkinRotateAnimator3 getInstance() { SkinRotateAnimator3 skinAlphaAnimator = new SkinRotateAnimator3(); return skinAlphaAnimator; } @Override
public SkinAnimator apply(@NonNull View view, @Nullable final Action action) {
wutongke/AndroidSkinAnimator
skin-support-design/src/main/java/skin/support/design/widget/SkinCompatTabLayout.java
// Path: skin-support/src/main/java/skin/support/content/res/SkinCompatResources.java // public class SkinCompatResources { // private static volatile SkinCompatResources sInstance; // private final Context mAppContext; // private Resources mResources; // private String mSkinPkgName; // private boolean isDefaultSkin; // // private SkinCompatResources(Context context) { // mAppContext = context.getApplicationContext(); // setSkinResource(mAppContext.getResources(), mAppContext.getPackageName()); // } // // public static void init(Context context) { // if (sInstance == null) { // synchronized (SkinCompatResources.class) { // if (sInstance == null) { // sInstance = new SkinCompatResources(context); // } // } // } // } // // public static SkinCompatResources getInstance() { // return sInstance; // } // // public void setSkinResource(Resources resources, String pkgName) { // mResources = resources; // mSkinPkgName = pkgName; // isDefaultSkin = mAppContext.getPackageName().equals(pkgName); // } // // public int getColor(int resId) { // int originColor = ContextCompat.getColor(mAppContext, resId); // if (isDefaultSkin) { // return originColor; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? originColor : mResources.getColor(targetResId); // } // // public Drawable getDrawable(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "drawable", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public Drawable getMipmap(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "mipmap", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public ColorStateList getColorStateList(int resId) { // ColorStateList colorStateList = ContextCompat.getColorStateList(mAppContext, resId); // if (isDefaultSkin) { // return colorStateList; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? colorStateList : mResources.getColorStateList(targetResId); // } // } // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // public abstract class SkinCompatHelper { // protected static final String TAG = SkinCompatHelper.class.getSimpleName(); // protected static final String SYSTEM_ID_PREFIX = "1"; // public static final int INVALID_ID = -1; // // final static public int checkResourceId(int resId) { // String hexResId = Integer.toHexString(resId); // SkinLog.d(TAG, "hexResId = " + hexResId); // return hexResId.startsWith(SYSTEM_ID_PREFIX) ? INVALID_ID : resId; // } // // abstract public void applySkin(); // } // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatSupportable.java // public interface SkinCompatSupportable { // void applySkin(); // } // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // public static final int INVALID_ID = -1;
import android.content.Context; import android.content.res.ColorStateList; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.os.Build; import android.support.design.widget.TabLayout; import android.support.v4.graphics.drawable.DrawableCompat; import android.util.AttributeSet; import skin.support.content.res.SkinCompatResources; import skin.support.design.R; import skin.support.widget.SkinCompatHelper; import skin.support.widget.SkinCompatSupportable; import static skin.support.widget.SkinCompatHelper.INVALID_ID;
mTabIndicatorColorResId = a.getResourceId(R.styleable.TabLayout_tabIndicatorColor, INVALID_ID); int tabTextAppearance = a.getResourceId(R.styleable.TabLayout_tabTextAppearance, R.style.TextAppearance_Design_Tab); // Text colors/sizes come from the text appearance first final TypedArray ta = context.obtainStyledAttributes(tabTextAppearance, R.styleable.SkinTextAppearance); try { mTabTextColorsResId = ta.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID); } finally { ta.recycle(); } if (a.hasValue(R.styleable.TabLayout_tabTextColor)) { // If we have an explicit text color set, use it instead mTabTextColorsResId = a.getResourceId(R.styleable.TabLayout_tabTextColor, INVALID_ID); } if (a.hasValue(R.styleable.TabLayout_tabSelectedTextColor)) { // We have an explicit selected text color set, so we need to make merge it with the // current colors. This is exposed so that developers can use theme attributes to set // this (theme attrs in ColorStateLists are Lollipop+) mTabSelectedTextColorResId = a.getResourceId(R.styleable.TabLayout_tabSelectedTextColor, INVALID_ID); } a.recycle(); applySkin(); } @Override public void applySkin() { int tabTextColor = INVALID_ID;
// Path: skin-support/src/main/java/skin/support/content/res/SkinCompatResources.java // public class SkinCompatResources { // private static volatile SkinCompatResources sInstance; // private final Context mAppContext; // private Resources mResources; // private String mSkinPkgName; // private boolean isDefaultSkin; // // private SkinCompatResources(Context context) { // mAppContext = context.getApplicationContext(); // setSkinResource(mAppContext.getResources(), mAppContext.getPackageName()); // } // // public static void init(Context context) { // if (sInstance == null) { // synchronized (SkinCompatResources.class) { // if (sInstance == null) { // sInstance = new SkinCompatResources(context); // } // } // } // } // // public static SkinCompatResources getInstance() { // return sInstance; // } // // public void setSkinResource(Resources resources, String pkgName) { // mResources = resources; // mSkinPkgName = pkgName; // isDefaultSkin = mAppContext.getPackageName().equals(pkgName); // } // // public int getColor(int resId) { // int originColor = ContextCompat.getColor(mAppContext, resId); // if (isDefaultSkin) { // return originColor; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? originColor : mResources.getColor(targetResId); // } // // public Drawable getDrawable(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "drawable", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public Drawable getMipmap(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "mipmap", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public ColorStateList getColorStateList(int resId) { // ColorStateList colorStateList = ContextCompat.getColorStateList(mAppContext, resId); // if (isDefaultSkin) { // return colorStateList; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? colorStateList : mResources.getColorStateList(targetResId); // } // } // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // public abstract class SkinCompatHelper { // protected static final String TAG = SkinCompatHelper.class.getSimpleName(); // protected static final String SYSTEM_ID_PREFIX = "1"; // public static final int INVALID_ID = -1; // // final static public int checkResourceId(int resId) { // String hexResId = Integer.toHexString(resId); // SkinLog.d(TAG, "hexResId = " + hexResId); // return hexResId.startsWith(SYSTEM_ID_PREFIX) ? INVALID_ID : resId; // } // // abstract public void applySkin(); // } // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatSupportable.java // public interface SkinCompatSupportable { // void applySkin(); // } // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // public static final int INVALID_ID = -1; // Path: skin-support-design/src/main/java/skin/support/design/widget/SkinCompatTabLayout.java import android.content.Context; import android.content.res.ColorStateList; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.os.Build; import android.support.design.widget.TabLayout; import android.support.v4.graphics.drawable.DrawableCompat; import android.util.AttributeSet; import skin.support.content.res.SkinCompatResources; import skin.support.design.R; import skin.support.widget.SkinCompatHelper; import skin.support.widget.SkinCompatSupportable; import static skin.support.widget.SkinCompatHelper.INVALID_ID; mTabIndicatorColorResId = a.getResourceId(R.styleable.TabLayout_tabIndicatorColor, INVALID_ID); int tabTextAppearance = a.getResourceId(R.styleable.TabLayout_tabTextAppearance, R.style.TextAppearance_Design_Tab); // Text colors/sizes come from the text appearance first final TypedArray ta = context.obtainStyledAttributes(tabTextAppearance, R.styleable.SkinTextAppearance); try { mTabTextColorsResId = ta.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID); } finally { ta.recycle(); } if (a.hasValue(R.styleable.TabLayout_tabTextColor)) { // If we have an explicit text color set, use it instead mTabTextColorsResId = a.getResourceId(R.styleable.TabLayout_tabTextColor, INVALID_ID); } if (a.hasValue(R.styleable.TabLayout_tabSelectedTextColor)) { // We have an explicit selected text color set, so we need to make merge it with the // current colors. This is exposed so that developers can use theme attributes to set // this (theme attrs in ColorStateLists are Lollipop+) mTabSelectedTextColorResId = a.getResourceId(R.styleable.TabLayout_tabSelectedTextColor, INVALID_ID); } a.recycle(); applySkin(); } @Override public void applySkin() { int tabTextColor = INVALID_ID;
mTabIndicatorColorResId = SkinCompatHelper.checkResourceId(mTabIndicatorColorResId);
wutongke/AndroidSkinAnimator
skin-support-design/src/main/java/skin/support/design/widget/SkinCompatTabLayout.java
// Path: skin-support/src/main/java/skin/support/content/res/SkinCompatResources.java // public class SkinCompatResources { // private static volatile SkinCompatResources sInstance; // private final Context mAppContext; // private Resources mResources; // private String mSkinPkgName; // private boolean isDefaultSkin; // // private SkinCompatResources(Context context) { // mAppContext = context.getApplicationContext(); // setSkinResource(mAppContext.getResources(), mAppContext.getPackageName()); // } // // public static void init(Context context) { // if (sInstance == null) { // synchronized (SkinCompatResources.class) { // if (sInstance == null) { // sInstance = new SkinCompatResources(context); // } // } // } // } // // public static SkinCompatResources getInstance() { // return sInstance; // } // // public void setSkinResource(Resources resources, String pkgName) { // mResources = resources; // mSkinPkgName = pkgName; // isDefaultSkin = mAppContext.getPackageName().equals(pkgName); // } // // public int getColor(int resId) { // int originColor = ContextCompat.getColor(mAppContext, resId); // if (isDefaultSkin) { // return originColor; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? originColor : mResources.getColor(targetResId); // } // // public Drawable getDrawable(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "drawable", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public Drawable getMipmap(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "mipmap", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public ColorStateList getColorStateList(int resId) { // ColorStateList colorStateList = ContextCompat.getColorStateList(mAppContext, resId); // if (isDefaultSkin) { // return colorStateList; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? colorStateList : mResources.getColorStateList(targetResId); // } // } // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // public abstract class SkinCompatHelper { // protected static final String TAG = SkinCompatHelper.class.getSimpleName(); // protected static final String SYSTEM_ID_PREFIX = "1"; // public static final int INVALID_ID = -1; // // final static public int checkResourceId(int resId) { // String hexResId = Integer.toHexString(resId); // SkinLog.d(TAG, "hexResId = " + hexResId); // return hexResId.startsWith(SYSTEM_ID_PREFIX) ? INVALID_ID : resId; // } // // abstract public void applySkin(); // } // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatSupportable.java // public interface SkinCompatSupportable { // void applySkin(); // } // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // public static final int INVALID_ID = -1;
import android.content.Context; import android.content.res.ColorStateList; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.os.Build; import android.support.design.widget.TabLayout; import android.support.v4.graphics.drawable.DrawableCompat; import android.util.AttributeSet; import skin.support.content.res.SkinCompatResources; import skin.support.design.R; import skin.support.widget.SkinCompatHelper; import skin.support.widget.SkinCompatSupportable; import static skin.support.widget.SkinCompatHelper.INVALID_ID;
int tabTextAppearance = a.getResourceId(R.styleable.TabLayout_tabTextAppearance, R.style.TextAppearance_Design_Tab); // Text colors/sizes come from the text appearance first final TypedArray ta = context.obtainStyledAttributes(tabTextAppearance, R.styleable.SkinTextAppearance); try { mTabTextColorsResId = ta.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID); } finally { ta.recycle(); } if (a.hasValue(R.styleable.TabLayout_tabTextColor)) { // If we have an explicit text color set, use it instead mTabTextColorsResId = a.getResourceId(R.styleable.TabLayout_tabTextColor, INVALID_ID); } if (a.hasValue(R.styleable.TabLayout_tabSelectedTextColor)) { // We have an explicit selected text color set, so we need to make merge it with the // current colors. This is exposed so that developers can use theme attributes to set // this (theme attrs in ColorStateLists are Lollipop+) mTabSelectedTextColorResId = a.getResourceId(R.styleable.TabLayout_tabSelectedTextColor, INVALID_ID); } a.recycle(); applySkin(); } @Override public void applySkin() { int tabTextColor = INVALID_ID; mTabIndicatorColorResId = SkinCompatHelper.checkResourceId(mTabIndicatorColorResId); if (mTabIndicatorColorResId != INVALID_ID) {
// Path: skin-support/src/main/java/skin/support/content/res/SkinCompatResources.java // public class SkinCompatResources { // private static volatile SkinCompatResources sInstance; // private final Context mAppContext; // private Resources mResources; // private String mSkinPkgName; // private boolean isDefaultSkin; // // private SkinCompatResources(Context context) { // mAppContext = context.getApplicationContext(); // setSkinResource(mAppContext.getResources(), mAppContext.getPackageName()); // } // // public static void init(Context context) { // if (sInstance == null) { // synchronized (SkinCompatResources.class) { // if (sInstance == null) { // sInstance = new SkinCompatResources(context); // } // } // } // } // // public static SkinCompatResources getInstance() { // return sInstance; // } // // public void setSkinResource(Resources resources, String pkgName) { // mResources = resources; // mSkinPkgName = pkgName; // isDefaultSkin = mAppContext.getPackageName().equals(pkgName); // } // // public int getColor(int resId) { // int originColor = ContextCompat.getColor(mAppContext, resId); // if (isDefaultSkin) { // return originColor; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? originColor : mResources.getColor(targetResId); // } // // public Drawable getDrawable(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "drawable", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public Drawable getMipmap(int resId) { // Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId); // if (isDefaultSkin) { // return originDrawable; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "mipmap", mSkinPkgName); // // return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId); // } // // public ColorStateList getColorStateList(int resId) { // ColorStateList colorStateList = ContextCompat.getColorStateList(mAppContext, resId); // if (isDefaultSkin) { // return colorStateList; // } // // String resName = mAppContext.getResources().getResourceEntryName(resId); // // int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName); // // return targetResId == 0 ? colorStateList : mResources.getColorStateList(targetResId); // } // } // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // public abstract class SkinCompatHelper { // protected static final String TAG = SkinCompatHelper.class.getSimpleName(); // protected static final String SYSTEM_ID_PREFIX = "1"; // public static final int INVALID_ID = -1; // // final static public int checkResourceId(int resId) { // String hexResId = Integer.toHexString(resId); // SkinLog.d(TAG, "hexResId = " + hexResId); // return hexResId.startsWith(SYSTEM_ID_PREFIX) ? INVALID_ID : resId; // } // // abstract public void applySkin(); // } // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatSupportable.java // public interface SkinCompatSupportable { // void applySkin(); // } // // Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java // public static final int INVALID_ID = -1; // Path: skin-support-design/src/main/java/skin/support/design/widget/SkinCompatTabLayout.java import android.content.Context; import android.content.res.ColorStateList; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.os.Build; import android.support.design.widget.TabLayout; import android.support.v4.graphics.drawable.DrawableCompat; import android.util.AttributeSet; import skin.support.content.res.SkinCompatResources; import skin.support.design.R; import skin.support.widget.SkinCompatHelper; import skin.support.widget.SkinCompatSupportable; import static skin.support.widget.SkinCompatHelper.INVALID_ID; int tabTextAppearance = a.getResourceId(R.styleable.TabLayout_tabTextAppearance, R.style.TextAppearance_Design_Tab); // Text colors/sizes come from the text appearance first final TypedArray ta = context.obtainStyledAttributes(tabTextAppearance, R.styleable.SkinTextAppearance); try { mTabTextColorsResId = ta.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID); } finally { ta.recycle(); } if (a.hasValue(R.styleable.TabLayout_tabTextColor)) { // If we have an explicit text color set, use it instead mTabTextColorsResId = a.getResourceId(R.styleable.TabLayout_tabTextColor, INVALID_ID); } if (a.hasValue(R.styleable.TabLayout_tabSelectedTextColor)) { // We have an explicit selected text color set, so we need to make merge it with the // current colors. This is exposed so that developers can use theme attributes to set // this (theme attrs in ColorStateLists are Lollipop+) mTabSelectedTextColorResId = a.getResourceId(R.styleable.TabLayout_tabSelectedTextColor, INVALID_ID); } a.recycle(); applySkin(); } @Override public void applySkin() { int tabTextColor = INVALID_ID; mTabIndicatorColorResId = SkinCompatHelper.checkResourceId(mTabIndicatorColorResId); if (mTabIndicatorColorResId != INVALID_ID) {
setSelectedTabIndicatorColor(SkinCompatResources.getInstance().getColor(mTabIndicatorColorResId));
wutongke/AndroidSkinAnimator
skin-support/src/main/java/skin/support/animator/SingleAnimator/hide/TranslationAlphaHideAnimator2.java
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorImpl.java // public abstract class ViewAnimatorImpl implements SkinAnimator { // @Override // public abstract SkinAnimator apply(@NonNull View view, @Nullable Action action); // // @Override // public SkinAnimator setPreDuration() { // return this; // } // // @Override // public SkinAnimator setAfterDuration() { // return this; // } // // @Override // public SkinAnimator setDuration() { // return this; // } // // @Override // public abstract void start(); // // protected void resetView(View view) { // view.setAlpha(1); // view.setScaleY(1); // view.setScaleX(1); // view.setRotation(0); // view.setTranslationX(0); // view.setTranslationY(0); // view.setPivotX(view.getWidth() / 2); // view.setPivotY(view.getHeight() / 2); // } // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // }
import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.os.Build; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.RequiresApi; import android.view.View; import android.view.animation.LinearInterpolator; import skin.support.animator.Action; import skin.support.animator.SingleAnimator.ViewAnimatorImpl; import skin.support.animator.SkinAnimator;
package skin.support.animator.SingleAnimator.hide; /** * Created by erfli on 2/25/17. */ public class TranslationAlphaHideAnimator2 extends ViewAnimatorImpl { private ObjectAnimator animator; private TranslationAlphaHideAnimator2() { } public static TranslationAlphaHideAnimator2 getInstance() { return new TranslationAlphaHideAnimator2(); } @Override
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorImpl.java // public abstract class ViewAnimatorImpl implements SkinAnimator { // @Override // public abstract SkinAnimator apply(@NonNull View view, @Nullable Action action); // // @Override // public SkinAnimator setPreDuration() { // return this; // } // // @Override // public SkinAnimator setAfterDuration() { // return this; // } // // @Override // public SkinAnimator setDuration() { // return this; // } // // @Override // public abstract void start(); // // protected void resetView(View view) { // view.setAlpha(1); // view.setScaleY(1); // view.setScaleX(1); // view.setRotation(0); // view.setTranslationX(0); // view.setTranslationY(0); // view.setPivotX(view.getWidth() / 2); // view.setPivotY(view.getHeight() / 2); // } // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // } // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/hide/TranslationAlphaHideAnimator2.java import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.os.Build; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.RequiresApi; import android.view.View; import android.view.animation.LinearInterpolator; import skin.support.animator.Action; import skin.support.animator.SingleAnimator.ViewAnimatorImpl; import skin.support.animator.SkinAnimator; package skin.support.animator.SingleAnimator.hide; /** * Created by erfli on 2/25/17. */ public class TranslationAlphaHideAnimator2 extends ViewAnimatorImpl { private ObjectAnimator animator; private TranslationAlphaHideAnimator2() { } public static TranslationAlphaHideAnimator2 getInstance() { return new TranslationAlphaHideAnimator2(); } @Override
public SkinAnimator apply(@NonNull final View view, @Nullable final Action action) {
wutongke/AndroidSkinAnimator
skin-support/src/main/java/skin/support/animator/SingleAnimator/hide/TranslationAlphaHideAnimator2.java
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorImpl.java // public abstract class ViewAnimatorImpl implements SkinAnimator { // @Override // public abstract SkinAnimator apply(@NonNull View view, @Nullable Action action); // // @Override // public SkinAnimator setPreDuration() { // return this; // } // // @Override // public SkinAnimator setAfterDuration() { // return this; // } // // @Override // public SkinAnimator setDuration() { // return this; // } // // @Override // public abstract void start(); // // protected void resetView(View view) { // view.setAlpha(1); // view.setScaleY(1); // view.setScaleX(1); // view.setRotation(0); // view.setTranslationX(0); // view.setTranslationY(0); // view.setPivotX(view.getWidth() / 2); // view.setPivotY(view.getHeight() / 2); // } // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // }
import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.os.Build; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.RequiresApi; import android.view.View; import android.view.animation.LinearInterpolator; import skin.support.animator.Action; import skin.support.animator.SingleAnimator.ViewAnimatorImpl; import skin.support.animator.SkinAnimator;
package skin.support.animator.SingleAnimator.hide; /** * Created by erfli on 2/25/17. */ public class TranslationAlphaHideAnimator2 extends ViewAnimatorImpl { private ObjectAnimator animator; private TranslationAlphaHideAnimator2() { } public static TranslationAlphaHideAnimator2 getInstance() { return new TranslationAlphaHideAnimator2(); } @Override
// Path: skin-support/src/main/java/skin/support/animator/Action.java // public interface Action { // void action(); // } // // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/ViewAnimatorImpl.java // public abstract class ViewAnimatorImpl implements SkinAnimator { // @Override // public abstract SkinAnimator apply(@NonNull View view, @Nullable Action action); // // @Override // public SkinAnimator setPreDuration() { // return this; // } // // @Override // public SkinAnimator setAfterDuration() { // return this; // } // // @Override // public SkinAnimator setDuration() { // return this; // } // // @Override // public abstract void start(); // // protected void resetView(View view) { // view.setAlpha(1); // view.setScaleY(1); // view.setScaleX(1); // view.setRotation(0); // view.setTranslationX(0); // view.setTranslationY(0); // view.setPivotX(view.getWidth() / 2); // view.setPivotY(view.getHeight() / 2); // } // } // // Path: skin-support/src/main/java/skin/support/animator/SkinAnimator.java // public interface SkinAnimator { // int PRE_DURATION = 200; // int AFTER_DURATION = 200; // // SkinAnimator apply(@NonNull View view, @Nullable Action action); // // SkinAnimator setPreDuration(); // // SkinAnimator setAfterDuration(); // // SkinAnimator setDuration(); // // void start(); // // } // Path: skin-support/src/main/java/skin/support/animator/SingleAnimator/hide/TranslationAlphaHideAnimator2.java import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.os.Build; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.RequiresApi; import android.view.View; import android.view.animation.LinearInterpolator; import skin.support.animator.Action; import skin.support.animator.SingleAnimator.ViewAnimatorImpl; import skin.support.animator.SkinAnimator; package skin.support.animator.SingleAnimator.hide; /** * Created by erfli on 2/25/17. */ public class TranslationAlphaHideAnimator2 extends ViewAnimatorImpl { private ObjectAnimator animator; private TranslationAlphaHideAnimator2() { } public static TranslationAlphaHideAnimator2 getInstance() { return new TranslationAlphaHideAnimator2(); } @Override
public SkinAnimator apply(@NonNull final View view, @Nullable final Action action) {
AhmedHani/Hidden-Markov-Model
src/ML/HMM/HMM_For_Testing.java
// Path: src/Util/Validation/Validator.java // public class Validator { // private static Validator ourInstance = new Validator(); // // public static Validator getInstance() { // return ourInstance; // } // // private Validator() { // } // // public boolean summationIsOne(Hashtable<String, Double> list) { // double sum = 0.0; // // for (double item : list.values()) { // sum += item; // } // // return sum == 1.0; // } // // public boolean isValidInitialProbabilities(Vector<String> states, Hashtable<String, Double> initialProbabilities) { // if (states.size() != initialProbabilities.size()) // return false; // // for (int i = 0; i < states.size(); i++) { // boolean found = false; // for (String state : initialProbabilities.keySet()) { // if (state.equals(states.get(i))) { // found = true; // break; // } // } // // if (!found) // return false; // } // // return true; // } // // public boolean isValidTransitionMatrix(Hashtable<Pair<String, String>, Double> transitionMatrix, Vector<String> states) { // if (transitionMatrix.size() != states.size() * states.size()) // return false; // // Hashtable<Pair<String, String>, Boolean> frequency = new Hashtable<Pair<String, String>, Boolean>(); // // for (Pair<String, String> item : transitionMatrix.keySet()) { // if (frequency.containsKey(item)) { // return false; // } // frequency.put(item, true); // } // // Hashtable<Pair<String, String>, Boolean> visited = new Hashtable<Pair<String, String>, Boolean>(); // // for (Pair<String, String> first : transitionMatrix.keySet()) { // double sum = 0.0; // int entered = 0; // String state = first.getKey(); // for (Pair<String, String> second: transitionMatrix.keySet()) { // if (state.equals(second.getKey()) && !visited.containsKey(second)) { // sum += transitionMatrix.get(second); // entered++; // visited.put(second, true); // } // } // // if (sum != 1.0 && entered > 0) { // return false; // } // } // // return true; // } // // public boolean isValidEmissionMatrix(Hashtable<Pair<String, String>, Double> emissionMatrix, Vector<String> states, Vector<String> observations) { // if (emissionMatrix.size() != observations.size() * states.size()) { // return false; // } // // for (Pair<String, String> item : emissionMatrix.keySet()) { // boolean found = false; // double sum = 0.0; // int count = 0; // for (int i = 0; i < states.size(); i++) { // for (int j = 0; j < observations.size(); j++) { // if (item.getKey().equals(states.get(i)) && item.getValue().equals(observations.get(j))) { // found = true; // break; // } // } // // if (found) // break; // } // // if (!found) // return false; // // for (Pair<String, String> item2 : emissionMatrix.keySet()) { // if (item.getKey().equals(item2.getKey())) { // sum += emissionMatrix.get(item2); // count++; // } // } // // if (sum != 1.0 && count > 0) // return false; // } // // return true; // } // }
import Util.Validation.Validator; import javafx.util.Pair; import java.util.*;
this.numberOfStates = states.size(); this.observations = observations; this.numberOfObservations = observations.size(); this.initialProbabilities = initialProbabilities; if (!this.validateInitialProbability(initialProbabilities)) throw new Exception("Initial Probabilities sum must be equal 1.0"); if (!this.validateInitialProbabilitiesAndStates(states, initialProbabilities)) throw new Exception("States size and Initial Probabilities size must be equal"); this.transitionMatrix = transitionMatrix; if (!this.validateTransitionMatrix(transitionMatrix, states)) throw new Exception("Check the transition matrix elements"); this.emissionMatrix = emissionMatrix; if (!this.validateEmissionMatrix(emissionMatrix, states, observations)) throw new Exception("Check the emission matrix elements"); } public HMM_For_Testing(String filepath) { } /** * * @param initialProbabilities A hashtable that is the initial probability vector of the states * @return [True/False] which specifies if the vector elements are logically right or not */ private boolean validateInitialProbability(Hashtable<String, Double> initialProbabilities) {
// Path: src/Util/Validation/Validator.java // public class Validator { // private static Validator ourInstance = new Validator(); // // public static Validator getInstance() { // return ourInstance; // } // // private Validator() { // } // // public boolean summationIsOne(Hashtable<String, Double> list) { // double sum = 0.0; // // for (double item : list.values()) { // sum += item; // } // // return sum == 1.0; // } // // public boolean isValidInitialProbabilities(Vector<String> states, Hashtable<String, Double> initialProbabilities) { // if (states.size() != initialProbabilities.size()) // return false; // // for (int i = 0; i < states.size(); i++) { // boolean found = false; // for (String state : initialProbabilities.keySet()) { // if (state.equals(states.get(i))) { // found = true; // break; // } // } // // if (!found) // return false; // } // // return true; // } // // public boolean isValidTransitionMatrix(Hashtable<Pair<String, String>, Double> transitionMatrix, Vector<String> states) { // if (transitionMatrix.size() != states.size() * states.size()) // return false; // // Hashtable<Pair<String, String>, Boolean> frequency = new Hashtable<Pair<String, String>, Boolean>(); // // for (Pair<String, String> item : transitionMatrix.keySet()) { // if (frequency.containsKey(item)) { // return false; // } // frequency.put(item, true); // } // // Hashtable<Pair<String, String>, Boolean> visited = new Hashtable<Pair<String, String>, Boolean>(); // // for (Pair<String, String> first : transitionMatrix.keySet()) { // double sum = 0.0; // int entered = 0; // String state = first.getKey(); // for (Pair<String, String> second: transitionMatrix.keySet()) { // if (state.equals(second.getKey()) && !visited.containsKey(second)) { // sum += transitionMatrix.get(second); // entered++; // visited.put(second, true); // } // } // // if (sum != 1.0 && entered > 0) { // return false; // } // } // // return true; // } // // public boolean isValidEmissionMatrix(Hashtable<Pair<String, String>, Double> emissionMatrix, Vector<String> states, Vector<String> observations) { // if (emissionMatrix.size() != observations.size() * states.size()) { // return false; // } // // for (Pair<String, String> item : emissionMatrix.keySet()) { // boolean found = false; // double sum = 0.0; // int count = 0; // for (int i = 0; i < states.size(); i++) { // for (int j = 0; j < observations.size(); j++) { // if (item.getKey().equals(states.get(i)) && item.getValue().equals(observations.get(j))) { // found = true; // break; // } // } // // if (found) // break; // } // // if (!found) // return false; // // for (Pair<String, String> item2 : emissionMatrix.keySet()) { // if (item.getKey().equals(item2.getKey())) { // sum += emissionMatrix.get(item2); // count++; // } // } // // if (sum != 1.0 && count > 0) // return false; // } // // return true; // } // } // Path: src/ML/HMM/HMM_For_Testing.java import Util.Validation.Validator; import javafx.util.Pair; import java.util.*; this.numberOfStates = states.size(); this.observations = observations; this.numberOfObservations = observations.size(); this.initialProbabilities = initialProbabilities; if (!this.validateInitialProbability(initialProbabilities)) throw new Exception("Initial Probabilities sum must be equal 1.0"); if (!this.validateInitialProbabilitiesAndStates(states, initialProbabilities)) throw new Exception("States size and Initial Probabilities size must be equal"); this.transitionMatrix = transitionMatrix; if (!this.validateTransitionMatrix(transitionMatrix, states)) throw new Exception("Check the transition matrix elements"); this.emissionMatrix = emissionMatrix; if (!this.validateEmissionMatrix(emissionMatrix, states, observations)) throw new Exception("Check the emission matrix elements"); } public HMM_For_Testing(String filepath) { } /** * * @param initialProbabilities A hashtable that is the initial probability vector of the states * @return [True/False] which specifies if the vector elements are logically right or not */ private boolean validateInitialProbability(Hashtable<String, Double> initialProbabilities) {
return Validator.getInstance().summationIsOne(initialProbabilities);
lcxl/lcxl-net-loader
loader/web/webtest/src/main/java/com/lcxbox/netloader/webtest/monitor/service/MonitorServiceImpl.java
// Path: loader/web/webtest/src/main/java/com/lcxbox/netloader/webtest/monitor/model/MonitorInfoBean.java // public class MonitorInfoBean { // /** 可使用内存. */ // private long totalMemory; // /** 剩余内存. */ // private long freeMemory; // /** 最大可使用内存. */ // private long maxMemory; // /** 操作系统. */ // private String osName; // /** 总的物理内存. */ // private long totalMemorySize; // /** 剩余的物理内存. */ // private long freePhysicalMemorySize; // /** 已使用的物理内存. */ // private long usedMemory; // /** 线程总数. */ // private int totalThread; // /** cpu使用率. */ // private double cpuRatio; // // private String hostAddress; // private String hostName; // // public long getTotalMemory() { // return totalMemory; // } // public void setTotalMemory(long totalMemory) { // this.totalMemory = totalMemory; // } // public long getFreeMemory() { // return freeMemory; // } // public void setFreeMemory(long freeMemory) { // this.freeMemory = freeMemory; // } // public long getMaxMemory() { // return maxMemory; // } // public void setMaxMemory(long maxMemory) { // this.maxMemory = maxMemory; // } // public String getOsName() { // return osName; // } // public void setOsName(String osName) { // this.osName = osName; // } // public long getTotalMemorySize() { // return totalMemorySize; // } // public void setTotalMemorySize(long totalMemorySize) { // this.totalMemorySize = totalMemorySize; // } // public long getFreePhysicalMemorySize() { // return freePhysicalMemorySize; // } // public void setFreePhysicalMemorySize(long freePhysicalMemorySize) { // this.freePhysicalMemorySize = freePhysicalMemorySize; // } // public long getUsedMemory() { // return usedMemory; // } // public void setUsedMemory(long usedMemory) { // this.usedMemory = usedMemory; // } // public int getTotalThread() { // return totalThread; // } // public void setTotalThread(int totalThread) { // this.totalThread = totalThread; // } // public double getCpuRatio() { // return cpuRatio; // } // public void setCpuRatio(double cpuRatio) { // this.cpuRatio = cpuRatio; // } // public String getHostAddress() { // return hostAddress; // } // public void setHostAddress(String hostAddress) { // this.hostAddress = hostAddress; // } // public String getHostName() { // return hostName; // } // public void setHostName(String hostName) { // this.hostName = hostName; // } // // // }
import java.lang.management.ManagementFactory; import java.net.InetAddress; import com.sun.management.OperatingSystemMXBean; import com.lcxbox.netloader.webtest.monitor.model.MonitorInfoBean;
package com.lcxbox.netloader.webtest.monitor.service; @SuppressWarnings("restriction") public class MonitorServiceImpl implements IMonitorService { private OperatingSystemMXBean osmxb; public MonitorServiceImpl() { osmxb = (OperatingSystemMXBean) ManagementFactory .getOperatingSystemMXBean(); osmxb.getSystemCpuLoad(); } /** * 获得当前的监控对象. * * @return 返回构造好的监控对象 * @throws Exception * @author GuoHuang */
// Path: loader/web/webtest/src/main/java/com/lcxbox/netloader/webtest/monitor/model/MonitorInfoBean.java // public class MonitorInfoBean { // /** 可使用内存. */ // private long totalMemory; // /** 剩余内存. */ // private long freeMemory; // /** 最大可使用内存. */ // private long maxMemory; // /** 操作系统. */ // private String osName; // /** 总的物理内存. */ // private long totalMemorySize; // /** 剩余的物理内存. */ // private long freePhysicalMemorySize; // /** 已使用的物理内存. */ // private long usedMemory; // /** 线程总数. */ // private int totalThread; // /** cpu使用率. */ // private double cpuRatio; // // private String hostAddress; // private String hostName; // // public long getTotalMemory() { // return totalMemory; // } // public void setTotalMemory(long totalMemory) { // this.totalMemory = totalMemory; // } // public long getFreeMemory() { // return freeMemory; // } // public void setFreeMemory(long freeMemory) { // this.freeMemory = freeMemory; // } // public long getMaxMemory() { // return maxMemory; // } // public void setMaxMemory(long maxMemory) { // this.maxMemory = maxMemory; // } // public String getOsName() { // return osName; // } // public void setOsName(String osName) { // this.osName = osName; // } // public long getTotalMemorySize() { // return totalMemorySize; // } // public void setTotalMemorySize(long totalMemorySize) { // this.totalMemorySize = totalMemorySize; // } // public long getFreePhysicalMemorySize() { // return freePhysicalMemorySize; // } // public void setFreePhysicalMemorySize(long freePhysicalMemorySize) { // this.freePhysicalMemorySize = freePhysicalMemorySize; // } // public long getUsedMemory() { // return usedMemory; // } // public void setUsedMemory(long usedMemory) { // this.usedMemory = usedMemory; // } // public int getTotalThread() { // return totalThread; // } // public void setTotalThread(int totalThread) { // this.totalThread = totalThread; // } // public double getCpuRatio() { // return cpuRatio; // } // public void setCpuRatio(double cpuRatio) { // this.cpuRatio = cpuRatio; // } // public String getHostAddress() { // return hostAddress; // } // public void setHostAddress(String hostAddress) { // this.hostAddress = hostAddress; // } // public String getHostName() { // return hostName; // } // public void setHostName(String hostName) { // this.hostName = hostName; // } // // // } // Path: loader/web/webtest/src/main/java/com/lcxbox/netloader/webtest/monitor/service/MonitorServiceImpl.java import java.lang.management.ManagementFactory; import java.net.InetAddress; import com.sun.management.OperatingSystemMXBean; import com.lcxbox.netloader.webtest.monitor.model.MonitorInfoBean; package com.lcxbox.netloader.webtest.monitor.service; @SuppressWarnings("restriction") public class MonitorServiceImpl implements IMonitorService { private OperatingSystemMXBean osmxb; public MonitorServiceImpl() { osmxb = (OperatingSystemMXBean) ManagementFactory .getOperatingSystemMXBean(); osmxb.getSystemCpuLoad(); } /** * 获得当前的监控对象. * * @return 返回构造好的监控对象 * @throws Exception * @author GuoHuang */
public MonitorInfoBean getMonitorInfoBean() throws Exception {
lcxl/lcxl-net-loader
loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/service/UserServiceImpl.java
// Path: loader/web/netloader-web/src/main/java/com/lcxbox/common/model/LcxlNetCode.java // public class LcxlNetCode { // // public final static String JSON_CODE = "code"; // public final static int JC_NONE = 0x00; // /** // * 获取模块列表命令 // */ // public final static int JC_MODULE_LIST = 0x01; // /** // * 获取服务器列表 // */ // public final static int JC_SERVER_LIST = 0x03; // /** // * 设置虚拟IP地址 // */ // public final static int JC_SET_VIRTUAL_ADDR = 0x04; // /** // * 添加服务器 // */ // public final static int JC_ADD_SERVER = 0x05; // /** // * 设置服务器 // */ // public final static int JC_SET_SERVER = 0x06; // /** // * 删除服务器 // */ // public final static int JC_DEL_SERVER = 0x07; // // public final static int JC_LOGON = 0x10; // // public final static String JSON_DATA = "data"; // public final static String JSON_MODULE_LIST = "module_list"; // public final static String JSON_SERVER_LIST = "server_list"; // public final static String JSON_MINIPORT_NET_LUID = "miniport_net_luid"; // // public final static String JSON_STATUS ="status"; // public final static int JS_SUCCESS =0x00; // public final static int JS_FAIL =0x01; // public final static int JS_JSON_DATA_NOT_FOUND =0x02; // public final static int JS_JSON_CODE_NOT_FOUND =0x03; // public final static int JS_JSON_CODE_IP_FORMAT_INVALID =0x04; // public final static int JS_UNKNOWN_HOST = 0x10; // public final static int JS_SOCKET_ERROR = 0x11; // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/model/LogonRequest.java // public class LogonRequest extends CommonRequest { // private String username; // private String password; // public String getUsername() { // return username; // } // public void setUsername(String username) { // this.username = username; // } // public String getPassword() { // return password; // } // public void setPassword(String password) { // this.password = password; // } // // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/model/LogonRespnse.java // public class LogonRespnse extends CommonResponse { // // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/socket/json/SocketRequest.java // public class SocketRequest { // public static <T> T jsonRequest(String host, int port, Object request, Class<T> responseCls) throws UnknownHostException, IOException { // ObjectMapper objectMapper = new ObjectMapper(); // // JsonSocket sock = new JsonSocket(host, port); // ByteArrayOutputStream os = new ByteArrayOutputStream(); // objectMapper.getJsonFactory().createJsonGenerator(os, JsonEncoding.UTF16_LE).writeObject(request); // String ret = new String(sock.sendData(os.toByteArray()),"UTF-16LE"); // os.close(); // sock.close(); // return objectMapper.readValue(ret, responseCls); // } // }
import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.net.SocketException; import java.net.UnknownHostException; import org.springframework.stereotype.Service; import com.lcxbox.common.model.LcxlNetCode; import com.lcxbox.netloader.user.model.LogonRequest; import com.lcxbox.netloader.user.model.LogonRespnse; import com.lcxbox.socket.json.SocketRequest;
package com.lcxbox.netloader.user.service; @Service() public class UserServiceImpl implements IUserService {
// Path: loader/web/netloader-web/src/main/java/com/lcxbox/common/model/LcxlNetCode.java // public class LcxlNetCode { // // public final static String JSON_CODE = "code"; // public final static int JC_NONE = 0x00; // /** // * 获取模块列表命令 // */ // public final static int JC_MODULE_LIST = 0x01; // /** // * 获取服务器列表 // */ // public final static int JC_SERVER_LIST = 0x03; // /** // * 设置虚拟IP地址 // */ // public final static int JC_SET_VIRTUAL_ADDR = 0x04; // /** // * 添加服务器 // */ // public final static int JC_ADD_SERVER = 0x05; // /** // * 设置服务器 // */ // public final static int JC_SET_SERVER = 0x06; // /** // * 删除服务器 // */ // public final static int JC_DEL_SERVER = 0x07; // // public final static int JC_LOGON = 0x10; // // public final static String JSON_DATA = "data"; // public final static String JSON_MODULE_LIST = "module_list"; // public final static String JSON_SERVER_LIST = "server_list"; // public final static String JSON_MINIPORT_NET_LUID = "miniport_net_luid"; // // public final static String JSON_STATUS ="status"; // public final static int JS_SUCCESS =0x00; // public final static int JS_FAIL =0x01; // public final static int JS_JSON_DATA_NOT_FOUND =0x02; // public final static int JS_JSON_CODE_NOT_FOUND =0x03; // public final static int JS_JSON_CODE_IP_FORMAT_INVALID =0x04; // public final static int JS_UNKNOWN_HOST = 0x10; // public final static int JS_SOCKET_ERROR = 0x11; // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/model/LogonRequest.java // public class LogonRequest extends CommonRequest { // private String username; // private String password; // public String getUsername() { // return username; // } // public void setUsername(String username) { // this.username = username; // } // public String getPassword() { // return password; // } // public void setPassword(String password) { // this.password = password; // } // // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/model/LogonRespnse.java // public class LogonRespnse extends CommonResponse { // // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/socket/json/SocketRequest.java // public class SocketRequest { // public static <T> T jsonRequest(String host, int port, Object request, Class<T> responseCls) throws UnknownHostException, IOException { // ObjectMapper objectMapper = new ObjectMapper(); // // JsonSocket sock = new JsonSocket(host, port); // ByteArrayOutputStream os = new ByteArrayOutputStream(); // objectMapper.getJsonFactory().createJsonGenerator(os, JsonEncoding.UTF16_LE).writeObject(request); // String ret = new String(sock.sendData(os.toByteArray()),"UTF-16LE"); // os.close(); // sock.close(); // return objectMapper.readValue(ret, responseCls); // } // } // Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/service/UserServiceImpl.java import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.net.SocketException; import java.net.UnknownHostException; import org.springframework.stereotype.Service; import com.lcxbox.common.model.LcxlNetCode; import com.lcxbox.netloader.user.model.LogonRequest; import com.lcxbox.netloader.user.model.LogonRespnse; import com.lcxbox.socket.json.SocketRequest; package com.lcxbox.netloader.user.service; @Service() public class UserServiceImpl implements IUserService {
public LogonRespnse logon(String host, Integer port, String username,
lcxl/lcxl-net-loader
loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/service/UserServiceImpl.java
// Path: loader/web/netloader-web/src/main/java/com/lcxbox/common/model/LcxlNetCode.java // public class LcxlNetCode { // // public final static String JSON_CODE = "code"; // public final static int JC_NONE = 0x00; // /** // * 获取模块列表命令 // */ // public final static int JC_MODULE_LIST = 0x01; // /** // * 获取服务器列表 // */ // public final static int JC_SERVER_LIST = 0x03; // /** // * 设置虚拟IP地址 // */ // public final static int JC_SET_VIRTUAL_ADDR = 0x04; // /** // * 添加服务器 // */ // public final static int JC_ADD_SERVER = 0x05; // /** // * 设置服务器 // */ // public final static int JC_SET_SERVER = 0x06; // /** // * 删除服务器 // */ // public final static int JC_DEL_SERVER = 0x07; // // public final static int JC_LOGON = 0x10; // // public final static String JSON_DATA = "data"; // public final static String JSON_MODULE_LIST = "module_list"; // public final static String JSON_SERVER_LIST = "server_list"; // public final static String JSON_MINIPORT_NET_LUID = "miniport_net_luid"; // // public final static String JSON_STATUS ="status"; // public final static int JS_SUCCESS =0x00; // public final static int JS_FAIL =0x01; // public final static int JS_JSON_DATA_NOT_FOUND =0x02; // public final static int JS_JSON_CODE_NOT_FOUND =0x03; // public final static int JS_JSON_CODE_IP_FORMAT_INVALID =0x04; // public final static int JS_UNKNOWN_HOST = 0x10; // public final static int JS_SOCKET_ERROR = 0x11; // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/model/LogonRequest.java // public class LogonRequest extends CommonRequest { // private String username; // private String password; // public String getUsername() { // return username; // } // public void setUsername(String username) { // this.username = username; // } // public String getPassword() { // return password; // } // public void setPassword(String password) { // this.password = password; // } // // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/model/LogonRespnse.java // public class LogonRespnse extends CommonResponse { // // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/socket/json/SocketRequest.java // public class SocketRequest { // public static <T> T jsonRequest(String host, int port, Object request, Class<T> responseCls) throws UnknownHostException, IOException { // ObjectMapper objectMapper = new ObjectMapper(); // // JsonSocket sock = new JsonSocket(host, port); // ByteArrayOutputStream os = new ByteArrayOutputStream(); // objectMapper.getJsonFactory().createJsonGenerator(os, JsonEncoding.UTF16_LE).writeObject(request); // String ret = new String(sock.sendData(os.toByteArray()),"UTF-16LE"); // os.close(); // sock.close(); // return objectMapper.readValue(ret, responseCls); // } // }
import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.net.SocketException; import java.net.UnknownHostException; import org.springframework.stereotype.Service; import com.lcxbox.common.model.LcxlNetCode; import com.lcxbox.netloader.user.model.LogonRequest; import com.lcxbox.netloader.user.model.LogonRespnse; import com.lcxbox.socket.json.SocketRequest;
package com.lcxbox.netloader.user.service; @Service() public class UserServiceImpl implements IUserService { public LogonRespnse logon(String host, Integer port, String username, String password) throws IOException { // TODO Auto-generated method stub
// Path: loader/web/netloader-web/src/main/java/com/lcxbox/common/model/LcxlNetCode.java // public class LcxlNetCode { // // public final static String JSON_CODE = "code"; // public final static int JC_NONE = 0x00; // /** // * 获取模块列表命令 // */ // public final static int JC_MODULE_LIST = 0x01; // /** // * 获取服务器列表 // */ // public final static int JC_SERVER_LIST = 0x03; // /** // * 设置虚拟IP地址 // */ // public final static int JC_SET_VIRTUAL_ADDR = 0x04; // /** // * 添加服务器 // */ // public final static int JC_ADD_SERVER = 0x05; // /** // * 设置服务器 // */ // public final static int JC_SET_SERVER = 0x06; // /** // * 删除服务器 // */ // public final static int JC_DEL_SERVER = 0x07; // // public final static int JC_LOGON = 0x10; // // public final static String JSON_DATA = "data"; // public final static String JSON_MODULE_LIST = "module_list"; // public final static String JSON_SERVER_LIST = "server_list"; // public final static String JSON_MINIPORT_NET_LUID = "miniport_net_luid"; // // public final static String JSON_STATUS ="status"; // public final static int JS_SUCCESS =0x00; // public final static int JS_FAIL =0x01; // public final static int JS_JSON_DATA_NOT_FOUND =0x02; // public final static int JS_JSON_CODE_NOT_FOUND =0x03; // public final static int JS_JSON_CODE_IP_FORMAT_INVALID =0x04; // public final static int JS_UNKNOWN_HOST = 0x10; // public final static int JS_SOCKET_ERROR = 0x11; // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/model/LogonRequest.java // public class LogonRequest extends CommonRequest { // private String username; // private String password; // public String getUsername() { // return username; // } // public void setUsername(String username) { // this.username = username; // } // public String getPassword() { // return password; // } // public void setPassword(String password) { // this.password = password; // } // // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/model/LogonRespnse.java // public class LogonRespnse extends CommonResponse { // // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/socket/json/SocketRequest.java // public class SocketRequest { // public static <T> T jsonRequest(String host, int port, Object request, Class<T> responseCls) throws UnknownHostException, IOException { // ObjectMapper objectMapper = new ObjectMapper(); // // JsonSocket sock = new JsonSocket(host, port); // ByteArrayOutputStream os = new ByteArrayOutputStream(); // objectMapper.getJsonFactory().createJsonGenerator(os, JsonEncoding.UTF16_LE).writeObject(request); // String ret = new String(sock.sendData(os.toByteArray()),"UTF-16LE"); // os.close(); // sock.close(); // return objectMapper.readValue(ret, responseCls); // } // } // Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/service/UserServiceImpl.java import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.net.SocketException; import java.net.UnknownHostException; import org.springframework.stereotype.Service; import com.lcxbox.common.model.LcxlNetCode; import com.lcxbox.netloader.user.model.LogonRequest; import com.lcxbox.netloader.user.model.LogonRespnse; import com.lcxbox.socket.json.SocketRequest; package com.lcxbox.netloader.user.service; @Service() public class UserServiceImpl implements IUserService { public LogonRespnse logon(String host, Integer port, String username, String password) throws IOException { // TODO Auto-generated method stub
LogonRequest request = new LogonRequest();
lcxl/lcxl-net-loader
loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/service/UserServiceImpl.java
// Path: loader/web/netloader-web/src/main/java/com/lcxbox/common/model/LcxlNetCode.java // public class LcxlNetCode { // // public final static String JSON_CODE = "code"; // public final static int JC_NONE = 0x00; // /** // * 获取模块列表命令 // */ // public final static int JC_MODULE_LIST = 0x01; // /** // * 获取服务器列表 // */ // public final static int JC_SERVER_LIST = 0x03; // /** // * 设置虚拟IP地址 // */ // public final static int JC_SET_VIRTUAL_ADDR = 0x04; // /** // * 添加服务器 // */ // public final static int JC_ADD_SERVER = 0x05; // /** // * 设置服务器 // */ // public final static int JC_SET_SERVER = 0x06; // /** // * 删除服务器 // */ // public final static int JC_DEL_SERVER = 0x07; // // public final static int JC_LOGON = 0x10; // // public final static String JSON_DATA = "data"; // public final static String JSON_MODULE_LIST = "module_list"; // public final static String JSON_SERVER_LIST = "server_list"; // public final static String JSON_MINIPORT_NET_LUID = "miniport_net_luid"; // // public final static String JSON_STATUS ="status"; // public final static int JS_SUCCESS =0x00; // public final static int JS_FAIL =0x01; // public final static int JS_JSON_DATA_NOT_FOUND =0x02; // public final static int JS_JSON_CODE_NOT_FOUND =0x03; // public final static int JS_JSON_CODE_IP_FORMAT_INVALID =0x04; // public final static int JS_UNKNOWN_HOST = 0x10; // public final static int JS_SOCKET_ERROR = 0x11; // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/model/LogonRequest.java // public class LogonRequest extends CommonRequest { // private String username; // private String password; // public String getUsername() { // return username; // } // public void setUsername(String username) { // this.username = username; // } // public String getPassword() { // return password; // } // public void setPassword(String password) { // this.password = password; // } // // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/model/LogonRespnse.java // public class LogonRespnse extends CommonResponse { // // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/socket/json/SocketRequest.java // public class SocketRequest { // public static <T> T jsonRequest(String host, int port, Object request, Class<T> responseCls) throws UnknownHostException, IOException { // ObjectMapper objectMapper = new ObjectMapper(); // // JsonSocket sock = new JsonSocket(host, port); // ByteArrayOutputStream os = new ByteArrayOutputStream(); // objectMapper.getJsonFactory().createJsonGenerator(os, JsonEncoding.UTF16_LE).writeObject(request); // String ret = new String(sock.sendData(os.toByteArray()),"UTF-16LE"); // os.close(); // sock.close(); // return objectMapper.readValue(ret, responseCls); // } // }
import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.net.SocketException; import java.net.UnknownHostException; import org.springframework.stereotype.Service; import com.lcxbox.common.model.LcxlNetCode; import com.lcxbox.netloader.user.model.LogonRequest; import com.lcxbox.netloader.user.model.LogonRespnse; import com.lcxbox.socket.json.SocketRequest;
package com.lcxbox.netloader.user.service; @Service() public class UserServiceImpl implements IUserService { public LogonRespnse logon(String host, Integer port, String username, String password) throws IOException { // TODO Auto-generated method stub LogonRequest request = new LogonRequest();
// Path: loader/web/netloader-web/src/main/java/com/lcxbox/common/model/LcxlNetCode.java // public class LcxlNetCode { // // public final static String JSON_CODE = "code"; // public final static int JC_NONE = 0x00; // /** // * 获取模块列表命令 // */ // public final static int JC_MODULE_LIST = 0x01; // /** // * 获取服务器列表 // */ // public final static int JC_SERVER_LIST = 0x03; // /** // * 设置虚拟IP地址 // */ // public final static int JC_SET_VIRTUAL_ADDR = 0x04; // /** // * 添加服务器 // */ // public final static int JC_ADD_SERVER = 0x05; // /** // * 设置服务器 // */ // public final static int JC_SET_SERVER = 0x06; // /** // * 删除服务器 // */ // public final static int JC_DEL_SERVER = 0x07; // // public final static int JC_LOGON = 0x10; // // public final static String JSON_DATA = "data"; // public final static String JSON_MODULE_LIST = "module_list"; // public final static String JSON_SERVER_LIST = "server_list"; // public final static String JSON_MINIPORT_NET_LUID = "miniport_net_luid"; // // public final static String JSON_STATUS ="status"; // public final static int JS_SUCCESS =0x00; // public final static int JS_FAIL =0x01; // public final static int JS_JSON_DATA_NOT_FOUND =0x02; // public final static int JS_JSON_CODE_NOT_FOUND =0x03; // public final static int JS_JSON_CODE_IP_FORMAT_INVALID =0x04; // public final static int JS_UNKNOWN_HOST = 0x10; // public final static int JS_SOCKET_ERROR = 0x11; // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/model/LogonRequest.java // public class LogonRequest extends CommonRequest { // private String username; // private String password; // public String getUsername() { // return username; // } // public void setUsername(String username) { // this.username = username; // } // public String getPassword() { // return password; // } // public void setPassword(String password) { // this.password = password; // } // // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/model/LogonRespnse.java // public class LogonRespnse extends CommonResponse { // // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/socket/json/SocketRequest.java // public class SocketRequest { // public static <T> T jsonRequest(String host, int port, Object request, Class<T> responseCls) throws UnknownHostException, IOException { // ObjectMapper objectMapper = new ObjectMapper(); // // JsonSocket sock = new JsonSocket(host, port); // ByteArrayOutputStream os = new ByteArrayOutputStream(); // objectMapper.getJsonFactory().createJsonGenerator(os, JsonEncoding.UTF16_LE).writeObject(request); // String ret = new String(sock.sendData(os.toByteArray()),"UTF-16LE"); // os.close(); // sock.close(); // return objectMapper.readValue(ret, responseCls); // } // } // Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/service/UserServiceImpl.java import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.net.SocketException; import java.net.UnknownHostException; import org.springframework.stereotype.Service; import com.lcxbox.common.model.LcxlNetCode; import com.lcxbox.netloader.user.model.LogonRequest; import com.lcxbox.netloader.user.model.LogonRespnse; import com.lcxbox.socket.json.SocketRequest; package com.lcxbox.netloader.user.service; @Service() public class UserServiceImpl implements IUserService { public LogonRespnse logon(String host, Integer port, String username, String password) throws IOException { // TODO Auto-generated method stub LogonRequest request = new LogonRequest();
request.setCode(LcxlNetCode.JC_LOGON);
lcxl/lcxl-net-loader
loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/service/UserServiceImpl.java
// Path: loader/web/netloader-web/src/main/java/com/lcxbox/common/model/LcxlNetCode.java // public class LcxlNetCode { // // public final static String JSON_CODE = "code"; // public final static int JC_NONE = 0x00; // /** // * 获取模块列表命令 // */ // public final static int JC_MODULE_LIST = 0x01; // /** // * 获取服务器列表 // */ // public final static int JC_SERVER_LIST = 0x03; // /** // * 设置虚拟IP地址 // */ // public final static int JC_SET_VIRTUAL_ADDR = 0x04; // /** // * 添加服务器 // */ // public final static int JC_ADD_SERVER = 0x05; // /** // * 设置服务器 // */ // public final static int JC_SET_SERVER = 0x06; // /** // * 删除服务器 // */ // public final static int JC_DEL_SERVER = 0x07; // // public final static int JC_LOGON = 0x10; // // public final static String JSON_DATA = "data"; // public final static String JSON_MODULE_LIST = "module_list"; // public final static String JSON_SERVER_LIST = "server_list"; // public final static String JSON_MINIPORT_NET_LUID = "miniport_net_luid"; // // public final static String JSON_STATUS ="status"; // public final static int JS_SUCCESS =0x00; // public final static int JS_FAIL =0x01; // public final static int JS_JSON_DATA_NOT_FOUND =0x02; // public final static int JS_JSON_CODE_NOT_FOUND =0x03; // public final static int JS_JSON_CODE_IP_FORMAT_INVALID =0x04; // public final static int JS_UNKNOWN_HOST = 0x10; // public final static int JS_SOCKET_ERROR = 0x11; // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/model/LogonRequest.java // public class LogonRequest extends CommonRequest { // private String username; // private String password; // public String getUsername() { // return username; // } // public void setUsername(String username) { // this.username = username; // } // public String getPassword() { // return password; // } // public void setPassword(String password) { // this.password = password; // } // // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/model/LogonRespnse.java // public class LogonRespnse extends CommonResponse { // // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/socket/json/SocketRequest.java // public class SocketRequest { // public static <T> T jsonRequest(String host, int port, Object request, Class<T> responseCls) throws UnknownHostException, IOException { // ObjectMapper objectMapper = new ObjectMapper(); // // JsonSocket sock = new JsonSocket(host, port); // ByteArrayOutputStream os = new ByteArrayOutputStream(); // objectMapper.getJsonFactory().createJsonGenerator(os, JsonEncoding.UTF16_LE).writeObject(request); // String ret = new String(sock.sendData(os.toByteArray()),"UTF-16LE"); // os.close(); // sock.close(); // return objectMapper.readValue(ret, responseCls); // } // }
import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.net.SocketException; import java.net.UnknownHostException; import org.springframework.stereotype.Service; import com.lcxbox.common.model.LcxlNetCode; import com.lcxbox.netloader.user.model.LogonRequest; import com.lcxbox.netloader.user.model.LogonRespnse; import com.lcxbox.socket.json.SocketRequest;
package com.lcxbox.netloader.user.service; @Service() public class UserServiceImpl implements IUserService { public LogonRespnse logon(String host, Integer port, String username, String password) throws IOException { // TODO Auto-generated method stub LogonRequest request = new LogonRequest(); request.setCode(LcxlNetCode.JC_LOGON); request.setUsername(username); request.setPassword(password); try {
// Path: loader/web/netloader-web/src/main/java/com/lcxbox/common/model/LcxlNetCode.java // public class LcxlNetCode { // // public final static String JSON_CODE = "code"; // public final static int JC_NONE = 0x00; // /** // * 获取模块列表命令 // */ // public final static int JC_MODULE_LIST = 0x01; // /** // * 获取服务器列表 // */ // public final static int JC_SERVER_LIST = 0x03; // /** // * 设置虚拟IP地址 // */ // public final static int JC_SET_VIRTUAL_ADDR = 0x04; // /** // * 添加服务器 // */ // public final static int JC_ADD_SERVER = 0x05; // /** // * 设置服务器 // */ // public final static int JC_SET_SERVER = 0x06; // /** // * 删除服务器 // */ // public final static int JC_DEL_SERVER = 0x07; // // public final static int JC_LOGON = 0x10; // // public final static String JSON_DATA = "data"; // public final static String JSON_MODULE_LIST = "module_list"; // public final static String JSON_SERVER_LIST = "server_list"; // public final static String JSON_MINIPORT_NET_LUID = "miniport_net_luid"; // // public final static String JSON_STATUS ="status"; // public final static int JS_SUCCESS =0x00; // public final static int JS_FAIL =0x01; // public final static int JS_JSON_DATA_NOT_FOUND =0x02; // public final static int JS_JSON_CODE_NOT_FOUND =0x03; // public final static int JS_JSON_CODE_IP_FORMAT_INVALID =0x04; // public final static int JS_UNKNOWN_HOST = 0x10; // public final static int JS_SOCKET_ERROR = 0x11; // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/model/LogonRequest.java // public class LogonRequest extends CommonRequest { // private String username; // private String password; // public String getUsername() { // return username; // } // public void setUsername(String username) { // this.username = username; // } // public String getPassword() { // return password; // } // public void setPassword(String password) { // this.password = password; // } // // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/model/LogonRespnse.java // public class LogonRespnse extends CommonResponse { // // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/socket/json/SocketRequest.java // public class SocketRequest { // public static <T> T jsonRequest(String host, int port, Object request, Class<T> responseCls) throws UnknownHostException, IOException { // ObjectMapper objectMapper = new ObjectMapper(); // // JsonSocket sock = new JsonSocket(host, port); // ByteArrayOutputStream os = new ByteArrayOutputStream(); // objectMapper.getJsonFactory().createJsonGenerator(os, JsonEncoding.UTF16_LE).writeObject(request); // String ret = new String(sock.sendData(os.toByteArray()),"UTF-16LE"); // os.close(); // sock.close(); // return objectMapper.readValue(ret, responseCls); // } // } // Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/service/UserServiceImpl.java import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.net.SocketException; import java.net.UnknownHostException; import org.springframework.stereotype.Service; import com.lcxbox.common.model.LcxlNetCode; import com.lcxbox.netloader.user.model.LogonRequest; import com.lcxbox.netloader.user.model.LogonRespnse; import com.lcxbox.socket.json.SocketRequest; package com.lcxbox.netloader.user.service; @Service() public class UserServiceImpl implements IUserService { public LogonRespnse logon(String host, Integer port, String username, String password) throws IOException { // TODO Auto-generated method stub LogonRequest request = new LogonRequest(); request.setCode(LcxlNetCode.JC_LOGON); request.setUsername(username); request.setPassword(password); try {
return SocketRequest.jsonRequest(host, port, request,
lcxl/lcxl-net-loader
loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/controller/UserController.java
// Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/model/LogonRespnse.java // public class LogonRespnse extends CommonResponse { // // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/service/IUserService.java // public interface IUserService { // public LogonRespnse logon(String host, Integer port, String username, String password) throws IOException; // }
import java.io.IOException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.lcxbox.netloader.user.model.LogonRespnse; import com.lcxbox.netloader.user.service.IUserService;
package com.lcxbox.netloader.user.controller; /** * 用户控制类 * @author lcxl * */ @Controller @RequestMapping(value = "/user") public class UserController { @Autowired
// Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/model/LogonRespnse.java // public class LogonRespnse extends CommonResponse { // // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/service/IUserService.java // public interface IUserService { // public LogonRespnse logon(String host, Integer port, String username, String password) throws IOException; // } // Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/controller/UserController.java import java.io.IOException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.lcxbox.netloader.user.model.LogonRespnse; import com.lcxbox.netloader.user.service.IUserService; package com.lcxbox.netloader.user.controller; /** * 用户控制类 * @author lcxl * */ @Controller @RequestMapping(value = "/user") public class UserController { @Autowired
private IUserService userService;
lcxl/lcxl-net-loader
loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/controller/UserController.java
// Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/model/LogonRespnse.java // public class LogonRespnse extends CommonResponse { // // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/service/IUserService.java // public interface IUserService { // public LogonRespnse logon(String host, Integer port, String username, String password) throws IOException; // }
import java.io.IOException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.lcxbox.netloader.user.model.LogonRespnse; import com.lcxbox.netloader.user.service.IUserService;
package com.lcxbox.netloader.user.controller; /** * 用户控制类 * @author lcxl * */ @Controller @RequestMapping(value = "/user") public class UserController { @Autowired private IUserService userService; /** * 登录 * @param request * @param response * @param host * @param port * @param username * @param password * @param rememberMe * @return * @throws IOException */ @RequestMapping(value = "/logon.do", method=RequestMethod.POST) @ResponseBody
// Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/model/LogonRespnse.java // public class LogonRespnse extends CommonResponse { // // } // // Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/service/IUserService.java // public interface IUserService { // public LogonRespnse logon(String host, Integer port, String username, String password) throws IOException; // } // Path: loader/web/netloader-web/src/main/java/com/lcxbox/netloader/user/controller/UserController.java import java.io.IOException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.lcxbox.netloader.user.model.LogonRespnse; import com.lcxbox.netloader.user.service.IUserService; package com.lcxbox.netloader.user.controller; /** * 用户控制类 * @author lcxl * */ @Controller @RequestMapping(value = "/user") public class UserController { @Autowired private IUserService userService; /** * 登录 * @param request * @param response * @param host * @param port * @param username * @param password * @param rememberMe * @return * @throws IOException */ @RequestMapping(value = "/logon.do", method=RequestMethod.POST) @ResponseBody
public LogonRespnse logon(HttpServletRequest request,
javadelight/delight-metrics
src/main/java/de/mxro/metrics/jre/Metrics.java
// Path: src/main/java/de/mxro/metrics/MetricsCommon.java // public class MetricsCommon extends PropertiesCommon { // // /** // * <p> // * Creates a metric node, which is not thread safe. Only use in single-threaded // * applications or environments (such as GWT/JavaScript). // * // * @return // */ // public static PropertyNode createUnsafe() { // return PropertiesCommon.createUnsafe( // PropertiesCommon.compositeFactory(new MetricsFactory(), PropertiesCommon.defaultFactory())); // } // // public static Factory<?, ?, ?> createUnsafeFactory() { // return new Factory<PropertyNode, Configuration, Dependencies>() { // // @Override // public boolean canInstantiate(final Configuration conf) { // // return conf instanceof MetricsConfiguration; // } // // @Override // public PropertyNode create(final Configuration conf, final Dependencies dependencies) { // return MetricsCommon.createUnsafe(); // } // }; // } // // public static PropertyOperation<Long> happened(final String id) { // return new MarkEvent().setId(id); // } // // public static PropertyOperation<Long> increment(final String id) { // return new CounterEvent(1).setId(id); // } // // public static PropertyOperation<Long> increment(final String id, final long by) { // return new CounterEvent(by).setId(id); // } // // public static PropertyOperation<Long> decrement(final String id) { // return new CounterEvent(-1).setId(id); // } // // /** // * Record a value and compute various statistics for the value, such as the mean // * etc. // * // * @param id // * @param value // * @return // */ // public static PropertyOperation<Long> value(final String id, final long value) { // return new HistrogramEvent(value).setId(id); // } // // public static PropertyOperation<Snapshot> retrieveHistogram(String id) { // return new RetrieveHistrogramEvent().setId(id); // } // // private static MetricRegistry registry = null; // // public static MetricRegistry getMetricRegistry() { // // if (registry == null) { // registry = new MetricRegistry(); // } // // return registry; // // } // // private static PropertyNode instance; // // public static PropertyNode get() { // return instance; // } // // public static void inject(final PropertyNode propertyNode) { // instance = propertyNode; // } // // } // // Path: src/main/java/de/mxro/metrics/MetricsConfiguration.java // public class MetricsConfiguration implements Configuration { // // } // // Path: src/main/java/de/mxro/metrics/internal/MetricsFactory.java // public class MetricsFactory implements PropertyFactory { // // private final <T> Metric createMetric(final Class<T> type) { // if (type.equals(Meter.class)) { // return new Meter(); // } // // if (type.equals(Counter.class)) { // return new Counter(); // } // // if (type.equals(Histogram.class)) { // return new Histogram(new ExponentiallyDecayingReservoir()); // } // // return null; // } // // @Override // @SuppressWarnings("unchecked") // public <T> T create(final String id, final Class<T> type) { // // final Metric metric = createMetric(type); // // if (metric == null) { // return null; // } // // if (MetricsCommon.getMetricRegistry().getNames().contains(id)) { // MetricsCommon.getMetricRegistry().remove(id); // } // // MetricsCommon.getMetricRegistry().register(id, metric); // // return (T) metric; // // } // // }
import delight.async.properties.PropertiesCommon; import delight.async.properties.PropertyNode; import delight.async.properties.jre.Properties; import delight.factories.Configuration; import delight.factories.Dependencies; import delight.factories.Factory; import de.mxro.metrics.MetricsCommon; import de.mxro.metrics.MetricsConfiguration; import de.mxro.metrics.internal.MetricsFactory;
package de.mxro.metrics.jre; /** * <p> * Convenient class to create new {@link PropertyNode}s and various metric * operations. * * @author <a href="http://www.mxro.de">Max Rohde</a> * */ public class Metrics extends MetricsCommon { public static PropertyNode create() { return Properties
// Path: src/main/java/de/mxro/metrics/MetricsCommon.java // public class MetricsCommon extends PropertiesCommon { // // /** // * <p> // * Creates a metric node, which is not thread safe. Only use in single-threaded // * applications or environments (such as GWT/JavaScript). // * // * @return // */ // public static PropertyNode createUnsafe() { // return PropertiesCommon.createUnsafe( // PropertiesCommon.compositeFactory(new MetricsFactory(), PropertiesCommon.defaultFactory())); // } // // public static Factory<?, ?, ?> createUnsafeFactory() { // return new Factory<PropertyNode, Configuration, Dependencies>() { // // @Override // public boolean canInstantiate(final Configuration conf) { // // return conf instanceof MetricsConfiguration; // } // // @Override // public PropertyNode create(final Configuration conf, final Dependencies dependencies) { // return MetricsCommon.createUnsafe(); // } // }; // } // // public static PropertyOperation<Long> happened(final String id) { // return new MarkEvent().setId(id); // } // // public static PropertyOperation<Long> increment(final String id) { // return new CounterEvent(1).setId(id); // } // // public static PropertyOperation<Long> increment(final String id, final long by) { // return new CounterEvent(by).setId(id); // } // // public static PropertyOperation<Long> decrement(final String id) { // return new CounterEvent(-1).setId(id); // } // // /** // * Record a value and compute various statistics for the value, such as the mean // * etc. // * // * @param id // * @param value // * @return // */ // public static PropertyOperation<Long> value(final String id, final long value) { // return new HistrogramEvent(value).setId(id); // } // // public static PropertyOperation<Snapshot> retrieveHistogram(String id) { // return new RetrieveHistrogramEvent().setId(id); // } // // private static MetricRegistry registry = null; // // public static MetricRegistry getMetricRegistry() { // // if (registry == null) { // registry = new MetricRegistry(); // } // // return registry; // // } // // private static PropertyNode instance; // // public static PropertyNode get() { // return instance; // } // // public static void inject(final PropertyNode propertyNode) { // instance = propertyNode; // } // // } // // Path: src/main/java/de/mxro/metrics/MetricsConfiguration.java // public class MetricsConfiguration implements Configuration { // // } // // Path: src/main/java/de/mxro/metrics/internal/MetricsFactory.java // public class MetricsFactory implements PropertyFactory { // // private final <T> Metric createMetric(final Class<T> type) { // if (type.equals(Meter.class)) { // return new Meter(); // } // // if (type.equals(Counter.class)) { // return new Counter(); // } // // if (type.equals(Histogram.class)) { // return new Histogram(new ExponentiallyDecayingReservoir()); // } // // return null; // } // // @Override // @SuppressWarnings("unchecked") // public <T> T create(final String id, final Class<T> type) { // // final Metric metric = createMetric(type); // // if (metric == null) { // return null; // } // // if (MetricsCommon.getMetricRegistry().getNames().contains(id)) { // MetricsCommon.getMetricRegistry().remove(id); // } // // MetricsCommon.getMetricRegistry().register(id, metric); // // return (T) metric; // // } // // } // Path: src/main/java/de/mxro/metrics/jre/Metrics.java import delight.async.properties.PropertiesCommon; import delight.async.properties.PropertyNode; import delight.async.properties.jre.Properties; import delight.factories.Configuration; import delight.factories.Dependencies; import delight.factories.Factory; import de.mxro.metrics.MetricsCommon; import de.mxro.metrics.MetricsConfiguration; import de.mxro.metrics.internal.MetricsFactory; package de.mxro.metrics.jre; /** * <p> * Convenient class to create new {@link PropertyNode}s and various metric * operations. * * @author <a href="http://www.mxro.de">Max Rohde</a> * */ public class Metrics extends MetricsCommon { public static PropertyNode create() { return Properties
.create(PropertiesCommon.compositeFactory(new MetricsFactory(), PropertiesCommon.defaultFactory()));
javadelight/delight-metrics
src/main/java/de/mxro/metrics/jre/Metrics.java
// Path: src/main/java/de/mxro/metrics/MetricsCommon.java // public class MetricsCommon extends PropertiesCommon { // // /** // * <p> // * Creates a metric node, which is not thread safe. Only use in single-threaded // * applications or environments (such as GWT/JavaScript). // * // * @return // */ // public static PropertyNode createUnsafe() { // return PropertiesCommon.createUnsafe( // PropertiesCommon.compositeFactory(new MetricsFactory(), PropertiesCommon.defaultFactory())); // } // // public static Factory<?, ?, ?> createUnsafeFactory() { // return new Factory<PropertyNode, Configuration, Dependencies>() { // // @Override // public boolean canInstantiate(final Configuration conf) { // // return conf instanceof MetricsConfiguration; // } // // @Override // public PropertyNode create(final Configuration conf, final Dependencies dependencies) { // return MetricsCommon.createUnsafe(); // } // }; // } // // public static PropertyOperation<Long> happened(final String id) { // return new MarkEvent().setId(id); // } // // public static PropertyOperation<Long> increment(final String id) { // return new CounterEvent(1).setId(id); // } // // public static PropertyOperation<Long> increment(final String id, final long by) { // return new CounterEvent(by).setId(id); // } // // public static PropertyOperation<Long> decrement(final String id) { // return new CounterEvent(-1).setId(id); // } // // /** // * Record a value and compute various statistics for the value, such as the mean // * etc. // * // * @param id // * @param value // * @return // */ // public static PropertyOperation<Long> value(final String id, final long value) { // return new HistrogramEvent(value).setId(id); // } // // public static PropertyOperation<Snapshot> retrieveHistogram(String id) { // return new RetrieveHistrogramEvent().setId(id); // } // // private static MetricRegistry registry = null; // // public static MetricRegistry getMetricRegistry() { // // if (registry == null) { // registry = new MetricRegistry(); // } // // return registry; // // } // // private static PropertyNode instance; // // public static PropertyNode get() { // return instance; // } // // public static void inject(final PropertyNode propertyNode) { // instance = propertyNode; // } // // } // // Path: src/main/java/de/mxro/metrics/MetricsConfiguration.java // public class MetricsConfiguration implements Configuration { // // } // // Path: src/main/java/de/mxro/metrics/internal/MetricsFactory.java // public class MetricsFactory implements PropertyFactory { // // private final <T> Metric createMetric(final Class<T> type) { // if (type.equals(Meter.class)) { // return new Meter(); // } // // if (type.equals(Counter.class)) { // return new Counter(); // } // // if (type.equals(Histogram.class)) { // return new Histogram(new ExponentiallyDecayingReservoir()); // } // // return null; // } // // @Override // @SuppressWarnings("unchecked") // public <T> T create(final String id, final Class<T> type) { // // final Metric metric = createMetric(type); // // if (metric == null) { // return null; // } // // if (MetricsCommon.getMetricRegistry().getNames().contains(id)) { // MetricsCommon.getMetricRegistry().remove(id); // } // // MetricsCommon.getMetricRegistry().register(id, metric); // // return (T) metric; // // } // // }
import delight.async.properties.PropertiesCommon; import delight.async.properties.PropertyNode; import delight.async.properties.jre.Properties; import delight.factories.Configuration; import delight.factories.Dependencies; import delight.factories.Factory; import de.mxro.metrics.MetricsCommon; import de.mxro.metrics.MetricsConfiguration; import de.mxro.metrics.internal.MetricsFactory;
package de.mxro.metrics.jre; /** * <p> * Convenient class to create new {@link PropertyNode}s and various metric * operations. * * @author <a href="http://www.mxro.de">Max Rohde</a> * */ public class Metrics extends MetricsCommon { public static PropertyNode create() { return Properties .create(PropertiesCommon.compositeFactory(new MetricsFactory(), PropertiesCommon.defaultFactory())); } public static Factory<?, ?, ?> createMetricsFactory() { return new Factory<PropertyNode, Configuration, Dependencies>() { @Override public boolean canInstantiate(final Configuration conf) {
// Path: src/main/java/de/mxro/metrics/MetricsCommon.java // public class MetricsCommon extends PropertiesCommon { // // /** // * <p> // * Creates a metric node, which is not thread safe. Only use in single-threaded // * applications or environments (such as GWT/JavaScript). // * // * @return // */ // public static PropertyNode createUnsafe() { // return PropertiesCommon.createUnsafe( // PropertiesCommon.compositeFactory(new MetricsFactory(), PropertiesCommon.defaultFactory())); // } // // public static Factory<?, ?, ?> createUnsafeFactory() { // return new Factory<PropertyNode, Configuration, Dependencies>() { // // @Override // public boolean canInstantiate(final Configuration conf) { // // return conf instanceof MetricsConfiguration; // } // // @Override // public PropertyNode create(final Configuration conf, final Dependencies dependencies) { // return MetricsCommon.createUnsafe(); // } // }; // } // // public static PropertyOperation<Long> happened(final String id) { // return new MarkEvent().setId(id); // } // // public static PropertyOperation<Long> increment(final String id) { // return new CounterEvent(1).setId(id); // } // // public static PropertyOperation<Long> increment(final String id, final long by) { // return new CounterEvent(by).setId(id); // } // // public static PropertyOperation<Long> decrement(final String id) { // return new CounterEvent(-1).setId(id); // } // // /** // * Record a value and compute various statistics for the value, such as the mean // * etc. // * // * @param id // * @param value // * @return // */ // public static PropertyOperation<Long> value(final String id, final long value) { // return new HistrogramEvent(value).setId(id); // } // // public static PropertyOperation<Snapshot> retrieveHistogram(String id) { // return new RetrieveHistrogramEvent().setId(id); // } // // private static MetricRegistry registry = null; // // public static MetricRegistry getMetricRegistry() { // // if (registry == null) { // registry = new MetricRegistry(); // } // // return registry; // // } // // private static PropertyNode instance; // // public static PropertyNode get() { // return instance; // } // // public static void inject(final PropertyNode propertyNode) { // instance = propertyNode; // } // // } // // Path: src/main/java/de/mxro/metrics/MetricsConfiguration.java // public class MetricsConfiguration implements Configuration { // // } // // Path: src/main/java/de/mxro/metrics/internal/MetricsFactory.java // public class MetricsFactory implements PropertyFactory { // // private final <T> Metric createMetric(final Class<T> type) { // if (type.equals(Meter.class)) { // return new Meter(); // } // // if (type.equals(Counter.class)) { // return new Counter(); // } // // if (type.equals(Histogram.class)) { // return new Histogram(new ExponentiallyDecayingReservoir()); // } // // return null; // } // // @Override // @SuppressWarnings("unchecked") // public <T> T create(final String id, final Class<T> type) { // // final Metric metric = createMetric(type); // // if (metric == null) { // return null; // } // // if (MetricsCommon.getMetricRegistry().getNames().contains(id)) { // MetricsCommon.getMetricRegistry().remove(id); // } // // MetricsCommon.getMetricRegistry().register(id, metric); // // return (T) metric; // // } // // } // Path: src/main/java/de/mxro/metrics/jre/Metrics.java import delight.async.properties.PropertiesCommon; import delight.async.properties.PropertyNode; import delight.async.properties.jre.Properties; import delight.factories.Configuration; import delight.factories.Dependencies; import delight.factories.Factory; import de.mxro.metrics.MetricsCommon; import de.mxro.metrics.MetricsConfiguration; import de.mxro.metrics.internal.MetricsFactory; package de.mxro.metrics.jre; /** * <p> * Convenient class to create new {@link PropertyNode}s and various metric * operations. * * @author <a href="http://www.mxro.de">Max Rohde</a> * */ public class Metrics extends MetricsCommon { public static PropertyNode create() { return Properties .create(PropertiesCommon.compositeFactory(new MetricsFactory(), PropertiesCommon.defaultFactory())); } public static Factory<?, ?, ?> createMetricsFactory() { return new Factory<PropertyNode, Configuration, Dependencies>() { @Override public boolean canInstantiate(final Configuration conf) {
return conf instanceof MetricsConfiguration;
javadelight/delight-metrics
src/test/java/de/mxro/metrics/tests/TestMeter.java
// Path: src/main/java/com/codahale/metrics/Meter.java // public class Meter implements Metered, ToJSON { // private static final long TICK_INTERVAL = 5000000000L;// TimeUnit.SECONDS.toNanos(5); // // private final EWMA m1Rate = EWMA.oneMinuteEWMA(); // private final EWMA m5Rate = EWMA.fiveMinuteEWMA(); // private final EWMA m15Rate = EWMA.fifteenMinuteEWMA(); // // private final LongAdder count = new LongAdderGwt(); // private final long startTime; // private long lastTick; // private final Clock clock; // // /** // * Creates a new {@link Meter}. // */ // public Meter() { // this(Clock.defaultClock()); // } // // /** // * Creates a new {@link Meter}. // * // * @param clock // * the clock to use for the meter ticks // */ // public Meter(final Clock clock) { // this.clock = clock; // this.startTime = this.clock.getTick(); // this.lastTick = startTime; // } // // /** // * Mark the occurrence of an event. // */ // public void mark() { // mark(1); // } // // /** // * Mark the occurrence of a given number of events. // * // * @param n // * the number of events // */ // public void mark(final long n) { // tickIfNecessary(); // count.add(n); // m1Rate.update(n); // m5Rate.update(n); // m15Rate.update(n); // } // // private void tickIfNecessary() { // final long oldTick = lastTick; // final long newTick = clock.getTick(); // final long age = newTick - oldTick; // // if (age > TICK_INTERVAL) { // final long newIntervalStartTick = newTick - age % TICK_INTERVAL; // if (lastTick == oldTick) { // lastTick = newIntervalStartTick; // final long requiredTicks = age / TICK_INTERVAL; // for (long i = 0; i < requiredTicks; i++) { // m1Rate.tick(); // m5Rate.tick(); // m15Rate.tick(); // } // } // // } // } // // @Override // public long getCount() { // return count.sum(); // } // // @Override // public double getFifteenMinuteRate() { // tickIfNecessary(); // return m15Rate.getRate(1000000000 /* 1 s in nanosecons */); // } // // @Override // public double getFiveMinuteRate() { // tickIfNecessary(); // return m5Rate.getRate(1000000000 /* 1 s in nanosecons */); // } // // @Override // public double getMeanRate() { // if (getCount() == 0) { // return 0.0; // } else { // final double elapsed = (clock.getTick() - startTime); // return getCount() / elapsed * 1000000000 /* 1 s in nanosecons */; // } // } // // @Override // public double getOneMinuteRate() { // tickIfNecessary(); // return m1Rate.getRate(1000000000 /* 1 s in nanosecons */); // } // // @Override // public String toString() { // // return toJSON().render(); // } // // @Override // public JSON toJSON() { // final JSONObject o = JSON.create(); // o.add("Total Events", count); // o.add("Events per Second (last Minute)", getOneMinuteRate()); // o.add("Events per Second (last 5 Minutes)", getFiveMinuteRate()); // o.add("Events per Second (last 15 Minutes)", getFifteenMinuteRate()); // return o; // } // // } // // Path: src/main/java/de/mxro/metrics/jre/Metrics.java // public class Metrics extends MetricsCommon { // // public static PropertyNode create() { // return Properties // .create(PropertiesCommon.compositeFactory(new MetricsFactory(), PropertiesCommon.defaultFactory())); // } // // public static Factory<?, ?, ?> createMetricsFactory() { // return new Factory<PropertyNode, Configuration, Dependencies>() { // // @Override // public boolean canInstantiate(final Configuration conf) { // // return conf instanceof MetricsConfiguration; // } // // @Override // public PropertyNode create(final Configuration conf, final Dependencies dependencies) { // return Metrics.create(); // } // }; // } // // private static PropertyNode metrics; // // /** // * <p> // * Sets the default metrics instance which can be accessed via Metrics.get() // * // * @param node // */ // public static void inject(final PropertyNode node) { // metrics = node; // MetricsCommon.inject(node); // } // // public static PropertyNode get() { // return metrics; // } // // }
import com.codahale.metrics.Meter; import de.mxro.metrics.jre.Metrics; import de.oehme.xtend.junit.Hamcrest; import de.oehme.xtend.junit.JUnit; import delight.async.properties.PropertyNode; import org.eclipse.xtext.xbase.lib.Exceptions; import org.eclipse.xtext.xbase.lib.Extension; import org.eclipse.xtext.xbase.lib.IntegerRange; import org.eclipse.xtext.xbase.lib.Procedures.Procedure0; import org.hamcrest.CoreMatchers; import org.hamcrest.Matcher; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.internal.ArrayComparisonFailure; import org.junit.rules.ErrorCollector;
package de.mxro.metrics.tests; @JUnit @Hamcrest @SuppressWarnings("all") public class TestMeter { @Test public void test_count() {
// Path: src/main/java/com/codahale/metrics/Meter.java // public class Meter implements Metered, ToJSON { // private static final long TICK_INTERVAL = 5000000000L;// TimeUnit.SECONDS.toNanos(5); // // private final EWMA m1Rate = EWMA.oneMinuteEWMA(); // private final EWMA m5Rate = EWMA.fiveMinuteEWMA(); // private final EWMA m15Rate = EWMA.fifteenMinuteEWMA(); // // private final LongAdder count = new LongAdderGwt(); // private final long startTime; // private long lastTick; // private final Clock clock; // // /** // * Creates a new {@link Meter}. // */ // public Meter() { // this(Clock.defaultClock()); // } // // /** // * Creates a new {@link Meter}. // * // * @param clock // * the clock to use for the meter ticks // */ // public Meter(final Clock clock) { // this.clock = clock; // this.startTime = this.clock.getTick(); // this.lastTick = startTime; // } // // /** // * Mark the occurrence of an event. // */ // public void mark() { // mark(1); // } // // /** // * Mark the occurrence of a given number of events. // * // * @param n // * the number of events // */ // public void mark(final long n) { // tickIfNecessary(); // count.add(n); // m1Rate.update(n); // m5Rate.update(n); // m15Rate.update(n); // } // // private void tickIfNecessary() { // final long oldTick = lastTick; // final long newTick = clock.getTick(); // final long age = newTick - oldTick; // // if (age > TICK_INTERVAL) { // final long newIntervalStartTick = newTick - age % TICK_INTERVAL; // if (lastTick == oldTick) { // lastTick = newIntervalStartTick; // final long requiredTicks = age / TICK_INTERVAL; // for (long i = 0; i < requiredTicks; i++) { // m1Rate.tick(); // m5Rate.tick(); // m15Rate.tick(); // } // } // // } // } // // @Override // public long getCount() { // return count.sum(); // } // // @Override // public double getFifteenMinuteRate() { // tickIfNecessary(); // return m15Rate.getRate(1000000000 /* 1 s in nanosecons */); // } // // @Override // public double getFiveMinuteRate() { // tickIfNecessary(); // return m5Rate.getRate(1000000000 /* 1 s in nanosecons */); // } // // @Override // public double getMeanRate() { // if (getCount() == 0) { // return 0.0; // } else { // final double elapsed = (clock.getTick() - startTime); // return getCount() / elapsed * 1000000000 /* 1 s in nanosecons */; // } // } // // @Override // public double getOneMinuteRate() { // tickIfNecessary(); // return m1Rate.getRate(1000000000 /* 1 s in nanosecons */); // } // // @Override // public String toString() { // // return toJSON().render(); // } // // @Override // public JSON toJSON() { // final JSONObject o = JSON.create(); // o.add("Total Events", count); // o.add("Events per Second (last Minute)", getOneMinuteRate()); // o.add("Events per Second (last 5 Minutes)", getFiveMinuteRate()); // o.add("Events per Second (last 15 Minutes)", getFifteenMinuteRate()); // return o; // } // // } // // Path: src/main/java/de/mxro/metrics/jre/Metrics.java // public class Metrics extends MetricsCommon { // // public static PropertyNode create() { // return Properties // .create(PropertiesCommon.compositeFactory(new MetricsFactory(), PropertiesCommon.defaultFactory())); // } // // public static Factory<?, ?, ?> createMetricsFactory() { // return new Factory<PropertyNode, Configuration, Dependencies>() { // // @Override // public boolean canInstantiate(final Configuration conf) { // // return conf instanceof MetricsConfiguration; // } // // @Override // public PropertyNode create(final Configuration conf, final Dependencies dependencies) { // return Metrics.create(); // } // }; // } // // private static PropertyNode metrics; // // /** // * <p> // * Sets the default metrics instance which can be accessed via Metrics.get() // * // * @param node // */ // public static void inject(final PropertyNode node) { // metrics = node; // MetricsCommon.inject(node); // } // // public static PropertyNode get() { // return metrics; // } // // } // Path: src/test/java/de/mxro/metrics/tests/TestMeter.java import com.codahale.metrics.Meter; import de.mxro.metrics.jre.Metrics; import de.oehme.xtend.junit.Hamcrest; import de.oehme.xtend.junit.JUnit; import delight.async.properties.PropertyNode; import org.eclipse.xtext.xbase.lib.Exceptions; import org.eclipse.xtext.xbase.lib.Extension; import org.eclipse.xtext.xbase.lib.IntegerRange; import org.eclipse.xtext.xbase.lib.Procedures.Procedure0; import org.hamcrest.CoreMatchers; import org.hamcrest.Matcher; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.internal.ArrayComparisonFailure; import org.junit.rules.ErrorCollector; package de.mxro.metrics.tests; @JUnit @Hamcrest @SuppressWarnings("all") public class TestMeter { @Test public void test_count() {
final PropertyNode m = Metrics.create();
javadelight/delight-metrics
src/test/java/de/mxro/metrics/tests/TestCounter.java
// Path: src/main/java/de/mxro/metrics/jre/Metrics.java // public class Metrics extends MetricsCommon { // // public static PropertyNode create() { // return Properties // .create(PropertiesCommon.compositeFactory(new MetricsFactory(), PropertiesCommon.defaultFactory())); // } // // public static Factory<?, ?, ?> createMetricsFactory() { // return new Factory<PropertyNode, Configuration, Dependencies>() { // // @Override // public boolean canInstantiate(final Configuration conf) { // // return conf instanceof MetricsConfiguration; // } // // @Override // public PropertyNode create(final Configuration conf, final Dependencies dependencies) { // return Metrics.create(); // } // }; // } // // private static PropertyNode metrics; // // /** // * <p> // * Sets the default metrics instance which can be accessed via Metrics.get() // * // * @param node // */ // public static void inject(final PropertyNode node) { // metrics = node; // MetricsCommon.inject(node); // } // // public static PropertyNode get() { // return metrics; // } // // }
import de.mxro.metrics.jre.Metrics; import de.oehme.xtend.junit.Hamcrest; import de.oehme.xtend.junit.JUnit; import delight.async.properties.PropertyNode; import org.eclipse.xtext.xbase.lib.Exceptions; import org.eclipse.xtext.xbase.lib.Extension; import org.eclipse.xtext.xbase.lib.IntegerRange; import org.eclipse.xtext.xbase.lib.Procedures.Procedure0; import org.hamcrest.CoreMatchers; import org.hamcrest.Matcher; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.internal.ArrayComparisonFailure; import org.junit.rules.ErrorCollector;
package de.mxro.metrics.tests; @JUnit @Hamcrest @SuppressWarnings("all") public class TestCounter { @Test public void test() {
// Path: src/main/java/de/mxro/metrics/jre/Metrics.java // public class Metrics extends MetricsCommon { // // public static PropertyNode create() { // return Properties // .create(PropertiesCommon.compositeFactory(new MetricsFactory(), PropertiesCommon.defaultFactory())); // } // // public static Factory<?, ?, ?> createMetricsFactory() { // return new Factory<PropertyNode, Configuration, Dependencies>() { // // @Override // public boolean canInstantiate(final Configuration conf) { // // return conf instanceof MetricsConfiguration; // } // // @Override // public PropertyNode create(final Configuration conf, final Dependencies dependencies) { // return Metrics.create(); // } // }; // } // // private static PropertyNode metrics; // // /** // * <p> // * Sets the default metrics instance which can be accessed via Metrics.get() // * // * @param node // */ // public static void inject(final PropertyNode node) { // metrics = node; // MetricsCommon.inject(node); // } // // public static PropertyNode get() { // return metrics; // } // // } // Path: src/test/java/de/mxro/metrics/tests/TestCounter.java import de.mxro.metrics.jre.Metrics; import de.oehme.xtend.junit.Hamcrest; import de.oehme.xtend.junit.JUnit; import delight.async.properties.PropertyNode; import org.eclipse.xtext.xbase.lib.Exceptions; import org.eclipse.xtext.xbase.lib.Extension; import org.eclipse.xtext.xbase.lib.IntegerRange; import org.eclipse.xtext.xbase.lib.Procedures.Procedure0; import org.hamcrest.CoreMatchers; import org.hamcrest.Matcher; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.internal.ArrayComparisonFailure; import org.junit.rules.ErrorCollector; package de.mxro.metrics.tests; @JUnit @Hamcrest @SuppressWarnings("all") public class TestCounter { @Test public void test() {
PropertyNode m = Metrics.create();
javadelight/delight-metrics
src/main/java/com/codahale/metrics/ExponentiallyDecayingReservoir.java
// Path: src/main/java/com/codahale/metrics/WeightedSnapshot.java // public static class WeightedSample { // public final long value; // public final double weight; // // public WeightedSample(final long value, final double weight) { // this.value = value; // this.weight = weight; // } // }
import static java.lang.Math.exp; import static java.lang.Math.min; import java.util.ArrayList; import java.util.Random; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; import com.codahale.metrics.WeightedSnapshot.WeightedSample;
package com.codahale.metrics; /** * An exponentially-decaying random reservoir of {@code long}s. Uses Cormode et * al's forward-decaying priority reservoir sampling method to produce a * statistically representative sampling reservoir, exponentially biased towards * newer entries. * * @see <a href="http://dimacs.rutgers.edu/~graham/pubs/papers/fwddecay.pdf"> * Cormode et al. Forward Decay: A Practical Time Decay Model for Streaming * Systems. ICDE '09: Proceedings of the 2009 IEEE International Conference * on Data Engineering (2009)</a> */ public class ExponentiallyDecayingReservoir implements Reservoir { private static final int DEFAULT_SIZE = 1028; private static final double DEFAULT_ALPHA = 0.015; private static final long RESCALE_THRESHOLD = TimeUnit.HOURS.toNanos(1);
// Path: src/main/java/com/codahale/metrics/WeightedSnapshot.java // public static class WeightedSample { // public final long value; // public final double weight; // // public WeightedSample(final long value, final double weight) { // this.value = value; // this.weight = weight; // } // } // Path: src/main/java/com/codahale/metrics/ExponentiallyDecayingReservoir.java import static java.lang.Math.exp; import static java.lang.Math.min; import java.util.ArrayList; import java.util.Random; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; import com.codahale.metrics.WeightedSnapshot.WeightedSample; package com.codahale.metrics; /** * An exponentially-decaying random reservoir of {@code long}s. Uses Cormode et * al's forward-decaying priority reservoir sampling method to produce a * statistically representative sampling reservoir, exponentially biased towards * newer entries. * * @see <a href="http://dimacs.rutgers.edu/~graham/pubs/papers/fwddecay.pdf"> * Cormode et al. Forward Decay: A Practical Time Decay Model for Streaming * Systems. ICDE '09: Proceedings of the 2009 IEEE International Conference * on Data Engineering (2009)</a> */ public class ExponentiallyDecayingReservoir implements Reservoir { private static final int DEFAULT_SIZE = 1028; private static final double DEFAULT_ALPHA = 0.015; private static final long RESCALE_THRESHOLD = TimeUnit.HOURS.toNanos(1);
private final ConcurrentSkipListMap<Double, WeightedSample> values;
javadelight/delight-metrics
src/test/java/de/mxro/metrics/tests/TestMultiThreaded.java
// Path: src/main/java/com/codahale/metrics/Meter.java // public class Meter implements Metered, ToJSON { // private static final long TICK_INTERVAL = 5000000000L;// TimeUnit.SECONDS.toNanos(5); // // private final EWMA m1Rate = EWMA.oneMinuteEWMA(); // private final EWMA m5Rate = EWMA.fiveMinuteEWMA(); // private final EWMA m15Rate = EWMA.fifteenMinuteEWMA(); // // private final LongAdder count = new LongAdderGwt(); // private final long startTime; // private long lastTick; // private final Clock clock; // // /** // * Creates a new {@link Meter}. // */ // public Meter() { // this(Clock.defaultClock()); // } // // /** // * Creates a new {@link Meter}. // * // * @param clock // * the clock to use for the meter ticks // */ // public Meter(final Clock clock) { // this.clock = clock; // this.startTime = this.clock.getTick(); // this.lastTick = startTime; // } // // /** // * Mark the occurrence of an event. // */ // public void mark() { // mark(1); // } // // /** // * Mark the occurrence of a given number of events. // * // * @param n // * the number of events // */ // public void mark(final long n) { // tickIfNecessary(); // count.add(n); // m1Rate.update(n); // m5Rate.update(n); // m15Rate.update(n); // } // // private void tickIfNecessary() { // final long oldTick = lastTick; // final long newTick = clock.getTick(); // final long age = newTick - oldTick; // // if (age > TICK_INTERVAL) { // final long newIntervalStartTick = newTick - age % TICK_INTERVAL; // if (lastTick == oldTick) { // lastTick = newIntervalStartTick; // final long requiredTicks = age / TICK_INTERVAL; // for (long i = 0; i < requiredTicks; i++) { // m1Rate.tick(); // m5Rate.tick(); // m15Rate.tick(); // } // } // // } // } // // @Override // public long getCount() { // return count.sum(); // } // // @Override // public double getFifteenMinuteRate() { // tickIfNecessary(); // return m15Rate.getRate(1000000000 /* 1 s in nanosecons */); // } // // @Override // public double getFiveMinuteRate() { // tickIfNecessary(); // return m5Rate.getRate(1000000000 /* 1 s in nanosecons */); // } // // @Override // public double getMeanRate() { // if (getCount() == 0) { // return 0.0; // } else { // final double elapsed = (clock.getTick() - startTime); // return getCount() / elapsed * 1000000000 /* 1 s in nanosecons */; // } // } // // @Override // public double getOneMinuteRate() { // tickIfNecessary(); // return m1Rate.getRate(1000000000 /* 1 s in nanosecons */); // } // // @Override // public String toString() { // // return toJSON().render(); // } // // @Override // public JSON toJSON() { // final JSONObject o = JSON.create(); // o.add("Total Events", count); // o.add("Events per Second (last Minute)", getOneMinuteRate()); // o.add("Events per Second (last 5 Minutes)", getFiveMinuteRate()); // o.add("Events per Second (last 15 Minutes)", getFifteenMinuteRate()); // return o; // } // // } // // Path: src/main/java/de/mxro/metrics/jre/Metrics.java // public class Metrics extends MetricsCommon { // // public static PropertyNode create() { // return Properties // .create(PropertiesCommon.compositeFactory(new MetricsFactory(), PropertiesCommon.defaultFactory())); // } // // public static Factory<?, ?, ?> createMetricsFactory() { // return new Factory<PropertyNode, Configuration, Dependencies>() { // // @Override // public boolean canInstantiate(final Configuration conf) { // // return conf instanceof MetricsConfiguration; // } // // @Override // public PropertyNode create(final Configuration conf, final Dependencies dependencies) { // return Metrics.create(); // } // }; // } // // private static PropertyNode metrics; // // /** // * <p> // * Sets the default metrics instance which can be accessed via Metrics.get() // * // * @param node // */ // public static void inject(final PropertyNode node) { // metrics = node; // MetricsCommon.inject(node); // } // // public static PropertyNode get() { // return metrics; // } // // }
import com.codahale.metrics.Meter; import de.mxro.metrics.jre.Metrics; import de.oehme.xtend.junit.Hamcrest; import de.oehme.xtend.junit.JUnit; import delight.async.properties.PropertyNode; import delight.functional.Closure; import java.util.Random; import org.eclipse.xtext.xbase.lib.Exceptions; import org.eclipse.xtext.xbase.lib.Extension; import org.eclipse.xtext.xbase.lib.IntegerRange; import org.eclipse.xtext.xbase.lib.Procedures.Procedure0; import org.hamcrest.CoreMatchers; import org.hamcrest.Matcher; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.internal.ArrayComparisonFailure; import org.junit.rules.ErrorCollector;
package de.mxro.metrics.tests; @JUnit @Hamcrest @SuppressWarnings("all") public class TestMultiThreaded { @Test public void test() { try {
// Path: src/main/java/com/codahale/metrics/Meter.java // public class Meter implements Metered, ToJSON { // private static final long TICK_INTERVAL = 5000000000L;// TimeUnit.SECONDS.toNanos(5); // // private final EWMA m1Rate = EWMA.oneMinuteEWMA(); // private final EWMA m5Rate = EWMA.fiveMinuteEWMA(); // private final EWMA m15Rate = EWMA.fifteenMinuteEWMA(); // // private final LongAdder count = new LongAdderGwt(); // private final long startTime; // private long lastTick; // private final Clock clock; // // /** // * Creates a new {@link Meter}. // */ // public Meter() { // this(Clock.defaultClock()); // } // // /** // * Creates a new {@link Meter}. // * // * @param clock // * the clock to use for the meter ticks // */ // public Meter(final Clock clock) { // this.clock = clock; // this.startTime = this.clock.getTick(); // this.lastTick = startTime; // } // // /** // * Mark the occurrence of an event. // */ // public void mark() { // mark(1); // } // // /** // * Mark the occurrence of a given number of events. // * // * @param n // * the number of events // */ // public void mark(final long n) { // tickIfNecessary(); // count.add(n); // m1Rate.update(n); // m5Rate.update(n); // m15Rate.update(n); // } // // private void tickIfNecessary() { // final long oldTick = lastTick; // final long newTick = clock.getTick(); // final long age = newTick - oldTick; // // if (age > TICK_INTERVAL) { // final long newIntervalStartTick = newTick - age % TICK_INTERVAL; // if (lastTick == oldTick) { // lastTick = newIntervalStartTick; // final long requiredTicks = age / TICK_INTERVAL; // for (long i = 0; i < requiredTicks; i++) { // m1Rate.tick(); // m5Rate.tick(); // m15Rate.tick(); // } // } // // } // } // // @Override // public long getCount() { // return count.sum(); // } // // @Override // public double getFifteenMinuteRate() { // tickIfNecessary(); // return m15Rate.getRate(1000000000 /* 1 s in nanosecons */); // } // // @Override // public double getFiveMinuteRate() { // tickIfNecessary(); // return m5Rate.getRate(1000000000 /* 1 s in nanosecons */); // } // // @Override // public double getMeanRate() { // if (getCount() == 0) { // return 0.0; // } else { // final double elapsed = (clock.getTick() - startTime); // return getCount() / elapsed * 1000000000 /* 1 s in nanosecons */; // } // } // // @Override // public double getOneMinuteRate() { // tickIfNecessary(); // return m1Rate.getRate(1000000000 /* 1 s in nanosecons */); // } // // @Override // public String toString() { // // return toJSON().render(); // } // // @Override // public JSON toJSON() { // final JSONObject o = JSON.create(); // o.add("Total Events", count); // o.add("Events per Second (last Minute)", getOneMinuteRate()); // o.add("Events per Second (last 5 Minutes)", getFiveMinuteRate()); // o.add("Events per Second (last 15 Minutes)", getFifteenMinuteRate()); // return o; // } // // } // // Path: src/main/java/de/mxro/metrics/jre/Metrics.java // public class Metrics extends MetricsCommon { // // public static PropertyNode create() { // return Properties // .create(PropertiesCommon.compositeFactory(new MetricsFactory(), PropertiesCommon.defaultFactory())); // } // // public static Factory<?, ?, ?> createMetricsFactory() { // return new Factory<PropertyNode, Configuration, Dependencies>() { // // @Override // public boolean canInstantiate(final Configuration conf) { // // return conf instanceof MetricsConfiguration; // } // // @Override // public PropertyNode create(final Configuration conf, final Dependencies dependencies) { // return Metrics.create(); // } // }; // } // // private static PropertyNode metrics; // // /** // * <p> // * Sets the default metrics instance which can be accessed via Metrics.get() // * // * @param node // */ // public static void inject(final PropertyNode node) { // metrics = node; // MetricsCommon.inject(node); // } // // public static PropertyNode get() { // return metrics; // } // // } // Path: src/test/java/de/mxro/metrics/tests/TestMultiThreaded.java import com.codahale.metrics.Meter; import de.mxro.metrics.jre.Metrics; import de.oehme.xtend.junit.Hamcrest; import de.oehme.xtend.junit.JUnit; import delight.async.properties.PropertyNode; import delight.functional.Closure; import java.util.Random; import org.eclipse.xtext.xbase.lib.Exceptions; import org.eclipse.xtext.xbase.lib.Extension; import org.eclipse.xtext.xbase.lib.IntegerRange; import org.eclipse.xtext.xbase.lib.Procedures.Procedure0; import org.hamcrest.CoreMatchers; import org.hamcrest.Matcher; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.internal.ArrayComparisonFailure; import org.junit.rules.ErrorCollector; package de.mxro.metrics.tests; @JUnit @Hamcrest @SuppressWarnings("all") public class TestMultiThreaded { @Test public void test() { try {
final PropertyNode m = Metrics.create();
javadelight/delight-metrics
src/test/java/de/mxro/metrics/examples/ExampleCounter.java
// Path: src/main/java/de/mxro/metrics/jre/Metrics.java // public class Metrics extends MetricsCommon { // // public static PropertyNode create() { // return Properties // .create(PropertiesCommon.compositeFactory(new MetricsFactory(), PropertiesCommon.defaultFactory())); // } // // public static Factory<?, ?, ?> createMetricsFactory() { // return new Factory<PropertyNode, Configuration, Dependencies>() { // // @Override // public boolean canInstantiate(final Configuration conf) { // // return conf instanceof MetricsConfiguration; // } // // @Override // public PropertyNode create(final Configuration conf, final Dependencies dependencies) { // return Metrics.create(); // } // }; // } // // private static PropertyNode metrics; // // /** // * <p> // * Sets the default metrics instance which can be accessed via Metrics.get() // * // * @param node // */ // public static void inject(final PropertyNode node) { // metrics = node; // MetricsCommon.inject(node); // } // // public static PropertyNode get() { // return metrics; // } // // }
import delight.async.properties.PropertyNode; import de.mxro.metrics.jre.Metrics;
package de.mxro.metrics.examples; public class ExampleCounter { public static void main(final String[] args) {
// Path: src/main/java/de/mxro/metrics/jre/Metrics.java // public class Metrics extends MetricsCommon { // // public static PropertyNode create() { // return Properties // .create(PropertiesCommon.compositeFactory(new MetricsFactory(), PropertiesCommon.defaultFactory())); // } // // public static Factory<?, ?, ?> createMetricsFactory() { // return new Factory<PropertyNode, Configuration, Dependencies>() { // // @Override // public boolean canInstantiate(final Configuration conf) { // // return conf instanceof MetricsConfiguration; // } // // @Override // public PropertyNode create(final Configuration conf, final Dependencies dependencies) { // return Metrics.create(); // } // }; // } // // private static PropertyNode metrics; // // /** // * <p> // * Sets the default metrics instance which can be accessed via Metrics.get() // * // * @param node // */ // public static void inject(final PropertyNode node) { // metrics = node; // MetricsCommon.inject(node); // } // // public static PropertyNode get() { // return metrics; // } // // } // Path: src/test/java/de/mxro/metrics/examples/ExampleCounter.java import delight.async.properties.PropertyNode; import de.mxro.metrics.jre.Metrics; package de.mxro.metrics.examples; public class ExampleCounter { public static void main(final String[] args) {
final PropertyNode m = Metrics.create();
javadelight/delight-metrics
src/test/java/de/mxro/metrics/tests/TestHistogram.java
// Path: src/main/java/de/mxro/metrics/MetricsCommon.java // public class MetricsCommon extends PropertiesCommon { // // /** // * <p> // * Creates a metric node, which is not thread safe. Only use in single-threaded // * applications or environments (such as GWT/JavaScript). // * // * @return // */ // public static PropertyNode createUnsafe() { // return PropertiesCommon.createUnsafe( // PropertiesCommon.compositeFactory(new MetricsFactory(), PropertiesCommon.defaultFactory())); // } // // public static Factory<?, ?, ?> createUnsafeFactory() { // return new Factory<PropertyNode, Configuration, Dependencies>() { // // @Override // public boolean canInstantiate(final Configuration conf) { // // return conf instanceof MetricsConfiguration; // } // // @Override // public PropertyNode create(final Configuration conf, final Dependencies dependencies) { // return MetricsCommon.createUnsafe(); // } // }; // } // // public static PropertyOperation<Long> happened(final String id) { // return new MarkEvent().setId(id); // } // // public static PropertyOperation<Long> increment(final String id) { // return new CounterEvent(1).setId(id); // } // // public static PropertyOperation<Long> increment(final String id, final long by) { // return new CounterEvent(by).setId(id); // } // // public static PropertyOperation<Long> decrement(final String id) { // return new CounterEvent(-1).setId(id); // } // // /** // * Record a value and compute various statistics for the value, such as the mean // * etc. // * // * @param id // * @param value // * @return // */ // public static PropertyOperation<Long> value(final String id, final long value) { // return new HistrogramEvent(value).setId(id); // } // // public static PropertyOperation<Snapshot> retrieveHistogram(String id) { // return new RetrieveHistrogramEvent().setId(id); // } // // private static MetricRegistry registry = null; // // public static MetricRegistry getMetricRegistry() { // // if (registry == null) { // registry = new MetricRegistry(); // } // // return registry; // // } // // private static PropertyNode instance; // // public static PropertyNode get() { // return instance; // } // // public static void inject(final PropertyNode propertyNode) { // instance = propertyNode; // } // // }
import de.mxro.metrics.MetricsCommon; import delight.async.properties.PropertyNode; import org.junit.Assert; import org.junit.Test;
package de.mxro.metrics.tests; @SuppressWarnings("all") public class TestHistogram { @Test public void test() {
// Path: src/main/java/de/mxro/metrics/MetricsCommon.java // public class MetricsCommon extends PropertiesCommon { // // /** // * <p> // * Creates a metric node, which is not thread safe. Only use in single-threaded // * applications or environments (such as GWT/JavaScript). // * // * @return // */ // public static PropertyNode createUnsafe() { // return PropertiesCommon.createUnsafe( // PropertiesCommon.compositeFactory(new MetricsFactory(), PropertiesCommon.defaultFactory())); // } // // public static Factory<?, ?, ?> createUnsafeFactory() { // return new Factory<PropertyNode, Configuration, Dependencies>() { // // @Override // public boolean canInstantiate(final Configuration conf) { // // return conf instanceof MetricsConfiguration; // } // // @Override // public PropertyNode create(final Configuration conf, final Dependencies dependencies) { // return MetricsCommon.createUnsafe(); // } // }; // } // // public static PropertyOperation<Long> happened(final String id) { // return new MarkEvent().setId(id); // } // // public static PropertyOperation<Long> increment(final String id) { // return new CounterEvent(1).setId(id); // } // // public static PropertyOperation<Long> increment(final String id, final long by) { // return new CounterEvent(by).setId(id); // } // // public static PropertyOperation<Long> decrement(final String id) { // return new CounterEvent(-1).setId(id); // } // // /** // * Record a value and compute various statistics for the value, such as the mean // * etc. // * // * @param id // * @param value // * @return // */ // public static PropertyOperation<Long> value(final String id, final long value) { // return new HistrogramEvent(value).setId(id); // } // // public static PropertyOperation<Snapshot> retrieveHistogram(String id) { // return new RetrieveHistrogramEvent().setId(id); // } // // private static MetricRegistry registry = null; // // public static MetricRegistry getMetricRegistry() { // // if (registry == null) { // registry = new MetricRegistry(); // } // // return registry; // // } // // private static PropertyNode instance; // // public static PropertyNode get() { // return instance; // } // // public static void inject(final PropertyNode propertyNode) { // instance = propertyNode; // } // // } // Path: src/test/java/de/mxro/metrics/tests/TestHistogram.java import de.mxro.metrics.MetricsCommon; import delight.async.properties.PropertyNode; import org.junit.Assert; import org.junit.Test; package de.mxro.metrics.tests; @SuppressWarnings("all") public class TestHistogram { @Test public void test() {
PropertyNode m = MetricsCommon.createUnsafe();
onesocialweb/osw-web
src/org/onesocialweb/gwt/client/ui/application/ContactsApplication.java
// Path: src/org/onesocialweb/gwt/client/ui/window/ContactsWindow.java // public class ContactsWindow extends AbstractWindow { // // // internationalization // private UserInterfaceText uiText = (UserInterfaceText) GWT.create(UserInterfaceText.class); // // private final ContactPanel contactPanel = new ContactPanel(); // private final ToggleButton toggleSearchPanel = new ToggleButton(new Image( // OswClient.getInstance().getPreference("theme_folder") // + "assets/search.png")); // private final SearchPanel searchPanel = new SearchPanel(); // // @Override // protected void onInit() { // setStyle("contactsWindow"); // setWindowTitle(uiText.Contacts()); // composeWindow(); // } // // @Override // protected void onShow() { // // correct the size of the contents based on visibility of statusPanel // if (searchPanel.isVisible()) { // getContents().getElement() // .setAttribute( // "style", // "top:" // + (getTitlebar().getElement() // .getClientHeight() + searchPanel // .getElement().getClientHeight()) // + ";"); // } else { // getContents().getElement().setAttribute( // "style", // "top:" + (getTitlebar().getElement().getClientHeight()) // + ";"); // } // } // // @Override // protected void onDestroy() { // contactPanel.onDestroy(); // } // // @Override // protected void onRepaint() { // updateLayout(); // } // // private void composeWindow() { // // // add components // getTopbar().add(searchPanel); // searchPanel.setVisible(true); // toggleSearchPanel.setDown(true); // // getActions().add(toggleSearchPanel); // toggleSearchPanel.setTitle(uiText.ShowSearchPanel()); // toggleSearchPanel.addStyleDependentName("toggleShowUpdate"); // // getContents().add(contactPanel); // // // add handlers // toggleSearchPanel.addClickHandler(new ClickHandler() { // public void onClick(ClickEvent event) { // toggleSearchPanel(); // } // }); // // } // // private void toggleSearchPanel() { // if (searchPanel.isVisible()) { // searchPanel.setVisible(false); // toggleSearchPanel.setTitle("Show search panel"); // } else { // searchPanel.setVisible(true); // toggleSearchPanel.setTitle("Hide search panel"); // searchPanel.onShow(); // } // // // force layout update on the Feed window itself // updateLayout(); // } // // private void updateLayout() { // // correct the size of the contents based on visibility of statusPanel // if (searchPanel.isVisible()) { // getContents().getElement() // .setAttribute( // "style", // "top:" // + (getTitlebar().getElement() // .getClientHeight() + searchPanel // .getElement().getClientHeight()) // + ";"); // } else { // getContents().getElement().setAttribute( // "style", // "top:" + (getTitlebar().getElement().getClientHeight()) // + ";"); // } // } // // }
import org.onesocialweb.gwt.client.ui.window.ContactsWindow;
/* * Copyright 2010 Vodafone Group Services Ltd. * * 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 org.onesocialweb.gwt.client.ui.application; public class ContactsApplication extends AbstractApplication { public ContactsApplication() { super(2); } @Override protected void onInit() { // Init the application slots getSlot(0).setSlotDimensions(0, 0, 50, 100); getSlot(1).setSlotDimensions(0, 50, 50, 100); // add default window to specific slots
// Path: src/org/onesocialweb/gwt/client/ui/window/ContactsWindow.java // public class ContactsWindow extends AbstractWindow { // // // internationalization // private UserInterfaceText uiText = (UserInterfaceText) GWT.create(UserInterfaceText.class); // // private final ContactPanel contactPanel = new ContactPanel(); // private final ToggleButton toggleSearchPanel = new ToggleButton(new Image( // OswClient.getInstance().getPreference("theme_folder") // + "assets/search.png")); // private final SearchPanel searchPanel = new SearchPanel(); // // @Override // protected void onInit() { // setStyle("contactsWindow"); // setWindowTitle(uiText.Contacts()); // composeWindow(); // } // // @Override // protected void onShow() { // // correct the size of the contents based on visibility of statusPanel // if (searchPanel.isVisible()) { // getContents().getElement() // .setAttribute( // "style", // "top:" // + (getTitlebar().getElement() // .getClientHeight() + searchPanel // .getElement().getClientHeight()) // + ";"); // } else { // getContents().getElement().setAttribute( // "style", // "top:" + (getTitlebar().getElement().getClientHeight()) // + ";"); // } // } // // @Override // protected void onDestroy() { // contactPanel.onDestroy(); // } // // @Override // protected void onRepaint() { // updateLayout(); // } // // private void composeWindow() { // // // add components // getTopbar().add(searchPanel); // searchPanel.setVisible(true); // toggleSearchPanel.setDown(true); // // getActions().add(toggleSearchPanel); // toggleSearchPanel.setTitle(uiText.ShowSearchPanel()); // toggleSearchPanel.addStyleDependentName("toggleShowUpdate"); // // getContents().add(contactPanel); // // // add handlers // toggleSearchPanel.addClickHandler(new ClickHandler() { // public void onClick(ClickEvent event) { // toggleSearchPanel(); // } // }); // // } // // private void toggleSearchPanel() { // if (searchPanel.isVisible()) { // searchPanel.setVisible(false); // toggleSearchPanel.setTitle("Show search panel"); // } else { // searchPanel.setVisible(true); // toggleSearchPanel.setTitle("Hide search panel"); // searchPanel.onShow(); // } // // // force layout update on the Feed window itself // updateLayout(); // } // // private void updateLayout() { // // correct the size of the contents based on visibility of statusPanel // if (searchPanel.isVisible()) { // getContents().getElement() // .setAttribute( // "style", // "top:" // + (getTitlebar().getElement() // .getClientHeight() + searchPanel // .getElement().getClientHeight()) // + ";"); // } else { // getContents().getElement().setAttribute( // "style", // "top:" + (getTitlebar().getElement().getClientHeight()) // + ";"); // } // } // // } // Path: src/org/onesocialweb/gwt/client/ui/application/ContactsApplication.java import org.onesocialweb.gwt.client.ui.window.ContactsWindow; /* * Copyright 2010 Vodafone Group Services Ltd. * * 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 org.onesocialweb.gwt.client.ui.application; public class ContactsApplication extends AbstractApplication { public ContactsApplication() { super(2); } @Override protected void onInit() { // Init the application slots getSlot(0).setSlotDimensions(0, 0, 50, 100); getSlot(1).setSlotDimensions(0, 50, 50, 100); // add default window to specific slots
addWindow(ContactsWindow.class.toString(), 0);
onesocialweb/osw-web
src/org/onesocialweb/gwt/client/task/TaskMonitor.java
// Path: src/org/onesocialweb/gwt/client/task/TaskEvent.java // public enum Type { // added, updated, completed // };
import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.onesocialweb.gwt.client.task.TaskEvent.Type; import org.onesocialweb.gwt.util.Observable; import org.onesocialweb.gwt.util.ObservableHelper; import org.onesocialweb.gwt.util.Observer;
/* * Copyright 2010 Vodafone Group Services Ltd. * * 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 org.onesocialweb.gwt.client.task; public class TaskMonitor implements Observable<TaskEvent> { private static TaskMonitor instance; private final ObservableHelper<TaskEvent> observableHelper = new ObservableHelper<TaskEvent>(); private final List<TaskInfo> tasks = new ArrayList<TaskInfo>(); private final TaskHandler handler = new TaskHandler(); public static TaskMonitor getInstance() { if (instance == null) { instance = new TaskMonitor(); } return instance; } @Override public void registerEventHandler(Observer<TaskEvent> handler) { observableHelper.registerEventHandler(handler); } @Override public void unregisterEventHandler(Observer<TaskEvent> handler) { observableHelper.unregisterEventHandler(handler); } public void addTask(TaskInfo task) { tasks.add(task); task.registerEventHandler(handler);
// Path: src/org/onesocialweb/gwt/client/task/TaskEvent.java // public enum Type { // added, updated, completed // }; // Path: src/org/onesocialweb/gwt/client/task/TaskMonitor.java import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.onesocialweb.gwt.client.task.TaskEvent.Type; import org.onesocialweb.gwt.util.Observable; import org.onesocialweb.gwt.util.ObservableHelper; import org.onesocialweb.gwt.util.Observer; /* * Copyright 2010 Vodafone Group Services Ltd. * * 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 org.onesocialweb.gwt.client.task; public class TaskMonitor implements Observable<TaskEvent> { private static TaskMonitor instance; private final ObservableHelper<TaskEvent> observableHelper = new ObservableHelper<TaskEvent>(); private final List<TaskInfo> tasks = new ArrayList<TaskInfo>(); private final TaskHandler handler = new TaskHandler(); public static TaskMonitor getInstance() { if (instance == null) { instance = new TaskMonitor(); } return instance; } @Override public void registerEventHandler(Observer<TaskEvent> handler) { observableHelper.registerEventHandler(handler); } @Override public void unregisterEventHandler(Observer<TaskEvent> handler) { observableHelper.unregisterEventHandler(handler); } public void addTask(TaskInfo task) { tasks.add(task); task.registerEventHandler(handler);
observableHelper.fireEvent(new DefaultTaskEvent(TaskEvent.Type.added,
onesocialweb/osw-web
src/org/onesocialweb/gwt/client/OswEntryPoint.java
// Path: src/org/onesocialweb/gwt/client/ui/window/ContactsWindowFactory.java // public class ContactsWindowFactory extends AbstractWindowFactory { // // @Override // public AbstractWindow createWindow() { // return new ContactsWindow(); // } // // @Override // public String getWindowClassname() { // return ContactsWindow.class.toString(); // } // // } // // Path: src/org/onesocialweb/gwt/client/ui/window/WindowFactory.java // public class WindowFactory { // // private static WindowFactory instance; // // public static WindowFactory getInstance() { // if (instance == null) { // instance = new WindowFactory(); // } // return instance; // } // // private AbstractMap<String, AbstractWindowFactory> factories = new HashMap<String, AbstractWindowFactory>(); // // public void registerFactory(AbstractWindowFactory factory) { // factories.put(factory.getWindowClassname(), factory); // } // // public AbstractWindow newWindow(String className) // throws MissingWindowFactoryException { // AbstractWindowFactory factory = factories.get(className); // if (factory != null) { // AbstractWindow window = factory.createWindow(); // window.init(); // return window; // } else { // throw new MissingWindowFactoryException(); // } // } // // /** // * Private constructor to enforce the singleton // */ // private WindowFactory() { // // // } // // }
import org.onesocialweb.gwt.client.ui.window.ContactsWindowFactory; import org.onesocialweb.gwt.client.ui.window.FeedWindowFactory; import org.onesocialweb.gwt.client.ui.window.PreferencesWindowFactory; import org.onesocialweb.gwt.client.ui.window.ProfileWindowFactory; import org.onesocialweb.gwt.client.ui.window.WindowFactory; import com.allen_sauer.gwt.log.client.DivLogger; import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.Widget;
/* * Copyright 2010 Vodafone Group Services Ltd. * * 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 org.onesocialweb.gwt.client; public class OswEntryPoint implements EntryPoint { public void onModuleLoad() { // Prepare a few things to get our pattern right
// Path: src/org/onesocialweb/gwt/client/ui/window/ContactsWindowFactory.java // public class ContactsWindowFactory extends AbstractWindowFactory { // // @Override // public AbstractWindow createWindow() { // return new ContactsWindow(); // } // // @Override // public String getWindowClassname() { // return ContactsWindow.class.toString(); // } // // } // // Path: src/org/onesocialweb/gwt/client/ui/window/WindowFactory.java // public class WindowFactory { // // private static WindowFactory instance; // // public static WindowFactory getInstance() { // if (instance == null) { // instance = new WindowFactory(); // } // return instance; // } // // private AbstractMap<String, AbstractWindowFactory> factories = new HashMap<String, AbstractWindowFactory>(); // // public void registerFactory(AbstractWindowFactory factory) { // factories.put(factory.getWindowClassname(), factory); // } // // public AbstractWindow newWindow(String className) // throws MissingWindowFactoryException { // AbstractWindowFactory factory = factories.get(className); // if (factory != null) { // AbstractWindow window = factory.createWindow(); // window.init(); // return window; // } else { // throw new MissingWindowFactoryException(); // } // } // // /** // * Private constructor to enforce the singleton // */ // private WindowFactory() { // // // } // // } // Path: src/org/onesocialweb/gwt/client/OswEntryPoint.java import org.onesocialweb.gwt.client.ui.window.ContactsWindowFactory; import org.onesocialweb.gwt.client.ui.window.FeedWindowFactory; import org.onesocialweb.gwt.client.ui.window.PreferencesWindowFactory; import org.onesocialweb.gwt.client.ui.window.ProfileWindowFactory; import org.onesocialweb.gwt.client.ui.window.WindowFactory; import com.allen_sauer.gwt.log.client.DivLogger; import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.Widget; /* * Copyright 2010 Vodafone Group Services Ltd. * * 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 org.onesocialweb.gwt.client; public class OswEntryPoint implements EntryPoint { public void onModuleLoad() { // Prepare a few things to get our pattern right
WindowFactory.getInstance().registerFactory(new ProfileWindowFactory());
onesocialweb/osw-web
src/org/onesocialweb/gwt/client/OswEntryPoint.java
// Path: src/org/onesocialweb/gwt/client/ui/window/ContactsWindowFactory.java // public class ContactsWindowFactory extends AbstractWindowFactory { // // @Override // public AbstractWindow createWindow() { // return new ContactsWindow(); // } // // @Override // public String getWindowClassname() { // return ContactsWindow.class.toString(); // } // // } // // Path: src/org/onesocialweb/gwt/client/ui/window/WindowFactory.java // public class WindowFactory { // // private static WindowFactory instance; // // public static WindowFactory getInstance() { // if (instance == null) { // instance = new WindowFactory(); // } // return instance; // } // // private AbstractMap<String, AbstractWindowFactory> factories = new HashMap<String, AbstractWindowFactory>(); // // public void registerFactory(AbstractWindowFactory factory) { // factories.put(factory.getWindowClassname(), factory); // } // // public AbstractWindow newWindow(String className) // throws MissingWindowFactoryException { // AbstractWindowFactory factory = factories.get(className); // if (factory != null) { // AbstractWindow window = factory.createWindow(); // window.init(); // return window; // } else { // throw new MissingWindowFactoryException(); // } // } // // /** // * Private constructor to enforce the singleton // */ // private WindowFactory() { // // // } // // }
import org.onesocialweb.gwt.client.ui.window.ContactsWindowFactory; import org.onesocialweb.gwt.client.ui.window.FeedWindowFactory; import org.onesocialweb.gwt.client.ui.window.PreferencesWindowFactory; import org.onesocialweb.gwt.client.ui.window.ProfileWindowFactory; import org.onesocialweb.gwt.client.ui.window.WindowFactory; import com.allen_sauer.gwt.log.client.DivLogger; import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.Widget;
/* * Copyright 2010 Vodafone Group Services Ltd. * * 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 org.onesocialweb.gwt.client; public class OswEntryPoint implements EntryPoint { public void onModuleLoad() { // Prepare a few things to get our pattern right WindowFactory.getInstance().registerFactory(new ProfileWindowFactory()); WindowFactory.getInstance().registerFactory(new FeedWindowFactory()); WindowFactory.getInstance().registerFactory( new PreferencesWindowFactory()); WindowFactory.getInstance()
// Path: src/org/onesocialweb/gwt/client/ui/window/ContactsWindowFactory.java // public class ContactsWindowFactory extends AbstractWindowFactory { // // @Override // public AbstractWindow createWindow() { // return new ContactsWindow(); // } // // @Override // public String getWindowClassname() { // return ContactsWindow.class.toString(); // } // // } // // Path: src/org/onesocialweb/gwt/client/ui/window/WindowFactory.java // public class WindowFactory { // // private static WindowFactory instance; // // public static WindowFactory getInstance() { // if (instance == null) { // instance = new WindowFactory(); // } // return instance; // } // // private AbstractMap<String, AbstractWindowFactory> factories = new HashMap<String, AbstractWindowFactory>(); // // public void registerFactory(AbstractWindowFactory factory) { // factories.put(factory.getWindowClassname(), factory); // } // // public AbstractWindow newWindow(String className) // throws MissingWindowFactoryException { // AbstractWindowFactory factory = factories.get(className); // if (factory != null) { // AbstractWindow window = factory.createWindow(); // window.init(); // return window; // } else { // throw new MissingWindowFactoryException(); // } // } // // /** // * Private constructor to enforce the singleton // */ // private WindowFactory() { // // // } // // } // Path: src/org/onesocialweb/gwt/client/OswEntryPoint.java import org.onesocialweb.gwt.client.ui.window.ContactsWindowFactory; import org.onesocialweb.gwt.client.ui.window.FeedWindowFactory; import org.onesocialweb.gwt.client.ui.window.PreferencesWindowFactory; import org.onesocialweb.gwt.client.ui.window.ProfileWindowFactory; import org.onesocialweb.gwt.client.ui.window.WindowFactory; import com.allen_sauer.gwt.log.client.DivLogger; import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.Widget; /* * Copyright 2010 Vodafone Group Services Ltd. * * 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 org.onesocialweb.gwt.client; public class OswEntryPoint implements EntryPoint { public void onModuleLoad() { // Prepare a few things to get our pattern right WindowFactory.getInstance().registerFactory(new ProfileWindowFactory()); WindowFactory.getInstance().registerFactory(new FeedWindowFactory()); WindowFactory.getInstance().registerFactory( new PreferencesWindowFactory()); WindowFactory.getInstance()
.registerFactory(new ContactsWindowFactory());
onesocialweb/osw-web
src/org/onesocialweb/gwt/client/ui/widget/compose/RecipientList.java
// Path: src/org/appfuse/client/widget/BulletList.java // public class BulletList extends ComplexPanel { // public BulletList() { // setElement(DOM.createElement("UL")); // } // // public void add(Widget w) { // super.add(w, getElement()); // } // // public void insert(Widget w, int beforeIndex) { // super.insert(w, getElement(), beforeIndex, true); // } // } // // Path: src/org/appfuse/client/widget/ListItem.java // public class ListItem extends ComplexPanel implements HasText, HasHTML, // HasClickHandlers, HasKeyDownHandlers, HasBlurHandlers { // HandlerRegistration clickHandler; // // public ListItem() { // setElement(DOM.createElement("LI")); // } // // public void add(Widget w) { // super.add(w, getElement()); // } // // public void insert(Widget w, int beforeIndex) { // super.insert(w, getElement(), beforeIndex, true); // } // // public String getText() { // return DOM.getInnerText(getElement()); // } // // public void setText(String text) { // DOM.setInnerText(getElement(), (text == null) ? "" : text); // } // // public void setId(String id) { // DOM.setElementAttribute(getElement(), "id", id); // } // // public String getHTML() { // return DOM.getInnerHTML(getElement()); // } // // public void setHTML(String html) { // DOM.setInnerHTML(getElement(), (html == null) ? "" : html); // } // // public HandlerRegistration addClickHandler(ClickHandler handler) { // return addDomHandler(handler, ClickEvent.getType()); // } // // public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) { // return addDomHandler(handler, KeyDownEvent.getType()); // } // // public HandlerRegistration addBlurHandler(BlurHandler handler) { // return addDomHandler(handler, BlurEvent.getType()); // } // } // // Path: src/org/appfuse/client/widget/Span.java // public class Span extends HTML implements HasText { // // public Span() { // super(DOM.createElement("span")); // } // // public Span(String text) { // this(); // setText(text); // } // }
import java.util.ArrayList; import java.util.List; import org.appfuse.client.widget.BulletList; import org.appfuse.client.widget.ListItem; import org.appfuse.client.widget.Paragraph; import org.appfuse.client.widget.Span; import org.onesocialweb.gwt.client.ui.event.ComponentHelper; import org.onesocialweb.gwt.client.ui.event.ComponentListener; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyDownEvent; import com.google.gwt.event.dom.client.KeyDownHandler; import com.google.gwt.event.dom.client.KeyPressEvent; import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.event.dom.client.KeyUpEvent; import com.google.gwt.event.dom.client.KeyUpHandler; import com.google.gwt.event.logical.shared.SelectionEvent; import com.google.gwt.event.logical.shared.SelectionHandler; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.SuggestBox; import com.google.gwt.user.client.ui.SuggestOracle; import com.google.gwt.user.client.ui.TextBox;
package org.onesocialweb.gwt.client.ui.widget.compose; public class RecipientList extends Composite { private final RecipientOracle oracle = RecipientOracle.getInstance(); private final TextBox itemBox = new TextBox(); private final SuggestBox box = new SuggestBox(oracle, itemBox); private List<String> itemsSelected = new ArrayList<String>(); private final ComponentHelper componentHelper = new ComponentHelper(); public RecipientList() { FlowPanel panel = new FlowPanel(); initWidget(panel); // 2. Show the following element structure and set the last <div> to // display: block /* * <ul class="token-input-list-facebook"> <li * class="token-input-input-token-facebook"> <input type="text"style= * "outline-color: -moz-use-text-color; outline-style: none; outline-width: medium;" * /> </li> </ul> <div class="token-input-dropdown-facebook" * style="display: none;"/> */ final Label grow = new Label(); panel.add(grow); grow.addStyleName("grow");
// Path: src/org/appfuse/client/widget/BulletList.java // public class BulletList extends ComplexPanel { // public BulletList() { // setElement(DOM.createElement("UL")); // } // // public void add(Widget w) { // super.add(w, getElement()); // } // // public void insert(Widget w, int beforeIndex) { // super.insert(w, getElement(), beforeIndex, true); // } // } // // Path: src/org/appfuse/client/widget/ListItem.java // public class ListItem extends ComplexPanel implements HasText, HasHTML, // HasClickHandlers, HasKeyDownHandlers, HasBlurHandlers { // HandlerRegistration clickHandler; // // public ListItem() { // setElement(DOM.createElement("LI")); // } // // public void add(Widget w) { // super.add(w, getElement()); // } // // public void insert(Widget w, int beforeIndex) { // super.insert(w, getElement(), beforeIndex, true); // } // // public String getText() { // return DOM.getInnerText(getElement()); // } // // public void setText(String text) { // DOM.setInnerText(getElement(), (text == null) ? "" : text); // } // // public void setId(String id) { // DOM.setElementAttribute(getElement(), "id", id); // } // // public String getHTML() { // return DOM.getInnerHTML(getElement()); // } // // public void setHTML(String html) { // DOM.setInnerHTML(getElement(), (html == null) ? "" : html); // } // // public HandlerRegistration addClickHandler(ClickHandler handler) { // return addDomHandler(handler, ClickEvent.getType()); // } // // public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) { // return addDomHandler(handler, KeyDownEvent.getType()); // } // // public HandlerRegistration addBlurHandler(BlurHandler handler) { // return addDomHandler(handler, BlurEvent.getType()); // } // } // // Path: src/org/appfuse/client/widget/Span.java // public class Span extends HTML implements HasText { // // public Span() { // super(DOM.createElement("span")); // } // // public Span(String text) { // this(); // setText(text); // } // } // Path: src/org/onesocialweb/gwt/client/ui/widget/compose/RecipientList.java import java.util.ArrayList; import java.util.List; import org.appfuse.client.widget.BulletList; import org.appfuse.client.widget.ListItem; import org.appfuse.client.widget.Paragraph; import org.appfuse.client.widget.Span; import org.onesocialweb.gwt.client.ui.event.ComponentHelper; import org.onesocialweb.gwt.client.ui.event.ComponentListener; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyDownEvent; import com.google.gwt.event.dom.client.KeyDownHandler; import com.google.gwt.event.dom.client.KeyPressEvent; import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.event.dom.client.KeyUpEvent; import com.google.gwt.event.dom.client.KeyUpHandler; import com.google.gwt.event.logical.shared.SelectionEvent; import com.google.gwt.event.logical.shared.SelectionHandler; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.SuggestBox; import com.google.gwt.user.client.ui.SuggestOracle; import com.google.gwt.user.client.ui.TextBox; package org.onesocialweb.gwt.client.ui.widget.compose; public class RecipientList extends Composite { private final RecipientOracle oracle = RecipientOracle.getInstance(); private final TextBox itemBox = new TextBox(); private final SuggestBox box = new SuggestBox(oracle, itemBox); private List<String> itemsSelected = new ArrayList<String>(); private final ComponentHelper componentHelper = new ComponentHelper(); public RecipientList() { FlowPanel panel = new FlowPanel(); initWidget(panel); // 2. Show the following element structure and set the last <div> to // display: block /* * <ul class="token-input-list-facebook"> <li * class="token-input-input-token-facebook"> <input type="text"style= * "outline-color: -moz-use-text-color; outline-style: none; outline-width: medium;" * /> </li> </ul> <div class="token-input-dropdown-facebook" * style="display: none;"/> */ final Label grow = new Label(); panel.add(grow); grow.addStyleName("grow");
final BulletList list = new BulletList();
onesocialweb/osw-web
src/org/onesocialweb/gwt/client/ui/widget/compose/RecipientList.java
// Path: src/org/appfuse/client/widget/BulletList.java // public class BulletList extends ComplexPanel { // public BulletList() { // setElement(DOM.createElement("UL")); // } // // public void add(Widget w) { // super.add(w, getElement()); // } // // public void insert(Widget w, int beforeIndex) { // super.insert(w, getElement(), beforeIndex, true); // } // } // // Path: src/org/appfuse/client/widget/ListItem.java // public class ListItem extends ComplexPanel implements HasText, HasHTML, // HasClickHandlers, HasKeyDownHandlers, HasBlurHandlers { // HandlerRegistration clickHandler; // // public ListItem() { // setElement(DOM.createElement("LI")); // } // // public void add(Widget w) { // super.add(w, getElement()); // } // // public void insert(Widget w, int beforeIndex) { // super.insert(w, getElement(), beforeIndex, true); // } // // public String getText() { // return DOM.getInnerText(getElement()); // } // // public void setText(String text) { // DOM.setInnerText(getElement(), (text == null) ? "" : text); // } // // public void setId(String id) { // DOM.setElementAttribute(getElement(), "id", id); // } // // public String getHTML() { // return DOM.getInnerHTML(getElement()); // } // // public void setHTML(String html) { // DOM.setInnerHTML(getElement(), (html == null) ? "" : html); // } // // public HandlerRegistration addClickHandler(ClickHandler handler) { // return addDomHandler(handler, ClickEvent.getType()); // } // // public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) { // return addDomHandler(handler, KeyDownEvent.getType()); // } // // public HandlerRegistration addBlurHandler(BlurHandler handler) { // return addDomHandler(handler, BlurEvent.getType()); // } // } // // Path: src/org/appfuse/client/widget/Span.java // public class Span extends HTML implements HasText { // // public Span() { // super(DOM.createElement("span")); // } // // public Span(String text) { // this(); // setText(text); // } // }
import java.util.ArrayList; import java.util.List; import org.appfuse.client.widget.BulletList; import org.appfuse.client.widget.ListItem; import org.appfuse.client.widget.Paragraph; import org.appfuse.client.widget.Span; import org.onesocialweb.gwt.client.ui.event.ComponentHelper; import org.onesocialweb.gwt.client.ui.event.ComponentListener; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyDownEvent; import com.google.gwt.event.dom.client.KeyDownHandler; import com.google.gwt.event.dom.client.KeyPressEvent; import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.event.dom.client.KeyUpEvent; import com.google.gwt.event.dom.client.KeyUpHandler; import com.google.gwt.event.logical.shared.SelectionEvent; import com.google.gwt.event.logical.shared.SelectionHandler; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.SuggestBox; import com.google.gwt.user.client.ui.SuggestOracle; import com.google.gwt.user.client.ui.TextBox;
package org.onesocialweb.gwt.client.ui.widget.compose; public class RecipientList extends Composite { private final RecipientOracle oracle = RecipientOracle.getInstance(); private final TextBox itemBox = new TextBox(); private final SuggestBox box = new SuggestBox(oracle, itemBox); private List<String> itemsSelected = new ArrayList<String>(); private final ComponentHelper componentHelper = new ComponentHelper(); public RecipientList() { FlowPanel panel = new FlowPanel(); initWidget(panel); // 2. Show the following element structure and set the last <div> to // display: block /* * <ul class="token-input-list-facebook"> <li * class="token-input-input-token-facebook"> <input type="text"style= * "outline-color: -moz-use-text-color; outline-style: none; outline-width: medium;" * /> </li> </ul> <div class="token-input-dropdown-facebook" * style="display: none;"/> */ final Label grow = new Label(); panel.add(grow); grow.addStyleName("grow"); final BulletList list = new BulletList(); list.setStyleName("token-input-list-facebook");
// Path: src/org/appfuse/client/widget/BulletList.java // public class BulletList extends ComplexPanel { // public BulletList() { // setElement(DOM.createElement("UL")); // } // // public void add(Widget w) { // super.add(w, getElement()); // } // // public void insert(Widget w, int beforeIndex) { // super.insert(w, getElement(), beforeIndex, true); // } // } // // Path: src/org/appfuse/client/widget/ListItem.java // public class ListItem extends ComplexPanel implements HasText, HasHTML, // HasClickHandlers, HasKeyDownHandlers, HasBlurHandlers { // HandlerRegistration clickHandler; // // public ListItem() { // setElement(DOM.createElement("LI")); // } // // public void add(Widget w) { // super.add(w, getElement()); // } // // public void insert(Widget w, int beforeIndex) { // super.insert(w, getElement(), beforeIndex, true); // } // // public String getText() { // return DOM.getInnerText(getElement()); // } // // public void setText(String text) { // DOM.setInnerText(getElement(), (text == null) ? "" : text); // } // // public void setId(String id) { // DOM.setElementAttribute(getElement(), "id", id); // } // // public String getHTML() { // return DOM.getInnerHTML(getElement()); // } // // public void setHTML(String html) { // DOM.setInnerHTML(getElement(), (html == null) ? "" : html); // } // // public HandlerRegistration addClickHandler(ClickHandler handler) { // return addDomHandler(handler, ClickEvent.getType()); // } // // public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) { // return addDomHandler(handler, KeyDownEvent.getType()); // } // // public HandlerRegistration addBlurHandler(BlurHandler handler) { // return addDomHandler(handler, BlurEvent.getType()); // } // } // // Path: src/org/appfuse/client/widget/Span.java // public class Span extends HTML implements HasText { // // public Span() { // super(DOM.createElement("span")); // } // // public Span(String text) { // this(); // setText(text); // } // } // Path: src/org/onesocialweb/gwt/client/ui/widget/compose/RecipientList.java import java.util.ArrayList; import java.util.List; import org.appfuse.client.widget.BulletList; import org.appfuse.client.widget.ListItem; import org.appfuse.client.widget.Paragraph; import org.appfuse.client.widget.Span; import org.onesocialweb.gwt.client.ui.event.ComponentHelper; import org.onesocialweb.gwt.client.ui.event.ComponentListener; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyDownEvent; import com.google.gwt.event.dom.client.KeyDownHandler; import com.google.gwt.event.dom.client.KeyPressEvent; import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.event.dom.client.KeyUpEvent; import com.google.gwt.event.dom.client.KeyUpHandler; import com.google.gwt.event.logical.shared.SelectionEvent; import com.google.gwt.event.logical.shared.SelectionHandler; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.SuggestBox; import com.google.gwt.user.client.ui.SuggestOracle; import com.google.gwt.user.client.ui.TextBox; package org.onesocialweb.gwt.client.ui.widget.compose; public class RecipientList extends Composite { private final RecipientOracle oracle = RecipientOracle.getInstance(); private final TextBox itemBox = new TextBox(); private final SuggestBox box = new SuggestBox(oracle, itemBox); private List<String> itemsSelected = new ArrayList<String>(); private final ComponentHelper componentHelper = new ComponentHelper(); public RecipientList() { FlowPanel panel = new FlowPanel(); initWidget(panel); // 2. Show the following element structure and set the last <div> to // display: block /* * <ul class="token-input-list-facebook"> <li * class="token-input-input-token-facebook"> <input type="text"style= * "outline-color: -moz-use-text-color; outline-style: none; outline-width: medium;" * /> </li> </ul> <div class="token-input-dropdown-facebook" * style="display: none;"/> */ final Label grow = new Label(); panel.add(grow); grow.addStyleName("grow"); final BulletList list = new BulletList(); list.setStyleName("token-input-list-facebook");
final ListItem item = new ListItem();
onesocialweb/osw-web
src/org/onesocialweb/gwt/client/ui/widget/compose/RecipientList.java
// Path: src/org/appfuse/client/widget/BulletList.java // public class BulletList extends ComplexPanel { // public BulletList() { // setElement(DOM.createElement("UL")); // } // // public void add(Widget w) { // super.add(w, getElement()); // } // // public void insert(Widget w, int beforeIndex) { // super.insert(w, getElement(), beforeIndex, true); // } // } // // Path: src/org/appfuse/client/widget/ListItem.java // public class ListItem extends ComplexPanel implements HasText, HasHTML, // HasClickHandlers, HasKeyDownHandlers, HasBlurHandlers { // HandlerRegistration clickHandler; // // public ListItem() { // setElement(DOM.createElement("LI")); // } // // public void add(Widget w) { // super.add(w, getElement()); // } // // public void insert(Widget w, int beforeIndex) { // super.insert(w, getElement(), beforeIndex, true); // } // // public String getText() { // return DOM.getInnerText(getElement()); // } // // public void setText(String text) { // DOM.setInnerText(getElement(), (text == null) ? "" : text); // } // // public void setId(String id) { // DOM.setElementAttribute(getElement(), "id", id); // } // // public String getHTML() { // return DOM.getInnerHTML(getElement()); // } // // public void setHTML(String html) { // DOM.setInnerHTML(getElement(), (html == null) ? "" : html); // } // // public HandlerRegistration addClickHandler(ClickHandler handler) { // return addDomHandler(handler, ClickEvent.getType()); // } // // public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) { // return addDomHandler(handler, KeyDownEvent.getType()); // } // // public HandlerRegistration addBlurHandler(BlurHandler handler) { // return addDomHandler(handler, BlurEvent.getType()); // } // } // // Path: src/org/appfuse/client/widget/Span.java // public class Span extends HTML implements HasText { // // public Span() { // super(DOM.createElement("span")); // } // // public Span(String text) { // this(); // setText(text); // } // }
import java.util.ArrayList; import java.util.List; import org.appfuse.client.widget.BulletList; import org.appfuse.client.widget.ListItem; import org.appfuse.client.widget.Paragraph; import org.appfuse.client.widget.Span; import org.onesocialweb.gwt.client.ui.event.ComponentHelper; import org.onesocialweb.gwt.client.ui.event.ComponentListener; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyDownEvent; import com.google.gwt.event.dom.client.KeyDownHandler; import com.google.gwt.event.dom.client.KeyPressEvent; import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.event.dom.client.KeyUpEvent; import com.google.gwt.event.dom.client.KeyUpHandler; import com.google.gwt.event.logical.shared.SelectionEvent; import com.google.gwt.event.logical.shared.SelectionHandler; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.SuggestBox; import com.google.gwt.user.client.ui.SuggestOracle; import com.google.gwt.user.client.ui.TextBox;
/** * Change to the following structure: <li class="token-input-token-facebook"> * <p> * What's New Scooby-Doo? * </p> * <span class="token-input-delete-token-facebook">x</span></li> */ final ListItem displayItem = new ListItem(); displayItem.setStyleName("token-input-token-facebook"); Paragraph p = new Paragraph(itemBox.getValue()); displayItem.addClickHandler(new ClickHandler() { public void onClick(ClickEvent clickEvent) { displayItem .addStyleName("token-input-selected-token-facebook"); } }); /** * TODO: Figure out how to select item and allow deleting with * backspace key displayItem.addKeyDownHandler(new KeyDownHandler() * { public void onKeyDown(KeyDownEvent event) { if * (event.getNativeKeyCode() == KeyCodes.KEY_BACKSPACE) { * removeListItem(displayItem, list); } } }); * displayItem.addBlurHandler(new BlurHandler() { public void * onBlur(BlurEvent blurEvent) { displayItem.removeStyleName( * "token-input-selected-token-facebook"); } }); */
// Path: src/org/appfuse/client/widget/BulletList.java // public class BulletList extends ComplexPanel { // public BulletList() { // setElement(DOM.createElement("UL")); // } // // public void add(Widget w) { // super.add(w, getElement()); // } // // public void insert(Widget w, int beforeIndex) { // super.insert(w, getElement(), beforeIndex, true); // } // } // // Path: src/org/appfuse/client/widget/ListItem.java // public class ListItem extends ComplexPanel implements HasText, HasHTML, // HasClickHandlers, HasKeyDownHandlers, HasBlurHandlers { // HandlerRegistration clickHandler; // // public ListItem() { // setElement(DOM.createElement("LI")); // } // // public void add(Widget w) { // super.add(w, getElement()); // } // // public void insert(Widget w, int beforeIndex) { // super.insert(w, getElement(), beforeIndex, true); // } // // public String getText() { // return DOM.getInnerText(getElement()); // } // // public void setText(String text) { // DOM.setInnerText(getElement(), (text == null) ? "" : text); // } // // public void setId(String id) { // DOM.setElementAttribute(getElement(), "id", id); // } // // public String getHTML() { // return DOM.getInnerHTML(getElement()); // } // // public void setHTML(String html) { // DOM.setInnerHTML(getElement(), (html == null) ? "" : html); // } // // public HandlerRegistration addClickHandler(ClickHandler handler) { // return addDomHandler(handler, ClickEvent.getType()); // } // // public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) { // return addDomHandler(handler, KeyDownEvent.getType()); // } // // public HandlerRegistration addBlurHandler(BlurHandler handler) { // return addDomHandler(handler, BlurEvent.getType()); // } // } // // Path: src/org/appfuse/client/widget/Span.java // public class Span extends HTML implements HasText { // // public Span() { // super(DOM.createElement("span")); // } // // public Span(String text) { // this(); // setText(text); // } // } // Path: src/org/onesocialweb/gwt/client/ui/widget/compose/RecipientList.java import java.util.ArrayList; import java.util.List; import org.appfuse.client.widget.BulletList; import org.appfuse.client.widget.ListItem; import org.appfuse.client.widget.Paragraph; import org.appfuse.client.widget.Span; import org.onesocialweb.gwt.client.ui.event.ComponentHelper; import org.onesocialweb.gwt.client.ui.event.ComponentListener; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyDownEvent; import com.google.gwt.event.dom.client.KeyDownHandler; import com.google.gwt.event.dom.client.KeyPressEvent; import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.event.dom.client.KeyUpEvent; import com.google.gwt.event.dom.client.KeyUpHandler; import com.google.gwt.event.logical.shared.SelectionEvent; import com.google.gwt.event.logical.shared.SelectionHandler; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.SuggestBox; import com.google.gwt.user.client.ui.SuggestOracle; import com.google.gwt.user.client.ui.TextBox; /** * Change to the following structure: <li class="token-input-token-facebook"> * <p> * What's New Scooby-Doo? * </p> * <span class="token-input-delete-token-facebook">x</span></li> */ final ListItem displayItem = new ListItem(); displayItem.setStyleName("token-input-token-facebook"); Paragraph p = new Paragraph(itemBox.getValue()); displayItem.addClickHandler(new ClickHandler() { public void onClick(ClickEvent clickEvent) { displayItem .addStyleName("token-input-selected-token-facebook"); } }); /** * TODO: Figure out how to select item and allow deleting with * backspace key displayItem.addKeyDownHandler(new KeyDownHandler() * { public void onKeyDown(KeyDownEvent event) { if * (event.getNativeKeyCode() == KeyCodes.KEY_BACKSPACE) { * removeListItem(displayItem, list); } } }); * displayItem.addBlurHandler(new BlurHandler() { public void * onBlur(BlurEvent blurEvent) { displayItem.removeStyleName( * "token-input-selected-token-facebook"); } }); */
Span span = new Span("x");
onesocialweb/osw-web
src/org/onesocialweb/gwt/client/ui/window/WindowFactory.java
// Path: src/org/onesocialweb/gwt/client/exception/MissingWindowFactoryException.java // @SuppressWarnings("serial") // public class MissingWindowFactoryException extends Exception { // // }
import java.util.AbstractMap; import java.util.HashMap; import org.onesocialweb.gwt.client.exception.MissingWindowFactoryException;
/* * Copyright 2010 Vodafone Group Services Ltd. * * 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 org.onesocialweb.gwt.client.ui.window; public class WindowFactory { private static WindowFactory instance; public static WindowFactory getInstance() { if (instance == null) { instance = new WindowFactory(); } return instance; } private AbstractMap<String, AbstractWindowFactory> factories = new HashMap<String, AbstractWindowFactory>(); public void registerFactory(AbstractWindowFactory factory) { factories.put(factory.getWindowClassname(), factory); } public AbstractWindow newWindow(String className)
// Path: src/org/onesocialweb/gwt/client/exception/MissingWindowFactoryException.java // @SuppressWarnings("serial") // public class MissingWindowFactoryException extends Exception { // // } // Path: src/org/onesocialweb/gwt/client/ui/window/WindowFactory.java import java.util.AbstractMap; import java.util.HashMap; import org.onesocialweb.gwt.client.exception.MissingWindowFactoryException; /* * Copyright 2010 Vodafone Group Services Ltd. * * 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 org.onesocialweb.gwt.client.ui.window; public class WindowFactory { private static WindowFactory instance; public static WindowFactory getInstance() { if (instance == null) { instance = new WindowFactory(); } return instance; } private AbstractMap<String, AbstractWindowFactory> factories = new HashMap<String, AbstractWindowFactory>(); public void registerFactory(AbstractWindowFactory factory) { factories.put(factory.getWindowClassname(), factory); } public AbstractWindow newWindow(String className)
throws MissingWindowFactoryException {
onesocialweb/osw-web
src/org/onesocialweb/gwt/client/ui/widget/SingleUploader.java
// Path: src/org/onesocialweb/gwt/client/ui/dialog/AlertDialog.java // public class AlertDialog extends AbstractDialog { // // // internationalization // private UserInterfaceText uiText = (UserInterfaceText) GWT // .create(UserInterfaceText.class); // // // private final LoginHandler loginHandler; // private static AlertDialog instance; // private Button buttonOK = new Button(uiText.OK()); // private Label message = new Label(); // // public static AlertDialog getInstance() { // if (instance == null) { // instance = new AlertDialog(); // } // return instance; // } // // public void showDialog(String message, String title) { // setText(title); // this.message.setText(message); // center(); // buttonOK.setFocus(true); // } // // private AlertDialog() { // // // Create dialog // VerticalPanel vpanel1 = new VerticalPanel(); // HorizontalPanel buttoncontainer = new HorizontalPanel(); // // vpanel1.add(message); // vpanel1.add(buttoncontainer); // // buttoncontainer.add(buttonOK); // buttoncontainer.setStyleName("dialogButtons"); // // setWidth("300px"); // setWidget(vpanel1); // // buttonOK.addClickHandler(new ClickHandler() { // public void onClick(ClickEvent event) { // // AlertDialog.getInstance().hide(); // } // }); // // } // // @Override // protected void onHide() { // // TODO Auto-generated method stub // // } // // @Override // protected void onShow() { // // TODO Auto-generated method stub // // } // // }
import org.onesocialweb.gwt.client.OswClient; import org.onesocialweb.gwt.client.ui.dialog.AlertDialog; import org.onesocialweb.gwt.service.OswServiceFactory; import org.onesocialweb.gwt.service.UpdateCallback; import org.onesocialweb.gwt.service.UploadStatus; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; import com.google.gwt.http.client.URL; import com.google.gwt.user.client.ui.FileUpload; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.FormPanel; import com.google.gwt.user.client.ui.Hidden; import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent;
form.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() { public void onSubmitComplete(SubmitCompleteEvent event) { // we are going to use the xmpp channel to monitor progress // instead } }); } public String getFileUrl() { return fileurl; } public void reset() { upload.setVisible(true); progress.setVisible(false); fileLabel.setText(""); fileLabel.setVisible(false); form.reset(); } private String getToken() { // get a token from the server String token = OswServiceFactory.getService().startUpload("123456", new UpdateCallback<UploadStatus>() { @Override public void onError() {
// Path: src/org/onesocialweb/gwt/client/ui/dialog/AlertDialog.java // public class AlertDialog extends AbstractDialog { // // // internationalization // private UserInterfaceText uiText = (UserInterfaceText) GWT // .create(UserInterfaceText.class); // // // private final LoginHandler loginHandler; // private static AlertDialog instance; // private Button buttonOK = new Button(uiText.OK()); // private Label message = new Label(); // // public static AlertDialog getInstance() { // if (instance == null) { // instance = new AlertDialog(); // } // return instance; // } // // public void showDialog(String message, String title) { // setText(title); // this.message.setText(message); // center(); // buttonOK.setFocus(true); // } // // private AlertDialog() { // // // Create dialog // VerticalPanel vpanel1 = new VerticalPanel(); // HorizontalPanel buttoncontainer = new HorizontalPanel(); // // vpanel1.add(message); // vpanel1.add(buttoncontainer); // // buttoncontainer.add(buttonOK); // buttoncontainer.setStyleName("dialogButtons"); // // setWidth("300px"); // setWidget(vpanel1); // // buttonOK.addClickHandler(new ClickHandler() { // public void onClick(ClickEvent event) { // // AlertDialog.getInstance().hide(); // } // }); // // } // // @Override // protected void onHide() { // // TODO Auto-generated method stub // // } // // @Override // protected void onShow() { // // TODO Auto-generated method stub // // } // // } // Path: src/org/onesocialweb/gwt/client/ui/widget/SingleUploader.java import org.onesocialweb.gwt.client.OswClient; import org.onesocialweb.gwt.client.ui.dialog.AlertDialog; import org.onesocialweb.gwt.service.OswServiceFactory; import org.onesocialweb.gwt.service.UpdateCallback; import org.onesocialweb.gwt.service.UploadStatus; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; import com.google.gwt.http.client.URL; import com.google.gwt.user.client.ui.FileUpload; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.FormPanel; import com.google.gwt.user.client.ui.Hidden; import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent; form.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() { public void onSubmitComplete(SubmitCompleteEvent event) { // we are going to use the xmpp channel to monitor progress // instead } }); } public String getFileUrl() { return fileurl; } public void reset() { upload.setVisible(true); progress.setVisible(false); fileLabel.setText(""); fileLabel.setVisible(false); form.reset(); } private String getToken() { // get a token from the server String token = OswServiceFactory.getService().startUpload("123456", new UpdateCallback<UploadStatus>() { @Override public void onError() {
AlertDialog
onesocialweb/osw-web
src/org/onesocialweb/gwt/client/task/DefaultTaskInfo.java
// Path: src/org/onesocialweb/gwt/client/task/TaskEvent.java // public enum Type { // added, updated, completed // };
import org.onesocialweb.gwt.client.task.TaskEvent.Type; import org.onesocialweb.gwt.util.ObservableHelper; import org.onesocialweb.gwt.util.Observer;
return message; } @Override public float getProgress() { return progress; } @Override public Status getStatus() { return status; } @Override public boolean hasProgress() { return hasProgress; } @Override public void registerEventHandler(Observer<TaskEvent> handler) { observableHelper.registerEventHandler(handler); } @Override public void unregisterEventHandler(Observer<TaskEvent> handler) { observableHelper.unregisterEventHandler(handler); } public void setMessage(String message) { this.message = message;
// Path: src/org/onesocialweb/gwt/client/task/TaskEvent.java // public enum Type { // added, updated, completed // }; // Path: src/org/onesocialweb/gwt/client/task/DefaultTaskInfo.java import org.onesocialweb.gwt.client.task.TaskEvent.Type; import org.onesocialweb.gwt.util.ObservableHelper; import org.onesocialweb.gwt.util.Observer; return message; } @Override public float getProgress() { return progress; } @Override public Status getStatus() { return status; } @Override public boolean hasProgress() { return hasProgress; } @Override public void registerEventHandler(Observer<TaskEvent> handler) { observableHelper.registerEventHandler(handler); } @Override public void unregisterEventHandler(Observer<TaskEvent> handler) { observableHelper.unregisterEventHandler(handler); } public void setMessage(String message) { this.message = message;
observableHelper.fireEvent(new DefaultTaskEvent(Type.updated, this));
onesocialweb/osw-web
src/org/onesocialweb/gwt/client/ui/application/ActivityApplication.java
// Path: src/org/onesocialweb/gwt/client/ui/window/FeedWindow.java // public class FeedWindow extends AbstractWindow { // // // internationalization // private UserInterfaceText uiText = (UserInterfaceText) GWT.create(UserInterfaceText.class); // // private final ToggleButton toggleStatusPanel = new ToggleButton(new Image( // OswClient.getInstance().getPreference("theme_folder") // + "assets/08-chat.png")); // private InboxPanel inboxPanel; // private NewActivityPanel statusPanel; // private StatusPanelListener statusPanelListener; // // @Override // protected void onInit() { // composeWindow(); // } // // @Override // protected void onResize() { // updateLayout(); // } // // @Override // protected void onRepaint() { // updateLayout(); // } // // @Override // protected void onDestroy() { // statusPanel.removeComponentListener(statusPanelListener); // } // // private void composeWindow() { // // // Setup window elements // setStyle("feedWindow"); // setWindowTitle(uiText.Activities()); // // // Prepare the panels // statusPanelListener = new StatusPanelListener(); // statusPanel = new NewActivityPanel(); // // statusPanel.setVisible(true); // statusPanel.addComponentListener(statusPanelListener); // // toggleStatusPanel.setDown(true); // toggleStatusPanel.setTitle(uiText.HideUpdatePanel()); // toggleStatusPanel.addStyleDependentName("toggleShowUpdate"); // toggleStatusPanel.addClickHandler(new ClickHandler() { // public void onClick(ClickEvent event) { // toggleStatusPanel(); // } // }); // // inboxPanel = new InboxPanel(); // inboxPanel.setModel(OswServiceFactory.getService().getInbox()); // // // Add the panels to the window // getTopbar().add(statusPanel); // getContents().add(inboxPanel); // getActions().add(toggleStatusPanel); // // statusPanel.addComponentListener(new ComponentListener() { // // @Override // public void componentShown(ComponentEvent e) {} // // @Override // public void componentResized(ComponentEvent e) { // updateLayout(); // } // // @Override // public void componentMoved(ComponentEvent e) {} // // @Override // public void componentHidden(ComponentEvent e) {} // }); // } // // private void toggleStatusPanel() { // if (statusPanel.isVisible()) { // statusPanel.setVisible(false); // toggleStatusPanel.setTitle(uiText.ShowUpdatePanel()); // } else { // statusPanel.setVisible(true); // toggleStatusPanel.setTitle(uiText.HideUpdatePanel()); // } // // // Force layout update on the Feed window itself // updateLayout(); // } // // private void updateLayout() { // // Correct the size of the contents based on visibility of statusPanel // if (statusPanel.isVisible()) { // getContents().getElement() // .setAttribute( // "style", // "top:" // + (getTitlebar().getElement() // .getClientHeight() + statusPanel // .getElement().getClientHeight()) // + ";"); // } else { // getContents().getElement().setAttribute( // "style", // "top:" + (getTitlebar().getElement().getClientHeight()) // + ";"); // } // } // // private class StatusPanelListener implements ComponentListener { // // @Override // public void componentHidden(ComponentEvent e) { // updateLayout(); // } // // @Override // public void componentMoved(ComponentEvent e) { // updateLayout(); // } // // @Override // public void componentResized(ComponentEvent e) { // updateLayout(); // } // // @Override // public void componentShown(ComponentEvent e) { // updateLayout(); // } // // } // }
import org.onesocialweb.gwt.client.ui.window.FeedWindow;
/* * Copyright 2010 Vodafone Group Services Ltd. * * 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 org.onesocialweb.gwt.client.ui.application; public class ActivityApplication extends AbstractApplication { public ActivityApplication() { super(2); } @Override protected void onInit() { // Initialize the slots getSlot(0).setSlotDimensions(0, 0, 50, 100); getSlot(1).setSlotDimensions(0, 50, 50, 100); // Add default window to specific slots
// Path: src/org/onesocialweb/gwt/client/ui/window/FeedWindow.java // public class FeedWindow extends AbstractWindow { // // // internationalization // private UserInterfaceText uiText = (UserInterfaceText) GWT.create(UserInterfaceText.class); // // private final ToggleButton toggleStatusPanel = new ToggleButton(new Image( // OswClient.getInstance().getPreference("theme_folder") // + "assets/08-chat.png")); // private InboxPanel inboxPanel; // private NewActivityPanel statusPanel; // private StatusPanelListener statusPanelListener; // // @Override // protected void onInit() { // composeWindow(); // } // // @Override // protected void onResize() { // updateLayout(); // } // // @Override // protected void onRepaint() { // updateLayout(); // } // // @Override // protected void onDestroy() { // statusPanel.removeComponentListener(statusPanelListener); // } // // private void composeWindow() { // // // Setup window elements // setStyle("feedWindow"); // setWindowTitle(uiText.Activities()); // // // Prepare the panels // statusPanelListener = new StatusPanelListener(); // statusPanel = new NewActivityPanel(); // // statusPanel.setVisible(true); // statusPanel.addComponentListener(statusPanelListener); // // toggleStatusPanel.setDown(true); // toggleStatusPanel.setTitle(uiText.HideUpdatePanel()); // toggleStatusPanel.addStyleDependentName("toggleShowUpdate"); // toggleStatusPanel.addClickHandler(new ClickHandler() { // public void onClick(ClickEvent event) { // toggleStatusPanel(); // } // }); // // inboxPanel = new InboxPanel(); // inboxPanel.setModel(OswServiceFactory.getService().getInbox()); // // // Add the panels to the window // getTopbar().add(statusPanel); // getContents().add(inboxPanel); // getActions().add(toggleStatusPanel); // // statusPanel.addComponentListener(new ComponentListener() { // // @Override // public void componentShown(ComponentEvent e) {} // // @Override // public void componentResized(ComponentEvent e) { // updateLayout(); // } // // @Override // public void componentMoved(ComponentEvent e) {} // // @Override // public void componentHidden(ComponentEvent e) {} // }); // } // // private void toggleStatusPanel() { // if (statusPanel.isVisible()) { // statusPanel.setVisible(false); // toggleStatusPanel.setTitle(uiText.ShowUpdatePanel()); // } else { // statusPanel.setVisible(true); // toggleStatusPanel.setTitle(uiText.HideUpdatePanel()); // } // // // Force layout update on the Feed window itself // updateLayout(); // } // // private void updateLayout() { // // Correct the size of the contents based on visibility of statusPanel // if (statusPanel.isVisible()) { // getContents().getElement() // .setAttribute( // "style", // "top:" // + (getTitlebar().getElement() // .getClientHeight() + statusPanel // .getElement().getClientHeight()) // + ";"); // } else { // getContents().getElement().setAttribute( // "style", // "top:" + (getTitlebar().getElement().getClientHeight()) // + ";"); // } // } // // private class StatusPanelListener implements ComponentListener { // // @Override // public void componentHidden(ComponentEvent e) { // updateLayout(); // } // // @Override // public void componentMoved(ComponentEvent e) { // updateLayout(); // } // // @Override // public void componentResized(ComponentEvent e) { // updateLayout(); // } // // @Override // public void componentShown(ComponentEvent e) { // updateLayout(); // } // // } // } // Path: src/org/onesocialweb/gwt/client/ui/application/ActivityApplication.java import org.onesocialweb.gwt.client.ui.window.FeedWindow; /* * Copyright 2010 Vodafone Group Services Ltd. * * 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 org.onesocialweb.gwt.client.ui.application; public class ActivityApplication extends AbstractApplication { public ActivityApplication() { super(2); } @Override protected void onInit() { // Initialize the slots getSlot(0).setSlotDimensions(0, 0, 50, 100); getSlot(1).setSlotDimensions(0, 50, 50, 100); // Add default window to specific slots
addWindow(FeedWindow.class.toString(), 0);
onesocialweb/osw-web
src/org/onesocialweb/gwt/client/ui/widget/contact/ContactPanel.java
// Path: src/org/onesocialweb/gwt/client/handler/ContactButtonHandler.java // public interface ContactButtonHandler { // // public void handleShow(int top, ContactItemView contact); // // public void handleHide(); // // } // // Path: src/org/onesocialweb/gwt/client/i18n/UserInterfaceText.java // public interface UserInterfaceText extends Constants { // // // Titles // String Welcome(); // String OopsCannotSearch(); // String WorkingOnThis(); // String Oops(); // String CannotAddPicture(); // String Privacy(); // String ImagePreview(); // // // Buttons / Tabs // String OK(); // String Save(); // String Cancel(); // String Login(); // String Logout(); // String Register(); // String Search(); // String Share(); // String FromUrl(); // String Upload(); // String ManagePerson(); // String ProfileAndContact(); // String Account(); // String Add(); // // // Labels // String YourUsername(); // String YourPassword(); // String ChooseUsername(); // String ChoosePassword(); // String EnterYourEmail(); // String EnterCode(); // String Following(); // String RememberMe(); // String Url(); // String Bio(); // String OnYourLists(); // String Followers(); // String FollowingPeople(); // String DisplayName(); // String FullName(); // String Birthday(); // String Gender(); // String Email(); // String Telephone(); // String Website(); // String ViewProfileOf(); // String YourLists(); // String Avatar(); // String General(); // String YourIdentity(); // String UserName(); // String FirstName(); // String Surname(); // String WhoCanSeeUpdate(); // String With(); // String ChangeLocale(); // String Language(); // String ShoutTo(); // String Pictures(); // String To(); // String VisibleTo(); // // // Application / window names // String Activities(); // String Preferences(); // String Contacts(); // String Profile(); // // // Field Values // String Male(); // String Female(); // String NotKnown(); // String NotApplicable(); // String Everyone(); // String You(); // // // Tooltips // String ShowSearchPanel(); // String HideSearchPanel(); // String ShowUpdatePanel(); // String HideUpdatePanel(); // String ViewProfile(); // String Chatty(); // String Away(); // String DoNotDisturb(); // String ExtendedAway(); // String Online(); // String NotAvailable(); // String DeleteFromContacts(); // String ShoutToContact(); // String FollowPerson(); // String UnfollowPerson(); // String SendPrivateMessage(); // String ChatWithPerson(); // String AddPicture(); // String ChangePrivacy(); // String ShoutToContacts(); // String EditProfile(); // String BackToDefault(); // String AddAvatar(); // String ClearPeople(); // String RemovePicture(); // String RemovePictures(); // String ShowPreview(); // // // Instructions // String PleaseUseUserAtDomain(); // String AccountUnavailable(); // String SelectFile(); // String SelectPictureUrl(); // String AddOrRemovePerson(); // String IdentityFixed(); // String SetLanguage(); // // // Notifications // String FetchingProfile(); // String FeatureNotImplemented(); // String FetchingActivities(); // String NoActivitiesAvailable(); // String UpdatingStatus(); // String UpdateSuccess(); // String WaitForUpload(); // String FetchingFollowers(); // String FetchingFollowing(); // String NoFollowers(); // String NoFollowing(); // String EmptyUpdate(); // // // Error // String FailedToGetProfile(); // String LoginFailure(); // String UpdateFailure(); // // // Months // String January(); // String February(); // String March(); // String April(); // String May(); // String June(); // String July(); // String August(); // String September(); // String October(); // String November(); // String December(); // // } // // Path: src/org/onesocialweb/gwt/client/ui/widget/StyledFlowPanel.java // public class StyledFlowPanel extends FlowPanel { // // public StyledFlowPanel(String classname) { // addStyleName(classname); // } // }
import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.Label; import java.util.Collections; import java.util.Comparator; import java.util.List; import org.onesocialweb.gwt.client.handler.ContactButtonHandler; import org.onesocialweb.gwt.client.i18n.UserInterfaceMessages; import org.onesocialweb.gwt.client.i18n.UserInterfaceText; import org.onesocialweb.gwt.client.ui.widget.StyledFlowPanel; import org.onesocialweb.gwt.service.OswService; import org.onesocialweb.gwt.service.OswServiceFactory; import org.onesocialweb.gwt.service.Roster; import org.onesocialweb.gwt.service.RosterEvent; import org.onesocialweb.gwt.service.RosterItem; import org.onesocialweb.gwt.util.Observer;
/* * Copyright 2010 Vodafone Group Services Ltd. * * 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 org.onesocialweb.gwt.client.ui.widget.contact; public class ContactPanel extends AbstractContactPanel<ContactItemView> { // internationalization private UserInterfaceMessages uiMessages = (UserInterfaceMessages) GWT.create(UserInterfaceMessages.class); private final ContactButtons buttons = new ContactButtons();
// Path: src/org/onesocialweb/gwt/client/handler/ContactButtonHandler.java // public interface ContactButtonHandler { // // public void handleShow(int top, ContactItemView contact); // // public void handleHide(); // // } // // Path: src/org/onesocialweb/gwt/client/i18n/UserInterfaceText.java // public interface UserInterfaceText extends Constants { // // // Titles // String Welcome(); // String OopsCannotSearch(); // String WorkingOnThis(); // String Oops(); // String CannotAddPicture(); // String Privacy(); // String ImagePreview(); // // // Buttons / Tabs // String OK(); // String Save(); // String Cancel(); // String Login(); // String Logout(); // String Register(); // String Search(); // String Share(); // String FromUrl(); // String Upload(); // String ManagePerson(); // String ProfileAndContact(); // String Account(); // String Add(); // // // Labels // String YourUsername(); // String YourPassword(); // String ChooseUsername(); // String ChoosePassword(); // String EnterYourEmail(); // String EnterCode(); // String Following(); // String RememberMe(); // String Url(); // String Bio(); // String OnYourLists(); // String Followers(); // String FollowingPeople(); // String DisplayName(); // String FullName(); // String Birthday(); // String Gender(); // String Email(); // String Telephone(); // String Website(); // String ViewProfileOf(); // String YourLists(); // String Avatar(); // String General(); // String YourIdentity(); // String UserName(); // String FirstName(); // String Surname(); // String WhoCanSeeUpdate(); // String With(); // String ChangeLocale(); // String Language(); // String ShoutTo(); // String Pictures(); // String To(); // String VisibleTo(); // // // Application / window names // String Activities(); // String Preferences(); // String Contacts(); // String Profile(); // // // Field Values // String Male(); // String Female(); // String NotKnown(); // String NotApplicable(); // String Everyone(); // String You(); // // // Tooltips // String ShowSearchPanel(); // String HideSearchPanel(); // String ShowUpdatePanel(); // String HideUpdatePanel(); // String ViewProfile(); // String Chatty(); // String Away(); // String DoNotDisturb(); // String ExtendedAway(); // String Online(); // String NotAvailable(); // String DeleteFromContacts(); // String ShoutToContact(); // String FollowPerson(); // String UnfollowPerson(); // String SendPrivateMessage(); // String ChatWithPerson(); // String AddPicture(); // String ChangePrivacy(); // String ShoutToContacts(); // String EditProfile(); // String BackToDefault(); // String AddAvatar(); // String ClearPeople(); // String RemovePicture(); // String RemovePictures(); // String ShowPreview(); // // // Instructions // String PleaseUseUserAtDomain(); // String AccountUnavailable(); // String SelectFile(); // String SelectPictureUrl(); // String AddOrRemovePerson(); // String IdentityFixed(); // String SetLanguage(); // // // Notifications // String FetchingProfile(); // String FeatureNotImplemented(); // String FetchingActivities(); // String NoActivitiesAvailable(); // String UpdatingStatus(); // String UpdateSuccess(); // String WaitForUpload(); // String FetchingFollowers(); // String FetchingFollowing(); // String NoFollowers(); // String NoFollowing(); // String EmptyUpdate(); // // // Error // String FailedToGetProfile(); // String LoginFailure(); // String UpdateFailure(); // // // Months // String January(); // String February(); // String March(); // String April(); // String May(); // String June(); // String July(); // String August(); // String September(); // String October(); // String November(); // String December(); // // } // // Path: src/org/onesocialweb/gwt/client/ui/widget/StyledFlowPanel.java // public class StyledFlowPanel extends FlowPanel { // // public StyledFlowPanel(String classname) { // addStyleName(classname); // } // } // Path: src/org/onesocialweb/gwt/client/ui/widget/contact/ContactPanel.java import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.Label; import java.util.Collections; import java.util.Comparator; import java.util.List; import org.onesocialweb.gwt.client.handler.ContactButtonHandler; import org.onesocialweb.gwt.client.i18n.UserInterfaceMessages; import org.onesocialweb.gwt.client.i18n.UserInterfaceText; import org.onesocialweb.gwt.client.ui.widget.StyledFlowPanel; import org.onesocialweb.gwt.service.OswService; import org.onesocialweb.gwt.service.OswServiceFactory; import org.onesocialweb.gwt.service.Roster; import org.onesocialweb.gwt.service.RosterEvent; import org.onesocialweb.gwt.service.RosterItem; import org.onesocialweb.gwt.util.Observer; /* * Copyright 2010 Vodafone Group Services Ltd. * * 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 org.onesocialweb.gwt.client.ui.widget.contact; public class ContactPanel extends AbstractContactPanel<ContactItemView> { // internationalization private UserInterfaceMessages uiMessages = (UserInterfaceMessages) GWT.create(UserInterfaceMessages.class); private final ContactButtons buttons = new ContactButtons();
private final StyledFlowPanel toolbar = new StyledFlowPanel("toolbar");
onesocialweb/osw-web
src/org/onesocialweb/gwt/client/ui/widget/contact/ContactPanel.java
// Path: src/org/onesocialweb/gwt/client/handler/ContactButtonHandler.java // public interface ContactButtonHandler { // // public void handleShow(int top, ContactItemView contact); // // public void handleHide(); // // } // // Path: src/org/onesocialweb/gwt/client/i18n/UserInterfaceText.java // public interface UserInterfaceText extends Constants { // // // Titles // String Welcome(); // String OopsCannotSearch(); // String WorkingOnThis(); // String Oops(); // String CannotAddPicture(); // String Privacy(); // String ImagePreview(); // // // Buttons / Tabs // String OK(); // String Save(); // String Cancel(); // String Login(); // String Logout(); // String Register(); // String Search(); // String Share(); // String FromUrl(); // String Upload(); // String ManagePerson(); // String ProfileAndContact(); // String Account(); // String Add(); // // // Labels // String YourUsername(); // String YourPassword(); // String ChooseUsername(); // String ChoosePassword(); // String EnterYourEmail(); // String EnterCode(); // String Following(); // String RememberMe(); // String Url(); // String Bio(); // String OnYourLists(); // String Followers(); // String FollowingPeople(); // String DisplayName(); // String FullName(); // String Birthday(); // String Gender(); // String Email(); // String Telephone(); // String Website(); // String ViewProfileOf(); // String YourLists(); // String Avatar(); // String General(); // String YourIdentity(); // String UserName(); // String FirstName(); // String Surname(); // String WhoCanSeeUpdate(); // String With(); // String ChangeLocale(); // String Language(); // String ShoutTo(); // String Pictures(); // String To(); // String VisibleTo(); // // // Application / window names // String Activities(); // String Preferences(); // String Contacts(); // String Profile(); // // // Field Values // String Male(); // String Female(); // String NotKnown(); // String NotApplicable(); // String Everyone(); // String You(); // // // Tooltips // String ShowSearchPanel(); // String HideSearchPanel(); // String ShowUpdatePanel(); // String HideUpdatePanel(); // String ViewProfile(); // String Chatty(); // String Away(); // String DoNotDisturb(); // String ExtendedAway(); // String Online(); // String NotAvailable(); // String DeleteFromContacts(); // String ShoutToContact(); // String FollowPerson(); // String UnfollowPerson(); // String SendPrivateMessage(); // String ChatWithPerson(); // String AddPicture(); // String ChangePrivacy(); // String ShoutToContacts(); // String EditProfile(); // String BackToDefault(); // String AddAvatar(); // String ClearPeople(); // String RemovePicture(); // String RemovePictures(); // String ShowPreview(); // // // Instructions // String PleaseUseUserAtDomain(); // String AccountUnavailable(); // String SelectFile(); // String SelectPictureUrl(); // String AddOrRemovePerson(); // String IdentityFixed(); // String SetLanguage(); // // // Notifications // String FetchingProfile(); // String FeatureNotImplemented(); // String FetchingActivities(); // String NoActivitiesAvailable(); // String UpdatingStatus(); // String UpdateSuccess(); // String WaitForUpload(); // String FetchingFollowers(); // String FetchingFollowing(); // String NoFollowers(); // String NoFollowing(); // String EmptyUpdate(); // // // Error // String FailedToGetProfile(); // String LoginFailure(); // String UpdateFailure(); // // // Months // String January(); // String February(); // String March(); // String April(); // String May(); // String June(); // String July(); // String August(); // String September(); // String October(); // String November(); // String December(); // // } // // Path: src/org/onesocialweb/gwt/client/ui/widget/StyledFlowPanel.java // public class StyledFlowPanel extends FlowPanel { // // public StyledFlowPanel(String classname) { // addStyleName(classname); // } // }
import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.Label; import java.util.Collections; import java.util.Comparator; import java.util.List; import org.onesocialweb.gwt.client.handler.ContactButtonHandler; import org.onesocialweb.gwt.client.i18n.UserInterfaceMessages; import org.onesocialweb.gwt.client.i18n.UserInterfaceText; import org.onesocialweb.gwt.client.ui.widget.StyledFlowPanel; import org.onesocialweb.gwt.service.OswService; import org.onesocialweb.gwt.service.OswServiceFactory; import org.onesocialweb.gwt.service.Roster; import org.onesocialweb.gwt.service.RosterEvent; import org.onesocialweb.gwt.service.RosterItem; import org.onesocialweb.gwt.util.Observer;
// make sure to kill the roster event handler if (rosterhandler != null) { roster.unregisterEventHandler(rosterhandler); } } private void repaint() { // Clear the current contacts contacts.clear(); // Get the roster items List<RosterItem> items = roster.getItems(); // Show nr of connections connectionsCount.setText(uiMessages.YouHaveNConnections(items.size())); // sort alphabetically Collections.sort(items, new Comparator<RosterItem>() { @Override public int compare(RosterItem o1, RosterItem o2) { return o1.getJid().compareToIgnoreCase(o2.getJid()); } }); // add all the contacts for (final RosterItem rosterItem : items) { ContactItemView contact = new ContactItemView(rosterItem); contacts.add(contact);
// Path: src/org/onesocialweb/gwt/client/handler/ContactButtonHandler.java // public interface ContactButtonHandler { // // public void handleShow(int top, ContactItemView contact); // // public void handleHide(); // // } // // Path: src/org/onesocialweb/gwt/client/i18n/UserInterfaceText.java // public interface UserInterfaceText extends Constants { // // // Titles // String Welcome(); // String OopsCannotSearch(); // String WorkingOnThis(); // String Oops(); // String CannotAddPicture(); // String Privacy(); // String ImagePreview(); // // // Buttons / Tabs // String OK(); // String Save(); // String Cancel(); // String Login(); // String Logout(); // String Register(); // String Search(); // String Share(); // String FromUrl(); // String Upload(); // String ManagePerson(); // String ProfileAndContact(); // String Account(); // String Add(); // // // Labels // String YourUsername(); // String YourPassword(); // String ChooseUsername(); // String ChoosePassword(); // String EnterYourEmail(); // String EnterCode(); // String Following(); // String RememberMe(); // String Url(); // String Bio(); // String OnYourLists(); // String Followers(); // String FollowingPeople(); // String DisplayName(); // String FullName(); // String Birthday(); // String Gender(); // String Email(); // String Telephone(); // String Website(); // String ViewProfileOf(); // String YourLists(); // String Avatar(); // String General(); // String YourIdentity(); // String UserName(); // String FirstName(); // String Surname(); // String WhoCanSeeUpdate(); // String With(); // String ChangeLocale(); // String Language(); // String ShoutTo(); // String Pictures(); // String To(); // String VisibleTo(); // // // Application / window names // String Activities(); // String Preferences(); // String Contacts(); // String Profile(); // // // Field Values // String Male(); // String Female(); // String NotKnown(); // String NotApplicable(); // String Everyone(); // String You(); // // // Tooltips // String ShowSearchPanel(); // String HideSearchPanel(); // String ShowUpdatePanel(); // String HideUpdatePanel(); // String ViewProfile(); // String Chatty(); // String Away(); // String DoNotDisturb(); // String ExtendedAway(); // String Online(); // String NotAvailable(); // String DeleteFromContacts(); // String ShoutToContact(); // String FollowPerson(); // String UnfollowPerson(); // String SendPrivateMessage(); // String ChatWithPerson(); // String AddPicture(); // String ChangePrivacy(); // String ShoutToContacts(); // String EditProfile(); // String BackToDefault(); // String AddAvatar(); // String ClearPeople(); // String RemovePicture(); // String RemovePictures(); // String ShowPreview(); // // // Instructions // String PleaseUseUserAtDomain(); // String AccountUnavailable(); // String SelectFile(); // String SelectPictureUrl(); // String AddOrRemovePerson(); // String IdentityFixed(); // String SetLanguage(); // // // Notifications // String FetchingProfile(); // String FeatureNotImplemented(); // String FetchingActivities(); // String NoActivitiesAvailable(); // String UpdatingStatus(); // String UpdateSuccess(); // String WaitForUpload(); // String FetchingFollowers(); // String FetchingFollowing(); // String NoFollowers(); // String NoFollowing(); // String EmptyUpdate(); // // // Error // String FailedToGetProfile(); // String LoginFailure(); // String UpdateFailure(); // // // Months // String January(); // String February(); // String March(); // String April(); // String May(); // String June(); // String July(); // String August(); // String September(); // String October(); // String November(); // String December(); // // } // // Path: src/org/onesocialweb/gwt/client/ui/widget/StyledFlowPanel.java // public class StyledFlowPanel extends FlowPanel { // // public StyledFlowPanel(String classname) { // addStyleName(classname); // } // } // Path: src/org/onesocialweb/gwt/client/ui/widget/contact/ContactPanel.java import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.Label; import java.util.Collections; import java.util.Comparator; import java.util.List; import org.onesocialweb.gwt.client.handler.ContactButtonHandler; import org.onesocialweb.gwt.client.i18n.UserInterfaceMessages; import org.onesocialweb.gwt.client.i18n.UserInterfaceText; import org.onesocialweb.gwt.client.ui.widget.StyledFlowPanel; import org.onesocialweb.gwt.service.OswService; import org.onesocialweb.gwt.service.OswServiceFactory; import org.onesocialweb.gwt.service.Roster; import org.onesocialweb.gwt.service.RosterEvent; import org.onesocialweb.gwt.service.RosterItem; import org.onesocialweb.gwt.util.Observer; // make sure to kill the roster event handler if (rosterhandler != null) { roster.unregisterEventHandler(rosterhandler); } } private void repaint() { // Clear the current contacts contacts.clear(); // Get the roster items List<RosterItem> items = roster.getItems(); // Show nr of connections connectionsCount.setText(uiMessages.YouHaveNConnections(items.size())); // sort alphabetically Collections.sort(items, new Comparator<RosterItem>() { @Override public int compare(RosterItem o1, RosterItem o2) { return o1.getJid().compareToIgnoreCase(o2.getJid()); } }); // add all the contacts for (final RosterItem rosterItem : items) { ContactItemView contact = new ContactItemView(rosterItem); contacts.add(contact);
contact.setButtonHandler(new ContactButtonHandler() {
onesocialweb/osw-web
src/org/onesocialweb/gwt/client/ui/widget/compose/PrivacyAttachmentPanel.java
// Path: src/org/onesocialweb/gwt/client/i18n/UserInterfaceText.java // public interface UserInterfaceText extends Constants { // // // Titles // String Welcome(); // String OopsCannotSearch(); // String WorkingOnThis(); // String Oops(); // String CannotAddPicture(); // String Privacy(); // String ImagePreview(); // // // Buttons / Tabs // String OK(); // String Save(); // String Cancel(); // String Login(); // String Logout(); // String Register(); // String Search(); // String Share(); // String FromUrl(); // String Upload(); // String ManagePerson(); // String ProfileAndContact(); // String Account(); // String Add(); // // // Labels // String YourUsername(); // String YourPassword(); // String ChooseUsername(); // String ChoosePassword(); // String EnterYourEmail(); // String EnterCode(); // String Following(); // String RememberMe(); // String Url(); // String Bio(); // String OnYourLists(); // String Followers(); // String FollowingPeople(); // String DisplayName(); // String FullName(); // String Birthday(); // String Gender(); // String Email(); // String Telephone(); // String Website(); // String ViewProfileOf(); // String YourLists(); // String Avatar(); // String General(); // String YourIdentity(); // String UserName(); // String FirstName(); // String Surname(); // String WhoCanSeeUpdate(); // String With(); // String ChangeLocale(); // String Language(); // String ShoutTo(); // String Pictures(); // String To(); // String VisibleTo(); // // // Application / window names // String Activities(); // String Preferences(); // String Contacts(); // String Profile(); // // // Field Values // String Male(); // String Female(); // String NotKnown(); // String NotApplicable(); // String Everyone(); // String You(); // // // Tooltips // String ShowSearchPanel(); // String HideSearchPanel(); // String ShowUpdatePanel(); // String HideUpdatePanel(); // String ViewProfile(); // String Chatty(); // String Away(); // String DoNotDisturb(); // String ExtendedAway(); // String Online(); // String NotAvailable(); // String DeleteFromContacts(); // String ShoutToContact(); // String FollowPerson(); // String UnfollowPerson(); // String SendPrivateMessage(); // String ChatWithPerson(); // String AddPicture(); // String ChangePrivacy(); // String ShoutToContacts(); // String EditProfile(); // String BackToDefault(); // String AddAvatar(); // String ClearPeople(); // String RemovePicture(); // String RemovePictures(); // String ShowPreview(); // // // Instructions // String PleaseUseUserAtDomain(); // String AccountUnavailable(); // String SelectFile(); // String SelectPictureUrl(); // String AddOrRemovePerson(); // String IdentityFixed(); // String SetLanguage(); // // // Notifications // String FetchingProfile(); // String FeatureNotImplemented(); // String FetchingActivities(); // String NoActivitiesAvailable(); // String UpdatingStatus(); // String UpdateSuccess(); // String WaitForUpload(); // String FetchingFollowers(); // String FetchingFollowing(); // String NoFollowers(); // String NoFollowing(); // String EmptyUpdate(); // // // Error // String FailedToGetProfile(); // String LoginFailure(); // String UpdateFailure(); // // // Months // String January(); // String February(); // String March(); // String April(); // String May(); // String June(); // String July(); // String August(); // String September(); // String October(); // String November(); // String December(); // // } // // Path: src/org/onesocialweb/gwt/client/ui/widget/StyledFlowPanel.java // public class StyledFlowPanel extends FlowPanel { // // public StyledFlowPanel(String classname) { // addStyleName(classname); // } // } // // Path: src/org/onesocialweb/gwt/client/ui/widget/StyledLabel.java // public class StyledLabel extends HTML { // // public StyledLabel(String classname, String htmlText) { // if (classname != null && classname.length() > 0) // addStyleName(classname); // setHTML(htmlText); // } // }
import com.google.gwt.user.client.ui.ListBox; import java.util.Set; import org.onesocialweb.gwt.client.OswClient; import org.onesocialweb.gwt.client.i18n.UserInterfaceText; import org.onesocialweb.gwt.client.ui.widget.StyledFlowPanel; import org.onesocialweb.gwt.client.ui.widget.StyledLabel; import org.onesocialweb.gwt.service.OswServiceFactory; import org.onesocialweb.gwt.service.Roster; import org.onesocialweb.gwt.service.RosterEvent; import org.onesocialweb.gwt.util.Observer; import org.onesocialweb.model.activity.ActivityObject; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.ui.Label;
/* * Copyright 2010 Vodafone Group Services Ltd. * * 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 org.onesocialweb.gwt.client.ui.widget.compose; public class PrivacyAttachmentPanel extends AbstractAttachmentPanel { // internationalization private UserInterfaceText uiText = (UserInterfaceText) GWT.create(UserInterfaceText.class); private ListBox visibility; public PrivacyAttachmentPanel() { setHeader(uiText.Privacy()); setVisible(false);
// Path: src/org/onesocialweb/gwt/client/i18n/UserInterfaceText.java // public interface UserInterfaceText extends Constants { // // // Titles // String Welcome(); // String OopsCannotSearch(); // String WorkingOnThis(); // String Oops(); // String CannotAddPicture(); // String Privacy(); // String ImagePreview(); // // // Buttons / Tabs // String OK(); // String Save(); // String Cancel(); // String Login(); // String Logout(); // String Register(); // String Search(); // String Share(); // String FromUrl(); // String Upload(); // String ManagePerson(); // String ProfileAndContact(); // String Account(); // String Add(); // // // Labels // String YourUsername(); // String YourPassword(); // String ChooseUsername(); // String ChoosePassword(); // String EnterYourEmail(); // String EnterCode(); // String Following(); // String RememberMe(); // String Url(); // String Bio(); // String OnYourLists(); // String Followers(); // String FollowingPeople(); // String DisplayName(); // String FullName(); // String Birthday(); // String Gender(); // String Email(); // String Telephone(); // String Website(); // String ViewProfileOf(); // String YourLists(); // String Avatar(); // String General(); // String YourIdentity(); // String UserName(); // String FirstName(); // String Surname(); // String WhoCanSeeUpdate(); // String With(); // String ChangeLocale(); // String Language(); // String ShoutTo(); // String Pictures(); // String To(); // String VisibleTo(); // // // Application / window names // String Activities(); // String Preferences(); // String Contacts(); // String Profile(); // // // Field Values // String Male(); // String Female(); // String NotKnown(); // String NotApplicable(); // String Everyone(); // String You(); // // // Tooltips // String ShowSearchPanel(); // String HideSearchPanel(); // String ShowUpdatePanel(); // String HideUpdatePanel(); // String ViewProfile(); // String Chatty(); // String Away(); // String DoNotDisturb(); // String ExtendedAway(); // String Online(); // String NotAvailable(); // String DeleteFromContacts(); // String ShoutToContact(); // String FollowPerson(); // String UnfollowPerson(); // String SendPrivateMessage(); // String ChatWithPerson(); // String AddPicture(); // String ChangePrivacy(); // String ShoutToContacts(); // String EditProfile(); // String BackToDefault(); // String AddAvatar(); // String ClearPeople(); // String RemovePicture(); // String RemovePictures(); // String ShowPreview(); // // // Instructions // String PleaseUseUserAtDomain(); // String AccountUnavailable(); // String SelectFile(); // String SelectPictureUrl(); // String AddOrRemovePerson(); // String IdentityFixed(); // String SetLanguage(); // // // Notifications // String FetchingProfile(); // String FeatureNotImplemented(); // String FetchingActivities(); // String NoActivitiesAvailable(); // String UpdatingStatus(); // String UpdateSuccess(); // String WaitForUpload(); // String FetchingFollowers(); // String FetchingFollowing(); // String NoFollowers(); // String NoFollowing(); // String EmptyUpdate(); // // // Error // String FailedToGetProfile(); // String LoginFailure(); // String UpdateFailure(); // // // Months // String January(); // String February(); // String March(); // String April(); // String May(); // String June(); // String July(); // String August(); // String September(); // String October(); // String November(); // String December(); // // } // // Path: src/org/onesocialweb/gwt/client/ui/widget/StyledFlowPanel.java // public class StyledFlowPanel extends FlowPanel { // // public StyledFlowPanel(String classname) { // addStyleName(classname); // } // } // // Path: src/org/onesocialweb/gwt/client/ui/widget/StyledLabel.java // public class StyledLabel extends HTML { // // public StyledLabel(String classname, String htmlText) { // if (classname != null && classname.length() > 0) // addStyleName(classname); // setHTML(htmlText); // } // } // Path: src/org/onesocialweb/gwt/client/ui/widget/compose/PrivacyAttachmentPanel.java import com.google.gwt.user.client.ui.ListBox; import java.util.Set; import org.onesocialweb.gwt.client.OswClient; import org.onesocialweb.gwt.client.i18n.UserInterfaceText; import org.onesocialweb.gwt.client.ui.widget.StyledFlowPanel; import org.onesocialweb.gwt.client.ui.widget.StyledLabel; import org.onesocialweb.gwt.service.OswServiceFactory; import org.onesocialweb.gwt.service.Roster; import org.onesocialweb.gwt.service.RosterEvent; import org.onesocialweb.gwt.util.Observer; import org.onesocialweb.model.activity.ActivityObject; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.ui.Label; /* * Copyright 2010 Vodafone Group Services Ltd. * * 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 org.onesocialweb.gwt.client.ui.widget.compose; public class PrivacyAttachmentPanel extends AbstractAttachmentPanel { // internationalization private UserInterfaceText uiText = (UserInterfaceText) GWT.create(UserInterfaceText.class); private ListBox visibility; public PrivacyAttachmentPanel() { setHeader(uiText.Privacy()); setVisible(false);
StyledFlowPanel layout = new StyledFlowPanel("privacyAttachment");
onesocialweb/osw-web
src/org/onesocialweb/gwt/client/ui/widget/ListSelector.java
// Path: src/org/onesocialweb/gwt/client/task/DefaultTaskInfo.java // public class DefaultTaskInfo implements TaskInfo { // // private final ObservableHelper<TaskEvent> observableHelper = new ObservableHelper<TaskEvent>(); // // private final boolean hasProgress; // // private float progress = 0; // // private String message; // // private Status status = Status.running; // // public DefaultTaskInfo(String message, boolean hasProgress) { // this.message = message; // this.hasProgress = hasProgress; // } // // @Override // public String getMessage() { // return message; // } // // @Override // public float getProgress() { // return progress; // } // // @Override // public Status getStatus() { // return status; // } // // @Override // public boolean hasProgress() { // return hasProgress; // } // // @Override // public void registerEventHandler(Observer<TaskEvent> handler) { // observableHelper.registerEventHandler(handler); // } // // @Override // public void unregisterEventHandler(Observer<TaskEvent> handler) { // observableHelper.unregisterEventHandler(handler); // } // // public void setMessage(String message) { // this.message = message; // observableHelper.fireEvent(new DefaultTaskEvent(Type.updated, this)); // } // // public void setProgress(float progress) { // this.progress = progress; // observableHelper.fireEvent(new DefaultTaskEvent(Type.updated, this)); // } // // public void complete(String message, Status status) { // this.status = status; // this.message = message; // observableHelper.fireEvent(new DefaultTaskEvent(Type.completed, this)); // } // // } // // Path: src/org/onesocialweb/gwt/client/task/TaskMonitor.java // public class TaskMonitor implements Observable<TaskEvent> { // // private static TaskMonitor instance; // // private final ObservableHelper<TaskEvent> observableHelper = new ObservableHelper<TaskEvent>(); // // private final List<TaskInfo> tasks = new ArrayList<TaskInfo>(); // // private final TaskHandler handler = new TaskHandler(); // // public static TaskMonitor getInstance() { // if (instance == null) { // instance = new TaskMonitor(); // } // return instance; // } // // @Override // public void registerEventHandler(Observer<TaskEvent> handler) { // observableHelper.registerEventHandler(handler); // } // // @Override // public void unregisterEventHandler(Observer<TaskEvent> handler) { // observableHelper.unregisterEventHandler(handler); // } // // public void addTask(TaskInfo task) { // tasks.add(task); // task.registerEventHandler(handler); // observableHelper.fireEvent(new DefaultTaskEvent(TaskEvent.Type.added, // task)); // } // // public List<TaskInfo> getTasks() { // return Collections.unmodifiableList(tasks); // } // // private class TaskHandler implements Observer<TaskEvent> { // // @Override // public void handleEvent(TaskEvent event) { // if (event.getType().equals(Type.completed)) { // tasks.remove(event.getTask()); // observableHelper.fireEvent(event); // } // } // // } // // // private constructor to maintain singleton // private TaskMonitor() { // // // } // // }
import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.TextBox; import java.util.ArrayList; import java.util.List; import java.util.Set; import org.onesocialweb.gwt.client.task.DefaultTaskInfo; import org.onesocialweb.gwt.client.task.TaskMonitor; import org.onesocialweb.gwt.client.task.TaskInfo.Status; import org.onesocialweb.gwt.service.OswService; import org.onesocialweb.gwt.service.OswServiceFactory; import org.onesocialweb.gwt.service.RequestCallback; import org.onesocialweb.gwt.service.RosterItem; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler;
addCheckbox(input.getText(), true); // empty the input field input.setText(""); } }); } public void addCheckbox(String list, Boolean value) { final CheckBox checkbox = new CheckBox(list); StyledFlowPanel fix = new StyledFlowPanel("fix"); checkbox.addStyleName("checkbox"); // manage checks and unchecks checkbox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { // is the item is checked? if (event.getValue() == true && !listed.contains(checkbox.getText()) && checkbox.getText()!=null && checkbox.getText().length()!=0) { // set the values listed.add(checkbox.getText()); rosterItem.setGroups(listed); // disable during processing checkbox.setEnabled(false); // show task
// Path: src/org/onesocialweb/gwt/client/task/DefaultTaskInfo.java // public class DefaultTaskInfo implements TaskInfo { // // private final ObservableHelper<TaskEvent> observableHelper = new ObservableHelper<TaskEvent>(); // // private final boolean hasProgress; // // private float progress = 0; // // private String message; // // private Status status = Status.running; // // public DefaultTaskInfo(String message, boolean hasProgress) { // this.message = message; // this.hasProgress = hasProgress; // } // // @Override // public String getMessage() { // return message; // } // // @Override // public float getProgress() { // return progress; // } // // @Override // public Status getStatus() { // return status; // } // // @Override // public boolean hasProgress() { // return hasProgress; // } // // @Override // public void registerEventHandler(Observer<TaskEvent> handler) { // observableHelper.registerEventHandler(handler); // } // // @Override // public void unregisterEventHandler(Observer<TaskEvent> handler) { // observableHelper.unregisterEventHandler(handler); // } // // public void setMessage(String message) { // this.message = message; // observableHelper.fireEvent(new DefaultTaskEvent(Type.updated, this)); // } // // public void setProgress(float progress) { // this.progress = progress; // observableHelper.fireEvent(new DefaultTaskEvent(Type.updated, this)); // } // // public void complete(String message, Status status) { // this.status = status; // this.message = message; // observableHelper.fireEvent(new DefaultTaskEvent(Type.completed, this)); // } // // } // // Path: src/org/onesocialweb/gwt/client/task/TaskMonitor.java // public class TaskMonitor implements Observable<TaskEvent> { // // private static TaskMonitor instance; // // private final ObservableHelper<TaskEvent> observableHelper = new ObservableHelper<TaskEvent>(); // // private final List<TaskInfo> tasks = new ArrayList<TaskInfo>(); // // private final TaskHandler handler = new TaskHandler(); // // public static TaskMonitor getInstance() { // if (instance == null) { // instance = new TaskMonitor(); // } // return instance; // } // // @Override // public void registerEventHandler(Observer<TaskEvent> handler) { // observableHelper.registerEventHandler(handler); // } // // @Override // public void unregisterEventHandler(Observer<TaskEvent> handler) { // observableHelper.unregisterEventHandler(handler); // } // // public void addTask(TaskInfo task) { // tasks.add(task); // task.registerEventHandler(handler); // observableHelper.fireEvent(new DefaultTaskEvent(TaskEvent.Type.added, // task)); // } // // public List<TaskInfo> getTasks() { // return Collections.unmodifiableList(tasks); // } // // private class TaskHandler implements Observer<TaskEvent> { // // @Override // public void handleEvent(TaskEvent event) { // if (event.getType().equals(Type.completed)) { // tasks.remove(event.getTask()); // observableHelper.fireEvent(event); // } // } // // } // // // private constructor to maintain singleton // private TaskMonitor() { // // // } // // } // Path: src/org/onesocialweb/gwt/client/ui/widget/ListSelector.java import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.TextBox; import java.util.ArrayList; import java.util.List; import java.util.Set; import org.onesocialweb.gwt.client.task.DefaultTaskInfo; import org.onesocialweb.gwt.client.task.TaskMonitor; import org.onesocialweb.gwt.client.task.TaskInfo.Status; import org.onesocialweb.gwt.service.OswService; import org.onesocialweb.gwt.service.OswServiceFactory; import org.onesocialweb.gwt.service.RequestCallback; import org.onesocialweb.gwt.service.RosterItem; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; addCheckbox(input.getText(), true); // empty the input field input.setText(""); } }); } public void addCheckbox(String list, Boolean value) { final CheckBox checkbox = new CheckBox(list); StyledFlowPanel fix = new StyledFlowPanel("fix"); checkbox.addStyleName("checkbox"); // manage checks and unchecks checkbox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { // is the item is checked? if (event.getValue() == true && !listed.contains(checkbox.getText()) && checkbox.getText()!=null && checkbox.getText().length()!=0) { // set the values listed.add(checkbox.getText()); rosterItem.setGroups(listed); // disable during processing checkbox.setEnabled(false); // show task
final DefaultTaskInfo task = new DefaultTaskInfo(
onesocialweb/osw-web
src/org/onesocialweb/gwt/client/ui/widget/ListSelector.java
// Path: src/org/onesocialweb/gwt/client/task/DefaultTaskInfo.java // public class DefaultTaskInfo implements TaskInfo { // // private final ObservableHelper<TaskEvent> observableHelper = new ObservableHelper<TaskEvent>(); // // private final boolean hasProgress; // // private float progress = 0; // // private String message; // // private Status status = Status.running; // // public DefaultTaskInfo(String message, boolean hasProgress) { // this.message = message; // this.hasProgress = hasProgress; // } // // @Override // public String getMessage() { // return message; // } // // @Override // public float getProgress() { // return progress; // } // // @Override // public Status getStatus() { // return status; // } // // @Override // public boolean hasProgress() { // return hasProgress; // } // // @Override // public void registerEventHandler(Observer<TaskEvent> handler) { // observableHelper.registerEventHandler(handler); // } // // @Override // public void unregisterEventHandler(Observer<TaskEvent> handler) { // observableHelper.unregisterEventHandler(handler); // } // // public void setMessage(String message) { // this.message = message; // observableHelper.fireEvent(new DefaultTaskEvent(Type.updated, this)); // } // // public void setProgress(float progress) { // this.progress = progress; // observableHelper.fireEvent(new DefaultTaskEvent(Type.updated, this)); // } // // public void complete(String message, Status status) { // this.status = status; // this.message = message; // observableHelper.fireEvent(new DefaultTaskEvent(Type.completed, this)); // } // // } // // Path: src/org/onesocialweb/gwt/client/task/TaskMonitor.java // public class TaskMonitor implements Observable<TaskEvent> { // // private static TaskMonitor instance; // // private final ObservableHelper<TaskEvent> observableHelper = new ObservableHelper<TaskEvent>(); // // private final List<TaskInfo> tasks = new ArrayList<TaskInfo>(); // // private final TaskHandler handler = new TaskHandler(); // // public static TaskMonitor getInstance() { // if (instance == null) { // instance = new TaskMonitor(); // } // return instance; // } // // @Override // public void registerEventHandler(Observer<TaskEvent> handler) { // observableHelper.registerEventHandler(handler); // } // // @Override // public void unregisterEventHandler(Observer<TaskEvent> handler) { // observableHelper.unregisterEventHandler(handler); // } // // public void addTask(TaskInfo task) { // tasks.add(task); // task.registerEventHandler(handler); // observableHelper.fireEvent(new DefaultTaskEvent(TaskEvent.Type.added, // task)); // } // // public List<TaskInfo> getTasks() { // return Collections.unmodifiableList(tasks); // } // // private class TaskHandler implements Observer<TaskEvent> { // // @Override // public void handleEvent(TaskEvent event) { // if (event.getType().equals(Type.completed)) { // tasks.remove(event.getTask()); // observableHelper.fireEvent(event); // } // } // // } // // // private constructor to maintain singleton // private TaskMonitor() { // // // } // // }
import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.TextBox; import java.util.ArrayList; import java.util.List; import java.util.Set; import org.onesocialweb.gwt.client.task.DefaultTaskInfo; import org.onesocialweb.gwt.client.task.TaskMonitor; import org.onesocialweb.gwt.client.task.TaskInfo.Status; import org.onesocialweb.gwt.service.OswService; import org.onesocialweb.gwt.service.OswServiceFactory; import org.onesocialweb.gwt.service.RequestCallback; import org.onesocialweb.gwt.service.RosterItem; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler;
input.setText(""); } }); } public void addCheckbox(String list, Boolean value) { final CheckBox checkbox = new CheckBox(list); StyledFlowPanel fix = new StyledFlowPanel("fix"); checkbox.addStyleName("checkbox"); // manage checks and unchecks checkbox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { // is the item is checked? if (event.getValue() == true && !listed.contains(checkbox.getText()) && checkbox.getText()!=null && checkbox.getText().length()!=0) { // set the values listed.add(checkbox.getText()); rosterItem.setGroups(listed); // disable during processing checkbox.setEnabled(false); // show task final DefaultTaskInfo task = new DefaultTaskInfo( "Adding person to the list", false);
// Path: src/org/onesocialweb/gwt/client/task/DefaultTaskInfo.java // public class DefaultTaskInfo implements TaskInfo { // // private final ObservableHelper<TaskEvent> observableHelper = new ObservableHelper<TaskEvent>(); // // private final boolean hasProgress; // // private float progress = 0; // // private String message; // // private Status status = Status.running; // // public DefaultTaskInfo(String message, boolean hasProgress) { // this.message = message; // this.hasProgress = hasProgress; // } // // @Override // public String getMessage() { // return message; // } // // @Override // public float getProgress() { // return progress; // } // // @Override // public Status getStatus() { // return status; // } // // @Override // public boolean hasProgress() { // return hasProgress; // } // // @Override // public void registerEventHandler(Observer<TaskEvent> handler) { // observableHelper.registerEventHandler(handler); // } // // @Override // public void unregisterEventHandler(Observer<TaskEvent> handler) { // observableHelper.unregisterEventHandler(handler); // } // // public void setMessage(String message) { // this.message = message; // observableHelper.fireEvent(new DefaultTaskEvent(Type.updated, this)); // } // // public void setProgress(float progress) { // this.progress = progress; // observableHelper.fireEvent(new DefaultTaskEvent(Type.updated, this)); // } // // public void complete(String message, Status status) { // this.status = status; // this.message = message; // observableHelper.fireEvent(new DefaultTaskEvent(Type.completed, this)); // } // // } // // Path: src/org/onesocialweb/gwt/client/task/TaskMonitor.java // public class TaskMonitor implements Observable<TaskEvent> { // // private static TaskMonitor instance; // // private final ObservableHelper<TaskEvent> observableHelper = new ObservableHelper<TaskEvent>(); // // private final List<TaskInfo> tasks = new ArrayList<TaskInfo>(); // // private final TaskHandler handler = new TaskHandler(); // // public static TaskMonitor getInstance() { // if (instance == null) { // instance = new TaskMonitor(); // } // return instance; // } // // @Override // public void registerEventHandler(Observer<TaskEvent> handler) { // observableHelper.registerEventHandler(handler); // } // // @Override // public void unregisterEventHandler(Observer<TaskEvent> handler) { // observableHelper.unregisterEventHandler(handler); // } // // public void addTask(TaskInfo task) { // tasks.add(task); // task.registerEventHandler(handler); // observableHelper.fireEvent(new DefaultTaskEvent(TaskEvent.Type.added, // task)); // } // // public List<TaskInfo> getTasks() { // return Collections.unmodifiableList(tasks); // } // // private class TaskHandler implements Observer<TaskEvent> { // // @Override // public void handleEvent(TaskEvent event) { // if (event.getType().equals(Type.completed)) { // tasks.remove(event.getTask()); // observableHelper.fireEvent(event); // } // } // // } // // // private constructor to maintain singleton // private TaskMonitor() { // // // } // // } // Path: src/org/onesocialweb/gwt/client/ui/widget/ListSelector.java import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.TextBox; import java.util.ArrayList; import java.util.List; import java.util.Set; import org.onesocialweb.gwt.client.task.DefaultTaskInfo; import org.onesocialweb.gwt.client.task.TaskMonitor; import org.onesocialweb.gwt.client.task.TaskInfo.Status; import org.onesocialweb.gwt.service.OswService; import org.onesocialweb.gwt.service.OswServiceFactory; import org.onesocialweb.gwt.service.RequestCallback; import org.onesocialweb.gwt.service.RosterItem; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; input.setText(""); } }); } public void addCheckbox(String list, Boolean value) { final CheckBox checkbox = new CheckBox(list); StyledFlowPanel fix = new StyledFlowPanel("fix"); checkbox.addStyleName("checkbox"); // manage checks and unchecks checkbox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { // is the item is checked? if (event.getValue() == true && !listed.contains(checkbox.getText()) && checkbox.getText()!=null && checkbox.getText().length()!=0) { // set the values listed.add(checkbox.getText()); rosterItem.setGroups(listed); // disable during processing checkbox.setEnabled(false); // show task final DefaultTaskInfo task = new DefaultTaskInfo( "Adding person to the list", false);
TaskMonitor.getInstance().addTask(task);
zaclimon/xipl
tiflibrary/src/main/java/com/google/android/media/tv/companionlibrary/model/Channel.java
// Path: tiflibrary/src/main/java/com/google/android/media/tv/companionlibrary/utils/CollectionUtils.java // public class CollectionUtils { // /** // * Returns an array with the arrays concatenated together. // * // * @see <a href="http://stackoverflow.com/a/784842/1122089">Stackoverflow answer</a> by <a // * href="http://stackoverflow.com/users/40342/joachim-sauer">Joachim Sauer</a> // */ // public static <T> T[] concatAll(T[] first, T[]... rest) { // int totalLength = first.length; // for (T[] array : rest) { // totalLength += array.length; // } // T[] result = Arrays.copyOf(first, totalLength); // int offset = first.length; // for (T[] array : rest) { // System.arraycopy(array, 0, result, offset, array.length); // offset += array.length; // } // return result; // } // }
import android.content.ContentValues; import android.content.Intent; import android.database.Cursor; import android.media.tv.TvContract; import android.os.Build; import android.text.TextUtils; import com.google.android.media.tv.companionlibrary.utils.CollectionUtils;
} private static String[] getProjection() { String[] baseColumns = new String[] { TvContract.Channels._ID, TvContract.Channels.COLUMN_DESCRIPTION, TvContract.Channels.COLUMN_DISPLAY_NAME, TvContract.Channels.COLUMN_DISPLAY_NUMBER, TvContract.Channels.COLUMN_INPUT_ID, TvContract.Channels.COLUMN_INTERNAL_PROVIDER_DATA, TvContract.Channels.COLUMN_NETWORK_AFFILIATION, TvContract.Channels.COLUMN_ORIGINAL_NETWORK_ID, TvContract.Channels.COLUMN_PACKAGE_NAME, TvContract.Channels.COLUMN_SEARCHABLE, TvContract.Channels.COLUMN_SERVICE_ID, TvContract.Channels.COLUMN_SERVICE_TYPE, TvContract.Channels.COLUMN_TRANSPORT_STREAM_ID, TvContract.Channels.COLUMN_TYPE, TvContract.Channels.COLUMN_VIDEO_FORMAT, }; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { String[] marshmallowColumns = new String[] { TvContract.Channels.COLUMN_APP_LINK_COLOR, TvContract.Channels.COLUMN_APP_LINK_ICON_URI, TvContract.Channels.COLUMN_APP_LINK_INTENT_URI, TvContract.Channels.COLUMN_APP_LINK_POSTER_ART_URI, TvContract.Channels.COLUMN_APP_LINK_TEXT };
// Path: tiflibrary/src/main/java/com/google/android/media/tv/companionlibrary/utils/CollectionUtils.java // public class CollectionUtils { // /** // * Returns an array with the arrays concatenated together. // * // * @see <a href="http://stackoverflow.com/a/784842/1122089">Stackoverflow answer</a> by <a // * href="http://stackoverflow.com/users/40342/joachim-sauer">Joachim Sauer</a> // */ // public static <T> T[] concatAll(T[] first, T[]... rest) { // int totalLength = first.length; // for (T[] array : rest) { // totalLength += array.length; // } // T[] result = Arrays.copyOf(first, totalLength); // int offset = first.length; // for (T[] array : rest) { // System.arraycopy(array, 0, result, offset, array.length); // offset += array.length; // } // return result; // } // } // Path: tiflibrary/src/main/java/com/google/android/media/tv/companionlibrary/model/Channel.java import android.content.ContentValues; import android.content.Intent; import android.database.Cursor; import android.media.tv.TvContract; import android.os.Build; import android.text.TextUtils; import com.google.android.media.tv.companionlibrary.utils.CollectionUtils; } private static String[] getProjection() { String[] baseColumns = new String[] { TvContract.Channels._ID, TvContract.Channels.COLUMN_DESCRIPTION, TvContract.Channels.COLUMN_DISPLAY_NAME, TvContract.Channels.COLUMN_DISPLAY_NUMBER, TvContract.Channels.COLUMN_INPUT_ID, TvContract.Channels.COLUMN_INTERNAL_PROVIDER_DATA, TvContract.Channels.COLUMN_NETWORK_AFFILIATION, TvContract.Channels.COLUMN_ORIGINAL_NETWORK_ID, TvContract.Channels.COLUMN_PACKAGE_NAME, TvContract.Channels.COLUMN_SEARCHABLE, TvContract.Channels.COLUMN_SERVICE_ID, TvContract.Channels.COLUMN_SERVICE_TYPE, TvContract.Channels.COLUMN_TRANSPORT_STREAM_ID, TvContract.Channels.COLUMN_TYPE, TvContract.Channels.COLUMN_VIDEO_FORMAT, }; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { String[] marshmallowColumns = new String[] { TvContract.Channels.COLUMN_APP_LINK_COLOR, TvContract.Channels.COLUMN_APP_LINK_ICON_URI, TvContract.Channels.COLUMN_APP_LINK_INTENT_URI, TvContract.Channels.COLUMN_APP_LINK_POSTER_ART_URI, TvContract.Channels.COLUMN_APP_LINK_TEXT };
return CollectionUtils.concatAll(baseColumns, marshmallowColumns);
zaclimon/xipl
library/src/main/java/com/zaclimon/xipl/ui/settings/ProviderSettingsObjectAdapter.java
// Path: library/src/main/java/com/zaclimon/xipl/ui/components/cardview/CardViewPresenter.java // public class CardViewPresenter extends Presenter { // // private CardViewImageProcessor mCardViewImageProcessor; // // /** // * Default constructor // */ // public CardViewPresenter() { // mCardViewImageProcessor = null; // } // // /** // * Additional constructor if processing an image from an external resource is required // * // * @param cardViewImageProcessor the processor which will be used to retrieve an image. // */ // public CardViewPresenter(CardViewImageProcessor cardViewImageProcessor) { // mCardViewImageProcessor = cardViewImageProcessor; // } // // @Override // public Presenter.ViewHolder onCreateViewHolder(ViewGroup parent) { // ImageCardView imageCardView = new ImageCardView(parent.getContext()); // // int widthPixels = (int) parent.getResources().getDimension(R.dimen.cardview_presenter_width); // int heightPixels = (int) parent.getResources().getDimension(R.dimen.cardview_presenter_height); // // imageCardView.setInfoVisibility(BaseCardView.CARD_REGION_VISIBLE_ALWAYS); // imageCardView.setFocusable(true); // imageCardView.setFocusableInTouchMode(true); // imageCardView.setMainImageDimensions(widthPixels, heightPixels); // return (new ViewHolder(imageCardView)); // } // // @Override // public void onBindViewHolder(ViewHolder viewHolder, Object item) { // final ImageCardView imageCardView = (ImageCardView) viewHolder.view; // Context context = viewHolder.view.getContext(); // // int widthPixels = (int) viewHolder.view.getResources().getDimension(R.dimen.cardview_presenter_width); // int heightPixels = (int) viewHolder.view.getResources().getDimension(R.dimen.cardview_presenter_height); // // if (item instanceof Bundle) { // // We're dealing with a Settings menu value // Bundle settingsBundle = (Bundle) item; // String name = context.getString(settingsBundle.getInt(ProviderSettingsObjectAdapter.BUNDLE_SETTINGS_NAME_ID)); // Drawable drawable = context.getDrawable(settingsBundle.getInt(ProviderSettingsObjectAdapter.BUNDLE_SETTINGS_DRAWABLE_ID)); // imageCardView.setTitleText(name); // imageCardView.setMainImage(drawable); // } else if (item instanceof AvContent) { // // We're dealing with an AvContent item (TvCatchup/VOD) // final AvContent avContent = (AvContent) item; // imageCardView.setTitleText(avContent.getTitle()); // // viewHolder.view.setOnLongClickListener(new View.OnLongClickListener() { // @Override // public boolean onLongClick(View view) { // Toast.makeText(view.getContext(), avContent.getTitle(), Toast.LENGTH_SHORT).show(); // return (true); // } // }); // // if (!TextUtils.isEmpty(avContent.getLogo()) && mCardViewImageProcessor != null) { // mCardViewImageProcessor.loadImage(avContent.getLogo(), widthPixels, heightPixels, imageCardView.getMainImageView()); // } // } // } // // @Override // public void onUnbindViewHolder(ViewHolder viewHolder) { // // } // }
import android.os.Bundle; import androidx.annotation.DrawableRes; import androidx.annotation.StringRes; import androidx.leanback.widget.ArrayObjectAdapter; import com.zaclimon.xipl.ui.components.cardview.CardViewPresenter; import java.util.List;
/* * Copyright 2017 Isaac Pateau * * 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 com.zaclimon.xipl.ui.settings; /** * Class extending {@link ArrayObjectAdapter} which gives a list of current * settings elements. * <p> * It's main view is a {@link CardViewPresenter} * * @author zaclimon * Creation date: 21/06/17 */ public abstract class ProviderSettingsObjectAdapter extends ArrayObjectAdapter { /** * Static variable for identifying the name id. */ public static final String BUNDLE_SETTINGS_NAME_ID = "bundle_name_id"; /** * Static variable for identifying the drawable id. */ public static final String BUNDLE_SETTINGS_DRAWABLE_ID = "bundle_drawable_id"; private final String LOG_TAG = getClass().getSimpleName(); /** * Default constructor. Useful if adding the sections manually */ public ProviderSettingsObjectAdapter() {
// Path: library/src/main/java/com/zaclimon/xipl/ui/components/cardview/CardViewPresenter.java // public class CardViewPresenter extends Presenter { // // private CardViewImageProcessor mCardViewImageProcessor; // // /** // * Default constructor // */ // public CardViewPresenter() { // mCardViewImageProcessor = null; // } // // /** // * Additional constructor if processing an image from an external resource is required // * // * @param cardViewImageProcessor the processor which will be used to retrieve an image. // */ // public CardViewPresenter(CardViewImageProcessor cardViewImageProcessor) { // mCardViewImageProcessor = cardViewImageProcessor; // } // // @Override // public Presenter.ViewHolder onCreateViewHolder(ViewGroup parent) { // ImageCardView imageCardView = new ImageCardView(parent.getContext()); // // int widthPixels = (int) parent.getResources().getDimension(R.dimen.cardview_presenter_width); // int heightPixels = (int) parent.getResources().getDimension(R.dimen.cardview_presenter_height); // // imageCardView.setInfoVisibility(BaseCardView.CARD_REGION_VISIBLE_ALWAYS); // imageCardView.setFocusable(true); // imageCardView.setFocusableInTouchMode(true); // imageCardView.setMainImageDimensions(widthPixels, heightPixels); // return (new ViewHolder(imageCardView)); // } // // @Override // public void onBindViewHolder(ViewHolder viewHolder, Object item) { // final ImageCardView imageCardView = (ImageCardView) viewHolder.view; // Context context = viewHolder.view.getContext(); // // int widthPixels = (int) viewHolder.view.getResources().getDimension(R.dimen.cardview_presenter_width); // int heightPixels = (int) viewHolder.view.getResources().getDimension(R.dimen.cardview_presenter_height); // // if (item instanceof Bundle) { // // We're dealing with a Settings menu value // Bundle settingsBundle = (Bundle) item; // String name = context.getString(settingsBundle.getInt(ProviderSettingsObjectAdapter.BUNDLE_SETTINGS_NAME_ID)); // Drawable drawable = context.getDrawable(settingsBundle.getInt(ProviderSettingsObjectAdapter.BUNDLE_SETTINGS_DRAWABLE_ID)); // imageCardView.setTitleText(name); // imageCardView.setMainImage(drawable); // } else if (item instanceof AvContent) { // // We're dealing with an AvContent item (TvCatchup/VOD) // final AvContent avContent = (AvContent) item; // imageCardView.setTitleText(avContent.getTitle()); // // viewHolder.view.setOnLongClickListener(new View.OnLongClickListener() { // @Override // public boolean onLongClick(View view) { // Toast.makeText(view.getContext(), avContent.getTitle(), Toast.LENGTH_SHORT).show(); // return (true); // } // }); // // if (!TextUtils.isEmpty(avContent.getLogo()) && mCardViewImageProcessor != null) { // mCardViewImageProcessor.loadImage(avContent.getLogo(), widthPixels, heightPixels, imageCardView.getMainImageView()); // } // } // } // // @Override // public void onUnbindViewHolder(ViewHolder viewHolder) { // // } // } // Path: library/src/main/java/com/zaclimon/xipl/ui/settings/ProviderSettingsObjectAdapter.java import android.os.Bundle; import androidx.annotation.DrawableRes; import androidx.annotation.StringRes; import androidx.leanback.widget.ArrayObjectAdapter; import com.zaclimon.xipl.ui.components.cardview.CardViewPresenter; import java.util.List; /* * Copyright 2017 Isaac Pateau * * 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 com.zaclimon.xipl.ui.settings; /** * Class extending {@link ArrayObjectAdapter} which gives a list of current * settings elements. * <p> * It's main view is a {@link CardViewPresenter} * * @author zaclimon * Creation date: 21/06/17 */ public abstract class ProviderSettingsObjectAdapter extends ArrayObjectAdapter { /** * Static variable for identifying the name id. */ public static final String BUNDLE_SETTINGS_NAME_ID = "bundle_name_id"; /** * Static variable for identifying the drawable id. */ public static final String BUNDLE_SETTINGS_DRAWABLE_ID = "bundle_drawable_id"; private final String LOG_TAG = getClass().getSimpleName(); /** * Default constructor. Useful if adding the sections manually */ public ProviderSettingsObjectAdapter() {
super(new CardViewPresenter());
zaclimon/xipl
tiflibrary/src/main/java/com/google/android/media/tv/companionlibrary/model/Program.java
// Path: tiflibrary/src/main/java/com/google/android/media/tv/companionlibrary/utils/CollectionUtils.java // public class CollectionUtils { // /** // * Returns an array with the arrays concatenated together. // * // * @see <a href="http://stackoverflow.com/a/784842/1122089">Stackoverflow answer</a> by <a // * href="http://stackoverflow.com/users/40342/joachim-sauer">Joachim Sauer</a> // */ // public static <T> T[] concatAll(T[] first, T[]... rest) { // int totalLength = first.length; // for (T[] array : rest) { // totalLength += array.length; // } // T[] result = Arrays.copyOf(first, totalLength); // int offset = first.length; // for (T[] array : rest) { // System.arraycopy(array, 0, result, offset, array.length); // offset += array.length; // } // return result; // } // }
import android.content.ContentValues; import android.database.Cursor; import android.media.tv.TvContentRating; import android.media.tv.TvContract; import android.os.Build; import androidx.annotation.NonNull; import android.text.TextUtils; import com.google.android.media.tv.companionlibrary.utils.CollectionUtils; import com.google.android.media.tv.companionlibrary.utils.TvContractUtils; import java.util.Arrays; import java.util.Objects;
TvContract.Programs.COLUMN_TITLE, TvContract.Programs.COLUMN_EPISODE_TITLE, (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) ? TvContract.Programs.COLUMN_SEASON_DISPLAY_NUMBER : TvContract.Programs.COLUMN_SEASON_NUMBER, (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) ? TvContract.Programs.COLUMN_EPISODE_DISPLAY_NUMBER : TvContract.Programs.COLUMN_EPISODE_NUMBER, TvContract.Programs.COLUMN_SHORT_DESCRIPTION, TvContract.Programs.COLUMN_LONG_DESCRIPTION, TvContract.Programs.COLUMN_POSTER_ART_URI, TvContract.Programs.COLUMN_THUMBNAIL_URI, TvContract.Programs.COLUMN_AUDIO_LANGUAGE, TvContract.Programs.COLUMN_BROADCAST_GENRE, TvContract.Programs.COLUMN_CANONICAL_GENRE, TvContract.Programs.COLUMN_CONTENT_RATING, TvContract.Programs.COLUMN_START_TIME_UTC_MILLIS, TvContract.Programs.COLUMN_END_TIME_UTC_MILLIS, TvContract.Programs.COLUMN_VIDEO_WIDTH, TvContract.Programs.COLUMN_VIDEO_HEIGHT, TvContract.Programs.COLUMN_INTERNAL_PROVIDER_DATA }; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { String[] marshmallowColumns = new String[] {TvContract.Programs.COLUMN_SEARCHABLE}; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { String[] nougatColumns = new String[] { TvContract.Programs.COLUMN_SEASON_TITLE, TvContract.Programs.COLUMN_RECORDING_PROHIBITED };
// Path: tiflibrary/src/main/java/com/google/android/media/tv/companionlibrary/utils/CollectionUtils.java // public class CollectionUtils { // /** // * Returns an array with the arrays concatenated together. // * // * @see <a href="http://stackoverflow.com/a/784842/1122089">Stackoverflow answer</a> by <a // * href="http://stackoverflow.com/users/40342/joachim-sauer">Joachim Sauer</a> // */ // public static <T> T[] concatAll(T[] first, T[]... rest) { // int totalLength = first.length; // for (T[] array : rest) { // totalLength += array.length; // } // T[] result = Arrays.copyOf(first, totalLength); // int offset = first.length; // for (T[] array : rest) { // System.arraycopy(array, 0, result, offset, array.length); // offset += array.length; // } // return result; // } // } // Path: tiflibrary/src/main/java/com/google/android/media/tv/companionlibrary/model/Program.java import android.content.ContentValues; import android.database.Cursor; import android.media.tv.TvContentRating; import android.media.tv.TvContract; import android.os.Build; import androidx.annotation.NonNull; import android.text.TextUtils; import com.google.android.media.tv.companionlibrary.utils.CollectionUtils; import com.google.android.media.tv.companionlibrary.utils.TvContractUtils; import java.util.Arrays; import java.util.Objects; TvContract.Programs.COLUMN_TITLE, TvContract.Programs.COLUMN_EPISODE_TITLE, (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) ? TvContract.Programs.COLUMN_SEASON_DISPLAY_NUMBER : TvContract.Programs.COLUMN_SEASON_NUMBER, (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) ? TvContract.Programs.COLUMN_EPISODE_DISPLAY_NUMBER : TvContract.Programs.COLUMN_EPISODE_NUMBER, TvContract.Programs.COLUMN_SHORT_DESCRIPTION, TvContract.Programs.COLUMN_LONG_DESCRIPTION, TvContract.Programs.COLUMN_POSTER_ART_URI, TvContract.Programs.COLUMN_THUMBNAIL_URI, TvContract.Programs.COLUMN_AUDIO_LANGUAGE, TvContract.Programs.COLUMN_BROADCAST_GENRE, TvContract.Programs.COLUMN_CANONICAL_GENRE, TvContract.Programs.COLUMN_CONTENT_RATING, TvContract.Programs.COLUMN_START_TIME_UTC_MILLIS, TvContract.Programs.COLUMN_END_TIME_UTC_MILLIS, TvContract.Programs.COLUMN_VIDEO_WIDTH, TvContract.Programs.COLUMN_VIDEO_HEIGHT, TvContract.Programs.COLUMN_INTERNAL_PROVIDER_DATA }; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { String[] marshmallowColumns = new String[] {TvContract.Programs.COLUMN_SEARCHABLE}; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { String[] nougatColumns = new String[] { TvContract.Programs.COLUMN_SEASON_TITLE, TvContract.Programs.COLUMN_RECORDING_PROHIBITED };
return CollectionUtils.concatAll(baseColumns, marshmallowColumns, nougatColumns);
zaclimon/xipl
library/src/main/java/com/zaclimon/xipl/ui/vod/VodPlaybackActivity.java
// Path: library/src/main/java/com/zaclimon/xipl/util/ActivityUtil.java // public class ActivityUtil { // // /** // * Verifies if the current user interface (UI) mode is for television (Mostly if we're in // * Android TV) // * // * @param activity the activity verifying the UI mode. // * @return true if the application is running in Android TV. // */ // public static boolean isTvMode(Activity activity) { // UiModeManager uiModeManager = (UiModeManager) activity.getSystemService(UI_MODE_SERVICE); // return (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION); // } // // /** // * Converts given density-independent pixels (dp) to pixels // * // * @param dp the number of dp to convert // * @param context the required context to convert the dp // * @return the number of pixel for the given dp. // */ // public static int dpToPixel(int dp, Context context) { // float density = context.getResources().getDisplayMetrics().density; // return ((int) (dp * density + 0.5f)); // } // // }
import android.app.Activity; import android.os.Bundle; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentTransaction; import com.zaclimon.xipl.R; import com.zaclimon.xipl.util.ActivityUtil;
/* * Copyright 2017 Isaac Pateau * * 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 com.zaclimon.xipl.ui.vod; /** * Activity responsible for VOD playback. * * @author zaclimon * Creation date: 11/08/17 */ public abstract class VodPlaybackActivity extends FragmentActivity { public static final int NO_THEME = -1; /** * Defines the theme id to set for this {@link Activity}. Note that the no theme might be set * with {@link #NO_THEME} * * @return the theme resource id or {@link #NO_THEME} if none set. */ protected abstract int getThemeId(); /** * Defines a {@link VodPlaybackFragment} that will be used to playback the given content. * * @return the fragment that will play the given content. */ protected abstract VodPlaybackFragment getVodPlaybackFragment(); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
// Path: library/src/main/java/com/zaclimon/xipl/util/ActivityUtil.java // public class ActivityUtil { // // /** // * Verifies if the current user interface (UI) mode is for television (Mostly if we're in // * Android TV) // * // * @param activity the activity verifying the UI mode. // * @return true if the application is running in Android TV. // */ // public static boolean isTvMode(Activity activity) { // UiModeManager uiModeManager = (UiModeManager) activity.getSystemService(UI_MODE_SERVICE); // return (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION); // } // // /** // * Converts given density-independent pixels (dp) to pixels // * // * @param dp the number of dp to convert // * @param context the required context to convert the dp // * @return the number of pixel for the given dp. // */ // public static int dpToPixel(int dp, Context context) { // float density = context.getResources().getDisplayMetrics().density; // return ((int) (dp * density + 0.5f)); // } // // } // Path: library/src/main/java/com/zaclimon/xipl/ui/vod/VodPlaybackActivity.java import android.app.Activity; import android.os.Bundle; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentTransaction; import com.zaclimon.xipl.R; import com.zaclimon.xipl.util.ActivityUtil; /* * Copyright 2017 Isaac Pateau * * 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 com.zaclimon.xipl.ui.vod; /** * Activity responsible for VOD playback. * * @author zaclimon * Creation date: 11/08/17 */ public abstract class VodPlaybackActivity extends FragmentActivity { public static final int NO_THEME = -1; /** * Defines the theme id to set for this {@link Activity}. Note that the no theme might be set * with {@link #NO_THEME} * * @return the theme resource id or {@link #NO_THEME} if none set. */ protected abstract int getThemeId(); /** * Defines a {@link VodPlaybackFragment} that will be used to playback the given content. * * @return the fragment that will play the given content. */ protected abstract VodPlaybackFragment getVodPlaybackFragment(); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
if (ActivityUtil.isTvMode(this) && getThemeId() != NO_THEME) {
zaclimon/xipl
library/src/main/java/com/zaclimon/xipl/ui/main/ProviderTvFragment.java
// Path: library/src/main/java/com/zaclimon/xipl/ui/search/ProviderSearchActivity.java // public abstract class ProviderSearchActivity extends FragmentActivity { // // /** // * Value to use if there is no custom theme set. // */ // public static final int NO_THEME = -1; // // /** // * Gets a custom {@link SearchSupportFragment} which will be used to get content. // * // * @return the corresponding fragment for searching. // */ // protected abstract SearchSupportFragment getSearchFragment(); // // /** // * Defines the theme id to set for this {@link Activity}. Note that the no default theme might // * be set with {@link #NO_THEME} // * // * @return the theme resource id or {@link #NO_THEME} if none set. // */ // protected abstract int getThemeId(); // // @Override // public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // if (getThemeId() == NO_THEME) { // setTheme(R.style.Theme_Leanback); // } else { // setTheme(getThemeId()); // } // // setContentView(R.layout.activity_search); // FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); // transaction.add(R.id.activity_search_fragment, getSearchFragment()); // transaction.commit(); // } // // @Override // public boolean onSearchRequested() { // startActivity(new Intent(this, this.getClass())); // return (true); // } // // }
import com.zaclimon.xipl.ui.search.ProviderSearchActivity; import java.util.Map; import android.content.Intent; import android.content.res.TypedArray; import android.os.Bundle; import androidx.leanback.app.BrowseSupportFragment; import androidx.leanback.app.RowsSupportFragment; import androidx.leanback.widget.ArrayObjectAdapter; import androidx.leanback.widget.HeaderItem; import androidx.leanback.widget.ListRowPresenter; import androidx.leanback.widget.PageRow; import androidx.leanback.widget.Row; import androidx.fragment.app.Fragment; import android.util.SparseArray; import android.util.TypedValue; import android.view.View;
/* * Copyright 2017 Isaac Pateau * * 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 com.zaclimon.xipl.ui.main; /** * Main fragment used for the Android TV variant of the application * * @author zaclimon * Creation date: 20/06/17 */ public abstract class ProviderTvFragment extends BrowseSupportFragment { private ArrayObjectAdapter mRowsAdapter; private SparseArray<RowsSupportFragment> mFragmentSparseArray; /** * Gets the application name * * @return the application name */ protected abstract String getAppName(); /** * Returns a map containing one or multiple {@link RowsSupportFragment} alongside their respective * header title(s). * * @return the list of RowsFragment mapped by title */ protected abstract Map<String, RowsSupportFragment> getFragmentMap();
// Path: library/src/main/java/com/zaclimon/xipl/ui/search/ProviderSearchActivity.java // public abstract class ProviderSearchActivity extends FragmentActivity { // // /** // * Value to use if there is no custom theme set. // */ // public static final int NO_THEME = -1; // // /** // * Gets a custom {@link SearchSupportFragment} which will be used to get content. // * // * @return the corresponding fragment for searching. // */ // protected abstract SearchSupportFragment getSearchFragment(); // // /** // * Defines the theme id to set for this {@link Activity}. Note that the no default theme might // * be set with {@link #NO_THEME} // * // * @return the theme resource id or {@link #NO_THEME} if none set. // */ // protected abstract int getThemeId(); // // @Override // public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // if (getThemeId() == NO_THEME) { // setTheme(R.style.Theme_Leanback); // } else { // setTheme(getThemeId()); // } // // setContentView(R.layout.activity_search); // FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); // transaction.add(R.id.activity_search_fragment, getSearchFragment()); // transaction.commit(); // } // // @Override // public boolean onSearchRequested() { // startActivity(new Intent(this, this.getClass())); // return (true); // } // // } // Path: library/src/main/java/com/zaclimon/xipl/ui/main/ProviderTvFragment.java import com.zaclimon.xipl.ui.search.ProviderSearchActivity; import java.util.Map; import android.content.Intent; import android.content.res.TypedArray; import android.os.Bundle; import androidx.leanback.app.BrowseSupportFragment; import androidx.leanback.app.RowsSupportFragment; import androidx.leanback.widget.ArrayObjectAdapter; import androidx.leanback.widget.HeaderItem; import androidx.leanback.widget.ListRowPresenter; import androidx.leanback.widget.PageRow; import androidx.leanback.widget.Row; import androidx.fragment.app.Fragment; import android.util.SparseArray; import android.util.TypedValue; import android.view.View; /* * Copyright 2017 Isaac Pateau * * 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 com.zaclimon.xipl.ui.main; /** * Main fragment used for the Android TV variant of the application * * @author zaclimon * Creation date: 20/06/17 */ public abstract class ProviderTvFragment extends BrowseSupportFragment { private ArrayObjectAdapter mRowsAdapter; private SparseArray<RowsSupportFragment> mFragmentSparseArray; /** * Gets the application name * * @return the application name */ protected abstract String getAppName(); /** * Returns a map containing one or multiple {@link RowsSupportFragment} alongside their respective * header title(s). * * @return the list of RowsFragment mapped by title */ protected abstract Map<String, RowsSupportFragment> getFragmentMap();
protected abstract Class<? extends ProviderSearchActivity> getSearchActivity();
zaclimon/xipl
library/src/main/java/com/zaclimon/xipl/util/AvContentUtil.java
// Path: library/src/main/java/com/zaclimon/xipl/Constants.java // public class Constants { // // // M3U file attributes // public static final Pattern ATTRIBUTE_TVG_ID_PATTERN = Pattern.compile("tvg-id.\"(.*?)\"", Pattern.CASE_INSENSITIVE); // public static final Pattern ATTRIBUTE_TVG_LOGO_PATTERN = Pattern.compile("tvg-logo.\"(.*?)\"", Pattern.CASE_INSENSITIVE); // public static final Pattern ATTRIBUTE_TVG_NAME_PATTERN = Pattern.compile("tvg-name.\"(.*?)\"", Pattern.CASE_INSENSITIVE); // public static final Pattern ATTRIBUTE_GROUP_TITLE_PATTERN = Pattern.compile("group-title.\"(.*?)\"", Pattern.CASE_INSENSITIVE); // // // Channel configuration stuff // public static final String EPG_ID_PROVIDER = "epg_id"; // public static final String CHANNEL_GENRES_PROVIDER = "channel_genres"; // public static final String[] CHANNEL_GENRES = new String[]{ // TvContract.Programs.Genres.ANIMAL_WILDLIFE, // TvContract.Programs.Genres.ARTS, // TvContract.Programs.Genres.COMEDY, // TvContract.Programs.Genres.DRAMA, // TvContract.Programs.Genres.EDUCATION, // TvContract.Programs.Genres.ENTERTAINMENT, // TvContract.Programs.Genres.FAMILY_KIDS, // TvContract.Programs.Genres.GAMING, // TvContract.Programs.Genres.LIFE_STYLE, // TvContract.Programs.Genres.MOVIES, // TvContract.Programs.Genres.MUSIC, // TvContract.Programs.Genres.NEWS, // TvContract.Programs.Genres.PREMIER, // TvContract.Programs.Genres.SHOPPING, // TvContract.Programs.Genres.SPORTS, // TvContract.Programs.Genres.TECH_SCIENCE, // TvContract.Programs.Genres.TRAVEL // }; // // private Constants(){} // } // // Path: library/src/main/java/com/zaclimon/xipl/model/AvContent.java // public class AvContent { // // private String mTitle; // private String mLogo; // private String mGroup; // private String mContentLink; // private String mContentCategory; // private int mId; // // public AvContent() {} // // /** // * Base constructor // * // * @param title the title of the content // * @param logo the URL pointing to the related logo of the content // * @param group the group in which a content might belong to // * @param contentCategory the category in which a content might belong to // * @param contentLink the URL pointing to the content itself // */ // public AvContent(String title, String logo, String group, String contentCategory, String contentLink) { // mTitle = title; // mLogo = logo; // mGroup = group; // mContentCategory = contentCategory; // mContentLink = contentLink; // } // // /** // * Constructor for an AvContent having a special identifier. // * // * @param title the title of the content // * @param logo the URL pointing to the related logo of the content // * @param group the category in which a content might belong to // * @param contentCategory the category in which a content might belong to // * @param contentLink the URL pointing to the content itself // * @param id An additional id that can be given to the content // */ // public AvContent(String title, String logo, String group, String contentCategory, String contentLink, int id) { // mTitle = title; // mLogo = logo; // mGroup = group; // mContentCategory = contentCategory; // mContentLink = contentLink; // mId = id; // } // // /** // * Gets the title // * // * @return the title of the content // */ // public String getTitle() { // return (mTitle); // } // // /** // * Gets the logo // * // * @return the logo URL of the content // */ // public String getLogo() { // return (mLogo); // } // // /** // * Gets the category // * // * @return the category of the content // */ // public String getGroup() { // return (mGroup); // } // // /** // * Gets the content category // * // * @return the category in which this content belongs to. // */ // public String getContentCategory() { // return (mContentCategory); // } // // /** // * Gets the link // * // * @return the link to the content // */ // public String getContentLink() { // return (mContentLink); // } // // /** // * Gets the id // * // * @return the id of the content if any // */ // public int getId() { // return (mId); // } // }
import java.util.regex.Matcher; import java.util.regex.Pattern; import android.text.TextUtils; import android.util.Log; import com.zaclimon.xipl.Constants; import com.zaclimon.xipl.model.AvContent; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set;
} return (contents); } /** * Generates all the required lines from a given playlist if that playlist had multiple lines. * * @param playlist the playlist as a list separated by it's lines * @return a list having the required M3U playlist lines. */ private static List<String> generatePlaylistLinesMulti(List<String> playlist) { List<String> contents = new ArrayList<>(); for (String playlistLine : playlist) { if (playlistLine.startsWith("#EXTINF") || playlistLine.startsWith("http://")) { contents.add(playlistLine); } } return (contents); } /** * Creates a {@link AvContent} from a given playlist line. * * @param playlistLine The required playlist line * @return the AvContent from this line */ private static AvContent createAvContent(String playlistLine, String contentLink, String contentCategory) {
// Path: library/src/main/java/com/zaclimon/xipl/Constants.java // public class Constants { // // // M3U file attributes // public static final Pattern ATTRIBUTE_TVG_ID_PATTERN = Pattern.compile("tvg-id.\"(.*?)\"", Pattern.CASE_INSENSITIVE); // public static final Pattern ATTRIBUTE_TVG_LOGO_PATTERN = Pattern.compile("tvg-logo.\"(.*?)\"", Pattern.CASE_INSENSITIVE); // public static final Pattern ATTRIBUTE_TVG_NAME_PATTERN = Pattern.compile("tvg-name.\"(.*?)\"", Pattern.CASE_INSENSITIVE); // public static final Pattern ATTRIBUTE_GROUP_TITLE_PATTERN = Pattern.compile("group-title.\"(.*?)\"", Pattern.CASE_INSENSITIVE); // // // Channel configuration stuff // public static final String EPG_ID_PROVIDER = "epg_id"; // public static final String CHANNEL_GENRES_PROVIDER = "channel_genres"; // public static final String[] CHANNEL_GENRES = new String[]{ // TvContract.Programs.Genres.ANIMAL_WILDLIFE, // TvContract.Programs.Genres.ARTS, // TvContract.Programs.Genres.COMEDY, // TvContract.Programs.Genres.DRAMA, // TvContract.Programs.Genres.EDUCATION, // TvContract.Programs.Genres.ENTERTAINMENT, // TvContract.Programs.Genres.FAMILY_KIDS, // TvContract.Programs.Genres.GAMING, // TvContract.Programs.Genres.LIFE_STYLE, // TvContract.Programs.Genres.MOVIES, // TvContract.Programs.Genres.MUSIC, // TvContract.Programs.Genres.NEWS, // TvContract.Programs.Genres.PREMIER, // TvContract.Programs.Genres.SHOPPING, // TvContract.Programs.Genres.SPORTS, // TvContract.Programs.Genres.TECH_SCIENCE, // TvContract.Programs.Genres.TRAVEL // }; // // private Constants(){} // } // // Path: library/src/main/java/com/zaclimon/xipl/model/AvContent.java // public class AvContent { // // private String mTitle; // private String mLogo; // private String mGroup; // private String mContentLink; // private String mContentCategory; // private int mId; // // public AvContent() {} // // /** // * Base constructor // * // * @param title the title of the content // * @param logo the URL pointing to the related logo of the content // * @param group the group in which a content might belong to // * @param contentCategory the category in which a content might belong to // * @param contentLink the URL pointing to the content itself // */ // public AvContent(String title, String logo, String group, String contentCategory, String contentLink) { // mTitle = title; // mLogo = logo; // mGroup = group; // mContentCategory = contentCategory; // mContentLink = contentLink; // } // // /** // * Constructor for an AvContent having a special identifier. // * // * @param title the title of the content // * @param logo the URL pointing to the related logo of the content // * @param group the category in which a content might belong to // * @param contentCategory the category in which a content might belong to // * @param contentLink the URL pointing to the content itself // * @param id An additional id that can be given to the content // */ // public AvContent(String title, String logo, String group, String contentCategory, String contentLink, int id) { // mTitle = title; // mLogo = logo; // mGroup = group; // mContentCategory = contentCategory; // mContentLink = contentLink; // mId = id; // } // // /** // * Gets the title // * // * @return the title of the content // */ // public String getTitle() { // return (mTitle); // } // // /** // * Gets the logo // * // * @return the logo URL of the content // */ // public String getLogo() { // return (mLogo); // } // // /** // * Gets the category // * // * @return the category of the content // */ // public String getGroup() { // return (mGroup); // } // // /** // * Gets the content category // * // * @return the category in which this content belongs to. // */ // public String getContentCategory() { // return (mContentCategory); // } // // /** // * Gets the link // * // * @return the link to the content // */ // public String getContentLink() { // return (mContentLink); // } // // /** // * Gets the id // * // * @return the id of the content if any // */ // public int getId() { // return (mId); // } // } // Path: library/src/main/java/com/zaclimon/xipl/util/AvContentUtil.java import java.util.regex.Matcher; import java.util.regex.Pattern; import android.text.TextUtils; import android.util.Log; import com.zaclimon.xipl.Constants; import com.zaclimon.xipl.model.AvContent; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; } return (contents); } /** * Generates all the required lines from a given playlist if that playlist had multiple lines. * * @param playlist the playlist as a list separated by it's lines * @return a list having the required M3U playlist lines. */ private static List<String> generatePlaylistLinesMulti(List<String> playlist) { List<String> contents = new ArrayList<>(); for (String playlistLine : playlist) { if (playlistLine.startsWith("#EXTINF") || playlistLine.startsWith("http://")) { contents.add(playlistLine); } } return (contents); } /** * Creates a {@link AvContent} from a given playlist line. * * @param playlistLine The required playlist line * @return the AvContent from this line */ private static AvContent createAvContent(String playlistLine, String contentLink, String contentCategory) {
if (Constants.ATTRIBUTE_TVG_NAME_PATTERN.matcher(playlistLine).find()) {
zaclimon/xipl
library/src/main/java/com/zaclimon/xipl/ui/vod/VodPlaybackFragment.java
// Path: library/src/main/java/com/zaclimon/xipl/properties/VodProperties.java // public interface VodProperties { // // /** // * Determines if a video should fit to the dimensions of the display. // * // * @return true if the video should fit to the display's dimensions. // */ // boolean isVideoFitToScreen(); // // /** // * Determines if an external player should be used for playback instead of the internal one. // * // * @return true if an external player should be used. // */ // boolean isExternalPlayerUsed(); // // }
import android.content.Intent; import android.net.Uri; import android.os.Build; import android.os.Bundle; import androidx.leanback.app.ErrorSupportFragment; import androidx.leanback.app.VideoSupportFragment; import androidx.leanback.app.VideoSupportFragmentGlueHost; import androidx.leanback.media.PlaybackTransportControlGlue; import androidx.fragment.app.FragmentTransaction; import android.util.DisplayMetrics; import com.google.android.exoplayer2.DefaultLoadControl; import com.google.android.exoplayer2.DefaultRenderersFactory; import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlayerFactory; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.ext.leanback.LeanbackPlayerAdapter; import com.google.android.exoplayer2.source.ExtractorMediaSource; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; import com.google.android.exoplayer2.util.Util; import com.zaclimon.xipl.R; import com.zaclimon.xipl.properties.VodProperties;
/* * Copyright 2017 Isaac Pateau * * 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 com.zaclimon.xipl.ui.vod; /** * Fragment responsible for a provider's VOD content playback * * @author zaclimon * Creation date: 11/08/17 */ public abstract class VodPlaybackFragment extends VideoSupportFragment { PlaybackTransportControlGlue<LeanbackPlayerAdapter> mPlayerGlue; SimpleExoPlayer mSimpleExoPlayer; /** * Retrieves the properties for a given VOD content * * @return the properties for a given content */
// Path: library/src/main/java/com/zaclimon/xipl/properties/VodProperties.java // public interface VodProperties { // // /** // * Determines if a video should fit to the dimensions of the display. // * // * @return true if the video should fit to the display's dimensions. // */ // boolean isVideoFitToScreen(); // // /** // * Determines if an external player should be used for playback instead of the internal one. // * // * @return true if an external player should be used. // */ // boolean isExternalPlayerUsed(); // // } // Path: library/src/main/java/com/zaclimon/xipl/ui/vod/VodPlaybackFragment.java import android.content.Intent; import android.net.Uri; import android.os.Build; import android.os.Bundle; import androidx.leanback.app.ErrorSupportFragment; import androidx.leanback.app.VideoSupportFragment; import androidx.leanback.app.VideoSupportFragmentGlueHost; import androidx.leanback.media.PlaybackTransportControlGlue; import androidx.fragment.app.FragmentTransaction; import android.util.DisplayMetrics; import com.google.android.exoplayer2.DefaultLoadControl; import com.google.android.exoplayer2.DefaultRenderersFactory; import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlayerFactory; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.ext.leanback.LeanbackPlayerAdapter; import com.google.android.exoplayer2.source.ExtractorMediaSource; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; import com.google.android.exoplayer2.util.Util; import com.zaclimon.xipl.R; import com.zaclimon.xipl.properties.VodProperties; /* * Copyright 2017 Isaac Pateau * * 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 com.zaclimon.xipl.ui.vod; /** * Fragment responsible for a provider's VOD content playback * * @author zaclimon * Creation date: 11/08/17 */ public abstract class VodPlaybackFragment extends VideoSupportFragment { PlaybackTransportControlGlue<LeanbackPlayerAdapter> mPlayerGlue; SimpleExoPlayer mSimpleExoPlayer; /** * Retrieves the properties for a given VOD content * * @return the properties for a given content */
protected abstract VodProperties getVodProperties();
TangXiaoLv/Surgeon
surgeon-core/src/main/java/com/surgeon/weaving/core/ReplaceAbleAspect.java
// Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/Continue.java // public interface Continue { // }
import com.surgeon.weaving.annotations.ReplaceAble; import com.surgeon.weaving.core.interfaces.Continue; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.After; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.reflect.MethodSignature; import static com.surgeon.weaving.core.ASPConstant.AFTER; import static com.surgeon.weaving.core.ASPConstant.BEFORE; import static com.surgeon.weaving.core.ASPConstant.EMPTY;
package com.surgeon.weaving.core; /** * Target interceptor. * * Singleton */ @Aspect public class ReplaceAbleAspect { @Pointcut("within(@com.surgeon.weaving.annotations.ReplaceAble *)") public void withinAnnotatedClass() { } @Pointcut("execution(!synthetic * *(..)) && withinAnnotatedClass()") public void methodInsideAnnotatedType() { } //any function with ReplaceAble @Pointcut("execution(@com.surgeon.weaving.annotations.ReplaceAble * *(..)) || methodInsideAnnotatedType()") public void method() { } @Around("method()") public Object replacedIfNeeded(ProceedingJoinPoint jPoint) throws Throwable { String[] pair = parseNamespaceAndMethodName(jPoint); String namespace = pair[0]; String function = pair[1]; //invoke before function MasterFinder.getInstance().findAndInvoke(namespace, BEFORE, function, jPoint.getThis(), jPoint.getArgs()); //invoke function Object result = MasterFinder.getInstance().findAndInvoke(namespace, EMPTY, function, new TargetHandle(jPoint), jPoint.getArgs());
// Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/Continue.java // public interface Continue { // } // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/ReplaceAbleAspect.java import com.surgeon.weaving.annotations.ReplaceAble; import com.surgeon.weaving.core.interfaces.Continue; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.After; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.reflect.MethodSignature; import static com.surgeon.weaving.core.ASPConstant.AFTER; import static com.surgeon.weaving.core.ASPConstant.BEFORE; import static com.surgeon.weaving.core.ASPConstant.EMPTY; package com.surgeon.weaving.core; /** * Target interceptor. * * Singleton */ @Aspect public class ReplaceAbleAspect { @Pointcut("within(@com.surgeon.weaving.annotations.ReplaceAble *)") public void withinAnnotatedClass() { } @Pointcut("execution(!synthetic * *(..)) && withinAnnotatedClass()") public void methodInsideAnnotatedType() { } //any function with ReplaceAble @Pointcut("execution(@com.surgeon.weaving.annotations.ReplaceAble * *(..)) || methodInsideAnnotatedType()") public void method() { } @Around("method()") public Object replacedIfNeeded(ProceedingJoinPoint jPoint) throws Throwable { String[] pair = parseNamespaceAndMethodName(jPoint); String namespace = pair[0]; String function = pair[1]; //invoke before function MasterFinder.getInstance().findAndInvoke(namespace, BEFORE, function, jPoint.getThis(), jPoint.getArgs()); //invoke function Object result = MasterFinder.getInstance().findAndInvoke(namespace, EMPTY, function, new TargetHandle(jPoint), jPoint.getArgs());
return result != Continue.class ? result : jPoint.proceed();
TangXiaoLv/Surgeon
surgeon-core/src/main/java/com/surgeon/weaving/core/MasterFinder.java
// Path: surgeon-core/src/main/java/com/surgeon/weaving/core/exceptions/SurgeonException.java // public class SurgeonException extends Exception { // // public SurgeonException() { // super(); // } // // public SurgeonException(String message) { // super(message); // } // // public SurgeonException(String message, Throwable cause) { // super(message, cause); // } // // public SurgeonException(Throwable cause) { // super(cause); // } // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/Continue.java // public interface Continue { // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/IMaster.java // public interface IMaster { // /** // * @param function The key of SurgeonMethod // */ // SurgeonMethod find(String function); // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/ISurgeon.java // public interface ISurgeon { // // /** // * Control current object to singleton. // */ // boolean singleton(); // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/Replacer.java // public interface Replacer<T> { // /** // * Called before original function called. // * // * @param params The original function input params. // */ // void before(Object[] params); // // /** // * Replace original function. // * // * @param params The original function input params. // * @return new return result. // */ // T replace(Object[] params) throws Throwable; // // /** // * Called after original function called. // * // * @param params The original function input params. // */ // void after(Object[] params); // }
import com.surgeon.weaving.core.exceptions.SurgeonException; import com.surgeon.weaving.core.interfaces.Continue; import com.surgeon.weaving.core.interfaces.IMaster; import com.surgeon.weaving.core.interfaces.ISurgeon; import com.surgeon.weaving.core.interfaces.Replacer; import java.lang.reflect.InvocationTargetException; import static android.text.TextUtils.isEmpty; import static com.surgeon.weaving.core.ASPConstant.AFTER; import static com.surgeon.weaving.core.ASPConstant.BEFORE;
package com.surgeon.weaving.core; /** * The master {@link ReplaceAbleAspect},Used for find replace function. */ class MasterFinder { private static final String PREFIX = "com.surgeon.weaving.masters.Master_"; private MasterFinder() { } private static class Lazy { static MasterFinder sMasterFinder = new MasterFinder(); } static MasterFinder getInstance() { return Lazy.sMasterFinder; } /** * Create {@link IMaster} and find replace function. * * @param namespace The namespace of function * @param prefix {@link ASPConstant#BEFORE},{@link ASPConstant#EMPTY}, {@link * ASPConstant#AFTER} * @param function The name of function. * @param target Original instance or {@link TargetHandle} * @param args Input params * @return new result */ Object findAndInvoke(String namespace, String prefix, String function, Object target, Object[] args) throws Throwable {
// Path: surgeon-core/src/main/java/com/surgeon/weaving/core/exceptions/SurgeonException.java // public class SurgeonException extends Exception { // // public SurgeonException() { // super(); // } // // public SurgeonException(String message) { // super(message); // } // // public SurgeonException(String message, Throwable cause) { // super(message, cause); // } // // public SurgeonException(Throwable cause) { // super(cause); // } // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/Continue.java // public interface Continue { // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/IMaster.java // public interface IMaster { // /** // * @param function The key of SurgeonMethod // */ // SurgeonMethod find(String function); // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/ISurgeon.java // public interface ISurgeon { // // /** // * Control current object to singleton. // */ // boolean singleton(); // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/Replacer.java // public interface Replacer<T> { // /** // * Called before original function called. // * // * @param params The original function input params. // */ // void before(Object[] params); // // /** // * Replace original function. // * // * @param params The original function input params. // * @return new return result. // */ // T replace(Object[] params) throws Throwable; // // /** // * Called after original function called. // * // * @param params The original function input params. // */ // void after(Object[] params); // } // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/MasterFinder.java import com.surgeon.weaving.core.exceptions.SurgeonException; import com.surgeon.weaving.core.interfaces.Continue; import com.surgeon.weaving.core.interfaces.IMaster; import com.surgeon.weaving.core.interfaces.ISurgeon; import com.surgeon.weaving.core.interfaces.Replacer; import java.lang.reflect.InvocationTargetException; import static android.text.TextUtils.isEmpty; import static com.surgeon.weaving.core.ASPConstant.AFTER; import static com.surgeon.weaving.core.ASPConstant.BEFORE; package com.surgeon.weaving.core; /** * The master {@link ReplaceAbleAspect},Used for find replace function. */ class MasterFinder { private static final String PREFIX = "com.surgeon.weaving.masters.Master_"; private MasterFinder() { } private static class Lazy { static MasterFinder sMasterFinder = new MasterFinder(); } static MasterFinder getInstance() { return Lazy.sMasterFinder; } /** * Create {@link IMaster} and find replace function. * * @param namespace The namespace of function * @param prefix {@link ASPConstant#BEFORE},{@link ASPConstant#EMPTY}, {@link * ASPConstant#AFTER} * @param function The name of function. * @param target Original instance or {@link TargetHandle} * @param args Input params * @return new result */ Object findAndInvoke(String namespace, String prefix, String function, Object target, Object[] args) throws Throwable {
if (isEmpty(namespace) || isEmpty(function)) return Continue.class;
TangXiaoLv/Surgeon
surgeon-core/src/main/java/com/surgeon/weaving/core/MasterFinder.java
// Path: surgeon-core/src/main/java/com/surgeon/weaving/core/exceptions/SurgeonException.java // public class SurgeonException extends Exception { // // public SurgeonException() { // super(); // } // // public SurgeonException(String message) { // super(message); // } // // public SurgeonException(String message, Throwable cause) { // super(message, cause); // } // // public SurgeonException(Throwable cause) { // super(cause); // } // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/Continue.java // public interface Continue { // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/IMaster.java // public interface IMaster { // /** // * @param function The key of SurgeonMethod // */ // SurgeonMethod find(String function); // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/ISurgeon.java // public interface ISurgeon { // // /** // * Control current object to singleton. // */ // boolean singleton(); // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/Replacer.java // public interface Replacer<T> { // /** // * Called before original function called. // * // * @param params The original function input params. // */ // void before(Object[] params); // // /** // * Replace original function. // * // * @param params The original function input params. // * @return new return result. // */ // T replace(Object[] params) throws Throwable; // // /** // * Called after original function called. // * // * @param params The original function input params. // */ // void after(Object[] params); // }
import com.surgeon.weaving.core.exceptions.SurgeonException; import com.surgeon.weaving.core.interfaces.Continue; import com.surgeon.weaving.core.interfaces.IMaster; import com.surgeon.weaving.core.interfaces.ISurgeon; import com.surgeon.weaving.core.interfaces.Replacer; import java.lang.reflect.InvocationTargetException; import static android.text.TextUtils.isEmpty; import static com.surgeon.weaving.core.ASPConstant.AFTER; import static com.surgeon.weaving.core.ASPConstant.BEFORE;
package com.surgeon.weaving.core; /** * The master {@link ReplaceAbleAspect},Used for find replace function. */ class MasterFinder { private static final String PREFIX = "com.surgeon.weaving.masters.Master_"; private MasterFinder() { } private static class Lazy { static MasterFinder sMasterFinder = new MasterFinder(); } static MasterFinder getInstance() { return Lazy.sMasterFinder; } /** * Create {@link IMaster} and find replace function. * * @param namespace The namespace of function * @param prefix {@link ASPConstant#BEFORE},{@link ASPConstant#EMPTY}, {@link * ASPConstant#AFTER} * @param function The name of function. * @param target Original instance or {@link TargetHandle} * @param args Input params * @return new result */ Object findAndInvoke(String namespace, String prefix, String function, Object target, Object[] args) throws Throwable { if (isEmpty(namespace) || isEmpty(function)) return Continue.class; try { String masterPath = PREFIX + namespace.replace(".", "_");
// Path: surgeon-core/src/main/java/com/surgeon/weaving/core/exceptions/SurgeonException.java // public class SurgeonException extends Exception { // // public SurgeonException() { // super(); // } // // public SurgeonException(String message) { // super(message); // } // // public SurgeonException(String message, Throwable cause) { // super(message, cause); // } // // public SurgeonException(Throwable cause) { // super(cause); // } // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/Continue.java // public interface Continue { // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/IMaster.java // public interface IMaster { // /** // * @param function The key of SurgeonMethod // */ // SurgeonMethod find(String function); // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/ISurgeon.java // public interface ISurgeon { // // /** // * Control current object to singleton. // */ // boolean singleton(); // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/Replacer.java // public interface Replacer<T> { // /** // * Called before original function called. // * // * @param params The original function input params. // */ // void before(Object[] params); // // /** // * Replace original function. // * // * @param params The original function input params. // * @return new return result. // */ // T replace(Object[] params) throws Throwable; // // /** // * Called after original function called. // * // * @param params The original function input params. // */ // void after(Object[] params); // } // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/MasterFinder.java import com.surgeon.weaving.core.exceptions.SurgeonException; import com.surgeon.weaving.core.interfaces.Continue; import com.surgeon.weaving.core.interfaces.IMaster; import com.surgeon.weaving.core.interfaces.ISurgeon; import com.surgeon.weaving.core.interfaces.Replacer; import java.lang.reflect.InvocationTargetException; import static android.text.TextUtils.isEmpty; import static com.surgeon.weaving.core.ASPConstant.AFTER; import static com.surgeon.weaving.core.ASPConstant.BEFORE; package com.surgeon.weaving.core; /** * The master {@link ReplaceAbleAspect},Used for find replace function. */ class MasterFinder { private static final String PREFIX = "com.surgeon.weaving.masters.Master_"; private MasterFinder() { } private static class Lazy { static MasterFinder sMasterFinder = new MasterFinder(); } static MasterFinder getInstance() { return Lazy.sMasterFinder; } /** * Create {@link IMaster} and find replace function. * * @param namespace The namespace of function * @param prefix {@link ASPConstant#BEFORE},{@link ASPConstant#EMPTY}, {@link * ASPConstant#AFTER} * @param function The name of function. * @param target Original instance or {@link TargetHandle} * @param args Input params * @return new result */ Object findAndInvoke(String namespace, String prefix, String function, Object target, Object[] args) throws Throwable { if (isEmpty(namespace) || isEmpty(function)) return Continue.class; try { String masterPath = PREFIX + namespace.replace(".", "_");
IMaster master = InnerCache.getInstance().getMaster(masterPath);
TangXiaoLv/Surgeon
surgeon-core/src/main/java/com/surgeon/weaving/core/MasterFinder.java
// Path: surgeon-core/src/main/java/com/surgeon/weaving/core/exceptions/SurgeonException.java // public class SurgeonException extends Exception { // // public SurgeonException() { // super(); // } // // public SurgeonException(String message) { // super(message); // } // // public SurgeonException(String message, Throwable cause) { // super(message, cause); // } // // public SurgeonException(Throwable cause) { // super(cause); // } // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/Continue.java // public interface Continue { // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/IMaster.java // public interface IMaster { // /** // * @param function The key of SurgeonMethod // */ // SurgeonMethod find(String function); // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/ISurgeon.java // public interface ISurgeon { // // /** // * Control current object to singleton. // */ // boolean singleton(); // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/Replacer.java // public interface Replacer<T> { // /** // * Called before original function called. // * // * @param params The original function input params. // */ // void before(Object[] params); // // /** // * Replace original function. // * // * @param params The original function input params. // * @return new return result. // */ // T replace(Object[] params) throws Throwable; // // /** // * Called after original function called. // * // * @param params The original function input params. // */ // void after(Object[] params); // }
import com.surgeon.weaving.core.exceptions.SurgeonException; import com.surgeon.weaving.core.interfaces.Continue; import com.surgeon.weaving.core.interfaces.IMaster; import com.surgeon.weaving.core.interfaces.ISurgeon; import com.surgeon.weaving.core.interfaces.Replacer; import java.lang.reflect.InvocationTargetException; import static android.text.TextUtils.isEmpty; import static com.surgeon.weaving.core.ASPConstant.AFTER; import static com.surgeon.weaving.core.ASPConstant.BEFORE;
Object target, Object[] args) throws Throwable { if (isEmpty(namespace) || isEmpty(function)) return Continue.class; try { String masterPath = PREFIX + namespace.replace(".", "_"); IMaster master = InnerCache.getInstance().getMaster(masterPath); if (master == null) { Class<?> clazz = Class.forName(masterPath); master = (IMaster) clazz.newInstance(); InnerCache.getInstance().putMaster(masterPath, master); } //copy args Object[] copyOfArgs = new Object[args.length + 1]; System.arraycopy(args, 0, copyOfArgs, 1, args.length); copyOfArgs[0] = target; //runtime repalce Object wrapper; String runtimeKey = namespace + "." + function; if (AFTER.equals(prefix)) { wrapper = InnerCache.getInstance().popReplaceWapper(runtimeKey); } else { wrapper = InnerCache.getInstance().getReplaceWapper(runtimeKey); } if (wrapper != Continue.class) { ReplaceWapper resultWapper = (ReplaceWapper) wrapper; if (!resultWapper.isReplacer()) return resultWapper.getResult();
// Path: surgeon-core/src/main/java/com/surgeon/weaving/core/exceptions/SurgeonException.java // public class SurgeonException extends Exception { // // public SurgeonException() { // super(); // } // // public SurgeonException(String message) { // super(message); // } // // public SurgeonException(String message, Throwable cause) { // super(message, cause); // } // // public SurgeonException(Throwable cause) { // super(cause); // } // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/Continue.java // public interface Continue { // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/IMaster.java // public interface IMaster { // /** // * @param function The key of SurgeonMethod // */ // SurgeonMethod find(String function); // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/ISurgeon.java // public interface ISurgeon { // // /** // * Control current object to singleton. // */ // boolean singleton(); // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/Replacer.java // public interface Replacer<T> { // /** // * Called before original function called. // * // * @param params The original function input params. // */ // void before(Object[] params); // // /** // * Replace original function. // * // * @param params The original function input params. // * @return new return result. // */ // T replace(Object[] params) throws Throwable; // // /** // * Called after original function called. // * // * @param params The original function input params. // */ // void after(Object[] params); // } // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/MasterFinder.java import com.surgeon.weaving.core.exceptions.SurgeonException; import com.surgeon.weaving.core.interfaces.Continue; import com.surgeon.weaving.core.interfaces.IMaster; import com.surgeon.weaving.core.interfaces.ISurgeon; import com.surgeon.weaving.core.interfaces.Replacer; import java.lang.reflect.InvocationTargetException; import static android.text.TextUtils.isEmpty; import static com.surgeon.weaving.core.ASPConstant.AFTER; import static com.surgeon.weaving.core.ASPConstant.BEFORE; Object target, Object[] args) throws Throwable { if (isEmpty(namespace) || isEmpty(function)) return Continue.class; try { String masterPath = PREFIX + namespace.replace(".", "_"); IMaster master = InnerCache.getInstance().getMaster(masterPath); if (master == null) { Class<?> clazz = Class.forName(masterPath); master = (IMaster) clazz.newInstance(); InnerCache.getInstance().putMaster(masterPath, master); } //copy args Object[] copyOfArgs = new Object[args.length + 1]; System.arraycopy(args, 0, copyOfArgs, 1, args.length); copyOfArgs[0] = target; //runtime repalce Object wrapper; String runtimeKey = namespace + "." + function; if (AFTER.equals(prefix)) { wrapper = InnerCache.getInstance().popReplaceWapper(runtimeKey); } else { wrapper = InnerCache.getInstance().getReplaceWapper(runtimeKey); } if (wrapper != Continue.class) { ReplaceWapper resultWapper = (ReplaceWapper) wrapper; if (!resultWapper.isReplacer()) return resultWapper.getResult();
Replacer replacer = (Replacer) resultWapper.getResult();
TangXiaoLv/Surgeon
surgeon-core/src/main/java/com/surgeon/weaving/core/MasterFinder.java
// Path: surgeon-core/src/main/java/com/surgeon/weaving/core/exceptions/SurgeonException.java // public class SurgeonException extends Exception { // // public SurgeonException() { // super(); // } // // public SurgeonException(String message) { // super(message); // } // // public SurgeonException(String message, Throwable cause) { // super(message, cause); // } // // public SurgeonException(Throwable cause) { // super(cause); // } // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/Continue.java // public interface Continue { // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/IMaster.java // public interface IMaster { // /** // * @param function The key of SurgeonMethod // */ // SurgeonMethod find(String function); // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/ISurgeon.java // public interface ISurgeon { // // /** // * Control current object to singleton. // */ // boolean singleton(); // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/Replacer.java // public interface Replacer<T> { // /** // * Called before original function called. // * // * @param params The original function input params. // */ // void before(Object[] params); // // /** // * Replace original function. // * // * @param params The original function input params. // * @return new return result. // */ // T replace(Object[] params) throws Throwable; // // /** // * Called after original function called. // * // * @param params The original function input params. // */ // void after(Object[] params); // }
import com.surgeon.weaving.core.exceptions.SurgeonException; import com.surgeon.weaving.core.interfaces.Continue; import com.surgeon.weaving.core.interfaces.IMaster; import com.surgeon.weaving.core.interfaces.ISurgeon; import com.surgeon.weaving.core.interfaces.Replacer; import java.lang.reflect.InvocationTargetException; import static android.text.TextUtils.isEmpty; import static com.surgeon.weaving.core.ASPConstant.AFTER; import static com.surgeon.weaving.core.ASPConstant.BEFORE;
String runtimeKey = namespace + "." + function; if (AFTER.equals(prefix)) { wrapper = InnerCache.getInstance().popReplaceWapper(runtimeKey); } else { wrapper = InnerCache.getInstance().getReplaceWapper(runtimeKey); } if (wrapper != Continue.class) { ReplaceWapper resultWapper = (ReplaceWapper) wrapper; if (!resultWapper.isReplacer()) return resultWapper.getResult(); Replacer replacer = (Replacer) resultWapper.getResult(); if (BEFORE.equals(prefix)) { replacer.before(copyOfArgs); } else if (AFTER.equals(prefix)) { replacer.after(copyOfArgs); } else { return replacer.replace(copyOfArgs); } return null; } //static repalce SurgeonMethod replaceMethod = master.find(prefix + function); if (replaceMethod != null) { return invoke(replaceMethod, copyOfArgs); } } catch (ClassNotFoundException ignored) { //ignored } catch (Exception e) {
// Path: surgeon-core/src/main/java/com/surgeon/weaving/core/exceptions/SurgeonException.java // public class SurgeonException extends Exception { // // public SurgeonException() { // super(); // } // // public SurgeonException(String message) { // super(message); // } // // public SurgeonException(String message, Throwable cause) { // super(message, cause); // } // // public SurgeonException(Throwable cause) { // super(cause); // } // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/Continue.java // public interface Continue { // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/IMaster.java // public interface IMaster { // /** // * @param function The key of SurgeonMethod // */ // SurgeonMethod find(String function); // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/ISurgeon.java // public interface ISurgeon { // // /** // * Control current object to singleton. // */ // boolean singleton(); // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/Replacer.java // public interface Replacer<T> { // /** // * Called before original function called. // * // * @param params The original function input params. // */ // void before(Object[] params); // // /** // * Replace original function. // * // * @param params The original function input params. // * @return new return result. // */ // T replace(Object[] params) throws Throwable; // // /** // * Called after original function called. // * // * @param params The original function input params. // */ // void after(Object[] params); // } // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/MasterFinder.java import com.surgeon.weaving.core.exceptions.SurgeonException; import com.surgeon.weaving.core.interfaces.Continue; import com.surgeon.weaving.core.interfaces.IMaster; import com.surgeon.weaving.core.interfaces.ISurgeon; import com.surgeon.weaving.core.interfaces.Replacer; import java.lang.reflect.InvocationTargetException; import static android.text.TextUtils.isEmpty; import static com.surgeon.weaving.core.ASPConstant.AFTER; import static com.surgeon.weaving.core.ASPConstant.BEFORE; String runtimeKey = namespace + "." + function; if (AFTER.equals(prefix)) { wrapper = InnerCache.getInstance().popReplaceWapper(runtimeKey); } else { wrapper = InnerCache.getInstance().getReplaceWapper(runtimeKey); } if (wrapper != Continue.class) { ReplaceWapper resultWapper = (ReplaceWapper) wrapper; if (!resultWapper.isReplacer()) return resultWapper.getResult(); Replacer replacer = (Replacer) resultWapper.getResult(); if (BEFORE.equals(prefix)) { replacer.before(copyOfArgs); } else if (AFTER.equals(prefix)) { replacer.after(copyOfArgs); } else { return replacer.replace(copyOfArgs); } return null; } //static repalce SurgeonMethod replaceMethod = master.find(prefix + function); if (replaceMethod != null) { return invoke(replaceMethod, copyOfArgs); } } catch (ClassNotFoundException ignored) { //ignored } catch (Exception e) {
throw new SurgeonException(e);
TangXiaoLv/Surgeon
surgeon-core/src/main/java/com/surgeon/weaving/core/MasterFinder.java
// Path: surgeon-core/src/main/java/com/surgeon/weaving/core/exceptions/SurgeonException.java // public class SurgeonException extends Exception { // // public SurgeonException() { // super(); // } // // public SurgeonException(String message) { // super(message); // } // // public SurgeonException(String message, Throwable cause) { // super(message, cause); // } // // public SurgeonException(Throwable cause) { // super(cause); // } // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/Continue.java // public interface Continue { // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/IMaster.java // public interface IMaster { // /** // * @param function The key of SurgeonMethod // */ // SurgeonMethod find(String function); // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/ISurgeon.java // public interface ISurgeon { // // /** // * Control current object to singleton. // */ // boolean singleton(); // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/Replacer.java // public interface Replacer<T> { // /** // * Called before original function called. // * // * @param params The original function input params. // */ // void before(Object[] params); // // /** // * Replace original function. // * // * @param params The original function input params. // * @return new return result. // */ // T replace(Object[] params) throws Throwable; // // /** // * Called after original function called. // * // * @param params The original function input params. // */ // void after(Object[] params); // }
import com.surgeon.weaving.core.exceptions.SurgeonException; import com.surgeon.weaving.core.interfaces.Continue; import com.surgeon.weaving.core.interfaces.IMaster; import com.surgeon.weaving.core.interfaces.ISurgeon; import com.surgeon.weaving.core.interfaces.Replacer; import java.lang.reflect.InvocationTargetException; import static android.text.TextUtils.isEmpty; import static com.surgeon.weaving.core.ASPConstant.AFTER; import static com.surgeon.weaving.core.ASPConstant.BEFORE;
} else if (AFTER.equals(prefix)) { replacer.after(copyOfArgs); } else { return replacer.replace(copyOfArgs); } return null; } //static repalce SurgeonMethod replaceMethod = master.find(prefix + function); if (replaceMethod != null) { return invoke(replaceMethod, copyOfArgs); } } catch (ClassNotFoundException ignored) { //ignored } catch (Exception e) { throw new SurgeonException(e); } return Continue.class; } private Object invoke(SurgeonMethod method, Object[] args) throws IllegalAccessException, InstantiationException, InvocationTargetException { Object ownerInstance = InnerCache.getInstance().getMethodOwner(method.getOwner()); //cache owner instance if (ownerInstance == null) { Class clazz = method.getOwner(); ownerInstance = clazz.newInstance();
// Path: surgeon-core/src/main/java/com/surgeon/weaving/core/exceptions/SurgeonException.java // public class SurgeonException extends Exception { // // public SurgeonException() { // super(); // } // // public SurgeonException(String message) { // super(message); // } // // public SurgeonException(String message, Throwable cause) { // super(message, cause); // } // // public SurgeonException(Throwable cause) { // super(cause); // } // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/Continue.java // public interface Continue { // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/IMaster.java // public interface IMaster { // /** // * @param function The key of SurgeonMethod // */ // SurgeonMethod find(String function); // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/ISurgeon.java // public interface ISurgeon { // // /** // * Control current object to singleton. // */ // boolean singleton(); // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/Replacer.java // public interface Replacer<T> { // /** // * Called before original function called. // * // * @param params The original function input params. // */ // void before(Object[] params); // // /** // * Replace original function. // * // * @param params The original function input params. // * @return new return result. // */ // T replace(Object[] params) throws Throwable; // // /** // * Called after original function called. // * // * @param params The original function input params. // */ // void after(Object[] params); // } // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/MasterFinder.java import com.surgeon.weaving.core.exceptions.SurgeonException; import com.surgeon.weaving.core.interfaces.Continue; import com.surgeon.weaving.core.interfaces.IMaster; import com.surgeon.weaving.core.interfaces.ISurgeon; import com.surgeon.weaving.core.interfaces.Replacer; import java.lang.reflect.InvocationTargetException; import static android.text.TextUtils.isEmpty; import static com.surgeon.weaving.core.ASPConstant.AFTER; import static com.surgeon.weaving.core.ASPConstant.BEFORE; } else if (AFTER.equals(prefix)) { replacer.after(copyOfArgs); } else { return replacer.replace(copyOfArgs); } return null; } //static repalce SurgeonMethod replaceMethod = master.find(prefix + function); if (replaceMethod != null) { return invoke(replaceMethod, copyOfArgs); } } catch (ClassNotFoundException ignored) { //ignored } catch (Exception e) { throw new SurgeonException(e); } return Continue.class; } private Object invoke(SurgeonMethod method, Object[] args) throws IllegalAccessException, InstantiationException, InvocationTargetException { Object ownerInstance = InnerCache.getInstance().getMethodOwner(method.getOwner()); //cache owner instance if (ownerInstance == null) { Class clazz = method.getOwner(); ownerInstance = clazz.newInstance();
if (ownerInstance instanceof ISurgeon && ((ISurgeon) ownerInstance).singleton()) {
TangXiaoLv/Surgeon
example/simple/src/main/java/com/tangxiaolv/surgeon/HotReplace.java
// Path: surgeon-core/src/main/java/com/surgeon/weaving/core/TargetHandle.java // public class TargetHandle { // // private Object target; // private ProceedingJoinPoint origin; // // TargetHandle(ProceedingJoinPoint origin) { // if (origin != null) { // this.origin = origin; // this.target = origin.getThis(); // } // } // // /** // * Invoke target function with new params. // * // * @param params input params // * @return new result // */ // public Object proceed(Object... params) throws Throwable { // if (origin != null) { // return origin.proceed(params); // } // return null; // } // // /** // * Get function owner object. // * // * @return The target function owner. // */ // public Object getTarget() { // return target; // } // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/ISurgeon.java // public interface ISurgeon { // // /** // * Control current object to singleton. // */ // boolean singleton(); // }
import android.view.View; import android.widget.Toast; import com.surgeon.weaving.annotations.Replace; import com.surgeon.weaving.core.TargetHandle; import com.surgeon.weaving.core.interfaces.ISurgeon;
package com.tangxiaolv.surgeon; public class HotReplace implements ISurgeon { /** * Replace target override function * * @param handle {@link TargetHandle} * @param view origin params */ @Replace(namespace = "com.tangxiaolv.sdk.SDKActivity", function = "oneClick")
// Path: surgeon-core/src/main/java/com/surgeon/weaving/core/TargetHandle.java // public class TargetHandle { // // private Object target; // private ProceedingJoinPoint origin; // // TargetHandle(ProceedingJoinPoint origin) { // if (origin != null) { // this.origin = origin; // this.target = origin.getThis(); // } // } // // /** // * Invoke target function with new params. // * // * @param params input params // * @return new result // */ // public Object proceed(Object... params) throws Throwable { // if (origin != null) { // return origin.proceed(params); // } // return null; // } // // /** // * Get function owner object. // * // * @return The target function owner. // */ // public Object getTarget() { // return target; // } // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/ISurgeon.java // public interface ISurgeon { // // /** // * Control current object to singleton. // */ // boolean singleton(); // } // Path: example/simple/src/main/java/com/tangxiaolv/surgeon/HotReplace.java import android.view.View; import android.widget.Toast; import com.surgeon.weaving.annotations.Replace; import com.surgeon.weaving.core.TargetHandle; import com.surgeon.weaving.core.interfaces.ISurgeon; package com.tangxiaolv.surgeon; public class HotReplace implements ISurgeon { /** * Replace target override function * * @param handle {@link TargetHandle} * @param view origin params */ @Replace(namespace = "com.tangxiaolv.sdk.SDKActivity", function = "oneClick")
public void showToast(TargetHandle handle, View view) {
TangXiaoLv/Surgeon
surgeon-core/src/main/java/com/surgeon/weaving/core/Surgeon.java
// Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/Replacer.java // public interface Replacer<T> { // /** // * Called before original function called. // * // * @param params The original function input params. // */ // void before(Object[] params); // // /** // * Replace original function. // * // * @param params The original function input params. // * @return new return result. // */ // T replace(Object[] params) throws Throwable; // // /** // * Called after original function called. // * // * @param params The original function input params. // */ // void after(Object[] params); // }
import com.surgeon.weaving.core.interfaces.Replacer;
package com.surgeon.weaving.core; public class Surgeon { /** * Runtime to replace original function's result. * * @param ref namespace + "." + function * @param result New result. */ public static void replace(String ref, Object result) { InnerCache.getInstance().addReplaceWapper(ref, new ReplaceWapper(result, false)); } /** * Runtime to replace original function. * * @param ref namespace + "." + function * @param replacer new function. */
// Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/Replacer.java // public interface Replacer<T> { // /** // * Called before original function called. // * // * @param params The original function input params. // */ // void before(Object[] params); // // /** // * Replace original function. // * // * @param params The original function input params. // * @return new return result. // */ // T replace(Object[] params) throws Throwable; // // /** // * Called after original function called. // * // * @param params The original function input params. // */ // void after(Object[] params); // } // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/Surgeon.java import com.surgeon.weaving.core.interfaces.Replacer; package com.surgeon.weaving.core; public class Surgeon { /** * Runtime to replace original function's result. * * @param ref namespace + "." + function * @param result New result. */ public static void replace(String ref, Object result) { InnerCache.getInstance().addReplaceWapper(ref, new ReplaceWapper(result, false)); } /** * Runtime to replace original function. * * @param ref namespace + "." + function * @param replacer new function. */
public static void replace(String ref, Replacer replacer) {
TangXiaoLv/Surgeon
surgeon-core/src/main/java/com/surgeon/weaving/core/InnerCache.java
// Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/IMaster.java // public interface IMaster { // /** // * @param function The key of SurgeonMethod // */ // SurgeonMethod find(String function); // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/Continue.java // public interface Continue { // }
import android.util.LruCache; import com.surgeon.weaving.core.interfaces.IMaster; import com.surgeon.weaving.core.interfaces.Continue; import java.util.HashMap; import java.util.Map;
synchronized IMaster getMaster(String key) { if (key != null) { return masterCache.get(key); } return null; } synchronized void putMethodOwner(Class owner, Object ownerInstance) { if (owner != null && ownerInstance != null && ownerCache.get(owner) == null) { ownerCache.put(owner, ownerInstance); } } synchronized Object getMethodOwner(Class owner) { if (owner != null) { return ownerCache.get(owner); } return null; } synchronized void addReplaceWapper(String ref, ReplaceWapper wapper) { if (ref != null) { replaceWapperCache.put(ref, wapper); } } synchronized Object popReplaceWapper(String ref) { if (replaceWapperCache.containsKey(ref)) { return replaceWapperCache.remove(ref); }
// Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/IMaster.java // public interface IMaster { // /** // * @param function The key of SurgeonMethod // */ // SurgeonMethod find(String function); // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/Continue.java // public interface Continue { // } // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/InnerCache.java import android.util.LruCache; import com.surgeon.weaving.core.interfaces.IMaster; import com.surgeon.weaving.core.interfaces.Continue; import java.util.HashMap; import java.util.Map; synchronized IMaster getMaster(String key) { if (key != null) { return masterCache.get(key); } return null; } synchronized void putMethodOwner(Class owner, Object ownerInstance) { if (owner != null && ownerInstance != null && ownerCache.get(owner) == null) { ownerCache.put(owner, ownerInstance); } } synchronized Object getMethodOwner(Class owner) { if (owner != null) { return ownerCache.get(owner); } return null; } synchronized void addReplaceWapper(String ref, ReplaceWapper wapper) { if (ref != null) { replaceWapperCache.put(ref, wapper); } } synchronized Object popReplaceWapper(String ref) { if (replaceWapperCache.containsKey(ref)) { return replaceWapperCache.remove(ref); }
return Continue.class;
TangXiaoLv/Surgeon
surgeon-compile/src/main/java/com/surgeon/weaving/compile/SurgeonProcessor.java
// Path: surgeon-compile/src/main/java/com/surgeon/weaving/compile/Utils.java // static String getFullTypesString(String agrsTypes) { // if (agrsTypes.contains(",")) { // String[] arr = agrsTypes.split(","); // StringBuilder builder = new StringBuilder(); // boolean mapAppear = false; // for (String s : arr) { // if (mapAppear) { // mapAppear = false; // continue; // } // if (s.contains("Map")) // mapAppear = true; // builder.append(removeGeneric(s)).append(".class,"); // // } // String result = builder.toString(); // return result.substring(0, result.length() - 1); // } else { // return removeGeneric(agrsTypes) + ".class"; // } // } // // Path: surgeon-compile/src/main/java/com/surgeon/weaving/compile/Utils.java // static boolean isEmpty(String s) { // return s == null || s.length() == 0; // }
import com.google.auto.common.SuperficialValidation; import com.squareup.javapoet.ClassName; import com.squareup.javapoet.FieldSpec; import com.squareup.javapoet.JavaFile; import com.squareup.javapoet.MethodSpec; import com.squareup.javapoet.TypeSpec; import com.surgeon.weaving.annotations.Replace; import com.surgeon.weaving.annotations.ReplaceAfter; import com.surgeon.weaving.annotations.ReplaceBefore; import java.io.IOException; import java.lang.annotation.Annotation; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.Filer; import javax.annotation.processing.ProcessingEnvironment; import javax.annotation.processing.RoundEnvironment; import javax.lang.model.SourceVersion; import javax.lang.model.element.Element; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.util.Elements; import javax.tools.Diagnostic; import static com.surgeon.weaving.compile.Utils.getFullTypesString; import static com.surgeon.weaving.compile.Utils.isEmpty;
} // Process each @ReplaceBefore element. for (Element e : env.getElementsAnnotatedWith(ReplaceBefore.class)) { if (!SuperficialValidation.validateElement(e)) { continue; } ReplaceBefore replace = e.getAnnotation(ReplaceBefore.class); parseReplace(e, group, "before_", replace.namespace(), replace.function()); } // Process each @ReplaceAfter element. for (Element e : env.getElementsAnnotatedWith(ReplaceAfter.class)) { if (!SuperficialValidation.validateElement(e)) { continue; } ReplaceAfter replace = e.getAnnotation(ReplaceAfter.class); parseReplace(e, group, "after_", replace.namespace(), replace.function()); } generateMasterJavaFile(group, javaFiles); return javaFiles; } private void parseReplace( Element e, Map<String, Map<String, Element>> group, String prefix, String namespace, String function) {
// Path: surgeon-compile/src/main/java/com/surgeon/weaving/compile/Utils.java // static String getFullTypesString(String agrsTypes) { // if (agrsTypes.contains(",")) { // String[] arr = agrsTypes.split(","); // StringBuilder builder = new StringBuilder(); // boolean mapAppear = false; // for (String s : arr) { // if (mapAppear) { // mapAppear = false; // continue; // } // if (s.contains("Map")) // mapAppear = true; // builder.append(removeGeneric(s)).append(".class,"); // // } // String result = builder.toString(); // return result.substring(0, result.length() - 1); // } else { // return removeGeneric(agrsTypes) + ".class"; // } // } // // Path: surgeon-compile/src/main/java/com/surgeon/weaving/compile/Utils.java // static boolean isEmpty(String s) { // return s == null || s.length() == 0; // } // Path: surgeon-compile/src/main/java/com/surgeon/weaving/compile/SurgeonProcessor.java import com.google.auto.common.SuperficialValidation; import com.squareup.javapoet.ClassName; import com.squareup.javapoet.FieldSpec; import com.squareup.javapoet.JavaFile; import com.squareup.javapoet.MethodSpec; import com.squareup.javapoet.TypeSpec; import com.surgeon.weaving.annotations.Replace; import com.surgeon.weaving.annotations.ReplaceAfter; import com.surgeon.weaving.annotations.ReplaceBefore; import java.io.IOException; import java.lang.annotation.Annotation; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.Filer; import javax.annotation.processing.ProcessingEnvironment; import javax.annotation.processing.RoundEnvironment; import javax.lang.model.SourceVersion; import javax.lang.model.element.Element; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.util.Elements; import javax.tools.Diagnostic; import static com.surgeon.weaving.compile.Utils.getFullTypesString; import static com.surgeon.weaving.compile.Utils.isEmpty; } // Process each @ReplaceBefore element. for (Element e : env.getElementsAnnotatedWith(ReplaceBefore.class)) { if (!SuperficialValidation.validateElement(e)) { continue; } ReplaceBefore replace = e.getAnnotation(ReplaceBefore.class); parseReplace(e, group, "before_", replace.namespace(), replace.function()); } // Process each @ReplaceAfter element. for (Element e : env.getElementsAnnotatedWith(ReplaceAfter.class)) { if (!SuperficialValidation.validateElement(e)) { continue; } ReplaceAfter replace = e.getAnnotation(ReplaceAfter.class); parseReplace(e, group, "after_", replace.namespace(), replace.function()); } generateMasterJavaFile(group, javaFiles); return javaFiles; } private void parseReplace( Element e, Map<String, Map<String, Element>> group, String prefix, String namespace, String function) {
if (isEmpty(namespace) || isEmpty(function)) {
TangXiaoLv/Surgeon
surgeon-compile/src/main/java/com/surgeon/weaving/compile/SurgeonProcessor.java
// Path: surgeon-compile/src/main/java/com/surgeon/weaving/compile/Utils.java // static String getFullTypesString(String agrsTypes) { // if (agrsTypes.contains(",")) { // String[] arr = agrsTypes.split(","); // StringBuilder builder = new StringBuilder(); // boolean mapAppear = false; // for (String s : arr) { // if (mapAppear) { // mapAppear = false; // continue; // } // if (s.contains("Map")) // mapAppear = true; // builder.append(removeGeneric(s)).append(".class,"); // // } // String result = builder.toString(); // return result.substring(0, result.length() - 1); // } else { // return removeGeneric(agrsTypes) + ".class"; // } // } // // Path: surgeon-compile/src/main/java/com/surgeon/weaving/compile/Utils.java // static boolean isEmpty(String s) { // return s == null || s.length() == 0; // }
import com.google.auto.common.SuperficialValidation; import com.squareup.javapoet.ClassName; import com.squareup.javapoet.FieldSpec; import com.squareup.javapoet.JavaFile; import com.squareup.javapoet.MethodSpec; import com.squareup.javapoet.TypeSpec; import com.surgeon.weaving.annotations.Replace; import com.surgeon.weaving.annotations.ReplaceAfter; import com.surgeon.weaving.annotations.ReplaceBefore; import java.io.IOException; import java.lang.annotation.Annotation; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.Filer; import javax.annotation.processing.ProcessingEnvironment; import javax.annotation.processing.RoundEnvironment; import javax.lang.model.SourceVersion; import javax.lang.model.element.Element; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.util.Elements; import javax.tools.Diagnostic; import static com.surgeon.weaving.compile.Utils.getFullTypesString; import static com.surgeon.weaving.compile.Utils.isEmpty;
String mirror_name_main = PREFIX + namespace.replace(".", "_"); TypeSpec clazz = TypeSpec.classBuilder(mirror_name_main) .addModifiers(Modifier.PUBLIC, Modifier.FINAL).addSuperinterface(ISurgeonMaster) // Fields .addFields(buildRouterModuleFields()) // constructor .addMethod(constructorBuilder.build()) // Methods .addMethod(invokeBuilder.build()) // doc .addJavadoc(FILE_DOC) .build(); JavaFile javaFile = JavaFile.builder(PACKAGE_NAME, clazz).build(); javaFiles.add(javaFile); } } private SurgeonMethod parseToSurgeonMethod(Element element) { SurgeonMethod method = new SurgeonMethod(); String args = ((ExecutableElement) element).getParameters().toString(); String types = ""; String additionParamsTypes = element.toString(); int start = additionParamsTypes.indexOf("("); int end = additionParamsTypes.indexOf(")"); if (end - start > 1) { // open1(java.lang.Object) => java.lang.Object.class) types = additionParamsTypes.substring(start + 1, end); if (types.lastIndexOf("...") != -1) types = types.replace("...", "[]");
// Path: surgeon-compile/src/main/java/com/surgeon/weaving/compile/Utils.java // static String getFullTypesString(String agrsTypes) { // if (agrsTypes.contains(",")) { // String[] arr = agrsTypes.split(","); // StringBuilder builder = new StringBuilder(); // boolean mapAppear = false; // for (String s : arr) { // if (mapAppear) { // mapAppear = false; // continue; // } // if (s.contains("Map")) // mapAppear = true; // builder.append(removeGeneric(s)).append(".class,"); // // } // String result = builder.toString(); // return result.substring(0, result.length() - 1); // } else { // return removeGeneric(agrsTypes) + ".class"; // } // } // // Path: surgeon-compile/src/main/java/com/surgeon/weaving/compile/Utils.java // static boolean isEmpty(String s) { // return s == null || s.length() == 0; // } // Path: surgeon-compile/src/main/java/com/surgeon/weaving/compile/SurgeonProcessor.java import com.google.auto.common.SuperficialValidation; import com.squareup.javapoet.ClassName; import com.squareup.javapoet.FieldSpec; import com.squareup.javapoet.JavaFile; import com.squareup.javapoet.MethodSpec; import com.squareup.javapoet.TypeSpec; import com.surgeon.weaving.annotations.Replace; import com.surgeon.weaving.annotations.ReplaceAfter; import com.surgeon.weaving.annotations.ReplaceBefore; import java.io.IOException; import java.lang.annotation.Annotation; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.Filer; import javax.annotation.processing.ProcessingEnvironment; import javax.annotation.processing.RoundEnvironment; import javax.lang.model.SourceVersion; import javax.lang.model.element.Element; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.util.Elements; import javax.tools.Diagnostic; import static com.surgeon.weaving.compile.Utils.getFullTypesString; import static com.surgeon.weaving.compile.Utils.isEmpty; String mirror_name_main = PREFIX + namespace.replace(".", "_"); TypeSpec clazz = TypeSpec.classBuilder(mirror_name_main) .addModifiers(Modifier.PUBLIC, Modifier.FINAL).addSuperinterface(ISurgeonMaster) // Fields .addFields(buildRouterModuleFields()) // constructor .addMethod(constructorBuilder.build()) // Methods .addMethod(invokeBuilder.build()) // doc .addJavadoc(FILE_DOC) .build(); JavaFile javaFile = JavaFile.builder(PACKAGE_NAME, clazz).build(); javaFiles.add(javaFile); } } private SurgeonMethod parseToSurgeonMethod(Element element) { SurgeonMethod method = new SurgeonMethod(); String args = ((ExecutableElement) element).getParameters().toString(); String types = ""; String additionParamsTypes = element.toString(); int start = additionParamsTypes.indexOf("("); int end = additionParamsTypes.indexOf(")"); if (end - start > 1) { // open1(java.lang.Object) => java.lang.Object.class) types = additionParamsTypes.substring(start + 1, end); if (types.lastIndexOf("...") != -1) types = types.replace("...", "[]");
additionParamsTypes = getFullTypesString(types) + ")";
TangXiaoLv/Surgeon
example/simple/src/main/java/com/tangxiaolv/surgeon/MainActivity.java
// Path: example/sdk/src/main/java/com/tangxiaolv/sdk/SDKActivity.java // @SuppressWarnings("all") // public class SDKActivity extends AppCompatActivity { // private TextView content; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(R.layout.activity_sdk); // content = (TextView) findViewById(R.id.content); // } // // public void addRuntimeResult(View view) { // //replace return value for target function // Surgeon.replace("com.tangxiaolv.sdk.SDKActivity.getTwo", "Runtime result"); // } // // public void addRuntimeMethod(View view) { // Surgeon.replace("com.tangxiaolv.sdk.SDKActivity.getTwo", new ReplacerImpl<String>() { // //params[0] = function owner's object,The other is origin params // @Override // public void before(Object[] params) { // super.before(params); // } // // //params[0] = TargetHandle,The other is origin params // @Override // public String replace(Object[] params) throws Throwable { // return super.replace(params); // } // // //params[0] = function owner's object,The other is origin params // @Override // public void after(Object[] params) { // super.after(params); // } // }); // } // // @ReplaceAble(namespace = "com.tangxiaolv.sdk.SDKActivity", function = "oneClick") // public void oneClick(View view) { // content.setText(getOne()); // } // // public void twoClick(View view) { // String two = getTwo(); // content.setText(two == null ? "null" : two); // } // // public void threeClick(View view) { // content.setText(getThree("Text")); // } // // @ReplaceAble(namespace = "com.tangxiaolv.sdk.SDKActivity", function = "getOne") // private String getOne() { // return "ONE"; // } // // @ReplaceAble(namespace = "com.tangxiaolv.sdk.SDKActivity", function = "getTwo") // private final static String getTwo() { // return "TWO"; // } // // @ReplaceAble(namespace = "com.tangxiaolv.sdk.SDKActivity", function = "getTwo.text") // private String getTwo(String text) { // return text; // } // // @ReplaceAble(namespace = "com.tangxiaolv.sdk.SDKActivity", function = "getThree.text") // private String getThree(String text) { // return "getThree_" + text; // } // }
import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.TextView; import com.tangxiaolv.sdk.SDKActivity;
package com.tangxiaolv.surgeon; public class MainActivity extends AppCompatActivity { private TextView content; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); content = (TextView) findViewById(R.id.content); } public void oneClick(View view) { content.setText("one"); } public void twoClick(View view) { content.setText("two"); } public void threeClick(View view) { content.setText("three"); } public void openSdk(View view) {
// Path: example/sdk/src/main/java/com/tangxiaolv/sdk/SDKActivity.java // @SuppressWarnings("all") // public class SDKActivity extends AppCompatActivity { // private TextView content; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(R.layout.activity_sdk); // content = (TextView) findViewById(R.id.content); // } // // public void addRuntimeResult(View view) { // //replace return value for target function // Surgeon.replace("com.tangxiaolv.sdk.SDKActivity.getTwo", "Runtime result"); // } // // public void addRuntimeMethod(View view) { // Surgeon.replace("com.tangxiaolv.sdk.SDKActivity.getTwo", new ReplacerImpl<String>() { // //params[0] = function owner's object,The other is origin params // @Override // public void before(Object[] params) { // super.before(params); // } // // //params[0] = TargetHandle,The other is origin params // @Override // public String replace(Object[] params) throws Throwable { // return super.replace(params); // } // // //params[0] = function owner's object,The other is origin params // @Override // public void after(Object[] params) { // super.after(params); // } // }); // } // // @ReplaceAble(namespace = "com.tangxiaolv.sdk.SDKActivity", function = "oneClick") // public void oneClick(View view) { // content.setText(getOne()); // } // // public void twoClick(View view) { // String two = getTwo(); // content.setText(two == null ? "null" : two); // } // // public void threeClick(View view) { // content.setText(getThree("Text")); // } // // @ReplaceAble(namespace = "com.tangxiaolv.sdk.SDKActivity", function = "getOne") // private String getOne() { // return "ONE"; // } // // @ReplaceAble(namespace = "com.tangxiaolv.sdk.SDKActivity", function = "getTwo") // private final static String getTwo() { // return "TWO"; // } // // @ReplaceAble(namespace = "com.tangxiaolv.sdk.SDKActivity", function = "getTwo.text") // private String getTwo(String text) { // return text; // } // // @ReplaceAble(namespace = "com.tangxiaolv.sdk.SDKActivity", function = "getThree.text") // private String getThree(String text) { // return "getThree_" + text; // } // } // Path: example/simple/src/main/java/com/tangxiaolv/surgeon/MainActivity.java import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.TextView; import com.tangxiaolv.sdk.SDKActivity; package com.tangxiaolv.surgeon; public class MainActivity extends AppCompatActivity { private TextView content; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); content = (TextView) findViewById(R.id.content); } public void oneClick(View view) { content.setText("one"); } public void twoClick(View view) { content.setText("two"); } public void threeClick(View view) { content.setText("three"); } public void openSdk(View view) {
startActivity(new Intent(this, SDKActivity.class));
TangXiaoLv/Surgeon
surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/ReplacerImpl.java
// Path: surgeon-core/src/main/java/com/surgeon/weaving/core/TargetHandle.java // public class TargetHandle { // // private Object target; // private ProceedingJoinPoint origin; // // TargetHandle(ProceedingJoinPoint origin) { // if (origin != null) { // this.origin = origin; // this.target = origin.getThis(); // } // } // // /** // * Invoke target function with new params. // * // * @param params input params // * @return new result // */ // public Object proceed(Object... params) throws Throwable { // if (origin != null) { // return origin.proceed(params); // } // return null; // } // // /** // * Get function owner object. // * // * @return The target function owner. // */ // public Object getTarget() { // return target; // } // }
import com.surgeon.weaving.core.TargetHandle;
package com.surgeon.weaving.core.interfaces; /** * The implements of {@link Replacer} * * @param <T> The return value of {@link Replacer#replace(Object[])} */ public class ReplacerImpl<T> implements Replacer<T> { @Override public void before(Object[] params) { //nothing } @SuppressWarnings("unchecked") @Override public T replace(Object[] params) throws Throwable { Object[] copy = new Object[params.length - 1]; System.arraycopy(params, 1, copy, 0, params.length - 1);
// Path: surgeon-core/src/main/java/com/surgeon/weaving/core/TargetHandle.java // public class TargetHandle { // // private Object target; // private ProceedingJoinPoint origin; // // TargetHandle(ProceedingJoinPoint origin) { // if (origin != null) { // this.origin = origin; // this.target = origin.getThis(); // } // } // // /** // * Invoke target function with new params. // * // * @param params input params // * @return new result // */ // public Object proceed(Object... params) throws Throwable { // if (origin != null) { // return origin.proceed(params); // } // return null; // } // // /** // * Get function owner object. // * // * @return The target function owner. // */ // public Object getTarget() { // return target; // } // } // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/ReplacerImpl.java import com.surgeon.weaving.core.TargetHandle; package com.surgeon.weaving.core.interfaces; /** * The implements of {@link Replacer} * * @param <T> The return value of {@link Replacer#replace(Object[])} */ public class ReplacerImpl<T> implements Replacer<T> { @Override public void before(Object[] params) { //nothing } @SuppressWarnings("unchecked") @Override public T replace(Object[] params) throws Throwable { Object[] copy = new Object[params.length - 1]; System.arraycopy(params, 1, copy, 0, params.length - 1);
return (T) ((TargetHandle) params[0]).proceed(copy);
TangXiaoLv/Surgeon
example/sdk/src/main/java/com/tangxiaolv/sdk/SDKActivity.java
// Path: surgeon-core/src/main/java/com/surgeon/weaving/core/Surgeon.java // public class Surgeon { // // /** // * Runtime to replace original function's result. // * // * @param ref namespace + "." + function // * @param result New result. // */ // public static void replace(String ref, Object result) { // InnerCache.getInstance().addReplaceWapper(ref, new ReplaceWapper(result, false)); // } // // /** // * Runtime to replace original function. // * // * @param ref namespace + "." + function // * @param replacer new function. // */ // public static void replace(String ref, Replacer replacer) { // InnerCache.getInstance().addReplaceWapper(ref, new ReplaceWapper(replacer, replacer != null)); // } // // /** // * Remove replaced result/function. // * // * @param ref namespace + "." + function // */ // public static void remove(String ref) { // InnerCache.getInstance().popReplaceWapper(ref); // } // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/ReplacerImpl.java // public class ReplacerImpl<T> implements Replacer<T> { // // @Override // public void before(Object[] params) { // //nothing // } // // @SuppressWarnings("unchecked") // @Override // public T replace(Object[] params) throws Throwable { // Object[] copy = new Object[params.length - 1]; // System.arraycopy(params, 1, copy, 0, params.length - 1); // return (T) ((TargetHandle) params[0]).proceed(copy); // } // // @Override // public void after(Object[] params) { // //nothing // } // }
import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.TextView; import com.surgeon.weaving.annotations.ReplaceAble; import com.surgeon.weaving.core.Surgeon; import com.surgeon.weaving.core.interfaces.ReplacerImpl;
package com.tangxiaolv.sdk; @SuppressWarnings("all") public class SDKActivity extends AppCompatActivity { private TextView content; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sdk); content = (TextView) findViewById(R.id.content); } public void addRuntimeResult(View view) { //replace return value for target function
// Path: surgeon-core/src/main/java/com/surgeon/weaving/core/Surgeon.java // public class Surgeon { // // /** // * Runtime to replace original function's result. // * // * @param ref namespace + "." + function // * @param result New result. // */ // public static void replace(String ref, Object result) { // InnerCache.getInstance().addReplaceWapper(ref, new ReplaceWapper(result, false)); // } // // /** // * Runtime to replace original function. // * // * @param ref namespace + "." + function // * @param replacer new function. // */ // public static void replace(String ref, Replacer replacer) { // InnerCache.getInstance().addReplaceWapper(ref, new ReplaceWapper(replacer, replacer != null)); // } // // /** // * Remove replaced result/function. // * // * @param ref namespace + "." + function // */ // public static void remove(String ref) { // InnerCache.getInstance().popReplaceWapper(ref); // } // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/ReplacerImpl.java // public class ReplacerImpl<T> implements Replacer<T> { // // @Override // public void before(Object[] params) { // //nothing // } // // @SuppressWarnings("unchecked") // @Override // public T replace(Object[] params) throws Throwable { // Object[] copy = new Object[params.length - 1]; // System.arraycopy(params, 1, copy, 0, params.length - 1); // return (T) ((TargetHandle) params[0]).proceed(copy); // } // // @Override // public void after(Object[] params) { // //nothing // } // } // Path: example/sdk/src/main/java/com/tangxiaolv/sdk/SDKActivity.java import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.TextView; import com.surgeon.weaving.annotations.ReplaceAble; import com.surgeon.weaving.core.Surgeon; import com.surgeon.weaving.core.interfaces.ReplacerImpl; package com.tangxiaolv.sdk; @SuppressWarnings("all") public class SDKActivity extends AppCompatActivity { private TextView content; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sdk); content = (TextView) findViewById(R.id.content); } public void addRuntimeResult(View view) { //replace return value for target function
Surgeon.replace("com.tangxiaolv.sdk.SDKActivity.getTwo", "Runtime result");
TangXiaoLv/Surgeon
example/sdk/src/main/java/com/tangxiaolv/sdk/SDKActivity.java
// Path: surgeon-core/src/main/java/com/surgeon/weaving/core/Surgeon.java // public class Surgeon { // // /** // * Runtime to replace original function's result. // * // * @param ref namespace + "." + function // * @param result New result. // */ // public static void replace(String ref, Object result) { // InnerCache.getInstance().addReplaceWapper(ref, new ReplaceWapper(result, false)); // } // // /** // * Runtime to replace original function. // * // * @param ref namespace + "." + function // * @param replacer new function. // */ // public static void replace(String ref, Replacer replacer) { // InnerCache.getInstance().addReplaceWapper(ref, new ReplaceWapper(replacer, replacer != null)); // } // // /** // * Remove replaced result/function. // * // * @param ref namespace + "." + function // */ // public static void remove(String ref) { // InnerCache.getInstance().popReplaceWapper(ref); // } // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/ReplacerImpl.java // public class ReplacerImpl<T> implements Replacer<T> { // // @Override // public void before(Object[] params) { // //nothing // } // // @SuppressWarnings("unchecked") // @Override // public T replace(Object[] params) throws Throwable { // Object[] copy = new Object[params.length - 1]; // System.arraycopy(params, 1, copy, 0, params.length - 1); // return (T) ((TargetHandle) params[0]).proceed(copy); // } // // @Override // public void after(Object[] params) { // //nothing // } // }
import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.TextView; import com.surgeon.weaving.annotations.ReplaceAble; import com.surgeon.weaving.core.Surgeon; import com.surgeon.weaving.core.interfaces.ReplacerImpl;
package com.tangxiaolv.sdk; @SuppressWarnings("all") public class SDKActivity extends AppCompatActivity { private TextView content; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sdk); content = (TextView) findViewById(R.id.content); } public void addRuntimeResult(View view) { //replace return value for target function Surgeon.replace("com.tangxiaolv.sdk.SDKActivity.getTwo", "Runtime result"); } public void addRuntimeMethod(View view) {
// Path: surgeon-core/src/main/java/com/surgeon/weaving/core/Surgeon.java // public class Surgeon { // // /** // * Runtime to replace original function's result. // * // * @param ref namespace + "." + function // * @param result New result. // */ // public static void replace(String ref, Object result) { // InnerCache.getInstance().addReplaceWapper(ref, new ReplaceWapper(result, false)); // } // // /** // * Runtime to replace original function. // * // * @param ref namespace + "." + function // * @param replacer new function. // */ // public static void replace(String ref, Replacer replacer) { // InnerCache.getInstance().addReplaceWapper(ref, new ReplaceWapper(replacer, replacer != null)); // } // // /** // * Remove replaced result/function. // * // * @param ref namespace + "." + function // */ // public static void remove(String ref) { // InnerCache.getInstance().popReplaceWapper(ref); // } // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/ReplacerImpl.java // public class ReplacerImpl<T> implements Replacer<T> { // // @Override // public void before(Object[] params) { // //nothing // } // // @SuppressWarnings("unchecked") // @Override // public T replace(Object[] params) throws Throwable { // Object[] copy = new Object[params.length - 1]; // System.arraycopy(params, 1, copy, 0, params.length - 1); // return (T) ((TargetHandle) params[0]).proceed(copy); // } // // @Override // public void after(Object[] params) { // //nothing // } // } // Path: example/sdk/src/main/java/com/tangxiaolv/sdk/SDKActivity.java import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.TextView; import com.surgeon.weaving.annotations.ReplaceAble; import com.surgeon.weaving.core.Surgeon; import com.surgeon.weaving.core.interfaces.ReplacerImpl; package com.tangxiaolv.sdk; @SuppressWarnings("all") public class SDKActivity extends AppCompatActivity { private TextView content; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sdk); content = (TextView) findViewById(R.id.content); } public void addRuntimeResult(View view) { //replace return value for target function Surgeon.replace("com.tangxiaolv.sdk.SDKActivity.getTwo", "Runtime result"); } public void addRuntimeMethod(View view) {
Surgeon.replace("com.tangxiaolv.sdk.SDKActivity.getTwo", new ReplacerImpl<String>() {
TangXiaoLv/Surgeon
example/simple/src/main/java/com/tangxiaolv/surgeon/HotReplace2.java
// Path: surgeon-core/src/main/java/com/surgeon/weaving/core/TargetHandle.java // public class TargetHandle { // // private Object target; // private ProceedingJoinPoint origin; // // TargetHandle(ProceedingJoinPoint origin) { // if (origin != null) { // this.origin = origin; // this.target = origin.getThis(); // } // } // // /** // * Invoke target function with new params. // * // * @param params input params // * @return new result // */ // public Object proceed(Object... params) throws Throwable { // if (origin != null) { // return origin.proceed(params); // } // return null; // } // // /** // * Get function owner object. // * // * @return The target function owner. // */ // public Object getTarget() { // return target; // } // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/ISurgeon.java // public interface ISurgeon { // // /** // * Control current object to singleton. // */ // boolean singleton(); // }
import android.util.Log; import com.surgeon.weaving.annotations.Replace; import com.surgeon.weaving.annotations.ReplaceAfter; import com.surgeon.weaving.annotations.ReplaceBefore; import com.surgeon.weaving.core.TargetHandle; import com.surgeon.weaving.core.interfaces.ISurgeon;
package com.tangxiaolv.surgeon; public class HotReplace2 implements ISurgeon { private final static String TAG = "HotReplace2"; /** * Called before target function call * * @param target The function owner's object. */ @ReplaceBefore(namespace = "com.tangxiaolv.sdk.SDKActivity", function = "getTwo") public void getTwoBefore(Object target) { Log.d(TAG, "getTwoBefore"); } /** * Replace target function * * @param handle The function owner's object. * @return new result */ @Replace(namespace = "com.tangxiaolv.sdk.SDKActivity", function = "getTwo")
// Path: surgeon-core/src/main/java/com/surgeon/weaving/core/TargetHandle.java // public class TargetHandle { // // private Object target; // private ProceedingJoinPoint origin; // // TargetHandle(ProceedingJoinPoint origin) { // if (origin != null) { // this.origin = origin; // this.target = origin.getThis(); // } // } // // /** // * Invoke target function with new params. // * // * @param params input params // * @return new result // */ // public Object proceed(Object... params) throws Throwable { // if (origin != null) { // return origin.proceed(params); // } // return null; // } // // /** // * Get function owner object. // * // * @return The target function owner. // */ // public Object getTarget() { // return target; // } // } // // Path: surgeon-core/src/main/java/com/surgeon/weaving/core/interfaces/ISurgeon.java // public interface ISurgeon { // // /** // * Control current object to singleton. // */ // boolean singleton(); // } // Path: example/simple/src/main/java/com/tangxiaolv/surgeon/HotReplace2.java import android.util.Log; import com.surgeon.weaving.annotations.Replace; import com.surgeon.weaving.annotations.ReplaceAfter; import com.surgeon.weaving.annotations.ReplaceBefore; import com.surgeon.weaving.core.TargetHandle; import com.surgeon.weaving.core.interfaces.ISurgeon; package com.tangxiaolv.surgeon; public class HotReplace2 implements ISurgeon { private final static String TAG = "HotReplace2"; /** * Called before target function call * * @param target The function owner's object. */ @ReplaceBefore(namespace = "com.tangxiaolv.sdk.SDKActivity", function = "getTwo") public void getTwoBefore(Object target) { Log.d(TAG, "getTwoBefore"); } /** * Replace target function * * @param handle The function owner's object. * @return new result */ @Replace(namespace = "com.tangxiaolv.sdk.SDKActivity", function = "getTwo")
public String getTwo(TargetHandle handle) {
lauriholmas/batmapper
src/main/java/com/glaurung/batMap/io/GuiDataPersister.java
// Path: src/main/java/com/glaurung/batMap/vo/GuiData.java // public class GuiData implements Serializable { // // // private static final long serialVersionUID = 1L; // // public GuiData( Point location, Dimension size ) { // this.location = location; // this.size = size; // } // // // private Point location; // private Dimension size; // // public int getX() { // return this.location.x; // } // // public int getY() { // return this.location.y; // } // // public int getHeight() { // return this.size.height; // } // // public int getWidth() { // return this.size.width; // } // // }
import java.awt.Dimension; import java.awt.Point; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import com.glaurung.batMap.vo.GuiData;
package com.glaurung.batMap.io; public class GuiDataPersister { private final static String FILENAME = "batMap.conf"; private final static String DIRNAME = "conf"; public static void save( String baseDir, Point location, Dimension size ) {
// Path: src/main/java/com/glaurung/batMap/vo/GuiData.java // public class GuiData implements Serializable { // // // private static final long serialVersionUID = 1L; // // public GuiData( Point location, Dimension size ) { // this.location = location; // this.size = size; // } // // // private Point location; // private Dimension size; // // public int getX() { // return this.location.x; // } // // public int getY() { // return this.location.y; // } // // public int getHeight() { // return this.size.height; // } // // public int getWidth() { // return this.size.width; // } // // } // Path: src/main/java/com/glaurung/batMap/io/GuiDataPersister.java import java.awt.Dimension; import java.awt.Point; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import com.glaurung.batMap.vo.GuiData; package com.glaurung.batMap.io; public class GuiDataPersister { private final static String FILENAME = "batMap.conf"; private final static String DIRNAME = "conf"; public static void save( String baseDir, Point location, Dimension size ) {
GuiData data = new GuiData( location, size );
lauriholmas/batmapper
src/test/java/com/glaurung/batMap/gui/ManualTest1.java
// Path: src/main/java/com/glaurung/batMap/gui/manual/ManualPanel.java // public class ManualPanel extends JPanel implements ComponentListener { // // private static final long serialVersionUID = 8922764153155463898L; // private JTextArea manualTextArea = new JTextArea(); // private final String MANUAL_FILE = "/manual.txt"; // private final Color TEXT_COLOR = Color.LIGHT_GRAY; // private final Color BG_COLOR = Color.BLACK; // private final int BORDERLINE = 7; // private JScrollPane scrollPane; // // // public ManualPanel() { // this.addComponentListener( this ); // this.setLayout( null ); // manualTextArea.setWrapStyleWord( true ); // // manualTextArea.setText( readManual() ); // manualTextArea.setEditable( false ); // scrollPane = new JScrollPane( manualTextArea ); // scrollPane.setPreferredSize( new Dimension( 800, 534 ) ); // scrollPane.setBounds( BORDERLINE, BORDERLINE, 800, 534 ); // this.setPreferredSize( new Dimension( 800, 534 ) ); // this.setBackground( BG_COLOR ); // manualTextArea.setForeground( TEXT_COLOR ); // manualTextArea.setBackground( BG_COLOR ); // manualTextArea.setLineWrap( true ); // this.add( scrollPane ); // } // // private String readManual() { // // try { // InputStream stream = getClass().getResourceAsStream( MANUAL_FILE ); // return IOUtils.toString( stream ); // } catch (IOException e) { // e.printStackTrace(); // return null; // } // } // // @Override // public void componentHidden( ComponentEvent e ) { // // } // // @Override // public void componentMoved( ComponentEvent e ) { // // } // // @Override // public void componentResized( ComponentEvent e ) { // this.scrollPane.setBounds( BORDERLINE, BORDERLINE, this.getWidth() - BORDERLINE * 2, this.getHeight() - BORDERLINE * 2 ); // // } // // @Override // public void componentShown( ComponentEvent e ) { // // } // // // }
import java.awt.FlowLayout; import javax.swing.JFrame; import com.glaurung.batMap.gui.manual.ManualPanel;
package com.glaurung.batMap.gui; public class ManualTest1 { public static void main( String[] args ) { JFrame frame = new JFrame( "Simple Graph View" ); frame.setLayout( new FlowLayout() ); frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
// Path: src/main/java/com/glaurung/batMap/gui/manual/ManualPanel.java // public class ManualPanel extends JPanel implements ComponentListener { // // private static final long serialVersionUID = 8922764153155463898L; // private JTextArea manualTextArea = new JTextArea(); // private final String MANUAL_FILE = "/manual.txt"; // private final Color TEXT_COLOR = Color.LIGHT_GRAY; // private final Color BG_COLOR = Color.BLACK; // private final int BORDERLINE = 7; // private JScrollPane scrollPane; // // // public ManualPanel() { // this.addComponentListener( this ); // this.setLayout( null ); // manualTextArea.setWrapStyleWord( true ); // // manualTextArea.setText( readManual() ); // manualTextArea.setEditable( false ); // scrollPane = new JScrollPane( manualTextArea ); // scrollPane.setPreferredSize( new Dimension( 800, 534 ) ); // scrollPane.setBounds( BORDERLINE, BORDERLINE, 800, 534 ); // this.setPreferredSize( new Dimension( 800, 534 ) ); // this.setBackground( BG_COLOR ); // manualTextArea.setForeground( TEXT_COLOR ); // manualTextArea.setBackground( BG_COLOR ); // manualTextArea.setLineWrap( true ); // this.add( scrollPane ); // } // // private String readManual() { // // try { // InputStream stream = getClass().getResourceAsStream( MANUAL_FILE ); // return IOUtils.toString( stream ); // } catch (IOException e) { // e.printStackTrace(); // return null; // } // } // // @Override // public void componentHidden( ComponentEvent e ) { // // } // // @Override // public void componentMoved( ComponentEvent e ) { // // } // // @Override // public void componentResized( ComponentEvent e ) { // this.scrollPane.setBounds( BORDERLINE, BORDERLINE, this.getWidth() - BORDERLINE * 2, this.getHeight() - BORDERLINE * 2 ); // // } // // @Override // public void componentShown( ComponentEvent e ) { // // } // // // } // Path: src/test/java/com/glaurung/batMap/gui/ManualTest1.java import java.awt.FlowLayout; import javax.swing.JFrame; import com.glaurung.batMap.gui.manual.ManualPanel; package com.glaurung.batMap.gui; public class ManualTest1 { public static void main( String[] args ) { JFrame frame = new JFrame( "Simple Graph View" ); frame.setLayout( new FlowLayout() ); frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.getContentPane().add( new ManualPanel() );
lauriholmas/batmapper
src/main/java/com/glaurung/batMap/gui/DrawingUtils.java
// Path: src/main/java/com/glaurung/batMap/vo/Exit.java // public class Exit implements Serializable { // // // private static final long serialVersionUID = 3983564665752135097L; // private String exit; // private String compassDir; // private boolean currentExit; // public final String TELEPORT = "teleport"; // // // public Exit( String exit ) { // this.exit = exit; // this.compassDir = this.checkWhatExitIs( exit ); // } // // private String checkWhatExitIs( String exit ) { // if (exit.equalsIgnoreCase( "n" ) || exit.equalsIgnoreCase( "north" )) // return "n"; // if (exit.equalsIgnoreCase( "e" ) || exit.equalsIgnoreCase( "east" )) // return "e"; // if (exit.equalsIgnoreCase( "s" ) || exit.equalsIgnoreCase( "south" )) // return "s"; // if (exit.equalsIgnoreCase( "w" ) || exit.equalsIgnoreCase( "west" )) // return "w"; // if (exit.equalsIgnoreCase( "ne" ) || exit.equalsIgnoreCase( "northeast" )) // return "ne"; // if (exit.equalsIgnoreCase( "nw" ) || exit.equalsIgnoreCase( "northwest" )) // return "nw"; // if (exit.equalsIgnoreCase( "se" ) || exit.equalsIgnoreCase( "southeast" )) // return "se"; // if (exit.equalsIgnoreCase( "sw" ) || exit.equalsIgnoreCase( "southwest" )) // return "sw"; // if (exit.equalsIgnoreCase( "d" ) || exit.equalsIgnoreCase( "down" )) // return "d"; // if (exit.equalsIgnoreCase( "u" ) || exit.equalsIgnoreCase( "up" )) // return "u"; // return null; // } // // public String getExit() { // return exit; // } // // public void setExit( String exit ) { // this.exit = exit; // } // // public String toString() { // return this.exit; // } // // public String getCompassDir() { // return compassDir; // } // // public boolean isCurrentExit() { // return currentExit; // } // // public void setCurrentExit( boolean currentExit ) { // this.currentExit = currentExit; // } // // public boolean equals( Object o ) { // if (o instanceof Exit) { // if (this.exit.equals( ( (Exit) o ).getExit() )) // return true; // } // return false; // // } // // }
import java.awt.geom.Point2D; import com.glaurung.batMap.vo.Exit;
package com.glaurung.batMap.gui; /** * This clas is used to get relative positions of rooms, give it a location and exit, * and it will give new location in distance to direction of exit * * @author lauri */ public class DrawingUtils { public static final int ROOM_SIZE = 90;
// Path: src/main/java/com/glaurung/batMap/vo/Exit.java // public class Exit implements Serializable { // // // private static final long serialVersionUID = 3983564665752135097L; // private String exit; // private String compassDir; // private boolean currentExit; // public final String TELEPORT = "teleport"; // // // public Exit( String exit ) { // this.exit = exit; // this.compassDir = this.checkWhatExitIs( exit ); // } // // private String checkWhatExitIs( String exit ) { // if (exit.equalsIgnoreCase( "n" ) || exit.equalsIgnoreCase( "north" )) // return "n"; // if (exit.equalsIgnoreCase( "e" ) || exit.equalsIgnoreCase( "east" )) // return "e"; // if (exit.equalsIgnoreCase( "s" ) || exit.equalsIgnoreCase( "south" )) // return "s"; // if (exit.equalsIgnoreCase( "w" ) || exit.equalsIgnoreCase( "west" )) // return "w"; // if (exit.equalsIgnoreCase( "ne" ) || exit.equalsIgnoreCase( "northeast" )) // return "ne"; // if (exit.equalsIgnoreCase( "nw" ) || exit.equalsIgnoreCase( "northwest" )) // return "nw"; // if (exit.equalsIgnoreCase( "se" ) || exit.equalsIgnoreCase( "southeast" )) // return "se"; // if (exit.equalsIgnoreCase( "sw" ) || exit.equalsIgnoreCase( "southwest" )) // return "sw"; // if (exit.equalsIgnoreCase( "d" ) || exit.equalsIgnoreCase( "down" )) // return "d"; // if (exit.equalsIgnoreCase( "u" ) || exit.equalsIgnoreCase( "up" )) // return "u"; // return null; // } // // public String getExit() { // return exit; // } // // public void setExit( String exit ) { // this.exit = exit; // } // // public String toString() { // return this.exit; // } // // public String getCompassDir() { // return compassDir; // } // // public boolean isCurrentExit() { // return currentExit; // } // // public void setCurrentExit( boolean currentExit ) { // this.currentExit = currentExit; // } // // public boolean equals( Object o ) { // if (o instanceof Exit) { // if (this.exit.equals( ( (Exit) o ).getExit() )) // return true; // } // return false; // // } // // } // Path: src/main/java/com/glaurung/batMap/gui/DrawingUtils.java import java.awt.geom.Point2D; import com.glaurung.batMap.vo.Exit; package com.glaurung.batMap.gui; /** * This clas is used to get relative positions of rooms, give it a location and exit, * and it will give new location in distance to direction of exit * * @author lauri */ public class DrawingUtils { public static final int ROOM_SIZE = 90;
public static Point2D getRelativePosition( Point2D location, Exit exit, boolean snapMode) {
lauriholmas/batmapper
src/main/java/com/glaurung/batMap/gui/ExitLabelRenderer.java
// Path: src/main/java/com/glaurung/batMap/vo/Exit.java // public class Exit implements Serializable { // // // private static final long serialVersionUID = 3983564665752135097L; // private String exit; // private String compassDir; // private boolean currentExit; // public final String TELEPORT = "teleport"; // // // public Exit( String exit ) { // this.exit = exit; // this.compassDir = this.checkWhatExitIs( exit ); // } // // private String checkWhatExitIs( String exit ) { // if (exit.equalsIgnoreCase( "n" ) || exit.equalsIgnoreCase( "north" )) // return "n"; // if (exit.equalsIgnoreCase( "e" ) || exit.equalsIgnoreCase( "east" )) // return "e"; // if (exit.equalsIgnoreCase( "s" ) || exit.equalsIgnoreCase( "south" )) // return "s"; // if (exit.equalsIgnoreCase( "w" ) || exit.equalsIgnoreCase( "west" )) // return "w"; // if (exit.equalsIgnoreCase( "ne" ) || exit.equalsIgnoreCase( "northeast" )) // return "ne"; // if (exit.equalsIgnoreCase( "nw" ) || exit.equalsIgnoreCase( "northwest" )) // return "nw"; // if (exit.equalsIgnoreCase( "se" ) || exit.equalsIgnoreCase( "southeast" )) // return "se"; // if (exit.equalsIgnoreCase( "sw" ) || exit.equalsIgnoreCase( "southwest" )) // return "sw"; // if (exit.equalsIgnoreCase( "d" ) || exit.equalsIgnoreCase( "down" )) // return "d"; // if (exit.equalsIgnoreCase( "u" ) || exit.equalsIgnoreCase( "up" )) // return "u"; // return null; // } // // public String getExit() { // return exit; // } // // public void setExit( String exit ) { // this.exit = exit; // } // // public String toString() { // return this.exit; // } // // public String getCompassDir() { // return compassDir; // } // // public boolean isCurrentExit() { // return currentExit; // } // // public void setCurrentExit( boolean currentExit ) { // this.currentExit = currentExit; // } // // public boolean equals( Object o ) { // if (o instanceof Exit) { // if (this.exit.equals( ( (Exit) o ).getExit() )) // return true; // } // return false; // // } // // }
import java.awt.Color; import java.awt.Component; import java.awt.Font; import javax.swing.JComponent; import com.glaurung.batMap.vo.Exit; import edu.uci.ics.jung.visualization.renderers.DefaultEdgeLabelRenderer;
package com.glaurung.batMap.gui; /** * currently used for coloring edgelabels based on selected or not * * @author lauri */ public class ExitLabelRenderer extends DefaultEdgeLabelRenderer { private static final long serialVersionUID = - 7389656600818368218L; protected Color pickedEdgeLabelColor = Color.blue; protected Color unPickedEdgeLabelColor = Color.red; public ExitLabelRenderer( Color pickedEdgeLabelColor, boolean rotateEdgeLabels ) { super( pickedEdgeLabelColor, rotateEdgeLabels ); } public ExitLabelRenderer() { super( Color.black, false ); } public <E> Component getEdgeLabelRendererComponent( JComponent vv, Object value, Font font, boolean isSelected, E edge ) { super.setForeground( vv.getForeground() );
// Path: src/main/java/com/glaurung/batMap/vo/Exit.java // public class Exit implements Serializable { // // // private static final long serialVersionUID = 3983564665752135097L; // private String exit; // private String compassDir; // private boolean currentExit; // public final String TELEPORT = "teleport"; // // // public Exit( String exit ) { // this.exit = exit; // this.compassDir = this.checkWhatExitIs( exit ); // } // // private String checkWhatExitIs( String exit ) { // if (exit.equalsIgnoreCase( "n" ) || exit.equalsIgnoreCase( "north" )) // return "n"; // if (exit.equalsIgnoreCase( "e" ) || exit.equalsIgnoreCase( "east" )) // return "e"; // if (exit.equalsIgnoreCase( "s" ) || exit.equalsIgnoreCase( "south" )) // return "s"; // if (exit.equalsIgnoreCase( "w" ) || exit.equalsIgnoreCase( "west" )) // return "w"; // if (exit.equalsIgnoreCase( "ne" ) || exit.equalsIgnoreCase( "northeast" )) // return "ne"; // if (exit.equalsIgnoreCase( "nw" ) || exit.equalsIgnoreCase( "northwest" )) // return "nw"; // if (exit.equalsIgnoreCase( "se" ) || exit.equalsIgnoreCase( "southeast" )) // return "se"; // if (exit.equalsIgnoreCase( "sw" ) || exit.equalsIgnoreCase( "southwest" )) // return "sw"; // if (exit.equalsIgnoreCase( "d" ) || exit.equalsIgnoreCase( "down" )) // return "d"; // if (exit.equalsIgnoreCase( "u" ) || exit.equalsIgnoreCase( "up" )) // return "u"; // return null; // } // // public String getExit() { // return exit; // } // // public void setExit( String exit ) { // this.exit = exit; // } // // public String toString() { // return this.exit; // } // // public String getCompassDir() { // return compassDir; // } // // public boolean isCurrentExit() { // return currentExit; // } // // public void setCurrentExit( boolean currentExit ) { // this.currentExit = currentExit; // } // // public boolean equals( Object o ) { // if (o instanceof Exit) { // if (this.exit.equals( ( (Exit) o ).getExit() )) // return true; // } // return false; // // } // // } // Path: src/main/java/com/glaurung/batMap/gui/ExitLabelRenderer.java import java.awt.Color; import java.awt.Component; import java.awt.Font; import javax.swing.JComponent; import com.glaurung.batMap.vo.Exit; import edu.uci.ics.jung.visualization.renderers.DefaultEdgeLabelRenderer; package com.glaurung.batMap.gui; /** * currently used for coloring edgelabels based on selected or not * * @author lauri */ public class ExitLabelRenderer extends DefaultEdgeLabelRenderer { private static final long serialVersionUID = - 7389656600818368218L; protected Color pickedEdgeLabelColor = Color.blue; protected Color unPickedEdgeLabelColor = Color.red; public ExitLabelRenderer( Color pickedEdgeLabelColor, boolean rotateEdgeLabels ) { super( pickedEdgeLabelColor, rotateEdgeLabels ); } public ExitLabelRenderer() { super( Color.black, false ); } public <E> Component getEdgeLabelRendererComponent( JComponent vv, Object value, Font font, boolean isSelected, E edge ) { super.setForeground( vv.getForeground() );
if (edge instanceof Exit) {
lauriholmas/batmapper
src/main/java/com/glaurung/batMap/io/CorpseHandlerDataPersister.java
// Path: src/main/java/com/glaurung/batMap/gui/corpses/CorpseModel.java // public class CorpseModel implements Serializable { // // /** // * // */ // private static final long serialVersionUID = 1L; // // //souls = 5 // public boolean lichdrain = false; // public boolean kharimsoul = false; // public boolean kharimSoulCorpse = false; // public boolean tsaraksoul = false; // public boolean ripSoulToKatana = false; // rip soul from corpse // public boolean arkemile = false; // soul AND corpse actually // // //loot = 5 // public boolean gac = false; // public boolean ga = false; // public boolean donate = false; // public boolean lootCorpse = false; // public boolean lootGround = false; // // //corpse = 13 // public boolean eatCorpse = false; // public boolean barbarianBurn = false; // public boolean feedCorpseTo = false; // public boolean beheading = false; // public boolean desecrateGround = false; // public boolean burialCere = false; // public boolean wakeCorpse = false; // public boolean dig = false; // public boolean aelenaOrgan = false; // public boolean aelenaFam = false; // public boolean dissect = false; // public boolean tin = false; // public boolean extractEther = false; // // //fucking undead wakes = 8 // public boolean wakeFollow = false; // public boolean wakeAgro = false; // public boolean wakeTalk = false; // public boolean wakeStatic = false; // public boolean lichWake = false; // public boolean vampireWake = false; // public boolean skeletonWake = false; // public boolean zombieWake = false; // // private String delim = ";"; // private String mountHandle = "snowman"; // private List<String> lootList = new LinkedList<String>(); // private String organ1 = "antenna"; // private String organ2 = "antenna"; // private String etherType = "no_focus"; // // // public String getDelim() { // return delim; // } // // public void setDelim( String delim ) { // this.delim = delim; // } // // public String getMountHandle() { // return mountHandle; // } // // public void setMountHandle( String mountHandle ) { // this.mountHandle = mountHandle; // } // // public List<String> getLootList() { // return lootList; // } // // public void setLootList( List<String> lootList ) { // this.lootList = lootList; // } // // public void clear() { // lichdrain = false; // kharimsoul = false; // kharimSoulCorpse = false; // tsaraksoul = false; // ripSoulToKatana = false; // arkemile = false; // gac = false; // ga = false; // eatCorpse = false; // donate = false; // lootCorpse = false; // lootGround = false; // barbarianBurn = false; // feedCorpseTo = false; // beheading = false; // desecrateGround = false; // burialCere = false; // wakeCorpse = false; // dig = false; // wakeFollow = false; // wakeAgro = false; // wakeTalk = false; // wakeStatic = false; // lichWake = false; // vampireWake = false; // skeletonWake = false; // zombieWake = false; // aelenaFam = false; // aelenaOrgan = false; // tin = false; // extractEther = false; // // delim = ""; // mountHandle = ""; // lootList = new LinkedList<String>(); // organ1 = "antenna"; // organ2 = "antenna"; // etherType = "no_focus"; // // } // // public String getOrgan1() { // return organ1; // } // // public String getOrgan2() { // return organ2; // } // // public void setOrgan1( String organ ) { // this.organ1 = organ; // } // // public void setOrgan2( String organ ) { // this.organ2 = organ; // // } // public String getEtherType() { // return etherType; // } // public void setEtherType( String etherType ) { // this.etherType = etherType; // } // // }
import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import com.glaurung.batMap.gui.corpses.CorpseModel;
package com.glaurung.batMap.io; public class CorpseHandlerDataPersister { private final static String FILENAME = "corpseHandler.conf"; private final static String DIRNAME = "conf";
// Path: src/main/java/com/glaurung/batMap/gui/corpses/CorpseModel.java // public class CorpseModel implements Serializable { // // /** // * // */ // private static final long serialVersionUID = 1L; // // //souls = 5 // public boolean lichdrain = false; // public boolean kharimsoul = false; // public boolean kharimSoulCorpse = false; // public boolean tsaraksoul = false; // public boolean ripSoulToKatana = false; // rip soul from corpse // public boolean arkemile = false; // soul AND corpse actually // // //loot = 5 // public boolean gac = false; // public boolean ga = false; // public boolean donate = false; // public boolean lootCorpse = false; // public boolean lootGround = false; // // //corpse = 13 // public boolean eatCorpse = false; // public boolean barbarianBurn = false; // public boolean feedCorpseTo = false; // public boolean beheading = false; // public boolean desecrateGround = false; // public boolean burialCere = false; // public boolean wakeCorpse = false; // public boolean dig = false; // public boolean aelenaOrgan = false; // public boolean aelenaFam = false; // public boolean dissect = false; // public boolean tin = false; // public boolean extractEther = false; // // //fucking undead wakes = 8 // public boolean wakeFollow = false; // public boolean wakeAgro = false; // public boolean wakeTalk = false; // public boolean wakeStatic = false; // public boolean lichWake = false; // public boolean vampireWake = false; // public boolean skeletonWake = false; // public boolean zombieWake = false; // // private String delim = ";"; // private String mountHandle = "snowman"; // private List<String> lootList = new LinkedList<String>(); // private String organ1 = "antenna"; // private String organ2 = "antenna"; // private String etherType = "no_focus"; // // // public String getDelim() { // return delim; // } // // public void setDelim( String delim ) { // this.delim = delim; // } // // public String getMountHandle() { // return mountHandle; // } // // public void setMountHandle( String mountHandle ) { // this.mountHandle = mountHandle; // } // // public List<String> getLootList() { // return lootList; // } // // public void setLootList( List<String> lootList ) { // this.lootList = lootList; // } // // public void clear() { // lichdrain = false; // kharimsoul = false; // kharimSoulCorpse = false; // tsaraksoul = false; // ripSoulToKatana = false; // arkemile = false; // gac = false; // ga = false; // eatCorpse = false; // donate = false; // lootCorpse = false; // lootGround = false; // barbarianBurn = false; // feedCorpseTo = false; // beheading = false; // desecrateGround = false; // burialCere = false; // wakeCorpse = false; // dig = false; // wakeFollow = false; // wakeAgro = false; // wakeTalk = false; // wakeStatic = false; // lichWake = false; // vampireWake = false; // skeletonWake = false; // zombieWake = false; // aelenaFam = false; // aelenaOrgan = false; // tin = false; // extractEther = false; // // delim = ""; // mountHandle = ""; // lootList = new LinkedList<String>(); // organ1 = "antenna"; // organ2 = "antenna"; // etherType = "no_focus"; // // } // // public String getOrgan1() { // return organ1; // } // // public String getOrgan2() { // return organ2; // } // // public void setOrgan1( String organ ) { // this.organ1 = organ; // } // // public void setOrgan2( String organ ) { // this.organ2 = organ; // // } // public String getEtherType() { // return etherType; // } // public void setEtherType( String etherType ) { // this.etherType = etherType; // } // // } // Path: src/main/java/com/glaurung/batMap/io/CorpseHandlerDataPersister.java import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import com.glaurung.batMap.gui.corpses.CorpseModel; package com.glaurung.batMap.io; public class CorpseHandlerDataPersister { private final static String FILENAME = "corpseHandler.conf"; private final static String DIRNAME = "conf";
public static void save( String baseDir, CorpseModel model ) {
kirby561/Android-Math-Notebook
src/rcos/main/recognition/LipiTKJNIInterface.java
// Path: src/rcos/main/Stroke.java // public class Stroke { // public Stroke() { // _points = new ArrayList<PointF>(); // _paint = new Paint(); // // // Just use a random color for now // _paint.setARGB(255, getRandColor(), getRandColor(), getRandColor()); // } // // /// Debundles the given stroke // public Stroke(Bundle stroke) { // this(); // // // Restore the points from the bundle // int pointCount = stroke.getInt("PointCount"); // for (int i = 0; i < pointCount; i++) { // float x = stroke.getFloat("PointX" + i); // float y = stroke.getFloat("PointY" + i); // addPoint(new PointF(x,y)); // } // // // Restore the Paint from the bundle // _paint.setColor(stroke.getInt("PaintColor")); // _paint.setStrokeWidth(stroke.getFloat("PaintStrokeWidth")); // } // // private int getRandColor() { // int rand = (int)Math.round(Math.random() * 255); // return rand; // } // // // Adds the given point to this stroke // public void addPoint(PointF point) { // _points.add(point); // // addPointToBoundingBox(point); // } // // // Expands the bounding box to accommodate the given point if necessary // private void addPointToBoundingBox(PointF point) { // if (_boundingBox == null) { // _boundingBox = new RectF(point.x, point.y, point.x, point.y); // return; // } // // // Expand the bounding box to include it, if necessary // _boundingBox.union(point.x, point.y); // } // // public ArrayList<PointF> getPoints() { // return _points; // } // // public int getNumberOfPoints() { // return _points.size(); // } // // public PointF getPointAt(int index) { // return _points.get(index); // } // // public RectF getBoundingBox() { // return _boundingBox; // } // // public Paint getPaint() { // return _paint; // } // // public void setPaint(Paint p) { // _paint = p; // } // // /// Bundles this stroke // public Bundle bundle() { // Bundle result = new Bundle(); // // // Write the points into the bundle // result.putInt("PointCount", getNumberOfPoints()); // for (int i = 0; i < getNumberOfPoints(); i++) { // result.putFloat("PointX" + i, _points.get(i).x); // result.putFloat("PointY" + i, _points.get(i).y); // } // // // Write the Paint into the bundle // result.putInt("PaintColor", _paint.getColor()); // result.putFloat("PaintStrokeWidth", _paint.getStrokeWidth()); // // return result; // } // // // The list of points in this stroke // private ArrayList<PointF> _points; // // private RectF _boundingBox = null; // // // The paint to use when drawing this stroke // private Paint _paint; // }
import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import android.graphics.PointF; import android.util.Log; import rcos.main.Stroke;
readIni.readLine(); readIni.readLine(); readIni.readLine(); while((line=readIni.readLine())!=null) { splited_line = line.split(" "); Log.d("JNI_LOG","split 0="+splited_line[0]); Log.d("JNI_LOG","split 1="+splited_line[1]); splited_line[0] = splited_line[0].substring(0, splited_line[0].length()-1); //trim out = sign if(splited_line[0].equals((new Integer(id)).toString())) { splited_line[1] = splited_line[1].substring(2); temp = Integer.parseInt(splited_line[1], 16); return String.valueOf((char)temp); } } readIni.close(); } catch(Exception ex) { Log.d("JNI_LOG","Exception in getSymbolName Function"+ex.toString()); return "-1"; } return "0"; } public void initialize() { initializeNative(_lipiDirectory, _project); }
// Path: src/rcos/main/Stroke.java // public class Stroke { // public Stroke() { // _points = new ArrayList<PointF>(); // _paint = new Paint(); // // // Just use a random color for now // _paint.setARGB(255, getRandColor(), getRandColor(), getRandColor()); // } // // /// Debundles the given stroke // public Stroke(Bundle stroke) { // this(); // // // Restore the points from the bundle // int pointCount = stroke.getInt("PointCount"); // for (int i = 0; i < pointCount; i++) { // float x = stroke.getFloat("PointX" + i); // float y = stroke.getFloat("PointY" + i); // addPoint(new PointF(x,y)); // } // // // Restore the Paint from the bundle // _paint.setColor(stroke.getInt("PaintColor")); // _paint.setStrokeWidth(stroke.getFloat("PaintStrokeWidth")); // } // // private int getRandColor() { // int rand = (int)Math.round(Math.random() * 255); // return rand; // } // // // Adds the given point to this stroke // public void addPoint(PointF point) { // _points.add(point); // // addPointToBoundingBox(point); // } // // // Expands the bounding box to accommodate the given point if necessary // private void addPointToBoundingBox(PointF point) { // if (_boundingBox == null) { // _boundingBox = new RectF(point.x, point.y, point.x, point.y); // return; // } // // // Expand the bounding box to include it, if necessary // _boundingBox.union(point.x, point.y); // } // // public ArrayList<PointF> getPoints() { // return _points; // } // // public int getNumberOfPoints() { // return _points.size(); // } // // public PointF getPointAt(int index) { // return _points.get(index); // } // // public RectF getBoundingBox() { // return _boundingBox; // } // // public Paint getPaint() { // return _paint; // } // // public void setPaint(Paint p) { // _paint = p; // } // // /// Bundles this stroke // public Bundle bundle() { // Bundle result = new Bundle(); // // // Write the points into the bundle // result.putInt("PointCount", getNumberOfPoints()); // for (int i = 0; i < getNumberOfPoints(); i++) { // result.putFloat("PointX" + i, _points.get(i).x); // result.putFloat("PointY" + i, _points.get(i).y); // } // // // Write the Paint into the bundle // result.putInt("PaintColor", _paint.getColor()); // result.putFloat("PaintStrokeWidth", _paint.getStrokeWidth()); // // return result; // } // // // The list of points in this stroke // private ArrayList<PointF> _points; // // private RectF _boundingBox = null; // // // The paint to use when drawing this stroke // private Paint _paint; // } // Path: src/rcos/main/recognition/LipiTKJNIInterface.java import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import android.graphics.PointF; import android.util.Log; import rcos.main.Stroke; readIni.readLine(); readIni.readLine(); readIni.readLine(); while((line=readIni.readLine())!=null) { splited_line = line.split(" "); Log.d("JNI_LOG","split 0="+splited_line[0]); Log.d("JNI_LOG","split 1="+splited_line[1]); splited_line[0] = splited_line[0].substring(0, splited_line[0].length()-1); //trim out = sign if(splited_line[0].equals((new Integer(id)).toString())) { splited_line[1] = splited_line[1].substring(2); temp = Integer.parseInt(splited_line[1], 16); return String.valueOf((char)temp); } } readIni.close(); } catch(Exception ex) { Log.d("JNI_LOG","Exception in getSymbolName Function"+ex.toString()); return "-1"; } return "0"; } public void initialize() { initializeNative(_lipiDirectory, _project); }
public LipitkResult[] recognize(Stroke[] strokes) {
kirby561/Android-Math-Notebook
src/rcos/main/Page.java
// Path: src/rcos/main/recognition/Symbol.java // public class Symbol { // private Stroke[] _strokes; // private String _character; // // public Symbol(Stroke[] strokes, String character) { // _strokes = strokes; // _character = character; // } // // public Stroke[] getStrokes() { // return _strokes; // } // // public String getCharacter() { // return _character; // } // } // // Path: src/rcos/main/recognition/LipiTKJNIInterface.java // public class LipiTKJNIInterface { // private String _lipiDirectory; // private String _project; // // static // { // try { // System.loadLibrary("lipitk"); // System.loadLibrary("jnilink"); // } catch (Exception ex) { // System.out.println(ex.getMessage()); // } // } // // // Initializes the interface with a directory to look for projects in // // the name of the project to use for recognition, and the name // // of the ShapeRecognizer to use. // public LipiTKJNIInterface(String lipiDirectory, String project) { // _lipiDirectory = lipiDirectory; // _project = project; // } // // public String getSymbolName(int id,String project_config_dir) // { // String line; // int temp; // String [] splited_line= null; // try // { // File map_file = new File(project_config_dir+"unicodeMapfile_alphanumeric.ini"); // BufferedReader readIni = new BufferedReader(new FileReader(map_file)); // readIni.readLine(); // readIni.readLine(); // readIni.readLine(); // readIni.readLine(); // while((line=readIni.readLine())!=null) // { // splited_line = line.split(" "); // Log.d("JNI_LOG","split 0="+splited_line[0]); // Log.d("JNI_LOG","split 1="+splited_line[1]); // splited_line[0] = splited_line[0].substring(0, splited_line[0].length()-1); //trim out = sign // if(splited_line[0].equals((new Integer(id)).toString())) // { // splited_line[1] = splited_line[1].substring(2); // temp = Integer.parseInt(splited_line[1], 16); // return String.valueOf((char)temp); // } // } // readIni.close(); // } // catch(Exception ex) // { // Log.d("JNI_LOG","Exception in getSymbolName Function"+ex.toString()); // return "-1"; // } // return "0"; // } // // public void initialize() { // initializeNative(_lipiDirectory, _project); // } // // public LipitkResult[] recognize(Stroke[] strokes) { // LipitkResult[] results = recognizeNative(strokes, strokes.length); // // for (LipitkResult result : results) // Log.d("jni", "ShapeID = " + result.Id + " Confidence = " + result.Confidence); // // return results; // } // // // Initializes the LipiTKEngine in native code // private native void initializeNative(String lipiDirectory, String project); // // // Returns a list of results when recognizing the given list of strokes // private native LipitkResult[] recognizeNative(Stroke[] strokes, int numJStrokes); // // public String getLipiDirectory() { // return _lipiDirectory; // } // // } // // Path: src/rcos/main/recognition/LipitkResult.java // public class LipitkResult { // // public LipitkResult() { // Id = -1; // Confidence = 0; // } // // public int Id; // public float Confidence; // }
import java.util.ArrayList; import java.util.Date; import java.util.Timer; import java.util.TimerTask; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PointF; import android.os.Bundle; import android.util.Log; import rcos.main.recognition.Symbol; import rcos.main.recognition.LipiTKJNIInterface; import rcos.main.recognition.LipitkResult;
package rcos.main; // A page contains what strokes to draw, // and all the information about that // notbook page. public class Page { private static final long RecognitionTimeout = 1500; // milliseconds private ArrayList<Stroke> _strokes; private Stroke[] _recognitionStrokes; public Object StrokesLock = new Object(); private Stroke[] _background;
// Path: src/rcos/main/recognition/Symbol.java // public class Symbol { // private Stroke[] _strokes; // private String _character; // // public Symbol(Stroke[] strokes, String character) { // _strokes = strokes; // _character = character; // } // // public Stroke[] getStrokes() { // return _strokes; // } // // public String getCharacter() { // return _character; // } // } // // Path: src/rcos/main/recognition/LipiTKJNIInterface.java // public class LipiTKJNIInterface { // private String _lipiDirectory; // private String _project; // // static // { // try { // System.loadLibrary("lipitk"); // System.loadLibrary("jnilink"); // } catch (Exception ex) { // System.out.println(ex.getMessage()); // } // } // // // Initializes the interface with a directory to look for projects in // // the name of the project to use for recognition, and the name // // of the ShapeRecognizer to use. // public LipiTKJNIInterface(String lipiDirectory, String project) { // _lipiDirectory = lipiDirectory; // _project = project; // } // // public String getSymbolName(int id,String project_config_dir) // { // String line; // int temp; // String [] splited_line= null; // try // { // File map_file = new File(project_config_dir+"unicodeMapfile_alphanumeric.ini"); // BufferedReader readIni = new BufferedReader(new FileReader(map_file)); // readIni.readLine(); // readIni.readLine(); // readIni.readLine(); // readIni.readLine(); // while((line=readIni.readLine())!=null) // { // splited_line = line.split(" "); // Log.d("JNI_LOG","split 0="+splited_line[0]); // Log.d("JNI_LOG","split 1="+splited_line[1]); // splited_line[0] = splited_line[0].substring(0, splited_line[0].length()-1); //trim out = sign // if(splited_line[0].equals((new Integer(id)).toString())) // { // splited_line[1] = splited_line[1].substring(2); // temp = Integer.parseInt(splited_line[1], 16); // return String.valueOf((char)temp); // } // } // readIni.close(); // } // catch(Exception ex) // { // Log.d("JNI_LOG","Exception in getSymbolName Function"+ex.toString()); // return "-1"; // } // return "0"; // } // // public void initialize() { // initializeNative(_lipiDirectory, _project); // } // // public LipitkResult[] recognize(Stroke[] strokes) { // LipitkResult[] results = recognizeNative(strokes, strokes.length); // // for (LipitkResult result : results) // Log.d("jni", "ShapeID = " + result.Id + " Confidence = " + result.Confidence); // // return results; // } // // // Initializes the LipiTKEngine in native code // private native void initializeNative(String lipiDirectory, String project); // // // Returns a list of results when recognizing the given list of strokes // private native LipitkResult[] recognizeNative(Stroke[] strokes, int numJStrokes); // // public String getLipiDirectory() { // return _lipiDirectory; // } // // } // // Path: src/rcos/main/recognition/LipitkResult.java // public class LipitkResult { // // public LipitkResult() { // Id = -1; // Confidence = 0; // } // // public int Id; // public float Confidence; // } // Path: src/rcos/main/Page.java import java.util.ArrayList; import java.util.Date; import java.util.Timer; import java.util.TimerTask; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PointF; import android.os.Bundle; import android.util.Log; import rcos.main.recognition.Symbol; import rcos.main.recognition.LipiTKJNIInterface; import rcos.main.recognition.LipitkResult; package rcos.main; // A page contains what strokes to draw, // and all the information about that // notbook page. public class Page { private static final long RecognitionTimeout = 1500; // milliseconds private ArrayList<Stroke> _strokes; private Stroke[] _recognitionStrokes; public Object StrokesLock = new Object(); private Stroke[] _background;
private ArrayList<Symbol> _symbols;
kirby561/Android-Math-Notebook
src/rcos/main/Page.java
// Path: src/rcos/main/recognition/Symbol.java // public class Symbol { // private Stroke[] _strokes; // private String _character; // // public Symbol(Stroke[] strokes, String character) { // _strokes = strokes; // _character = character; // } // // public Stroke[] getStrokes() { // return _strokes; // } // // public String getCharacter() { // return _character; // } // } // // Path: src/rcos/main/recognition/LipiTKJNIInterface.java // public class LipiTKJNIInterface { // private String _lipiDirectory; // private String _project; // // static // { // try { // System.loadLibrary("lipitk"); // System.loadLibrary("jnilink"); // } catch (Exception ex) { // System.out.println(ex.getMessage()); // } // } // // // Initializes the interface with a directory to look for projects in // // the name of the project to use for recognition, and the name // // of the ShapeRecognizer to use. // public LipiTKJNIInterface(String lipiDirectory, String project) { // _lipiDirectory = lipiDirectory; // _project = project; // } // // public String getSymbolName(int id,String project_config_dir) // { // String line; // int temp; // String [] splited_line= null; // try // { // File map_file = new File(project_config_dir+"unicodeMapfile_alphanumeric.ini"); // BufferedReader readIni = new BufferedReader(new FileReader(map_file)); // readIni.readLine(); // readIni.readLine(); // readIni.readLine(); // readIni.readLine(); // while((line=readIni.readLine())!=null) // { // splited_line = line.split(" "); // Log.d("JNI_LOG","split 0="+splited_line[0]); // Log.d("JNI_LOG","split 1="+splited_line[1]); // splited_line[0] = splited_line[0].substring(0, splited_line[0].length()-1); //trim out = sign // if(splited_line[0].equals((new Integer(id)).toString())) // { // splited_line[1] = splited_line[1].substring(2); // temp = Integer.parseInt(splited_line[1], 16); // return String.valueOf((char)temp); // } // } // readIni.close(); // } // catch(Exception ex) // { // Log.d("JNI_LOG","Exception in getSymbolName Function"+ex.toString()); // return "-1"; // } // return "0"; // } // // public void initialize() { // initializeNative(_lipiDirectory, _project); // } // // public LipitkResult[] recognize(Stroke[] strokes) { // LipitkResult[] results = recognizeNative(strokes, strokes.length); // // for (LipitkResult result : results) // Log.d("jni", "ShapeID = " + result.Id + " Confidence = " + result.Confidence); // // return results; // } // // // Initializes the LipiTKEngine in native code // private native void initializeNative(String lipiDirectory, String project); // // // Returns a list of results when recognizing the given list of strokes // private native LipitkResult[] recognizeNative(Stroke[] strokes, int numJStrokes); // // public String getLipiDirectory() { // return _lipiDirectory; // } // // } // // Path: src/rcos/main/recognition/LipitkResult.java // public class LipitkResult { // // public LipitkResult() { // Id = -1; // Confidence = 0; // } // // public int Id; // public float Confidence; // }
import java.util.ArrayList; import java.util.Date; import java.util.Timer; import java.util.TimerTask; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PointF; import android.os.Bundle; import android.util.Log; import rcos.main.recognition.Symbol; import rcos.main.recognition.LipiTKJNIInterface; import rcos.main.recognition.LipitkResult;
package rcos.main; // A page contains what strokes to draw, // and all the information about that // notbook page. public class Page { private static final long RecognitionTimeout = 1500; // milliseconds private ArrayList<Stroke> _strokes; private Stroke[] _recognitionStrokes; public Object StrokesLock = new Object(); private Stroke[] _background; private ArrayList<Symbol> _symbols; private Timer _timer;
// Path: src/rcos/main/recognition/Symbol.java // public class Symbol { // private Stroke[] _strokes; // private String _character; // // public Symbol(Stroke[] strokes, String character) { // _strokes = strokes; // _character = character; // } // // public Stroke[] getStrokes() { // return _strokes; // } // // public String getCharacter() { // return _character; // } // } // // Path: src/rcos/main/recognition/LipiTKJNIInterface.java // public class LipiTKJNIInterface { // private String _lipiDirectory; // private String _project; // // static // { // try { // System.loadLibrary("lipitk"); // System.loadLibrary("jnilink"); // } catch (Exception ex) { // System.out.println(ex.getMessage()); // } // } // // // Initializes the interface with a directory to look for projects in // // the name of the project to use for recognition, and the name // // of the ShapeRecognizer to use. // public LipiTKJNIInterface(String lipiDirectory, String project) { // _lipiDirectory = lipiDirectory; // _project = project; // } // // public String getSymbolName(int id,String project_config_dir) // { // String line; // int temp; // String [] splited_line= null; // try // { // File map_file = new File(project_config_dir+"unicodeMapfile_alphanumeric.ini"); // BufferedReader readIni = new BufferedReader(new FileReader(map_file)); // readIni.readLine(); // readIni.readLine(); // readIni.readLine(); // readIni.readLine(); // while((line=readIni.readLine())!=null) // { // splited_line = line.split(" "); // Log.d("JNI_LOG","split 0="+splited_line[0]); // Log.d("JNI_LOG","split 1="+splited_line[1]); // splited_line[0] = splited_line[0].substring(0, splited_line[0].length()-1); //trim out = sign // if(splited_line[0].equals((new Integer(id)).toString())) // { // splited_line[1] = splited_line[1].substring(2); // temp = Integer.parseInt(splited_line[1], 16); // return String.valueOf((char)temp); // } // } // readIni.close(); // } // catch(Exception ex) // { // Log.d("JNI_LOG","Exception in getSymbolName Function"+ex.toString()); // return "-1"; // } // return "0"; // } // // public void initialize() { // initializeNative(_lipiDirectory, _project); // } // // public LipitkResult[] recognize(Stroke[] strokes) { // LipitkResult[] results = recognizeNative(strokes, strokes.length); // // for (LipitkResult result : results) // Log.d("jni", "ShapeID = " + result.Id + " Confidence = " + result.Confidence); // // return results; // } // // // Initializes the LipiTKEngine in native code // private native void initializeNative(String lipiDirectory, String project); // // // Returns a list of results when recognizing the given list of strokes // private native LipitkResult[] recognizeNative(Stroke[] strokes, int numJStrokes); // // public String getLipiDirectory() { // return _lipiDirectory; // } // // } // // Path: src/rcos/main/recognition/LipitkResult.java // public class LipitkResult { // // public LipitkResult() { // Id = -1; // Confidence = 0; // } // // public int Id; // public float Confidence; // } // Path: src/rcos/main/Page.java import java.util.ArrayList; import java.util.Date; import java.util.Timer; import java.util.TimerTask; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PointF; import android.os.Bundle; import android.util.Log; import rcos.main.recognition.Symbol; import rcos.main.recognition.LipiTKJNIInterface; import rcos.main.recognition.LipitkResult; package rcos.main; // A page contains what strokes to draw, // and all the information about that // notbook page. public class Page { private static final long RecognitionTimeout = 1500; // milliseconds private ArrayList<Stroke> _strokes; private Stroke[] _recognitionStrokes; public Object StrokesLock = new Object(); private Stroke[] _background; private ArrayList<Symbol> _symbols; private Timer _timer;
private LipiTKJNIInterface _recognizer;
kirby561/Android-Math-Notebook
src/rcos/main/Page.java
// Path: src/rcos/main/recognition/Symbol.java // public class Symbol { // private Stroke[] _strokes; // private String _character; // // public Symbol(Stroke[] strokes, String character) { // _strokes = strokes; // _character = character; // } // // public Stroke[] getStrokes() { // return _strokes; // } // // public String getCharacter() { // return _character; // } // } // // Path: src/rcos/main/recognition/LipiTKJNIInterface.java // public class LipiTKJNIInterface { // private String _lipiDirectory; // private String _project; // // static // { // try { // System.loadLibrary("lipitk"); // System.loadLibrary("jnilink"); // } catch (Exception ex) { // System.out.println(ex.getMessage()); // } // } // // // Initializes the interface with a directory to look for projects in // // the name of the project to use for recognition, and the name // // of the ShapeRecognizer to use. // public LipiTKJNIInterface(String lipiDirectory, String project) { // _lipiDirectory = lipiDirectory; // _project = project; // } // // public String getSymbolName(int id,String project_config_dir) // { // String line; // int temp; // String [] splited_line= null; // try // { // File map_file = new File(project_config_dir+"unicodeMapfile_alphanumeric.ini"); // BufferedReader readIni = new BufferedReader(new FileReader(map_file)); // readIni.readLine(); // readIni.readLine(); // readIni.readLine(); // readIni.readLine(); // while((line=readIni.readLine())!=null) // { // splited_line = line.split(" "); // Log.d("JNI_LOG","split 0="+splited_line[0]); // Log.d("JNI_LOG","split 1="+splited_line[1]); // splited_line[0] = splited_line[0].substring(0, splited_line[0].length()-1); //trim out = sign // if(splited_line[0].equals((new Integer(id)).toString())) // { // splited_line[1] = splited_line[1].substring(2); // temp = Integer.parseInt(splited_line[1], 16); // return String.valueOf((char)temp); // } // } // readIni.close(); // } // catch(Exception ex) // { // Log.d("JNI_LOG","Exception in getSymbolName Function"+ex.toString()); // return "-1"; // } // return "0"; // } // // public void initialize() { // initializeNative(_lipiDirectory, _project); // } // // public LipitkResult[] recognize(Stroke[] strokes) { // LipitkResult[] results = recognizeNative(strokes, strokes.length); // // for (LipitkResult result : results) // Log.d("jni", "ShapeID = " + result.Id + " Confidence = " + result.Confidence); // // return results; // } // // // Initializes the LipiTKEngine in native code // private native void initializeNative(String lipiDirectory, String project); // // // Returns a list of results when recognizing the given list of strokes // private native LipitkResult[] recognizeNative(Stroke[] strokes, int numJStrokes); // // public String getLipiDirectory() { // return _lipiDirectory; // } // // } // // Path: src/rcos/main/recognition/LipitkResult.java // public class LipitkResult { // // public LipitkResult() { // Id = -1; // Confidence = 0; // } // // public int Id; // public float Confidence; // }
import java.util.ArrayList; import java.util.Date; import java.util.Timer; import java.util.TimerTask; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PointF; import android.os.Bundle; import android.util.Log; import rcos.main.recognition.Symbol; import rcos.main.recognition.LipiTKJNIInterface; import rcos.main.recognition.LipitkResult;
public void addStroke(Stroke stroke) { synchronized (StrokesLock) { _strokes.add(stroke); Log.w("Page", "Added Stroke"); if (!_enableRecognition) return; // Start a timer for recognition (or restart it if it's going) if (_timer != null) { _timer.cancel(); _timer.purge(); _timer = null; if (_recognitionStrokes != null) for (Stroke s : _recognitionStrokes) _strokes.add(s); } _recognitionStrokes = new Stroke[_strokes.size()]; for (int s = 0; s < _strokes.size(); s++) _recognitionStrokes[s] = _strokes.get(s); _strokes.clear(); TimerTask task = new TimerTask() { @Override public void run() { synchronized (StrokesLock) { // Recognize our current strokes Log.w("Page", "Timer Event");
// Path: src/rcos/main/recognition/Symbol.java // public class Symbol { // private Stroke[] _strokes; // private String _character; // // public Symbol(Stroke[] strokes, String character) { // _strokes = strokes; // _character = character; // } // // public Stroke[] getStrokes() { // return _strokes; // } // // public String getCharacter() { // return _character; // } // } // // Path: src/rcos/main/recognition/LipiTKJNIInterface.java // public class LipiTKJNIInterface { // private String _lipiDirectory; // private String _project; // // static // { // try { // System.loadLibrary("lipitk"); // System.loadLibrary("jnilink"); // } catch (Exception ex) { // System.out.println(ex.getMessage()); // } // } // // // Initializes the interface with a directory to look for projects in // // the name of the project to use for recognition, and the name // // of the ShapeRecognizer to use. // public LipiTKJNIInterface(String lipiDirectory, String project) { // _lipiDirectory = lipiDirectory; // _project = project; // } // // public String getSymbolName(int id,String project_config_dir) // { // String line; // int temp; // String [] splited_line= null; // try // { // File map_file = new File(project_config_dir+"unicodeMapfile_alphanumeric.ini"); // BufferedReader readIni = new BufferedReader(new FileReader(map_file)); // readIni.readLine(); // readIni.readLine(); // readIni.readLine(); // readIni.readLine(); // while((line=readIni.readLine())!=null) // { // splited_line = line.split(" "); // Log.d("JNI_LOG","split 0="+splited_line[0]); // Log.d("JNI_LOG","split 1="+splited_line[1]); // splited_line[0] = splited_line[0].substring(0, splited_line[0].length()-1); //trim out = sign // if(splited_line[0].equals((new Integer(id)).toString())) // { // splited_line[1] = splited_line[1].substring(2); // temp = Integer.parseInt(splited_line[1], 16); // return String.valueOf((char)temp); // } // } // readIni.close(); // } // catch(Exception ex) // { // Log.d("JNI_LOG","Exception in getSymbolName Function"+ex.toString()); // return "-1"; // } // return "0"; // } // // public void initialize() { // initializeNative(_lipiDirectory, _project); // } // // public LipitkResult[] recognize(Stroke[] strokes) { // LipitkResult[] results = recognizeNative(strokes, strokes.length); // // for (LipitkResult result : results) // Log.d("jni", "ShapeID = " + result.Id + " Confidence = " + result.Confidence); // // return results; // } // // // Initializes the LipiTKEngine in native code // private native void initializeNative(String lipiDirectory, String project); // // // Returns a list of results when recognizing the given list of strokes // private native LipitkResult[] recognizeNative(Stroke[] strokes, int numJStrokes); // // public String getLipiDirectory() { // return _lipiDirectory; // } // // } // // Path: src/rcos/main/recognition/LipitkResult.java // public class LipitkResult { // // public LipitkResult() { // Id = -1; // Confidence = 0; // } // // public int Id; // public float Confidence; // } // Path: src/rcos/main/Page.java import java.util.ArrayList; import java.util.Date; import java.util.Timer; import java.util.TimerTask; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PointF; import android.os.Bundle; import android.util.Log; import rcos.main.recognition.Symbol; import rcos.main.recognition.LipiTKJNIInterface; import rcos.main.recognition.LipitkResult; public void addStroke(Stroke stroke) { synchronized (StrokesLock) { _strokes.add(stroke); Log.w("Page", "Added Stroke"); if (!_enableRecognition) return; // Start a timer for recognition (or restart it if it's going) if (_timer != null) { _timer.cancel(); _timer.purge(); _timer = null; if (_recognitionStrokes != null) for (Stroke s : _recognitionStrokes) _strokes.add(s); } _recognitionStrokes = new Stroke[_strokes.size()]; for (int s = 0; s < _strokes.size(); s++) _recognitionStrokes[s] = _strokes.get(s); _strokes.clear(); TimerTask task = new TimerTask() { @Override public void run() { synchronized (StrokesLock) { // Recognize our current strokes Log.w("Page", "Timer Event");
LipitkResult[] results = _recognizer.recognize(_recognitionStrokes);
kirby561/Android-Math-Notebook
src/rcos/main/CommandManager.java
// Path: src/rcos/main/commands/Command.java // public interface Command { // void doCommand(); // void undo(); // boolean isUndoable(); // }
import java.util.Stack; import rcos.main.commands.Command;
package rcos.main; public class CommandManager { private int _maxUndos;
// Path: src/rcos/main/commands/Command.java // public interface Command { // void doCommand(); // void undo(); // boolean isUndoable(); // } // Path: src/rcos/main/CommandManager.java import java.util.Stack; import rcos.main.commands.Command; package rcos.main; public class CommandManager { private int _maxUndos;
private Stack<Command> _commands;
dkharrat/NexusDialog
nexusdialog/src/main/java/com/github/dkharrat/nexusdialog/controllers/LabeledFieldController.java
// Path: nexusdialog/src/main/java/com/github/dkharrat/nexusdialog/FormElementController.java // public abstract class FormElementController { // private final Context context; // private final String name; // private FormModel model; // private View view; // // /** // * Constructs a new instance with the specified name. // * // * @param ctx the Android context // * @param name the name of this instance // */ // protected FormElementController(Context ctx, String name) { // this.context = ctx; // this.name = name; // } // // /** // * Returns the Android context associated with this element. // * // * @return the Android context associated with this element // */ // public Context getContext() { // return context; // } // // /** // * Returns the name of this form element. // * // * @return the name of the element // */ // public String getName() { // return name; // } // // void setModel(FormModel model) { // this.model = model; // } // // /** // * Returns the associated model of this form element. // * // * @return the associated model of this form element // */ // public FormModel getModel() { // return model; // } // // /** // * Returns the associated view for this element. // * // * @return the view for this element // */ // public View getView() { // if (view == null) { // view = createView(); // } // return view; // } // // /** // * Indicates if the view has been created. // * // * @return true if the view was created, or false otherwise. // */ // public boolean isViewCreated() { // return view != null; // } // // /** // * Constructs the view for this element. // * // * @return a newly created view for this element // */ // protected abstract View createView(); // // /** // * Refreshes the view of this element to reflect current model. // */ // public abstract void refresh(); // // /** // * Display an error message on the element. // * // * @param message The message to display. // */ // public abstract void setError(String message); // } // // Path: nexusdialog/src/main/java/com/github/dkharrat/nexusdialog/validations/InputValidator.java // public interface InputValidator { // /** // * Defines the validity of an object against a specific requirement. // * // * @param value The input value to check. // * @param fieldName The name of the field, // * can be used to generate a specific error message. // * @param fieldLabel The label of the field, // * can be used to generate a specific error message. // * @return ValidationError If the input does not pass the validation requirements, null otherwise. // */ // ValidationError validate(Object value, String fieldName, String fieldLabel); // } // // Path: nexusdialog/src/main/java/com/github/dkharrat/nexusdialog/validations/RequiredFieldValidator.java // public class RequiredFieldValidator implements InputValidator { // @Override // public ValidationError validate(Object value, String fieldName, String fieldLabel) { // if (value == null || (value instanceof String && TextUtils.isEmpty((String) value))) { // return new RequiredField(fieldName, fieldLabel); // } // return null; // } // // /** // * Makes every instances of {@link RequiredFieldValidator} equal. // * // * @param o The object to compare. // * @return true if o is also an instance of RequiredFieldValidator, false otherwise. // */ // @Override // public boolean equals(Object o) { // return super.equals(o) || o != null && getClass() == o.getClass(); // } // // /** // * Every instance of {{@link RequiredFieldValidator}} share the same hashcode. // * // * @return 0 // */ // @Override // public int hashCode() { // return 0; // } // } // // Path: nexusdialog/src/main/java/com/github/dkharrat/nexusdialog/validations/ValidationError.java // public abstract class ValidationError { // private final String fieldName; // private final String fieldLabel; // // /** // * Creates a new instance with the specified field name. // * // * @param fieldName the field name // * @param fieldLabel the field label // */ // public ValidationError(String fieldName, String fieldLabel) { // this.fieldName = fieldName; // this.fieldLabel = fieldLabel; // } // // /** // * Returns the name of the field associated with the validation error. // * // * @return the name of the field that has the error // */ // public String getFieldName() { // return fieldName; // } // // /** // * Returns the label associated to the field. // * // * @return the display value of the field. // */ // public String getFieldLabel() { // return fieldLabel; // } // // /** // * Returns a human-readable description of the validation error. // * // * @param resources the application's resources // * @return a string describing the error // */ // public abstract String getMessage(Resources resources); // }
import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.widget.FrameLayout; import android.widget.TextView; import com.github.dkharrat.nexusdialog.FormElementController; import com.github.dkharrat.nexusdialog.R; import com.github.dkharrat.nexusdialog.validations.InputValidator; import com.github.dkharrat.nexusdialog.validations.RequiredFieldValidator; import com.github.dkharrat.nexusdialog.validations.ValidationError; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set;
package com.github.dkharrat.nexusdialog.controllers; /** * An abstract class that represents a generic form field with an associated label. */ public abstract class LabeledFieldController extends FormElementController { private static final RequiredFieldValidator REQUIRED_FIELD_VALIDATOR = new RequiredFieldValidator(); private final String labelText; private View fieldView; private TextView errorView;
// Path: nexusdialog/src/main/java/com/github/dkharrat/nexusdialog/FormElementController.java // public abstract class FormElementController { // private final Context context; // private final String name; // private FormModel model; // private View view; // // /** // * Constructs a new instance with the specified name. // * // * @param ctx the Android context // * @param name the name of this instance // */ // protected FormElementController(Context ctx, String name) { // this.context = ctx; // this.name = name; // } // // /** // * Returns the Android context associated with this element. // * // * @return the Android context associated with this element // */ // public Context getContext() { // return context; // } // // /** // * Returns the name of this form element. // * // * @return the name of the element // */ // public String getName() { // return name; // } // // void setModel(FormModel model) { // this.model = model; // } // // /** // * Returns the associated model of this form element. // * // * @return the associated model of this form element // */ // public FormModel getModel() { // return model; // } // // /** // * Returns the associated view for this element. // * // * @return the view for this element // */ // public View getView() { // if (view == null) { // view = createView(); // } // return view; // } // // /** // * Indicates if the view has been created. // * // * @return true if the view was created, or false otherwise. // */ // public boolean isViewCreated() { // return view != null; // } // // /** // * Constructs the view for this element. // * // * @return a newly created view for this element // */ // protected abstract View createView(); // // /** // * Refreshes the view of this element to reflect current model. // */ // public abstract void refresh(); // // /** // * Display an error message on the element. // * // * @param message The message to display. // */ // public abstract void setError(String message); // } // // Path: nexusdialog/src/main/java/com/github/dkharrat/nexusdialog/validations/InputValidator.java // public interface InputValidator { // /** // * Defines the validity of an object against a specific requirement. // * // * @param value The input value to check. // * @param fieldName The name of the field, // * can be used to generate a specific error message. // * @param fieldLabel The label of the field, // * can be used to generate a specific error message. // * @return ValidationError If the input does not pass the validation requirements, null otherwise. // */ // ValidationError validate(Object value, String fieldName, String fieldLabel); // } // // Path: nexusdialog/src/main/java/com/github/dkharrat/nexusdialog/validations/RequiredFieldValidator.java // public class RequiredFieldValidator implements InputValidator { // @Override // public ValidationError validate(Object value, String fieldName, String fieldLabel) { // if (value == null || (value instanceof String && TextUtils.isEmpty((String) value))) { // return new RequiredField(fieldName, fieldLabel); // } // return null; // } // // /** // * Makes every instances of {@link RequiredFieldValidator} equal. // * // * @param o The object to compare. // * @return true if o is also an instance of RequiredFieldValidator, false otherwise. // */ // @Override // public boolean equals(Object o) { // return super.equals(o) || o != null && getClass() == o.getClass(); // } // // /** // * Every instance of {{@link RequiredFieldValidator}} share the same hashcode. // * // * @return 0 // */ // @Override // public int hashCode() { // return 0; // } // } // // Path: nexusdialog/src/main/java/com/github/dkharrat/nexusdialog/validations/ValidationError.java // public abstract class ValidationError { // private final String fieldName; // private final String fieldLabel; // // /** // * Creates a new instance with the specified field name. // * // * @param fieldName the field name // * @param fieldLabel the field label // */ // public ValidationError(String fieldName, String fieldLabel) { // this.fieldName = fieldName; // this.fieldLabel = fieldLabel; // } // // /** // * Returns the name of the field associated with the validation error. // * // * @return the name of the field that has the error // */ // public String getFieldName() { // return fieldName; // } // // /** // * Returns the label associated to the field. // * // * @return the display value of the field. // */ // public String getFieldLabel() { // return fieldLabel; // } // // /** // * Returns a human-readable description of the validation error. // * // * @param resources the application's resources // * @return a string describing the error // */ // public abstract String getMessage(Resources resources); // } // Path: nexusdialog/src/main/java/com/github/dkharrat/nexusdialog/controllers/LabeledFieldController.java import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.widget.FrameLayout; import android.widget.TextView; import com.github.dkharrat.nexusdialog.FormElementController; import com.github.dkharrat.nexusdialog.R; import com.github.dkharrat.nexusdialog.validations.InputValidator; import com.github.dkharrat.nexusdialog.validations.RequiredFieldValidator; import com.github.dkharrat.nexusdialog.validations.ValidationError; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; package com.github.dkharrat.nexusdialog.controllers; /** * An abstract class that represents a generic form field with an associated label. */ public abstract class LabeledFieldController extends FormElementController { private static final RequiredFieldValidator REQUIRED_FIELD_VALIDATOR = new RequiredFieldValidator(); private final String labelText; private View fieldView; private TextView errorView;
private Set<InputValidator> validators;