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
czy1121/sdk3rd
ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/share/ShareData.java
// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/share/image/resource/ImageResource.java // public interface ImageResource { // // String toUri(); // // Bitmap toBitmap(); // // byte[] toBytes(); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/share/media/IMediaObject.java // public interface IMediaObject { // int TYPE_INVALID = 0; // int TYPE_TEXT = 1; // int TYPE_IMAGE = 2; // int TYPE_TEXT_IMAGE = 3; // int TYPE_EMOJI = 4; // int TYPE_MUSIC = 5; // int TYPE_VIDEO = 6; // int TYPE_WEB = 7; // int TYPE_FILE = 8; // // int type(); // }
import android.text.TextUtils; import ezy.sdk3rd.social.share.image.resource.ImageResource; import ezy.sdk3rd.social.share.media.IMediaObject;
package ezy.sdk3rd.social.share; public class ShareData { public static final int THUMB_LIMIT = 24576; public static final int THUMB_LIMIT_WX = 32*1024; public static final int IMAGE_LIMIT = 491520; public static final String DEFAULT_TITLE = "这里是标题"; public static final String DEFAULT_DESCRIPTION = "这里是描述"; public String url = ""; public String text = ""; public String title = ""; public String description = "";
// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/share/image/resource/ImageResource.java // public interface ImageResource { // // String toUri(); // // Bitmap toBitmap(); // // byte[] toBytes(); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/share/media/IMediaObject.java // public interface IMediaObject { // int TYPE_INVALID = 0; // int TYPE_TEXT = 1; // int TYPE_IMAGE = 2; // int TYPE_TEXT_IMAGE = 3; // int TYPE_EMOJI = 4; // int TYPE_MUSIC = 5; // int TYPE_VIDEO = 6; // int TYPE_WEB = 7; // int TYPE_FILE = 8; // // int type(); // } // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/share/ShareData.java import android.text.TextUtils; import ezy.sdk3rd.social.share.image.resource.ImageResource; import ezy.sdk3rd.social.share.media.IMediaObject; package ezy.sdk3rd.social.share; public class ShareData { public static final int THUMB_LIMIT = 24576; public static final int THUMB_LIMIT_WX = 32*1024; public static final int IMAGE_LIMIT = 491520; public static final String DEFAULT_TITLE = "这里是标题"; public static final String DEFAULT_DESCRIPTION = "这里是描述"; public String url = ""; public String text = ""; public String title = ""; public String description = "";
public ImageResource thumb;
czy1121/sdk3rd
ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/share/ShareData.java
// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/share/image/resource/ImageResource.java // public interface ImageResource { // // String toUri(); // // Bitmap toBitmap(); // // byte[] toBytes(); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/share/media/IMediaObject.java // public interface IMediaObject { // int TYPE_INVALID = 0; // int TYPE_TEXT = 1; // int TYPE_IMAGE = 2; // int TYPE_TEXT_IMAGE = 3; // int TYPE_EMOJI = 4; // int TYPE_MUSIC = 5; // int TYPE_VIDEO = 6; // int TYPE_WEB = 7; // int TYPE_FILE = 8; // // int type(); // }
import android.text.TextUtils; import ezy.sdk3rd.social.share.image.resource.ImageResource; import ezy.sdk3rd.social.share.media.IMediaObject;
package ezy.sdk3rd.social.share; public class ShareData { public static final int THUMB_LIMIT = 24576; public static final int THUMB_LIMIT_WX = 32*1024; public static final int IMAGE_LIMIT = 491520; public static final String DEFAULT_TITLE = "这里是标题"; public static final String DEFAULT_DESCRIPTION = "这里是描述"; public String url = ""; public String text = ""; public String title = ""; public String description = ""; public ImageResource thumb;
// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/share/image/resource/ImageResource.java // public interface ImageResource { // // String toUri(); // // Bitmap toBitmap(); // // byte[] toBytes(); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/share/media/IMediaObject.java // public interface IMediaObject { // int TYPE_INVALID = 0; // int TYPE_TEXT = 1; // int TYPE_IMAGE = 2; // int TYPE_TEXT_IMAGE = 3; // int TYPE_EMOJI = 4; // int TYPE_MUSIC = 5; // int TYPE_VIDEO = 6; // int TYPE_WEB = 7; // int TYPE_FILE = 8; // // int type(); // } // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/share/ShareData.java import android.text.TextUtils; import ezy.sdk3rd.social.share.image.resource.ImageResource; import ezy.sdk3rd.social.share.media.IMediaObject; package ezy.sdk3rd.social.share; public class ShareData { public static final int THUMB_LIMIT = 24576; public static final int THUMB_LIMIT_WX = 32*1024; public static final int IMAGE_LIMIT = 491520; public static final String DEFAULT_TITLE = "这里是标题"; public static final String DEFAULT_DESCRIPTION = "这里是描述"; public String url = ""; public String text = ""; public String title = ""; public String description = ""; public ImageResource thumb;
public IMediaObject media;
czy1121/sdk3rd
ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/platforms/weixin/WXPayment.java
// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/payment/IPayable.java // public interface IPayable extends IResult { // void pay(String data, OnCallback<String> callback); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/OnCallback.java // public interface OnCallback<T> { // void onStarted(Activity activity); // void onCompleted(Activity activity); // void onSucceed(Activity activity, T result); // void onFailed(Activity activity, int code, String message); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/Platform.java // public class Platform { // final String name; // final String appId; // // Map<String, String> extra; // // public Platform(@NonNull String name, @NonNull String appId) { // this.name = name; // this.appId = appId; // } // // public String getName() { // return name; // } // // public String getAppId() { // return appId; // } // // public String extra(String key) { // return extra == null ? "" : extra.get(key); // } // // public Platform extra(String key, String value) { // if (extra == null) { // extra = new HashMap<>(); // } // extra.put(key, value); // return this; // } // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/ResultCode.java // public class ResultCode { // public static final int RESULT_OK = 0; // public static final int RESULT_PENDING = 1; // public static final int RESULT_CANCELLED = 2; // public static final int RESULT_FAILED = 3; // // }
import android.app.Activity; import android.support.annotation.NonNull; import android.text.TextUtils; import android.util.Log; import com.tencent.mm.opensdk.modelpay.PayReq; import com.tencent.mm.opensdk.modelpay.PayResp; import com.tencent.mm.opensdk.openapi.WXAPIFactory; import org.json.JSONObject; import ezy.sdk3rd.social.payment.IPayable; import ezy.sdk3rd.social.sdk.OnCallback; import ezy.sdk3rd.social.sdk.Platform; import ezy.sdk3rd.social.sdk.ResultCode;
package ezy.sdk3rd.social.platforms.weixin; /** * Created by ezy on 17/3/18. */ public class WXPayment extends WXBase implements IPayable { WXPayment(Activity activity, Platform platform) { super(activity, platform); } @Override
// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/payment/IPayable.java // public interface IPayable extends IResult { // void pay(String data, OnCallback<String> callback); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/OnCallback.java // public interface OnCallback<T> { // void onStarted(Activity activity); // void onCompleted(Activity activity); // void onSucceed(Activity activity, T result); // void onFailed(Activity activity, int code, String message); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/Platform.java // public class Platform { // final String name; // final String appId; // // Map<String, String> extra; // // public Platform(@NonNull String name, @NonNull String appId) { // this.name = name; // this.appId = appId; // } // // public String getName() { // return name; // } // // public String getAppId() { // return appId; // } // // public String extra(String key) { // return extra == null ? "" : extra.get(key); // } // // public Platform extra(String key, String value) { // if (extra == null) { // extra = new HashMap<>(); // } // extra.put(key, value); // return this; // } // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/ResultCode.java // public class ResultCode { // public static final int RESULT_OK = 0; // public static final int RESULT_PENDING = 1; // public static final int RESULT_CANCELLED = 2; // public static final int RESULT_FAILED = 3; // // } // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/platforms/weixin/WXPayment.java import android.app.Activity; import android.support.annotation.NonNull; import android.text.TextUtils; import android.util.Log; import com.tencent.mm.opensdk.modelpay.PayReq; import com.tencent.mm.opensdk.modelpay.PayResp; import com.tencent.mm.opensdk.openapi.WXAPIFactory; import org.json.JSONObject; import ezy.sdk3rd.social.payment.IPayable; import ezy.sdk3rd.social.sdk.OnCallback; import ezy.sdk3rd.social.sdk.Platform; import ezy.sdk3rd.social.sdk.ResultCode; package ezy.sdk3rd.social.platforms.weixin; /** * Created by ezy on 17/3/18. */ public class WXPayment extends WXBase implements IPayable { WXPayment(Activity activity, Platform platform) { super(activity, platform); } @Override
public void pay(String data, final @NonNull OnCallback<String> callback) {
czy1121/sdk3rd
ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/platforms/weixin/WXPayment.java
// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/payment/IPayable.java // public interface IPayable extends IResult { // void pay(String data, OnCallback<String> callback); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/OnCallback.java // public interface OnCallback<T> { // void onStarted(Activity activity); // void onCompleted(Activity activity); // void onSucceed(Activity activity, T result); // void onFailed(Activity activity, int code, String message); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/Platform.java // public class Platform { // final String name; // final String appId; // // Map<String, String> extra; // // public Platform(@NonNull String name, @NonNull String appId) { // this.name = name; // this.appId = appId; // } // // public String getName() { // return name; // } // // public String getAppId() { // return appId; // } // // public String extra(String key) { // return extra == null ? "" : extra.get(key); // } // // public Platform extra(String key, String value) { // if (extra == null) { // extra = new HashMap<>(); // } // extra.put(key, value); // return this; // } // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/ResultCode.java // public class ResultCode { // public static final int RESULT_OK = 0; // public static final int RESULT_PENDING = 1; // public static final int RESULT_CANCELLED = 2; // public static final int RESULT_FAILED = 3; // // }
import android.app.Activity; import android.support.annotation.NonNull; import android.text.TextUtils; import android.util.Log; import com.tencent.mm.opensdk.modelpay.PayReq; import com.tencent.mm.opensdk.modelpay.PayResp; import com.tencent.mm.opensdk.openapi.WXAPIFactory; import org.json.JSONObject; import ezy.sdk3rd.social.payment.IPayable; import ezy.sdk3rd.social.sdk.OnCallback; import ezy.sdk3rd.social.sdk.Platform; import ezy.sdk3rd.social.sdk.ResultCode;
package ezy.sdk3rd.social.platforms.weixin; /** * Created by ezy on 17/3/18. */ public class WXPayment extends WXBase implements IPayable { WXPayment(Activity activity, Platform platform) { super(activity, platform); } @Override public void pay(String data, final @NonNull OnCallback<String> callback) { PayReq req = new PayReq(); Log.e(TAG, "data ==> " + data); try { JSONObject o = new JSONObject(data); req.appId = o.getString("appid"); req.partnerId = o.getString("partnerid"); req.prepayId = o.getString("prepayid"); req.packageValue = o.getString("package"); req.nonceStr = o.getString("noncestr"); req.timeStamp = o.getString("timestamp"); req.sign = o.getString("sign"); req.transaction = req.nonceStr; } catch (Exception e) { Log.e(TAG, "parse error ==> " + e.toString()); } if (!TextUtils.isEmpty(req.appId)) { mApi = WXAPIFactory.createWXAPI(mActivity.getApplicationContext(), req.appId, true); mApi.registerApp(req.appId); } mCallback = callback; if (!mApi.isWXAppInstalled()) {
// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/payment/IPayable.java // public interface IPayable extends IResult { // void pay(String data, OnCallback<String> callback); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/OnCallback.java // public interface OnCallback<T> { // void onStarted(Activity activity); // void onCompleted(Activity activity); // void onSucceed(Activity activity, T result); // void onFailed(Activity activity, int code, String message); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/Platform.java // public class Platform { // final String name; // final String appId; // // Map<String, String> extra; // // public Platform(@NonNull String name, @NonNull String appId) { // this.name = name; // this.appId = appId; // } // // public String getName() { // return name; // } // // public String getAppId() { // return appId; // } // // public String extra(String key) { // return extra == null ? "" : extra.get(key); // } // // public Platform extra(String key, String value) { // if (extra == null) { // extra = new HashMap<>(); // } // extra.put(key, value); // return this; // } // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/ResultCode.java // public class ResultCode { // public static final int RESULT_OK = 0; // public static final int RESULT_PENDING = 1; // public static final int RESULT_CANCELLED = 2; // public static final int RESULT_FAILED = 3; // // } // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/platforms/weixin/WXPayment.java import android.app.Activity; import android.support.annotation.NonNull; import android.text.TextUtils; import android.util.Log; import com.tencent.mm.opensdk.modelpay.PayReq; import com.tencent.mm.opensdk.modelpay.PayResp; import com.tencent.mm.opensdk.openapi.WXAPIFactory; import org.json.JSONObject; import ezy.sdk3rd.social.payment.IPayable; import ezy.sdk3rd.social.sdk.OnCallback; import ezy.sdk3rd.social.sdk.Platform; import ezy.sdk3rd.social.sdk.ResultCode; package ezy.sdk3rd.social.platforms.weixin; /** * Created by ezy on 17/3/18. */ public class WXPayment extends WXBase implements IPayable { WXPayment(Activity activity, Platform platform) { super(activity, platform); } @Override public void pay(String data, final @NonNull OnCallback<String> callback) { PayReq req = new PayReq(); Log.e(TAG, "data ==> " + data); try { JSONObject o = new JSONObject(data); req.appId = o.getString("appid"); req.partnerId = o.getString("partnerid"); req.prepayId = o.getString("prepayid"); req.packageValue = o.getString("package"); req.nonceStr = o.getString("noncestr"); req.timeStamp = o.getString("timestamp"); req.sign = o.getString("sign"); req.transaction = req.nonceStr; } catch (Exception e) { Log.e(TAG, "parse error ==> " + e.toString()); } if (!TextUtils.isEmpty(req.appId)) { mApi = WXAPIFactory.createWXAPI(mActivity.getApplicationContext(), req.appId, true); mApi.registerApp(req.appId); } mCallback = callback; if (!mApi.isWXAppInstalled()) {
mCallback.onFailed(mActivity, ResultCode.RESULT_FAILED, "您未安装微信!");
czy1121/sdk3rd
ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/platforms/alipay/Alipay.java
// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/payment/IPayable.java // public interface IPayable extends IResult { // void pay(String data, OnCallback<String> callback); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/OnCallback.java // public interface OnCallback<T> { // void onStarted(Activity activity); // void onCompleted(Activity activity); // void onSucceed(Activity activity, T result); // void onFailed(Activity activity, int code, String message); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/Platform.java // public class Platform { // final String name; // final String appId; // // Map<String, String> extra; // // public Platform(@NonNull String name, @NonNull String appId) { // this.name = name; // this.appId = appId; // } // // public String getName() { // return name; // } // // public String getAppId() { // return appId; // } // // public String extra(String key) { // return extra == null ? "" : extra.get(key); // } // // public Platform extra(String key, String value) { // if (extra == null) { // extra = new HashMap<>(); // } // extra.put(key, value); // return this; // } // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/ResultCode.java // public class ResultCode { // public static final int RESULT_OK = 0; // public static final int RESULT_PENDING = 1; // public static final int RESULT_CANCELLED = 2; // public static final int RESULT_FAILED = 3; // // }
import android.app.Activity; import android.content.Intent; import android.os.AsyncTask; import com.alipay.sdk.app.PayTask; import ezy.sdk3rd.social.payment.IPayable; import ezy.sdk3rd.social.sdk.OnCallback; import ezy.sdk3rd.social.sdk.Platform; import ezy.sdk3rd.social.sdk.ResultCode;
package ezy.sdk3rd.social.platforms.alipay; public class Alipay implements IPayable { public static final String TAG = "ezy.sdk3rd.alipay"; Activity mActivity;
// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/payment/IPayable.java // public interface IPayable extends IResult { // void pay(String data, OnCallback<String> callback); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/OnCallback.java // public interface OnCallback<T> { // void onStarted(Activity activity); // void onCompleted(Activity activity); // void onSucceed(Activity activity, T result); // void onFailed(Activity activity, int code, String message); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/Platform.java // public class Platform { // final String name; // final String appId; // // Map<String, String> extra; // // public Platform(@NonNull String name, @NonNull String appId) { // this.name = name; // this.appId = appId; // } // // public String getName() { // return name; // } // // public String getAppId() { // return appId; // } // // public String extra(String key) { // return extra == null ? "" : extra.get(key); // } // // public Platform extra(String key, String value) { // if (extra == null) { // extra = new HashMap<>(); // } // extra.put(key, value); // return this; // } // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/ResultCode.java // public class ResultCode { // public static final int RESULT_OK = 0; // public static final int RESULT_PENDING = 1; // public static final int RESULT_CANCELLED = 2; // public static final int RESULT_FAILED = 3; // // } // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/platforms/alipay/Alipay.java import android.app.Activity; import android.content.Intent; import android.os.AsyncTask; import com.alipay.sdk.app.PayTask; import ezy.sdk3rd.social.payment.IPayable; import ezy.sdk3rd.social.sdk.OnCallback; import ezy.sdk3rd.social.sdk.Platform; import ezy.sdk3rd.social.sdk.ResultCode; package ezy.sdk3rd.social.platforms.alipay; public class Alipay implements IPayable { public static final String TAG = "ezy.sdk3rd.alipay"; Activity mActivity;
Alipay(Activity activity, Platform platform) {
czy1121/sdk3rd
ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/platforms/alipay/Alipay.java
// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/payment/IPayable.java // public interface IPayable extends IResult { // void pay(String data, OnCallback<String> callback); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/OnCallback.java // public interface OnCallback<T> { // void onStarted(Activity activity); // void onCompleted(Activity activity); // void onSucceed(Activity activity, T result); // void onFailed(Activity activity, int code, String message); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/Platform.java // public class Platform { // final String name; // final String appId; // // Map<String, String> extra; // // public Platform(@NonNull String name, @NonNull String appId) { // this.name = name; // this.appId = appId; // } // // public String getName() { // return name; // } // // public String getAppId() { // return appId; // } // // public String extra(String key) { // return extra == null ? "" : extra.get(key); // } // // public Platform extra(String key, String value) { // if (extra == null) { // extra = new HashMap<>(); // } // extra.put(key, value); // return this; // } // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/ResultCode.java // public class ResultCode { // public static final int RESULT_OK = 0; // public static final int RESULT_PENDING = 1; // public static final int RESULT_CANCELLED = 2; // public static final int RESULT_FAILED = 3; // // }
import android.app.Activity; import android.content.Intent; import android.os.AsyncTask; import com.alipay.sdk.app.PayTask; import ezy.sdk3rd.social.payment.IPayable; import ezy.sdk3rd.social.sdk.OnCallback; import ezy.sdk3rd.social.sdk.Platform; import ezy.sdk3rd.social.sdk.ResultCode;
package ezy.sdk3rd.social.platforms.alipay; public class Alipay implements IPayable { public static final String TAG = "ezy.sdk3rd.alipay"; Activity mActivity; Alipay(Activity activity, Platform platform) { mActivity = activity; } @Override
// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/payment/IPayable.java // public interface IPayable extends IResult { // void pay(String data, OnCallback<String> callback); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/OnCallback.java // public interface OnCallback<T> { // void onStarted(Activity activity); // void onCompleted(Activity activity); // void onSucceed(Activity activity, T result); // void onFailed(Activity activity, int code, String message); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/Platform.java // public class Platform { // final String name; // final String appId; // // Map<String, String> extra; // // public Platform(@NonNull String name, @NonNull String appId) { // this.name = name; // this.appId = appId; // } // // public String getName() { // return name; // } // // public String getAppId() { // return appId; // } // // public String extra(String key) { // return extra == null ? "" : extra.get(key); // } // // public Platform extra(String key, String value) { // if (extra == null) { // extra = new HashMap<>(); // } // extra.put(key, value); // return this; // } // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/ResultCode.java // public class ResultCode { // public static final int RESULT_OK = 0; // public static final int RESULT_PENDING = 1; // public static final int RESULT_CANCELLED = 2; // public static final int RESULT_FAILED = 3; // // } // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/platforms/alipay/Alipay.java import android.app.Activity; import android.content.Intent; import android.os.AsyncTask; import com.alipay.sdk.app.PayTask; import ezy.sdk3rd.social.payment.IPayable; import ezy.sdk3rd.social.sdk.OnCallback; import ezy.sdk3rd.social.sdk.Platform; import ezy.sdk3rd.social.sdk.ResultCode; package ezy.sdk3rd.social.platforms.alipay; public class Alipay implements IPayable { public static final String TAG = "ezy.sdk3rd.alipay"; Activity mActivity; Alipay(Activity activity, Platform platform) { mActivity = activity; } @Override
public void pay(final String data, final OnCallback<String> callback) {
czy1121/sdk3rd
ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/platforms/alipay/Alipay.java
// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/payment/IPayable.java // public interface IPayable extends IResult { // void pay(String data, OnCallback<String> callback); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/OnCallback.java // public interface OnCallback<T> { // void onStarted(Activity activity); // void onCompleted(Activity activity); // void onSucceed(Activity activity, T result); // void onFailed(Activity activity, int code, String message); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/Platform.java // public class Platform { // final String name; // final String appId; // // Map<String, String> extra; // // public Platform(@NonNull String name, @NonNull String appId) { // this.name = name; // this.appId = appId; // } // // public String getName() { // return name; // } // // public String getAppId() { // return appId; // } // // public String extra(String key) { // return extra == null ? "" : extra.get(key); // } // // public Platform extra(String key, String value) { // if (extra == null) { // extra = new HashMap<>(); // } // extra.put(key, value); // return this; // } // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/ResultCode.java // public class ResultCode { // public static final int RESULT_OK = 0; // public static final int RESULT_PENDING = 1; // public static final int RESULT_CANCELLED = 2; // public static final int RESULT_FAILED = 3; // // }
import android.app.Activity; import android.content.Intent; import android.os.AsyncTask; import com.alipay.sdk.app.PayTask; import ezy.sdk3rd.social.payment.IPayable; import ezy.sdk3rd.social.sdk.OnCallback; import ezy.sdk3rd.social.sdk.Platform; import ezy.sdk3rd.social.sdk.ResultCode;
package ezy.sdk3rd.social.platforms.alipay; public class Alipay implements IPayable { public static final String TAG = "ezy.sdk3rd.alipay"; Activity mActivity; Alipay(Activity activity, Platform platform) { mActivity = activity; } @Override public void pay(final String data, final OnCallback<String> callback) { new AsyncTask<String, Void, Result>() { @Override protected void onPreExecute() { callback.onStarted(mActivity); } @Override protected Result doInBackground(String... params) { final PayTask task = new PayTask(mActivity); return new Result(task.payV2(data, true)); } @Override protected void onPostExecute(Result result) { String message = "[" + result.resultStatus + "]" + result.resultText; if (result.isSuccess()) { callback.onSucceed(mActivity, ""); } else if (result.isPending()) {
// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/payment/IPayable.java // public interface IPayable extends IResult { // void pay(String data, OnCallback<String> callback); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/OnCallback.java // public interface OnCallback<T> { // void onStarted(Activity activity); // void onCompleted(Activity activity); // void onSucceed(Activity activity, T result); // void onFailed(Activity activity, int code, String message); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/Platform.java // public class Platform { // final String name; // final String appId; // // Map<String, String> extra; // // public Platform(@NonNull String name, @NonNull String appId) { // this.name = name; // this.appId = appId; // } // // public String getName() { // return name; // } // // public String getAppId() { // return appId; // } // // public String extra(String key) { // return extra == null ? "" : extra.get(key); // } // // public Platform extra(String key, String value) { // if (extra == null) { // extra = new HashMap<>(); // } // extra.put(key, value); // return this; // } // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/ResultCode.java // public class ResultCode { // public static final int RESULT_OK = 0; // public static final int RESULT_PENDING = 1; // public static final int RESULT_CANCELLED = 2; // public static final int RESULT_FAILED = 3; // // } // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/platforms/alipay/Alipay.java import android.app.Activity; import android.content.Intent; import android.os.AsyncTask; import com.alipay.sdk.app.PayTask; import ezy.sdk3rd.social.payment.IPayable; import ezy.sdk3rd.social.sdk.OnCallback; import ezy.sdk3rd.social.sdk.Platform; import ezy.sdk3rd.social.sdk.ResultCode; package ezy.sdk3rd.social.platforms.alipay; public class Alipay implements IPayable { public static final String TAG = "ezy.sdk3rd.alipay"; Activity mActivity; Alipay(Activity activity, Platform platform) { mActivity = activity; } @Override public void pay(final String data, final OnCallback<String> callback) { new AsyncTask<String, Void, Result>() { @Override protected void onPreExecute() { callback.onStarted(mActivity); } @Override protected Result doInBackground(String... params) { final PayTask task = new PayTask(mActivity); return new Result(task.payV2(data, true)); } @Override protected void onPostExecute(Result result) { String message = "[" + result.resultStatus + "]" + result.resultText; if (result.isSuccess()) { callback.onSucceed(mActivity, ""); } else if (result.isPending()) {
callback.onFailed(mActivity, ResultCode.RESULT_PENDING, message);
czy1121/sdk3rd
ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/platforms/weibo/WBAuth.java
// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/authorize/IAuthorize.java // public interface IAuthorize extends IResult { // void authorize(OnCallback<String> callback); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/OnCallback.java // public interface OnCallback<T> { // void onStarted(Activity activity); // void onCompleted(Activity activity); // void onSucceed(Activity activity, T result); // void onFailed(Activity activity, int code, String message); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/Platform.java // public class Platform { // final String name; // final String appId; // // Map<String, String> extra; // // public Platform(@NonNull String name, @NonNull String appId) { // this.name = name; // this.appId = appId; // } // // public String getName() { // return name; // } // // public String getAppId() { // return appId; // } // // public String extra(String key) { // return extra == null ? "" : extra.get(key); // } // // public Platform extra(String key, String value) { // if (extra == null) { // extra = new HashMap<>(); // } // extra.put(key, value); // return this; // } // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/ResultCode.java // public class ResultCode { // public static final int RESULT_OK = 0; // public static final int RESULT_PENDING = 1; // public static final int RESULT_CANCELLED = 2; // public static final int RESULT_FAILED = 3; // // }
import android.app.Activity; import android.content.Intent; import android.support.annotation.NonNull; import android.util.Log; import com.sina.weibo.sdk.WbSdk; import com.sina.weibo.sdk.auth.AuthInfo; import com.sina.weibo.sdk.auth.Oauth2AccessToken; import com.sina.weibo.sdk.auth.WbAuthListener; import com.sina.weibo.sdk.auth.WbConnectErrorMessage; import com.sina.weibo.sdk.auth.sso.SsoHandler; import ezy.sdk3rd.social.authorize.IAuthorize; import ezy.sdk3rd.social.sdk.OnCallback; import ezy.sdk3rd.social.sdk.Platform; import ezy.sdk3rd.social.sdk.ResultCode;
package ezy.sdk3rd.social.platforms.weibo; /** * Created by ezy on 17/3/18. */ public class WBAuth implements IAuthorize { public static final String TAG = "ezy.sdk3rd.weibo.auth"; Activity mActivity;
// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/authorize/IAuthorize.java // public interface IAuthorize extends IResult { // void authorize(OnCallback<String> callback); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/OnCallback.java // public interface OnCallback<T> { // void onStarted(Activity activity); // void onCompleted(Activity activity); // void onSucceed(Activity activity, T result); // void onFailed(Activity activity, int code, String message); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/Platform.java // public class Platform { // final String name; // final String appId; // // Map<String, String> extra; // // public Platform(@NonNull String name, @NonNull String appId) { // this.name = name; // this.appId = appId; // } // // public String getName() { // return name; // } // // public String getAppId() { // return appId; // } // // public String extra(String key) { // return extra == null ? "" : extra.get(key); // } // // public Platform extra(String key, String value) { // if (extra == null) { // extra = new HashMap<>(); // } // extra.put(key, value); // return this; // } // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/ResultCode.java // public class ResultCode { // public static final int RESULT_OK = 0; // public static final int RESULT_PENDING = 1; // public static final int RESULT_CANCELLED = 2; // public static final int RESULT_FAILED = 3; // // } // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/platforms/weibo/WBAuth.java import android.app.Activity; import android.content.Intent; import android.support.annotation.NonNull; import android.util.Log; import com.sina.weibo.sdk.WbSdk; import com.sina.weibo.sdk.auth.AuthInfo; import com.sina.weibo.sdk.auth.Oauth2AccessToken; import com.sina.weibo.sdk.auth.WbAuthListener; import com.sina.weibo.sdk.auth.WbConnectErrorMessage; import com.sina.weibo.sdk.auth.sso.SsoHandler; import ezy.sdk3rd.social.authorize.IAuthorize; import ezy.sdk3rd.social.sdk.OnCallback; import ezy.sdk3rd.social.sdk.Platform; import ezy.sdk3rd.social.sdk.ResultCode; package ezy.sdk3rd.social.platforms.weibo; /** * Created by ezy on 17/3/18. */ public class WBAuth implements IAuthorize { public static final String TAG = "ezy.sdk3rd.weibo.auth"; Activity mActivity;
Platform mPlatform;
czy1121/sdk3rd
ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/platforms/weibo/WBAuth.java
// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/authorize/IAuthorize.java // public interface IAuthorize extends IResult { // void authorize(OnCallback<String> callback); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/OnCallback.java // public interface OnCallback<T> { // void onStarted(Activity activity); // void onCompleted(Activity activity); // void onSucceed(Activity activity, T result); // void onFailed(Activity activity, int code, String message); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/Platform.java // public class Platform { // final String name; // final String appId; // // Map<String, String> extra; // // public Platform(@NonNull String name, @NonNull String appId) { // this.name = name; // this.appId = appId; // } // // public String getName() { // return name; // } // // public String getAppId() { // return appId; // } // // public String extra(String key) { // return extra == null ? "" : extra.get(key); // } // // public Platform extra(String key, String value) { // if (extra == null) { // extra = new HashMap<>(); // } // extra.put(key, value); // return this; // } // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/ResultCode.java // public class ResultCode { // public static final int RESULT_OK = 0; // public static final int RESULT_PENDING = 1; // public static final int RESULT_CANCELLED = 2; // public static final int RESULT_FAILED = 3; // // }
import android.app.Activity; import android.content.Intent; import android.support.annotation.NonNull; import android.util.Log; import com.sina.weibo.sdk.WbSdk; import com.sina.weibo.sdk.auth.AuthInfo; import com.sina.weibo.sdk.auth.Oauth2AccessToken; import com.sina.weibo.sdk.auth.WbAuthListener; import com.sina.weibo.sdk.auth.WbConnectErrorMessage; import com.sina.weibo.sdk.auth.sso.SsoHandler; import ezy.sdk3rd.social.authorize.IAuthorize; import ezy.sdk3rd.social.sdk.OnCallback; import ezy.sdk3rd.social.sdk.Platform; import ezy.sdk3rd.social.sdk.ResultCode;
package ezy.sdk3rd.social.platforms.weibo; /** * Created by ezy on 17/3/18. */ public class WBAuth implements IAuthorize { public static final String TAG = "ezy.sdk3rd.weibo.auth"; Activity mActivity; Platform mPlatform; SsoHandler mApi; WBAuth(Activity activity, Platform platform) { WbSdk.install(activity, new AuthInfo(activity, platform.getAppId(), platform.extra("redirectUrl"), "all")); mActivity = activity; mPlatform = platform; mApi = new SsoHandler(mActivity); } @Override
// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/authorize/IAuthorize.java // public interface IAuthorize extends IResult { // void authorize(OnCallback<String> callback); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/OnCallback.java // public interface OnCallback<T> { // void onStarted(Activity activity); // void onCompleted(Activity activity); // void onSucceed(Activity activity, T result); // void onFailed(Activity activity, int code, String message); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/Platform.java // public class Platform { // final String name; // final String appId; // // Map<String, String> extra; // // public Platform(@NonNull String name, @NonNull String appId) { // this.name = name; // this.appId = appId; // } // // public String getName() { // return name; // } // // public String getAppId() { // return appId; // } // // public String extra(String key) { // return extra == null ? "" : extra.get(key); // } // // public Platform extra(String key, String value) { // if (extra == null) { // extra = new HashMap<>(); // } // extra.put(key, value); // return this; // } // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/ResultCode.java // public class ResultCode { // public static final int RESULT_OK = 0; // public static final int RESULT_PENDING = 1; // public static final int RESULT_CANCELLED = 2; // public static final int RESULT_FAILED = 3; // // } // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/platforms/weibo/WBAuth.java import android.app.Activity; import android.content.Intent; import android.support.annotation.NonNull; import android.util.Log; import com.sina.weibo.sdk.WbSdk; import com.sina.weibo.sdk.auth.AuthInfo; import com.sina.weibo.sdk.auth.Oauth2AccessToken; import com.sina.weibo.sdk.auth.WbAuthListener; import com.sina.weibo.sdk.auth.WbConnectErrorMessage; import com.sina.weibo.sdk.auth.sso.SsoHandler; import ezy.sdk3rd.social.authorize.IAuthorize; import ezy.sdk3rd.social.sdk.OnCallback; import ezy.sdk3rd.social.sdk.Platform; import ezy.sdk3rd.social.sdk.ResultCode; package ezy.sdk3rd.social.platforms.weibo; /** * Created by ezy on 17/3/18. */ public class WBAuth implements IAuthorize { public static final String TAG = "ezy.sdk3rd.weibo.auth"; Activity mActivity; Platform mPlatform; SsoHandler mApi; WBAuth(Activity activity, Platform platform) { WbSdk.install(activity, new AuthInfo(activity, platform.getAppId(), platform.extra("redirectUrl"), "all")); mActivity = activity; mPlatform = platform; mApi = new SsoHandler(mActivity); } @Override
public void authorize(@NonNull final OnCallback<String> callback) {
czy1121/sdk3rd
ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/platforms/weibo/WBAuth.java
// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/authorize/IAuthorize.java // public interface IAuthorize extends IResult { // void authorize(OnCallback<String> callback); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/OnCallback.java // public interface OnCallback<T> { // void onStarted(Activity activity); // void onCompleted(Activity activity); // void onSucceed(Activity activity, T result); // void onFailed(Activity activity, int code, String message); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/Platform.java // public class Platform { // final String name; // final String appId; // // Map<String, String> extra; // // public Platform(@NonNull String name, @NonNull String appId) { // this.name = name; // this.appId = appId; // } // // public String getName() { // return name; // } // // public String getAppId() { // return appId; // } // // public String extra(String key) { // return extra == null ? "" : extra.get(key); // } // // public Platform extra(String key, String value) { // if (extra == null) { // extra = new HashMap<>(); // } // extra.put(key, value); // return this; // } // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/ResultCode.java // public class ResultCode { // public static final int RESULT_OK = 0; // public static final int RESULT_PENDING = 1; // public static final int RESULT_CANCELLED = 2; // public static final int RESULT_FAILED = 3; // // }
import android.app.Activity; import android.content.Intent; import android.support.annotation.NonNull; import android.util.Log; import com.sina.weibo.sdk.WbSdk; import com.sina.weibo.sdk.auth.AuthInfo; import com.sina.weibo.sdk.auth.Oauth2AccessToken; import com.sina.weibo.sdk.auth.WbAuthListener; import com.sina.weibo.sdk.auth.WbConnectErrorMessage; import com.sina.weibo.sdk.auth.sso.SsoHandler; import ezy.sdk3rd.social.authorize.IAuthorize; import ezy.sdk3rd.social.sdk.OnCallback; import ezy.sdk3rd.social.sdk.Platform; import ezy.sdk3rd.social.sdk.ResultCode;
package ezy.sdk3rd.social.platforms.weibo; /** * Created by ezy on 17/3/18. */ public class WBAuth implements IAuthorize { public static final String TAG = "ezy.sdk3rd.weibo.auth"; Activity mActivity; Platform mPlatform; SsoHandler mApi; WBAuth(Activity activity, Platform platform) { WbSdk.install(activity, new AuthInfo(activity, platform.getAppId(), platform.extra("redirectUrl"), "all")); mActivity = activity; mPlatform = platform; mApi = new SsoHandler(mActivity); } @Override public void authorize(@NonNull final OnCallback<String> callback) { callback.onStarted(mActivity); mApi.authorize(new WbAuthListener() { @Override public void onSuccess(Oauth2AccessToken token) { Log.e(TAG, token.toString()); if (token.isSessionValid()) { callback.onSucceed(mActivity, "token|" + token.getUid() + "|" + token.getToken()); } callback.onCompleted(mActivity); } @Override public void cancel() { Log.e(TAG, "用户取消了登录");
// Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/authorize/IAuthorize.java // public interface IAuthorize extends IResult { // void authorize(OnCallback<String> callback); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/OnCallback.java // public interface OnCallback<T> { // void onStarted(Activity activity); // void onCompleted(Activity activity); // void onSucceed(Activity activity, T result); // void onFailed(Activity activity, int code, String message); // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/Platform.java // public class Platform { // final String name; // final String appId; // // Map<String, String> extra; // // public Platform(@NonNull String name, @NonNull String appId) { // this.name = name; // this.appId = appId; // } // // public String getName() { // return name; // } // // public String getAppId() { // return appId; // } // // public String extra(String key) { // return extra == null ? "" : extra.get(key); // } // // public Platform extra(String key, String value) { // if (extra == null) { // extra = new HashMap<>(); // } // extra.put(key, value); // return this; // } // } // // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/sdk/ResultCode.java // public class ResultCode { // public static final int RESULT_OK = 0; // public static final int RESULT_PENDING = 1; // public static final int RESULT_CANCELLED = 2; // public static final int RESULT_FAILED = 3; // // } // Path: ezy.sdk3rd.social/src/main/java/ezy/sdk3rd/social/platforms/weibo/WBAuth.java import android.app.Activity; import android.content.Intent; import android.support.annotation.NonNull; import android.util.Log; import com.sina.weibo.sdk.WbSdk; import com.sina.weibo.sdk.auth.AuthInfo; import com.sina.weibo.sdk.auth.Oauth2AccessToken; import com.sina.weibo.sdk.auth.WbAuthListener; import com.sina.weibo.sdk.auth.WbConnectErrorMessage; import com.sina.weibo.sdk.auth.sso.SsoHandler; import ezy.sdk3rd.social.authorize.IAuthorize; import ezy.sdk3rd.social.sdk.OnCallback; import ezy.sdk3rd.social.sdk.Platform; import ezy.sdk3rd.social.sdk.ResultCode; package ezy.sdk3rd.social.platforms.weibo; /** * Created by ezy on 17/3/18. */ public class WBAuth implements IAuthorize { public static final String TAG = "ezy.sdk3rd.weibo.auth"; Activity mActivity; Platform mPlatform; SsoHandler mApi; WBAuth(Activity activity, Platform platform) { WbSdk.install(activity, new AuthInfo(activity, platform.getAppId(), platform.extra("redirectUrl"), "all")); mActivity = activity; mPlatform = platform; mApi = new SsoHandler(mActivity); } @Override public void authorize(@NonNull final OnCallback<String> callback) { callback.onStarted(mActivity); mApi.authorize(new WbAuthListener() { @Override public void onSuccess(Oauth2AccessToken token) { Log.e(TAG, token.toString()); if (token.isSessionValid()) { callback.onSucceed(mActivity, "token|" + token.getUid() + "|" + token.getToken()); } callback.onCompleted(mActivity); } @Override public void cancel() { Log.e(TAG, "用户取消了登录");
callback.onFailed(mActivity, ResultCode.RESULT_CANCELLED, "用户取消了登录");
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/about/AboutActivity.java
// Path: app/src/main/java/moe/yukinoneko/diycode/base/BaseActivity.java // public abstract class BaseActivity extends RxAppCompatActivity { // // protected Unbinder unbinder; // // @Nullable // @BindView(R.id.toolbar) // protected Toolbar toolbar; // // @BindColor(R.color.navigation) // protected int navigationColor; // // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(provideContentViewId()); // // unbinder = ButterKnife.bind(this); // // if (toolbar != null) { // setSupportActionBar(toolbar); // if (getSupportActionBar() != null) { // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // } // } // // @Override // protected void onPostCreate(@Nullable Bundle savedInstanceState) { // super.onPostCreate(savedInstanceState); // setNavigationIconColor(navigationColor); // } // // @Override // public boolean onOptionsItemSelected(MenuItem item) { // if (item.getItemId() == android.R.id.home) { // finish(); // return true; // } // return super.onOptionsItemSelected(item); // } // // @Override // protected void onDestroy() { // super.onDestroy(); // // if (unbinder != null) { // unbinder.unbind(); // } // } // // protected abstract int provideContentViewId(); // // protected void setToolBarTitle(CharSequence title) { // if (toolbar != null) { // toolbar.setTitle(title); // } // } // // protected void setDisplayShowTitleEnabled(boolean enabled) { // ActionBar actionBar = getSupportActionBar(); // if (actionBar != null) { // actionBar.setDisplayShowTitleEnabled(enabled); // } // } // // protected void setNavigationIconColor(@ColorInt int color) { // if (toolbar != null) { // Drawable icon = toolbar.getNavigationIcon(); // if (icon != null) { // DrawableCompat.setTint(icon, color); // } // } // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/Tools.java // public class Tools { // public static String getVersionName(Context context) { // try { // PackageManager packageManager = context.getPackageManager(); // PackageInfo packageInfo = packageManager.getPackageInfo(context.getPackageName(), 0); // return packageInfo.versionName; // // } catch (PackageManager.NameNotFoundException e) { // e.printStackTrace(); // } // return "unknown"; // } // }
import moe.yukinoneko.diycode.R; import moe.yukinoneko.diycode.base.BaseActivity; import moe.yukinoneko.diycode.tool.Tools; import android.os.Bundle; import android.support.v7.app.AlertDialog; import android.support.v7.widget.AppCompatTextView; import android.webkit.WebView; import java.util.Locale; import butterknife.BindView; import butterknife.OnClick;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.about; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class AboutActivity extends BaseActivity { @BindView(R.id.text_app_version) AppCompatTextView textAppVersion; @Override protected int provideContentViewId() { return R.layout.activity_about; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
// Path: app/src/main/java/moe/yukinoneko/diycode/base/BaseActivity.java // public abstract class BaseActivity extends RxAppCompatActivity { // // protected Unbinder unbinder; // // @Nullable // @BindView(R.id.toolbar) // protected Toolbar toolbar; // // @BindColor(R.color.navigation) // protected int navigationColor; // // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(provideContentViewId()); // // unbinder = ButterKnife.bind(this); // // if (toolbar != null) { // setSupportActionBar(toolbar); // if (getSupportActionBar() != null) { // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // } // } // // @Override // protected void onPostCreate(@Nullable Bundle savedInstanceState) { // super.onPostCreate(savedInstanceState); // setNavigationIconColor(navigationColor); // } // // @Override // public boolean onOptionsItemSelected(MenuItem item) { // if (item.getItemId() == android.R.id.home) { // finish(); // return true; // } // return super.onOptionsItemSelected(item); // } // // @Override // protected void onDestroy() { // super.onDestroy(); // // if (unbinder != null) { // unbinder.unbind(); // } // } // // protected abstract int provideContentViewId(); // // protected void setToolBarTitle(CharSequence title) { // if (toolbar != null) { // toolbar.setTitle(title); // } // } // // protected void setDisplayShowTitleEnabled(boolean enabled) { // ActionBar actionBar = getSupportActionBar(); // if (actionBar != null) { // actionBar.setDisplayShowTitleEnabled(enabled); // } // } // // protected void setNavigationIconColor(@ColorInt int color) { // if (toolbar != null) { // Drawable icon = toolbar.getNavigationIcon(); // if (icon != null) { // DrawableCompat.setTint(icon, color); // } // } // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/Tools.java // public class Tools { // public static String getVersionName(Context context) { // try { // PackageManager packageManager = context.getPackageManager(); // PackageInfo packageInfo = packageManager.getPackageInfo(context.getPackageName(), 0); // return packageInfo.versionName; // // } catch (PackageManager.NameNotFoundException e) { // e.printStackTrace(); // } // return "unknown"; // } // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/about/AboutActivity.java import moe.yukinoneko.diycode.R; import moe.yukinoneko.diycode.base.BaseActivity; import moe.yukinoneko.diycode.tool.Tools; import android.os.Bundle; import android.support.v7.app.AlertDialog; import android.support.v7.widget.AppCompatTextView; import android.webkit.WebView; import java.util.Locale; import butterknife.BindView; import butterknife.OnClick; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.about; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class AboutActivity extends BaseActivity { @BindView(R.id.text_app_version) AppCompatTextView textAppVersion; @Override protected int provideContentViewId() { return R.layout.activity_about; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
textAppVersion.setText(String.format(Locale.getDefault(), "Version %s", Tools.getVersionName(this)));
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/tool/ErrorHandler.java
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/Error.java // public class Error { // @SerializedName("error") public String error; // } // // Path: app/src/main/java/moe/yukinoneko/diycode/api/DiyCodeRetrofit.java // public static final Gson GSON = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").create();
import static moe.yukinoneko.diycode.api.DiyCodeRetrofit.GSON; import android.content.Context; import android.support.annotation.NonNull; import java.net.UnknownHostException; import io.reactivex.functions.Consumer; import moe.yukinoneko.diycode.R; import moe.yukinoneko.diycode.bean.Error; import retrofit2.HttpException;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.tool; /** * Created by SamuelGjk on 2017/4/1. */ public class ErrorHandler { public static Consumer<Throwable> errorConsumer(final Context context) { return new Consumer<Throwable>() { @Override public void accept(@NonNull Throwable throwable) { String errorMessage = null; if (throwable instanceof HttpException) { HttpException httpException = (HttpException) throwable;
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/Error.java // public class Error { // @SerializedName("error") public String error; // } // // Path: app/src/main/java/moe/yukinoneko/diycode/api/DiyCodeRetrofit.java // public static final Gson GSON = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").create(); // Path: app/src/main/java/moe/yukinoneko/diycode/tool/ErrorHandler.java import static moe.yukinoneko.diycode.api.DiyCodeRetrofit.GSON; import android.content.Context; import android.support.annotation.NonNull; import java.net.UnknownHostException; import io.reactivex.functions.Consumer; import moe.yukinoneko.diycode.R; import moe.yukinoneko.diycode.bean.Error; import retrofit2.HttpException; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.tool; /** * Created by SamuelGjk on 2017/4/1. */ public class ErrorHandler { public static Consumer<Throwable> errorConsumer(final Context context) { return new Consumer<Throwable>() { @Override public void accept(@NonNull Throwable throwable) { String errorMessage = null; if (throwable instanceof HttpException) { HttpException httpException = (HttpException) throwable;
errorMessage = GSON.fromJson(httpException.response().errorBody().charStream(), Error.class).error;
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/tool/ErrorHandler.java
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/Error.java // public class Error { // @SerializedName("error") public String error; // } // // Path: app/src/main/java/moe/yukinoneko/diycode/api/DiyCodeRetrofit.java // public static final Gson GSON = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").create();
import static moe.yukinoneko.diycode.api.DiyCodeRetrofit.GSON; import android.content.Context; import android.support.annotation.NonNull; import java.net.UnknownHostException; import io.reactivex.functions.Consumer; import moe.yukinoneko.diycode.R; import moe.yukinoneko.diycode.bean.Error; import retrofit2.HttpException;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.tool; /** * Created by SamuelGjk on 2017/4/1. */ public class ErrorHandler { public static Consumer<Throwable> errorConsumer(final Context context) { return new Consumer<Throwable>() { @Override public void accept(@NonNull Throwable throwable) { String errorMessage = null; if (throwable instanceof HttpException) { HttpException httpException = (HttpException) throwable;
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/Error.java // public class Error { // @SerializedName("error") public String error; // } // // Path: app/src/main/java/moe/yukinoneko/diycode/api/DiyCodeRetrofit.java // public static final Gson GSON = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").create(); // Path: app/src/main/java/moe/yukinoneko/diycode/tool/ErrorHandler.java import static moe.yukinoneko.diycode.api.DiyCodeRetrofit.GSON; import android.content.Context; import android.support.annotation.NonNull; import java.net.UnknownHostException; import io.reactivex.functions.Consumer; import moe.yukinoneko.diycode.R; import moe.yukinoneko.diycode.bean.Error; import retrofit2.HttpException; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.tool; /** * Created by SamuelGjk on 2017/4/1. */ public class ErrorHandler { public static Consumer<Throwable> errorConsumer(final Context context) { return new Consumer<Throwable>() { @Override public void accept(@NonNull Throwable throwable) { String errorMessage = null; if (throwable instanceof HttpException) { HttpException httpException = (HttpException) throwable;
errorMessage = GSON.fromJson(httpException.response().errorBody().charStream(), Error.class).error;
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/user/UserContract.java
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/User.java // public class User implements Parcelable { // @SerializedName("id") public int id; // 用户 id // @SerializedName("login") public String login; // 用户名 // @SerializedName("name") public String name; // 昵称 // @SerializedName("avatar_url") public String avatarUrl; // 头像链接 // @SerializedName("location") public String location; // 城市 // @SerializedName("company") public String company; // 公司 // @SerializedName("twitter") public String twitter; // twitter // @SerializedName("website") public String website; // 网站地址 // @SerializedName("bio") public String bio; // 个人介绍 // @SerializedName("tagline") public String tagline; // 签名 // @SerializedName("github") public String github; // github // @SerializedName("created_at") public String createdAt; // 创建时间 // @SerializedName("email") public String email; // email // @SerializedName("topics_count") public int topicsCount; // 话题数量 // @SerializedName("replies_count") public int repliesCount; // 回复数量 // @SerializedName("following_count") public int followingCount; // 关注人数 // @SerializedName("followers_count") public int followersCount; // 粉丝人数 // @SerializedName("favorites_count") public int favoritesCount; // 收藏数 // @SerializedName("level") public String level; // 等级 // @SerializedName("level_name") public String levelName; // 等级名称 // // protected User(Parcel in) { // id = in.readInt(); // login = in.readString(); // name = in.readString(); // avatarUrl = in.readString(); // location = in.readString(); // company = in.readString(); // twitter = in.readString(); // website = in.readString(); // bio = in.readString(); // tagline = in.readString(); // github = in.readString(); // createdAt = in.readString(); // email = in.readString(); // topicsCount = in.readInt(); // repliesCount = in.readInt(); // followingCount = in.readInt(); // followersCount = in.readInt(); // favoritesCount = in.readInt(); // level = in.readString(); // levelName = in.readString(); // } // // public static final Creator<User> CREATOR = new Creator<User>() { // @Override // public User createFromParcel(Parcel in) { // return new User(in); // } // // @Override // public User[] newArray(int size) { // return new User[size]; // } // }; // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeInt(id); // dest.writeString(login); // dest.writeString(name); // dest.writeString(avatarUrl); // dest.writeString(location); // dest.writeString(company); // dest.writeString(twitter); // dest.writeString(website); // dest.writeString(bio); // dest.writeString(tagline); // dest.writeString(github); // dest.writeString(createdAt); // dest.writeString(email); // dest.writeInt(topicsCount); // dest.writeInt(repliesCount); // dest.writeInt(followingCount); // dest.writeInt(followersCount); // dest.writeInt(favoritesCount); // dest.writeString(level); // dest.writeString(levelName); // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BaseView.java // public interface BaseView { // Context getContext(); // // <T> LifecycleTransformer<T> bindToLife(); // }
import moe.yukinoneko.diycode.mvp.BaseView; import moe.yukinoneko.diycode.bean.User; import moe.yukinoneko.diycode.mvp.BasePresenter;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.user; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class UserContract { interface View extends BaseView {
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/User.java // public class User implements Parcelable { // @SerializedName("id") public int id; // 用户 id // @SerializedName("login") public String login; // 用户名 // @SerializedName("name") public String name; // 昵称 // @SerializedName("avatar_url") public String avatarUrl; // 头像链接 // @SerializedName("location") public String location; // 城市 // @SerializedName("company") public String company; // 公司 // @SerializedName("twitter") public String twitter; // twitter // @SerializedName("website") public String website; // 网站地址 // @SerializedName("bio") public String bio; // 个人介绍 // @SerializedName("tagline") public String tagline; // 签名 // @SerializedName("github") public String github; // github // @SerializedName("created_at") public String createdAt; // 创建时间 // @SerializedName("email") public String email; // email // @SerializedName("topics_count") public int topicsCount; // 话题数量 // @SerializedName("replies_count") public int repliesCount; // 回复数量 // @SerializedName("following_count") public int followingCount; // 关注人数 // @SerializedName("followers_count") public int followersCount; // 粉丝人数 // @SerializedName("favorites_count") public int favoritesCount; // 收藏数 // @SerializedName("level") public String level; // 等级 // @SerializedName("level_name") public String levelName; // 等级名称 // // protected User(Parcel in) { // id = in.readInt(); // login = in.readString(); // name = in.readString(); // avatarUrl = in.readString(); // location = in.readString(); // company = in.readString(); // twitter = in.readString(); // website = in.readString(); // bio = in.readString(); // tagline = in.readString(); // github = in.readString(); // createdAt = in.readString(); // email = in.readString(); // topicsCount = in.readInt(); // repliesCount = in.readInt(); // followingCount = in.readInt(); // followersCount = in.readInt(); // favoritesCount = in.readInt(); // level = in.readString(); // levelName = in.readString(); // } // // public static final Creator<User> CREATOR = new Creator<User>() { // @Override // public User createFromParcel(Parcel in) { // return new User(in); // } // // @Override // public User[] newArray(int size) { // return new User[size]; // } // }; // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeInt(id); // dest.writeString(login); // dest.writeString(name); // dest.writeString(avatarUrl); // dest.writeString(location); // dest.writeString(company); // dest.writeString(twitter); // dest.writeString(website); // dest.writeString(bio); // dest.writeString(tagline); // dest.writeString(github); // dest.writeString(createdAt); // dest.writeString(email); // dest.writeInt(topicsCount); // dest.writeInt(repliesCount); // dest.writeInt(followingCount); // dest.writeInt(followersCount); // dest.writeInt(favoritesCount); // dest.writeString(level); // dest.writeString(levelName); // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BaseView.java // public interface BaseView { // Context getContext(); // // <T> LifecycleTransformer<T> bindToLife(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/user/UserContract.java import moe.yukinoneko.diycode.mvp.BaseView; import moe.yukinoneko.diycode.bean.User; import moe.yukinoneko.diycode.mvp.BasePresenter; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.user; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class UserContract { interface View extends BaseView {
void updateUser(User user);
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/user/UserContract.java
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/User.java // public class User implements Parcelable { // @SerializedName("id") public int id; // 用户 id // @SerializedName("login") public String login; // 用户名 // @SerializedName("name") public String name; // 昵称 // @SerializedName("avatar_url") public String avatarUrl; // 头像链接 // @SerializedName("location") public String location; // 城市 // @SerializedName("company") public String company; // 公司 // @SerializedName("twitter") public String twitter; // twitter // @SerializedName("website") public String website; // 网站地址 // @SerializedName("bio") public String bio; // 个人介绍 // @SerializedName("tagline") public String tagline; // 签名 // @SerializedName("github") public String github; // github // @SerializedName("created_at") public String createdAt; // 创建时间 // @SerializedName("email") public String email; // email // @SerializedName("topics_count") public int topicsCount; // 话题数量 // @SerializedName("replies_count") public int repliesCount; // 回复数量 // @SerializedName("following_count") public int followingCount; // 关注人数 // @SerializedName("followers_count") public int followersCount; // 粉丝人数 // @SerializedName("favorites_count") public int favoritesCount; // 收藏数 // @SerializedName("level") public String level; // 等级 // @SerializedName("level_name") public String levelName; // 等级名称 // // protected User(Parcel in) { // id = in.readInt(); // login = in.readString(); // name = in.readString(); // avatarUrl = in.readString(); // location = in.readString(); // company = in.readString(); // twitter = in.readString(); // website = in.readString(); // bio = in.readString(); // tagline = in.readString(); // github = in.readString(); // createdAt = in.readString(); // email = in.readString(); // topicsCount = in.readInt(); // repliesCount = in.readInt(); // followingCount = in.readInt(); // followersCount = in.readInt(); // favoritesCount = in.readInt(); // level = in.readString(); // levelName = in.readString(); // } // // public static final Creator<User> CREATOR = new Creator<User>() { // @Override // public User createFromParcel(Parcel in) { // return new User(in); // } // // @Override // public User[] newArray(int size) { // return new User[size]; // } // }; // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeInt(id); // dest.writeString(login); // dest.writeString(name); // dest.writeString(avatarUrl); // dest.writeString(location); // dest.writeString(company); // dest.writeString(twitter); // dest.writeString(website); // dest.writeString(bio); // dest.writeString(tagline); // dest.writeString(github); // dest.writeString(createdAt); // dest.writeString(email); // dest.writeInt(topicsCount); // dest.writeInt(repliesCount); // dest.writeInt(followingCount); // dest.writeInt(followersCount); // dest.writeInt(favoritesCount); // dest.writeString(level); // dest.writeString(levelName); // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BaseView.java // public interface BaseView { // Context getContext(); // // <T> LifecycleTransformer<T> bindToLife(); // }
import moe.yukinoneko.diycode.mvp.BaseView; import moe.yukinoneko.diycode.bean.User; import moe.yukinoneko.diycode.mvp.BasePresenter;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.user; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class UserContract { interface View extends BaseView { void updateUser(User user); void error(); }
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/User.java // public class User implements Parcelable { // @SerializedName("id") public int id; // 用户 id // @SerializedName("login") public String login; // 用户名 // @SerializedName("name") public String name; // 昵称 // @SerializedName("avatar_url") public String avatarUrl; // 头像链接 // @SerializedName("location") public String location; // 城市 // @SerializedName("company") public String company; // 公司 // @SerializedName("twitter") public String twitter; // twitter // @SerializedName("website") public String website; // 网站地址 // @SerializedName("bio") public String bio; // 个人介绍 // @SerializedName("tagline") public String tagline; // 签名 // @SerializedName("github") public String github; // github // @SerializedName("created_at") public String createdAt; // 创建时间 // @SerializedName("email") public String email; // email // @SerializedName("topics_count") public int topicsCount; // 话题数量 // @SerializedName("replies_count") public int repliesCount; // 回复数量 // @SerializedName("following_count") public int followingCount; // 关注人数 // @SerializedName("followers_count") public int followersCount; // 粉丝人数 // @SerializedName("favorites_count") public int favoritesCount; // 收藏数 // @SerializedName("level") public String level; // 等级 // @SerializedName("level_name") public String levelName; // 等级名称 // // protected User(Parcel in) { // id = in.readInt(); // login = in.readString(); // name = in.readString(); // avatarUrl = in.readString(); // location = in.readString(); // company = in.readString(); // twitter = in.readString(); // website = in.readString(); // bio = in.readString(); // tagline = in.readString(); // github = in.readString(); // createdAt = in.readString(); // email = in.readString(); // topicsCount = in.readInt(); // repliesCount = in.readInt(); // followingCount = in.readInt(); // followersCount = in.readInt(); // favoritesCount = in.readInt(); // level = in.readString(); // levelName = in.readString(); // } // // public static final Creator<User> CREATOR = new Creator<User>() { // @Override // public User createFromParcel(Parcel in) { // return new User(in); // } // // @Override // public User[] newArray(int size) { // return new User[size]; // } // }; // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeInt(id); // dest.writeString(login); // dest.writeString(name); // dest.writeString(avatarUrl); // dest.writeString(location); // dest.writeString(company); // dest.writeString(twitter); // dest.writeString(website); // dest.writeString(bio); // dest.writeString(tagline); // dest.writeString(github); // dest.writeString(createdAt); // dest.writeString(email); // dest.writeInt(topicsCount); // dest.writeInt(repliesCount); // dest.writeInt(followingCount); // dest.writeInt(followersCount); // dest.writeInt(favoritesCount); // dest.writeString(level); // dest.writeString(levelName); // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BaseView.java // public interface BaseView { // Context getContext(); // // <T> LifecycleTransformer<T> bindToLife(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/user/UserContract.java import moe.yukinoneko.diycode.mvp.BaseView; import moe.yukinoneko.diycode.bean.User; import moe.yukinoneko.diycode.mvp.BasePresenter; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.user; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class UserContract { interface View extends BaseView { void updateUser(User user); void error(); }
interface Presenter extends BasePresenter<View> {
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/api/DiyCodeRetrofit.java
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/Token.java // public class Token { // // @SerializedName("access_token") public String accessToken; // 用户令牌(获取相关数据使用) // @SerializedName("token_type") public String tokenType; // 令牌类型 // @SerializedName("expires_in") public int expiresIn; // 过期时间 // @SerializedName("refresh_token") public String refreshToken; // 刷新令牌(获取新的令牌) // @SerializedName("created_at") public int createdAt; // 创建时间 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/UserHelper.java // public class UserHelper { // // private static final String TOKEN = "token"; // private static final String USER = "user"; // // private static SharedPreferences prefs; // // public static void init(Context context) { // prefs = new SecurePreferences(context.getApplicationContext()); // } // // public static void saveToken(Token token) { // prefs.edit().putString(TOKEN, GSON.toJson(token)).apply(); // } // // public static Token getToken() { // String tokenJson = prefs.getString(TOKEN, null); // if (tokenJson != null) { // return GSON.fromJson(tokenJson, Token.class); // } // return null; // } // // public static boolean isLogin() { // return null != getToken(); // } // // public static boolean hasUser() { // return null != getUser(); // } // // public static void saveUser(User user) { // prefs.edit().putString(USER, GSON.toJson(user)).apply(); // } // // public static User getUser() { // String userJson = prefs.getString(USER, null); // if (userJson != null) { // return GSON.fromJson(userJson, User.class); // } // return null; // } // // public static void logout() { // prefs.edit().remove(USER).remove(TOKEN).apply(); // } // }
import com.google.gson.Gson; import com.google.gson.GsonBuilder; import java.io.IOException; import java.util.concurrent.TimeUnit; import io.reactivex.schedulers.Schedulers; import moe.yukinoneko.diycode.bean.Token; import moe.yukinoneko.diycode.tool.UserHelper; import okhttp3.Authenticator; import okhttp3.Interceptor; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import okhttp3.Route; import retrofit2.Call; import retrofit2.Retrofit; import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.POST;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.api; /** * Created by SamuelGjk on 2017/3/23. */ public class DiyCodeRetrofit { public static final Gson GSON = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").create(); private Retrofit retrofit; private DiyCodeService service; private static class HolderClass { private static final DiyCodeRetrofit INSTANCE = new DiyCodeRetrofit(); } public static DiyCodeService api() { return HolderClass.INSTANCE.service; } private DiyCodeRetrofit() { // 为所有请求自动添加 token Interceptor tokenInterceptor = new Interceptor() { @Override public okhttp3.Response intercept(Chain chain) throws IOException { Request originalRequest = chain.request(); // 如果当前没有缓存 token 或者请求已经附带 token 了,就不再添加
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/Token.java // public class Token { // // @SerializedName("access_token") public String accessToken; // 用户令牌(获取相关数据使用) // @SerializedName("token_type") public String tokenType; // 令牌类型 // @SerializedName("expires_in") public int expiresIn; // 过期时间 // @SerializedName("refresh_token") public String refreshToken; // 刷新令牌(获取新的令牌) // @SerializedName("created_at") public int createdAt; // 创建时间 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/UserHelper.java // public class UserHelper { // // private static final String TOKEN = "token"; // private static final String USER = "user"; // // private static SharedPreferences prefs; // // public static void init(Context context) { // prefs = new SecurePreferences(context.getApplicationContext()); // } // // public static void saveToken(Token token) { // prefs.edit().putString(TOKEN, GSON.toJson(token)).apply(); // } // // public static Token getToken() { // String tokenJson = prefs.getString(TOKEN, null); // if (tokenJson != null) { // return GSON.fromJson(tokenJson, Token.class); // } // return null; // } // // public static boolean isLogin() { // return null != getToken(); // } // // public static boolean hasUser() { // return null != getUser(); // } // // public static void saveUser(User user) { // prefs.edit().putString(USER, GSON.toJson(user)).apply(); // } // // public static User getUser() { // String userJson = prefs.getString(USER, null); // if (userJson != null) { // return GSON.fromJson(userJson, User.class); // } // return null; // } // // public static void logout() { // prefs.edit().remove(USER).remove(TOKEN).apply(); // } // } // Path: app/src/main/java/moe/yukinoneko/diycode/api/DiyCodeRetrofit.java import com.google.gson.Gson; import com.google.gson.GsonBuilder; import java.io.IOException; import java.util.concurrent.TimeUnit; import io.reactivex.schedulers.Schedulers; import moe.yukinoneko.diycode.bean.Token; import moe.yukinoneko.diycode.tool.UserHelper; import okhttp3.Authenticator; import okhttp3.Interceptor; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import okhttp3.Route; import retrofit2.Call; import retrofit2.Retrofit; import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.POST; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.api; /** * Created by SamuelGjk on 2017/3/23. */ public class DiyCodeRetrofit { public static final Gson GSON = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").create(); private Retrofit retrofit; private DiyCodeService service; private static class HolderClass { private static final DiyCodeRetrofit INSTANCE = new DiyCodeRetrofit(); } public static DiyCodeService api() { return HolderClass.INSTANCE.service; } private DiyCodeRetrofit() { // 为所有请求自动添加 token Interceptor tokenInterceptor = new Interceptor() { @Override public okhttp3.Response intercept(Chain chain) throws IOException { Request originalRequest = chain.request(); // 如果当前没有缓存 token 或者请求已经附带 token 了,就不再添加
if (!UserHelper.isLogin() || alreadyHasAuthorizationHeader(originalRequest)) {
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/api/DiyCodeRetrofit.java
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/Token.java // public class Token { // // @SerializedName("access_token") public String accessToken; // 用户令牌(获取相关数据使用) // @SerializedName("token_type") public String tokenType; // 令牌类型 // @SerializedName("expires_in") public int expiresIn; // 过期时间 // @SerializedName("refresh_token") public String refreshToken; // 刷新令牌(获取新的令牌) // @SerializedName("created_at") public int createdAt; // 创建时间 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/UserHelper.java // public class UserHelper { // // private static final String TOKEN = "token"; // private static final String USER = "user"; // // private static SharedPreferences prefs; // // public static void init(Context context) { // prefs = new SecurePreferences(context.getApplicationContext()); // } // // public static void saveToken(Token token) { // prefs.edit().putString(TOKEN, GSON.toJson(token)).apply(); // } // // public static Token getToken() { // String tokenJson = prefs.getString(TOKEN, null); // if (tokenJson != null) { // return GSON.fromJson(tokenJson, Token.class); // } // return null; // } // // public static boolean isLogin() { // return null != getToken(); // } // // public static boolean hasUser() { // return null != getUser(); // } // // public static void saveUser(User user) { // prefs.edit().putString(USER, GSON.toJson(user)).apply(); // } // // public static User getUser() { // String userJson = prefs.getString(USER, null); // if (userJson != null) { // return GSON.fromJson(userJson, User.class); // } // return null; // } // // public static void logout() { // prefs.edit().remove(USER).remove(TOKEN).apply(); // } // }
import com.google.gson.Gson; import com.google.gson.GsonBuilder; import java.io.IOException; import java.util.concurrent.TimeUnit; import io.reactivex.schedulers.Schedulers; import moe.yukinoneko.diycode.bean.Token; import moe.yukinoneko.diycode.tool.UserHelper; import okhttp3.Authenticator; import okhttp3.Interceptor; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import okhttp3.Route; import retrofit2.Call; import retrofit2.Retrofit; import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.POST;
} private DiyCodeRetrofit() { // 为所有请求自动添加 token Interceptor tokenInterceptor = new Interceptor() { @Override public okhttp3.Response intercept(Chain chain) throws IOException { Request originalRequest = chain.request(); // 如果当前没有缓存 token 或者请求已经附带 token 了,就不再添加 if (!UserHelper.isLogin() || alreadyHasAuthorizationHeader(originalRequest)) { return chain.proceed(originalRequest); } String token = OAuth.TOKEN_PREFIX + UserHelper.getToken().accessToken; // 为请求附加 token Request authorised = originalRequest.newBuilder() .header(OAuth.KEY_TOKEN, token) .build(); return chain.proceed(authorised); } }; // 自动刷新 token Authenticator authenticator = new Authenticator() { @Override public Request authenticate(Route route, Response response) { TokenService tokenService = retrofit.create(TokenService.class); String accessToken = ""; try { if (UserHelper.isLogin()) {
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/Token.java // public class Token { // // @SerializedName("access_token") public String accessToken; // 用户令牌(获取相关数据使用) // @SerializedName("token_type") public String tokenType; // 令牌类型 // @SerializedName("expires_in") public int expiresIn; // 过期时间 // @SerializedName("refresh_token") public String refreshToken; // 刷新令牌(获取新的令牌) // @SerializedName("created_at") public int createdAt; // 创建时间 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/UserHelper.java // public class UserHelper { // // private static final String TOKEN = "token"; // private static final String USER = "user"; // // private static SharedPreferences prefs; // // public static void init(Context context) { // prefs = new SecurePreferences(context.getApplicationContext()); // } // // public static void saveToken(Token token) { // prefs.edit().putString(TOKEN, GSON.toJson(token)).apply(); // } // // public static Token getToken() { // String tokenJson = prefs.getString(TOKEN, null); // if (tokenJson != null) { // return GSON.fromJson(tokenJson, Token.class); // } // return null; // } // // public static boolean isLogin() { // return null != getToken(); // } // // public static boolean hasUser() { // return null != getUser(); // } // // public static void saveUser(User user) { // prefs.edit().putString(USER, GSON.toJson(user)).apply(); // } // // public static User getUser() { // String userJson = prefs.getString(USER, null); // if (userJson != null) { // return GSON.fromJson(userJson, User.class); // } // return null; // } // // public static void logout() { // prefs.edit().remove(USER).remove(TOKEN).apply(); // } // } // Path: app/src/main/java/moe/yukinoneko/diycode/api/DiyCodeRetrofit.java import com.google.gson.Gson; import com.google.gson.GsonBuilder; import java.io.IOException; import java.util.concurrent.TimeUnit; import io.reactivex.schedulers.Schedulers; import moe.yukinoneko.diycode.bean.Token; import moe.yukinoneko.diycode.tool.UserHelper; import okhttp3.Authenticator; import okhttp3.Interceptor; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import okhttp3.Route; import retrofit2.Call; import retrofit2.Retrofit; import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.POST; } private DiyCodeRetrofit() { // 为所有请求自动添加 token Interceptor tokenInterceptor = new Interceptor() { @Override public okhttp3.Response intercept(Chain chain) throws IOException { Request originalRequest = chain.request(); // 如果当前没有缓存 token 或者请求已经附带 token 了,就不再添加 if (!UserHelper.isLogin() || alreadyHasAuthorizationHeader(originalRequest)) { return chain.proceed(originalRequest); } String token = OAuth.TOKEN_PREFIX + UserHelper.getToken().accessToken; // 为请求附加 token Request authorised = originalRequest.newBuilder() .header(OAuth.KEY_TOKEN, token) .build(); return chain.proceed(authorised); } }; // 自动刷新 token Authenticator authenticator = new Authenticator() { @Override public Request authenticate(Route route, Response response) { TokenService tokenService = retrofit.create(TokenService.class); String accessToken = ""; try { if (UserHelper.isLogin()) {
Call<Token> call = tokenService.refreshToken(OAuth.client_id,
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/reply/create/CreateReplyActivity.java
// Path: app/src/main/java/moe/yukinoneko/diycode/mvp/MVPBaseActivity.java // public abstract class MVPBaseActivity<V extends BaseView, T extends BasePresenterImpl<V>> extends BaseActivity implements BaseView { // protected T presenter; // // @SuppressWarnings("unchecked") // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // presenter = getInstance(this, 1); // presenter.attachView((V) this); // // super.onCreate(savedInstanceState); // } // // @Override // protected void onDestroy() { // if (presenter != null) { // presenter.detachView(); // } // super.onDestroy(); // } // // @Override // public Context getContext() { // return this; // } // // @Override // public <T> LifecycleTransformer<T> bindToLife() { // return this.<T>bindToLifecycle(); // } // // @SuppressWarnings("unchecked") // public <T> T getInstance(Object o, int i) { // try { // return ((Class<T>) ((ParameterizedType) (o.getClass().getGenericSuperclass())).getActualTypeArguments()[i]).newInstance(); // } catch (InstantiationException | IllegalAccessException | ClassCastException e) { // e.printStackTrace(); // } // return null; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/StringHelper.java // public static String trim(CharSequence input) { // return input.toString().trim(); // }
import moe.yukinoneko.diycode.R; import moe.yukinoneko.diycode.mvp.MVPBaseActivity; import static moe.yukinoneko.diycode.tool.StringHelper.trim; import android.app.ProgressDialog; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.v7.widget.AppCompatEditText; import android.view.Menu; import android.view.MenuItem; import butterknife.BindView;
progressDialog = new ProgressDialog(this); progressDialog.setCancelable(false); progressDialog.setMessage("请稍后..."); String prefix = getIntent().getStringExtra(EXTRA_PREFIX); editContent.setText(prefix); editContent.setSelection(prefix.length()); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.send, menu); return super.onCreateOptionsMenu(menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.action_send) { Intent intent = getIntent(); presenter.newReply( intent.getStringExtra(EXTRA_FEED_TYPE), intent.getIntExtra(EXTRA_FEED_ID, -1) ); return true; } return super.onOptionsItemSelected(item); } @Override public String getContent() {
// Path: app/src/main/java/moe/yukinoneko/diycode/mvp/MVPBaseActivity.java // public abstract class MVPBaseActivity<V extends BaseView, T extends BasePresenterImpl<V>> extends BaseActivity implements BaseView { // protected T presenter; // // @SuppressWarnings("unchecked") // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // presenter = getInstance(this, 1); // presenter.attachView((V) this); // // super.onCreate(savedInstanceState); // } // // @Override // protected void onDestroy() { // if (presenter != null) { // presenter.detachView(); // } // super.onDestroy(); // } // // @Override // public Context getContext() { // return this; // } // // @Override // public <T> LifecycleTransformer<T> bindToLife() { // return this.<T>bindToLifecycle(); // } // // @SuppressWarnings("unchecked") // public <T> T getInstance(Object o, int i) { // try { // return ((Class<T>) ((ParameterizedType) (o.getClass().getGenericSuperclass())).getActualTypeArguments()[i]).newInstance(); // } catch (InstantiationException | IllegalAccessException | ClassCastException e) { // e.printStackTrace(); // } // return null; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/StringHelper.java // public static String trim(CharSequence input) { // return input.toString().trim(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/reply/create/CreateReplyActivity.java import moe.yukinoneko.diycode.R; import moe.yukinoneko.diycode.mvp.MVPBaseActivity; import static moe.yukinoneko.diycode.tool.StringHelper.trim; import android.app.ProgressDialog; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.v7.widget.AppCompatEditText; import android.view.Menu; import android.view.MenuItem; import butterknife.BindView; progressDialog = new ProgressDialog(this); progressDialog.setCancelable(false); progressDialog.setMessage("请稍后..."); String prefix = getIntent().getStringExtra(EXTRA_PREFIX); editContent.setText(prefix); editContent.setSelection(prefix.length()); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.send, menu); return super.onCreateOptionsMenu(menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.action_send) { Intent intent = getIntent(); presenter.newReply( intent.getStringExtra(EXTRA_FEED_TYPE), intent.getIntExtra(EXTRA_FEED_ID, -1) ); return true; } return super.onOptionsItemSelected(item); } @Override public String getContent() {
return trim(editContent.getText());
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/tool/UserHelper.java
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/Token.java // public class Token { // // @SerializedName("access_token") public String accessToken; // 用户令牌(获取相关数据使用) // @SerializedName("token_type") public String tokenType; // 令牌类型 // @SerializedName("expires_in") public int expiresIn; // 过期时间 // @SerializedName("refresh_token") public String refreshToken; // 刷新令牌(获取新的令牌) // @SerializedName("created_at") public int createdAt; // 创建时间 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/User.java // public class User implements Parcelable { // @SerializedName("id") public int id; // 用户 id // @SerializedName("login") public String login; // 用户名 // @SerializedName("name") public String name; // 昵称 // @SerializedName("avatar_url") public String avatarUrl; // 头像链接 // @SerializedName("location") public String location; // 城市 // @SerializedName("company") public String company; // 公司 // @SerializedName("twitter") public String twitter; // twitter // @SerializedName("website") public String website; // 网站地址 // @SerializedName("bio") public String bio; // 个人介绍 // @SerializedName("tagline") public String tagline; // 签名 // @SerializedName("github") public String github; // github // @SerializedName("created_at") public String createdAt; // 创建时间 // @SerializedName("email") public String email; // email // @SerializedName("topics_count") public int topicsCount; // 话题数量 // @SerializedName("replies_count") public int repliesCount; // 回复数量 // @SerializedName("following_count") public int followingCount; // 关注人数 // @SerializedName("followers_count") public int followersCount; // 粉丝人数 // @SerializedName("favorites_count") public int favoritesCount; // 收藏数 // @SerializedName("level") public String level; // 等级 // @SerializedName("level_name") public String levelName; // 等级名称 // // protected User(Parcel in) { // id = in.readInt(); // login = in.readString(); // name = in.readString(); // avatarUrl = in.readString(); // location = in.readString(); // company = in.readString(); // twitter = in.readString(); // website = in.readString(); // bio = in.readString(); // tagline = in.readString(); // github = in.readString(); // createdAt = in.readString(); // email = in.readString(); // topicsCount = in.readInt(); // repliesCount = in.readInt(); // followingCount = in.readInt(); // followersCount = in.readInt(); // favoritesCount = in.readInt(); // level = in.readString(); // levelName = in.readString(); // } // // public static final Creator<User> CREATOR = new Creator<User>() { // @Override // public User createFromParcel(Parcel in) { // return new User(in); // } // // @Override // public User[] newArray(int size) { // return new User[size]; // } // }; // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeInt(id); // dest.writeString(login); // dest.writeString(name); // dest.writeString(avatarUrl); // dest.writeString(location); // dest.writeString(company); // dest.writeString(twitter); // dest.writeString(website); // dest.writeString(bio); // dest.writeString(tagline); // dest.writeString(github); // dest.writeString(createdAt); // dest.writeString(email); // dest.writeInt(topicsCount); // dest.writeInt(repliesCount); // dest.writeInt(followingCount); // dest.writeInt(followersCount); // dest.writeInt(favoritesCount); // dest.writeString(level); // dest.writeString(levelName); // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/api/DiyCodeRetrofit.java // public static final Gson GSON = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").create();
import android.content.Context; import android.content.SharedPreferences; import com.securepreferences.SecurePreferences; import moe.yukinoneko.diycode.bean.Token; import moe.yukinoneko.diycode.bean.User; import static moe.yukinoneko.diycode.api.DiyCodeRetrofit.GSON;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.tool; /** * Created by SamuelGjk on 2017/3/23. */ public class UserHelper { private static final String TOKEN = "token"; private static final String USER = "user"; private static SharedPreferences prefs; public static void init(Context context) { prefs = new SecurePreferences(context.getApplicationContext()); }
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/Token.java // public class Token { // // @SerializedName("access_token") public String accessToken; // 用户令牌(获取相关数据使用) // @SerializedName("token_type") public String tokenType; // 令牌类型 // @SerializedName("expires_in") public int expiresIn; // 过期时间 // @SerializedName("refresh_token") public String refreshToken; // 刷新令牌(获取新的令牌) // @SerializedName("created_at") public int createdAt; // 创建时间 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/User.java // public class User implements Parcelable { // @SerializedName("id") public int id; // 用户 id // @SerializedName("login") public String login; // 用户名 // @SerializedName("name") public String name; // 昵称 // @SerializedName("avatar_url") public String avatarUrl; // 头像链接 // @SerializedName("location") public String location; // 城市 // @SerializedName("company") public String company; // 公司 // @SerializedName("twitter") public String twitter; // twitter // @SerializedName("website") public String website; // 网站地址 // @SerializedName("bio") public String bio; // 个人介绍 // @SerializedName("tagline") public String tagline; // 签名 // @SerializedName("github") public String github; // github // @SerializedName("created_at") public String createdAt; // 创建时间 // @SerializedName("email") public String email; // email // @SerializedName("topics_count") public int topicsCount; // 话题数量 // @SerializedName("replies_count") public int repliesCount; // 回复数量 // @SerializedName("following_count") public int followingCount; // 关注人数 // @SerializedName("followers_count") public int followersCount; // 粉丝人数 // @SerializedName("favorites_count") public int favoritesCount; // 收藏数 // @SerializedName("level") public String level; // 等级 // @SerializedName("level_name") public String levelName; // 等级名称 // // protected User(Parcel in) { // id = in.readInt(); // login = in.readString(); // name = in.readString(); // avatarUrl = in.readString(); // location = in.readString(); // company = in.readString(); // twitter = in.readString(); // website = in.readString(); // bio = in.readString(); // tagline = in.readString(); // github = in.readString(); // createdAt = in.readString(); // email = in.readString(); // topicsCount = in.readInt(); // repliesCount = in.readInt(); // followingCount = in.readInt(); // followersCount = in.readInt(); // favoritesCount = in.readInt(); // level = in.readString(); // levelName = in.readString(); // } // // public static final Creator<User> CREATOR = new Creator<User>() { // @Override // public User createFromParcel(Parcel in) { // return new User(in); // } // // @Override // public User[] newArray(int size) { // return new User[size]; // } // }; // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeInt(id); // dest.writeString(login); // dest.writeString(name); // dest.writeString(avatarUrl); // dest.writeString(location); // dest.writeString(company); // dest.writeString(twitter); // dest.writeString(website); // dest.writeString(bio); // dest.writeString(tagline); // dest.writeString(github); // dest.writeString(createdAt); // dest.writeString(email); // dest.writeInt(topicsCount); // dest.writeInt(repliesCount); // dest.writeInt(followingCount); // dest.writeInt(followersCount); // dest.writeInt(favoritesCount); // dest.writeString(level); // dest.writeString(levelName); // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/api/DiyCodeRetrofit.java // public static final Gson GSON = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").create(); // Path: app/src/main/java/moe/yukinoneko/diycode/tool/UserHelper.java import android.content.Context; import android.content.SharedPreferences; import com.securepreferences.SecurePreferences; import moe.yukinoneko.diycode.bean.Token; import moe.yukinoneko.diycode.bean.User; import static moe.yukinoneko.diycode.api.DiyCodeRetrofit.GSON; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.tool; /** * Created by SamuelGjk on 2017/3/23. */ public class UserHelper { private static final String TOKEN = "token"; private static final String USER = "user"; private static SharedPreferences prefs; public static void init(Context context) { prefs = new SecurePreferences(context.getApplicationContext()); }
public static void saveToken(Token token) {
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/tool/UserHelper.java
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/Token.java // public class Token { // // @SerializedName("access_token") public String accessToken; // 用户令牌(获取相关数据使用) // @SerializedName("token_type") public String tokenType; // 令牌类型 // @SerializedName("expires_in") public int expiresIn; // 过期时间 // @SerializedName("refresh_token") public String refreshToken; // 刷新令牌(获取新的令牌) // @SerializedName("created_at") public int createdAt; // 创建时间 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/User.java // public class User implements Parcelable { // @SerializedName("id") public int id; // 用户 id // @SerializedName("login") public String login; // 用户名 // @SerializedName("name") public String name; // 昵称 // @SerializedName("avatar_url") public String avatarUrl; // 头像链接 // @SerializedName("location") public String location; // 城市 // @SerializedName("company") public String company; // 公司 // @SerializedName("twitter") public String twitter; // twitter // @SerializedName("website") public String website; // 网站地址 // @SerializedName("bio") public String bio; // 个人介绍 // @SerializedName("tagline") public String tagline; // 签名 // @SerializedName("github") public String github; // github // @SerializedName("created_at") public String createdAt; // 创建时间 // @SerializedName("email") public String email; // email // @SerializedName("topics_count") public int topicsCount; // 话题数量 // @SerializedName("replies_count") public int repliesCount; // 回复数量 // @SerializedName("following_count") public int followingCount; // 关注人数 // @SerializedName("followers_count") public int followersCount; // 粉丝人数 // @SerializedName("favorites_count") public int favoritesCount; // 收藏数 // @SerializedName("level") public String level; // 等级 // @SerializedName("level_name") public String levelName; // 等级名称 // // protected User(Parcel in) { // id = in.readInt(); // login = in.readString(); // name = in.readString(); // avatarUrl = in.readString(); // location = in.readString(); // company = in.readString(); // twitter = in.readString(); // website = in.readString(); // bio = in.readString(); // tagline = in.readString(); // github = in.readString(); // createdAt = in.readString(); // email = in.readString(); // topicsCount = in.readInt(); // repliesCount = in.readInt(); // followingCount = in.readInt(); // followersCount = in.readInt(); // favoritesCount = in.readInt(); // level = in.readString(); // levelName = in.readString(); // } // // public static final Creator<User> CREATOR = new Creator<User>() { // @Override // public User createFromParcel(Parcel in) { // return new User(in); // } // // @Override // public User[] newArray(int size) { // return new User[size]; // } // }; // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeInt(id); // dest.writeString(login); // dest.writeString(name); // dest.writeString(avatarUrl); // dest.writeString(location); // dest.writeString(company); // dest.writeString(twitter); // dest.writeString(website); // dest.writeString(bio); // dest.writeString(tagline); // dest.writeString(github); // dest.writeString(createdAt); // dest.writeString(email); // dest.writeInt(topicsCount); // dest.writeInt(repliesCount); // dest.writeInt(followingCount); // dest.writeInt(followersCount); // dest.writeInt(favoritesCount); // dest.writeString(level); // dest.writeString(levelName); // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/api/DiyCodeRetrofit.java // public static final Gson GSON = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").create();
import android.content.Context; import android.content.SharedPreferences; import com.securepreferences.SecurePreferences; import moe.yukinoneko.diycode.bean.Token; import moe.yukinoneko.diycode.bean.User; import static moe.yukinoneko.diycode.api.DiyCodeRetrofit.GSON;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.tool; /** * Created by SamuelGjk on 2017/3/23. */ public class UserHelper { private static final String TOKEN = "token"; private static final String USER = "user"; private static SharedPreferences prefs; public static void init(Context context) { prefs = new SecurePreferences(context.getApplicationContext()); } public static void saveToken(Token token) {
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/Token.java // public class Token { // // @SerializedName("access_token") public String accessToken; // 用户令牌(获取相关数据使用) // @SerializedName("token_type") public String tokenType; // 令牌类型 // @SerializedName("expires_in") public int expiresIn; // 过期时间 // @SerializedName("refresh_token") public String refreshToken; // 刷新令牌(获取新的令牌) // @SerializedName("created_at") public int createdAt; // 创建时间 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/User.java // public class User implements Parcelable { // @SerializedName("id") public int id; // 用户 id // @SerializedName("login") public String login; // 用户名 // @SerializedName("name") public String name; // 昵称 // @SerializedName("avatar_url") public String avatarUrl; // 头像链接 // @SerializedName("location") public String location; // 城市 // @SerializedName("company") public String company; // 公司 // @SerializedName("twitter") public String twitter; // twitter // @SerializedName("website") public String website; // 网站地址 // @SerializedName("bio") public String bio; // 个人介绍 // @SerializedName("tagline") public String tagline; // 签名 // @SerializedName("github") public String github; // github // @SerializedName("created_at") public String createdAt; // 创建时间 // @SerializedName("email") public String email; // email // @SerializedName("topics_count") public int topicsCount; // 话题数量 // @SerializedName("replies_count") public int repliesCount; // 回复数量 // @SerializedName("following_count") public int followingCount; // 关注人数 // @SerializedName("followers_count") public int followersCount; // 粉丝人数 // @SerializedName("favorites_count") public int favoritesCount; // 收藏数 // @SerializedName("level") public String level; // 等级 // @SerializedName("level_name") public String levelName; // 等级名称 // // protected User(Parcel in) { // id = in.readInt(); // login = in.readString(); // name = in.readString(); // avatarUrl = in.readString(); // location = in.readString(); // company = in.readString(); // twitter = in.readString(); // website = in.readString(); // bio = in.readString(); // tagline = in.readString(); // github = in.readString(); // createdAt = in.readString(); // email = in.readString(); // topicsCount = in.readInt(); // repliesCount = in.readInt(); // followingCount = in.readInt(); // followersCount = in.readInt(); // favoritesCount = in.readInt(); // level = in.readString(); // levelName = in.readString(); // } // // public static final Creator<User> CREATOR = new Creator<User>() { // @Override // public User createFromParcel(Parcel in) { // return new User(in); // } // // @Override // public User[] newArray(int size) { // return new User[size]; // } // }; // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeInt(id); // dest.writeString(login); // dest.writeString(name); // dest.writeString(avatarUrl); // dest.writeString(location); // dest.writeString(company); // dest.writeString(twitter); // dest.writeString(website); // dest.writeString(bio); // dest.writeString(tagline); // dest.writeString(github); // dest.writeString(createdAt); // dest.writeString(email); // dest.writeInt(topicsCount); // dest.writeInt(repliesCount); // dest.writeInt(followingCount); // dest.writeInt(followersCount); // dest.writeInt(favoritesCount); // dest.writeString(level); // dest.writeString(levelName); // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/api/DiyCodeRetrofit.java // public static final Gson GSON = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").create(); // Path: app/src/main/java/moe/yukinoneko/diycode/tool/UserHelper.java import android.content.Context; import android.content.SharedPreferences; import com.securepreferences.SecurePreferences; import moe.yukinoneko.diycode.bean.Token; import moe.yukinoneko.diycode.bean.User; import static moe.yukinoneko.diycode.api.DiyCodeRetrofit.GSON; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.tool; /** * Created by SamuelGjk on 2017/3/23. */ public class UserHelper { private static final String TOKEN = "token"; private static final String USER = "user"; private static SharedPreferences prefs; public static void init(Context context) { prefs = new SecurePreferences(context.getApplicationContext()); } public static void saveToken(Token token) {
prefs.edit().putString(TOKEN, GSON.toJson(token)).apply();
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/news/create/CreateNewsContract.java
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/NewsNode.java // public class NewsNode { // @SerializedName("id") public int id; // 新闻节点 id // @SerializedName("name") public String name; // 名称 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BaseView.java // public interface BaseView { // Context getContext(); // // <T> LifecycleTransformer<T> bindToLife(); // }
import moe.yukinoneko.diycode.bean.NewsNode; import moe.yukinoneko.diycode.mvp.BasePresenter; import moe.yukinoneko.diycode.mvp.BaseView; import java.util.List;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.news.create; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class CreateNewsContract { interface View extends BaseView {
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/NewsNode.java // public class NewsNode { // @SerializedName("id") public int id; // 新闻节点 id // @SerializedName("name") public String name; // 名称 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BaseView.java // public interface BaseView { // Context getContext(); // // <T> LifecycleTransformer<T> bindToLife(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/news/create/CreateNewsContract.java import moe.yukinoneko.diycode.bean.NewsNode; import moe.yukinoneko.diycode.mvp.BasePresenter; import moe.yukinoneko.diycode.mvp.BaseView; import java.util.List; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.news.create; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class CreateNewsContract { interface View extends BaseView {
void updateNodes(List<NewsNode> nodes);
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/news/create/CreateNewsContract.java
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/NewsNode.java // public class NewsNode { // @SerializedName("id") public int id; // 新闻节点 id // @SerializedName("name") public String name; // 名称 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BaseView.java // public interface BaseView { // Context getContext(); // // <T> LifecycleTransformer<T> bindToLife(); // }
import moe.yukinoneko.diycode.bean.NewsNode; import moe.yukinoneko.diycode.mvp.BasePresenter; import moe.yukinoneko.diycode.mvp.BaseView; import java.util.List;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.news.create; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class CreateNewsContract { interface View extends BaseView { void updateNodes(List<NewsNode> nodes); String getNewsTitle(); String getLink(); void showProgress(boolean show); void titleError(); void linkError(); void createSuccessful(); }
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/NewsNode.java // public class NewsNode { // @SerializedName("id") public int id; // 新闻节点 id // @SerializedName("name") public String name; // 名称 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BaseView.java // public interface BaseView { // Context getContext(); // // <T> LifecycleTransformer<T> bindToLife(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/news/create/CreateNewsContract.java import moe.yukinoneko.diycode.bean.NewsNode; import moe.yukinoneko.diycode.mvp.BasePresenter; import moe.yukinoneko.diycode.mvp.BaseView; import java.util.List; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.news.create; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class CreateNewsContract { interface View extends BaseView { void updateNodes(List<NewsNode> nodes); String getNewsTitle(); String getLink(); void showProgress(boolean show); void titleError(); void linkError(); void createSuccessful(); }
interface Presenter extends BasePresenter<View> {
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/misc/DiyCodeWebViewClient.java
// Path: app/src/main/java/moe/yukinoneko/diycode/tool/UrlHelper.java // public static String getMimeType(String url) { // if (url.endsWith(".png") || url.endsWith(".PNG")) { // return "data:image/png;base64,"; // } else if (url.endsWith(".jpg") || url.endsWith(".jpeg") || url.endsWith(".JPG") || url.endsWith(".JPEG")) { // return "data:image/jpg;base64,"; // } else if (url.endsWith(".gif") || url.endsWith(".GIF")) { // return "data:image/gif;base64,"; // } else { // return ""; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/UrlHelper.java // public static boolean isGifSuffix(String url) { // return url.endsWith(".gif") // || url.endsWith(".GIF"); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/UrlHelper.java // public static boolean isImageSuffix(String url) { // return url.endsWith(".png") // || url.endsWith(".PNG") // || url.endsWith(".jpg") // || url.endsWith(".JPG") // || url.endsWith(".jpeg") // || url.endsWith(".JPEG"); // }
import com.bumptech.glide.request.animation.GlideAnimation; import com.bumptech.glide.request.target.SimpleTarget; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import static android.text.TextUtils.isEmpty; import static moe.yukinoneko.diycode.tool.UrlHelper.getMimeType; import static moe.yukinoneko.diycode.tool.UrlHelper.isGifSuffix; import static moe.yukinoneko.diycode.tool.UrlHelper.isImageSuffix; import android.content.Context; import android.os.Build; import android.support.annotation.Nullable; import android.support.annotation.RequiresApi; import android.webkit.WebResourceRequest; import android.webkit.WebResourceResponse; import android.webkit.WebView; import android.webkit.WebViewClient; import com.bumptech.glide.Glide;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.misc; /** * Created by SamuelGjk on 2017/4/24. */ public class DiyCodeWebViewClient extends WebViewClient { private Context context; private ACache aCache; public DiyCodeWebViewClient(Context context) { this.context = context; aCache = ACache.get(context); } // 监听加载了哪些资源 @Override public void onLoadResource(WebView view, final String url) { // 是图片就缓存
// Path: app/src/main/java/moe/yukinoneko/diycode/tool/UrlHelper.java // public static String getMimeType(String url) { // if (url.endsWith(".png") || url.endsWith(".PNG")) { // return "data:image/png;base64,"; // } else if (url.endsWith(".jpg") || url.endsWith(".jpeg") || url.endsWith(".JPG") || url.endsWith(".JPEG")) { // return "data:image/jpg;base64,"; // } else if (url.endsWith(".gif") || url.endsWith(".GIF")) { // return "data:image/gif;base64,"; // } else { // return ""; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/UrlHelper.java // public static boolean isGifSuffix(String url) { // return url.endsWith(".gif") // || url.endsWith(".GIF"); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/UrlHelper.java // public static boolean isImageSuffix(String url) { // return url.endsWith(".png") // || url.endsWith(".PNG") // || url.endsWith(".jpg") // || url.endsWith(".JPG") // || url.endsWith(".jpeg") // || url.endsWith(".JPEG"); // } // Path: app/src/main/java/moe/yukinoneko/diycode/misc/DiyCodeWebViewClient.java import com.bumptech.glide.request.animation.GlideAnimation; import com.bumptech.glide.request.target.SimpleTarget; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import static android.text.TextUtils.isEmpty; import static moe.yukinoneko.diycode.tool.UrlHelper.getMimeType; import static moe.yukinoneko.diycode.tool.UrlHelper.isGifSuffix; import static moe.yukinoneko.diycode.tool.UrlHelper.isImageSuffix; import android.content.Context; import android.os.Build; import android.support.annotation.Nullable; import android.support.annotation.RequiresApi; import android.webkit.WebResourceRequest; import android.webkit.WebResourceResponse; import android.webkit.WebView; import android.webkit.WebViewClient; import com.bumptech.glide.Glide; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.misc; /** * Created by SamuelGjk on 2017/4/24. */ public class DiyCodeWebViewClient extends WebViewClient { private Context context; private ACache aCache; public DiyCodeWebViewClient(Context context) { this.context = context; aCache = ACache.get(context); } // 监听加载了哪些资源 @Override public void onLoadResource(WebView view, final String url) { // 是图片就缓存
if (isImageSuffix(url) || isGifSuffix(url)) {
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/misc/DiyCodeWebViewClient.java
// Path: app/src/main/java/moe/yukinoneko/diycode/tool/UrlHelper.java // public static String getMimeType(String url) { // if (url.endsWith(".png") || url.endsWith(".PNG")) { // return "data:image/png;base64,"; // } else if (url.endsWith(".jpg") || url.endsWith(".jpeg") || url.endsWith(".JPG") || url.endsWith(".JPEG")) { // return "data:image/jpg;base64,"; // } else if (url.endsWith(".gif") || url.endsWith(".GIF")) { // return "data:image/gif;base64,"; // } else { // return ""; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/UrlHelper.java // public static boolean isGifSuffix(String url) { // return url.endsWith(".gif") // || url.endsWith(".GIF"); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/UrlHelper.java // public static boolean isImageSuffix(String url) { // return url.endsWith(".png") // || url.endsWith(".PNG") // || url.endsWith(".jpg") // || url.endsWith(".JPG") // || url.endsWith(".jpeg") // || url.endsWith(".JPEG"); // }
import com.bumptech.glide.request.animation.GlideAnimation; import com.bumptech.glide.request.target.SimpleTarget; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import static android.text.TextUtils.isEmpty; import static moe.yukinoneko.diycode.tool.UrlHelper.getMimeType; import static moe.yukinoneko.diycode.tool.UrlHelper.isGifSuffix; import static moe.yukinoneko.diycode.tool.UrlHelper.isImageSuffix; import android.content.Context; import android.os.Build; import android.support.annotation.Nullable; import android.support.annotation.RequiresApi; import android.webkit.WebResourceRequest; import android.webkit.WebResourceResponse; import android.webkit.WebView; import android.webkit.WebViewClient; import com.bumptech.glide.Glide;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.misc; /** * Created by SamuelGjk on 2017/4/24. */ public class DiyCodeWebViewClient extends WebViewClient { private Context context; private ACache aCache; public DiyCodeWebViewClient(Context context) { this.context = context; aCache = ACache.get(context); } // 监听加载了哪些资源 @Override public void onLoadResource(WebView view, final String url) { // 是图片就缓存
// Path: app/src/main/java/moe/yukinoneko/diycode/tool/UrlHelper.java // public static String getMimeType(String url) { // if (url.endsWith(".png") || url.endsWith(".PNG")) { // return "data:image/png;base64,"; // } else if (url.endsWith(".jpg") || url.endsWith(".jpeg") || url.endsWith(".JPG") || url.endsWith(".JPEG")) { // return "data:image/jpg;base64,"; // } else if (url.endsWith(".gif") || url.endsWith(".GIF")) { // return "data:image/gif;base64,"; // } else { // return ""; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/UrlHelper.java // public static boolean isGifSuffix(String url) { // return url.endsWith(".gif") // || url.endsWith(".GIF"); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/UrlHelper.java // public static boolean isImageSuffix(String url) { // return url.endsWith(".png") // || url.endsWith(".PNG") // || url.endsWith(".jpg") // || url.endsWith(".JPG") // || url.endsWith(".jpeg") // || url.endsWith(".JPEG"); // } // Path: app/src/main/java/moe/yukinoneko/diycode/misc/DiyCodeWebViewClient.java import com.bumptech.glide.request.animation.GlideAnimation; import com.bumptech.glide.request.target.SimpleTarget; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import static android.text.TextUtils.isEmpty; import static moe.yukinoneko.diycode.tool.UrlHelper.getMimeType; import static moe.yukinoneko.diycode.tool.UrlHelper.isGifSuffix; import static moe.yukinoneko.diycode.tool.UrlHelper.isImageSuffix; import android.content.Context; import android.os.Build; import android.support.annotation.Nullable; import android.support.annotation.RequiresApi; import android.webkit.WebResourceRequest; import android.webkit.WebResourceResponse; import android.webkit.WebView; import android.webkit.WebViewClient; import com.bumptech.glide.Glide; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.misc; /** * Created by SamuelGjk on 2017/4/24. */ public class DiyCodeWebViewClient extends WebViewClient { private Context context; private ACache aCache; public DiyCodeWebViewClient(Context context) { this.context = context; aCache = ACache.get(context); } // 监听加载了哪些资源 @Override public void onLoadResource(WebView view, final String url) { // 是图片就缓存
if (isImageSuffix(url) || isGifSuffix(url)) {
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/misc/DiyCodeWebViewClient.java
// Path: app/src/main/java/moe/yukinoneko/diycode/tool/UrlHelper.java // public static String getMimeType(String url) { // if (url.endsWith(".png") || url.endsWith(".PNG")) { // return "data:image/png;base64,"; // } else if (url.endsWith(".jpg") || url.endsWith(".jpeg") || url.endsWith(".JPG") || url.endsWith(".JPEG")) { // return "data:image/jpg;base64,"; // } else if (url.endsWith(".gif") || url.endsWith(".GIF")) { // return "data:image/gif;base64,"; // } else { // return ""; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/UrlHelper.java // public static boolean isGifSuffix(String url) { // return url.endsWith(".gif") // || url.endsWith(".GIF"); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/UrlHelper.java // public static boolean isImageSuffix(String url) { // return url.endsWith(".png") // || url.endsWith(".PNG") // || url.endsWith(".jpg") // || url.endsWith(".JPG") // || url.endsWith(".jpeg") // || url.endsWith(".JPEG"); // }
import com.bumptech.glide.request.animation.GlideAnimation; import com.bumptech.glide.request.target.SimpleTarget; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import static android.text.TextUtils.isEmpty; import static moe.yukinoneko.diycode.tool.UrlHelper.getMimeType; import static moe.yukinoneko.diycode.tool.UrlHelper.isGifSuffix; import static moe.yukinoneko.diycode.tool.UrlHelper.isImageSuffix; import android.content.Context; import android.os.Build; import android.support.annotation.Nullable; import android.support.annotation.RequiresApi; import android.webkit.WebResourceRequest; import android.webkit.WebResourceResponse; import android.webkit.WebView; import android.webkit.WebViewClient; import com.bumptech.glide.Glide;
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @Override public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) { String url = request.getUrl().toString(); WebResourceResponse response = getWebResourceResponse(url); if (response != null) return response; return super.shouldInterceptRequest(view, request); } @SuppressWarnings("deprecation") @Override public WebResourceResponse shouldInterceptRequest(WebView view, String url) { WebResourceResponse response = getWebResourceResponse(url); if (response != null) return response; return super.shouldInterceptRequest(view, url); } /** * 获取本地资源 */ @Nullable private WebResourceResponse getWebResourceResponse(String url) { try { // 如果是图片且本地有缓存 if (isImageSuffix(url) || isGifSuffix(url)) { String cachePath = aCache.getAsString(url); if (!isEmpty(cachePath)) { File cacheFile = new File(cachePath); if (cacheFile.exists()) {
// Path: app/src/main/java/moe/yukinoneko/diycode/tool/UrlHelper.java // public static String getMimeType(String url) { // if (url.endsWith(".png") || url.endsWith(".PNG")) { // return "data:image/png;base64,"; // } else if (url.endsWith(".jpg") || url.endsWith(".jpeg") || url.endsWith(".JPG") || url.endsWith(".JPEG")) { // return "data:image/jpg;base64,"; // } else if (url.endsWith(".gif") || url.endsWith(".GIF")) { // return "data:image/gif;base64,"; // } else { // return ""; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/UrlHelper.java // public static boolean isGifSuffix(String url) { // return url.endsWith(".gif") // || url.endsWith(".GIF"); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/UrlHelper.java // public static boolean isImageSuffix(String url) { // return url.endsWith(".png") // || url.endsWith(".PNG") // || url.endsWith(".jpg") // || url.endsWith(".JPG") // || url.endsWith(".jpeg") // || url.endsWith(".JPEG"); // } // Path: app/src/main/java/moe/yukinoneko/diycode/misc/DiyCodeWebViewClient.java import com.bumptech.glide.request.animation.GlideAnimation; import com.bumptech.glide.request.target.SimpleTarget; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import static android.text.TextUtils.isEmpty; import static moe.yukinoneko.diycode.tool.UrlHelper.getMimeType; import static moe.yukinoneko.diycode.tool.UrlHelper.isGifSuffix; import static moe.yukinoneko.diycode.tool.UrlHelper.isImageSuffix; import android.content.Context; import android.os.Build; import android.support.annotation.Nullable; import android.support.annotation.RequiresApi; import android.webkit.WebResourceRequest; import android.webkit.WebResourceResponse; import android.webkit.WebView; import android.webkit.WebViewClient; import com.bumptech.glide.Glide; @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @Override public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) { String url = request.getUrl().toString(); WebResourceResponse response = getWebResourceResponse(url); if (response != null) return response; return super.shouldInterceptRequest(view, request); } @SuppressWarnings("deprecation") @Override public WebResourceResponse shouldInterceptRequest(WebView view, String url) { WebResourceResponse response = getWebResourceResponse(url); if (response != null) return response; return super.shouldInterceptRequest(view, url); } /** * 获取本地资源 */ @Nullable private WebResourceResponse getWebResourceResponse(String url) { try { // 如果是图片且本地有缓存 if (isImageSuffix(url) || isGifSuffix(url)) { String cachePath = aCache.getAsString(url); if (!isEmpty(cachePath)) { File cacheFile = new File(cachePath); if (cacheFile.exists()) {
return new WebResourceResponse(getMimeType(url), "base64", new FileInputStream(cacheFile));
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/login/LoginActivity.java
// Path: app/src/main/java/moe/yukinoneko/diycode/event/LoginEvent.java // public class LoginEvent { // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/MVPBaseActivity.java // public abstract class MVPBaseActivity<V extends BaseView, T extends BasePresenterImpl<V>> extends BaseActivity implements BaseView { // protected T presenter; // // @SuppressWarnings("unchecked") // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // presenter = getInstance(this, 1); // presenter.attachView((V) this); // // super.onCreate(savedInstanceState); // } // // @Override // protected void onDestroy() { // if (presenter != null) { // presenter.detachView(); // } // super.onDestroy(); // } // // @Override // public Context getContext() { // return this; // } // // @Override // public <T> LifecycleTransformer<T> bindToLife() { // return this.<T>bindToLifecycle(); // } // // @SuppressWarnings("unchecked") // public <T> T getInstance(Object o, int i) { // try { // return ((Class<T>) ((ParameterizedType) (o.getClass().getGenericSuperclass())).getActualTypeArguments()[i]).newInstance(); // } catch (InstantiationException | IllegalAccessException | ClassCastException e) { // e.printStackTrace(); // } // return null; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/StringHelper.java // public static String trim(CharSequence input) { // return input.toString().trim(); // }
import org.greenrobot.eventbus.EventBus; import butterknife.BindView; import butterknife.OnClick; import moe.yukinoneko.diycode.R; import moe.yukinoneko.diycode.event.LoginEvent; import moe.yukinoneko.diycode.mvp.MVPBaseActivity; import static android.text.TextUtils.isEmpty; import static moe.yukinoneko.diycode.tool.StringHelper.trim; import android.app.ProgressDialog; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.design.widget.TextInputEditText; import android.support.design.widget.TextInputLayout; import android.text.Editable; import android.text.TextWatcher; import android.view.View;
} @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { if (!isEmpty(s)) { passwordHint.setErrorEnabled(false); } } }); } @OnClick({ R.id.button_close, R.id.button_sign_in }) public void onClick(View view) { switch (view.getId()) { case R.id.button_close: finish(); break; case R.id.button_sign_in: presenter.login(); break; } } @Override public String getUsername() {
// Path: app/src/main/java/moe/yukinoneko/diycode/event/LoginEvent.java // public class LoginEvent { // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/MVPBaseActivity.java // public abstract class MVPBaseActivity<V extends BaseView, T extends BasePresenterImpl<V>> extends BaseActivity implements BaseView { // protected T presenter; // // @SuppressWarnings("unchecked") // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // presenter = getInstance(this, 1); // presenter.attachView((V) this); // // super.onCreate(savedInstanceState); // } // // @Override // protected void onDestroy() { // if (presenter != null) { // presenter.detachView(); // } // super.onDestroy(); // } // // @Override // public Context getContext() { // return this; // } // // @Override // public <T> LifecycleTransformer<T> bindToLife() { // return this.<T>bindToLifecycle(); // } // // @SuppressWarnings("unchecked") // public <T> T getInstance(Object o, int i) { // try { // return ((Class<T>) ((ParameterizedType) (o.getClass().getGenericSuperclass())).getActualTypeArguments()[i]).newInstance(); // } catch (InstantiationException | IllegalAccessException | ClassCastException e) { // e.printStackTrace(); // } // return null; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/StringHelper.java // public static String trim(CharSequence input) { // return input.toString().trim(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/login/LoginActivity.java import org.greenrobot.eventbus.EventBus; import butterknife.BindView; import butterknife.OnClick; import moe.yukinoneko.diycode.R; import moe.yukinoneko.diycode.event.LoginEvent; import moe.yukinoneko.diycode.mvp.MVPBaseActivity; import static android.text.TextUtils.isEmpty; import static moe.yukinoneko.diycode.tool.StringHelper.trim; import android.app.ProgressDialog; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.design.widget.TextInputEditText; import android.support.design.widget.TextInputLayout; import android.text.Editable; import android.text.TextWatcher; import android.view.View; } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { if (!isEmpty(s)) { passwordHint.setErrorEnabled(false); } } }); } @OnClick({ R.id.button_close, R.id.button_sign_in }) public void onClick(View view) { switch (view.getId()) { case R.id.button_close: finish(); break; case R.id.button_sign_in: presenter.login(); break; } } @Override public String getUsername() {
return trim(editUsername.getText());
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/login/LoginActivity.java
// Path: app/src/main/java/moe/yukinoneko/diycode/event/LoginEvent.java // public class LoginEvent { // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/MVPBaseActivity.java // public abstract class MVPBaseActivity<V extends BaseView, T extends BasePresenterImpl<V>> extends BaseActivity implements BaseView { // protected T presenter; // // @SuppressWarnings("unchecked") // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // presenter = getInstance(this, 1); // presenter.attachView((V) this); // // super.onCreate(savedInstanceState); // } // // @Override // protected void onDestroy() { // if (presenter != null) { // presenter.detachView(); // } // super.onDestroy(); // } // // @Override // public Context getContext() { // return this; // } // // @Override // public <T> LifecycleTransformer<T> bindToLife() { // return this.<T>bindToLifecycle(); // } // // @SuppressWarnings("unchecked") // public <T> T getInstance(Object o, int i) { // try { // return ((Class<T>) ((ParameterizedType) (o.getClass().getGenericSuperclass())).getActualTypeArguments()[i]).newInstance(); // } catch (InstantiationException | IllegalAccessException | ClassCastException e) { // e.printStackTrace(); // } // return null; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/StringHelper.java // public static String trim(CharSequence input) { // return input.toString().trim(); // }
import org.greenrobot.eventbus.EventBus; import butterknife.BindView; import butterknife.OnClick; import moe.yukinoneko.diycode.R; import moe.yukinoneko.diycode.event.LoginEvent; import moe.yukinoneko.diycode.mvp.MVPBaseActivity; import static android.text.TextUtils.isEmpty; import static moe.yukinoneko.diycode.tool.StringHelper.trim; import android.app.ProgressDialog; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.design.widget.TextInputEditText; import android.support.design.widget.TextInputLayout; import android.text.Editable; import android.text.TextWatcher; import android.view.View;
finish(); break; case R.id.button_sign_in: presenter.login(); break; } } @Override public String getUsername() { return trim(editUsername.getText()); } @Override public String getPassword() { return trim(editPassword.getText()); } @Override public void nameError() { usernameHint.setError(getString(R.string.username_non_null)); } @Override public void passwordError() { passwordHint.setError(getString(R.string.password_non_null)); } @Override public void LoginSuccessful() {
// Path: app/src/main/java/moe/yukinoneko/diycode/event/LoginEvent.java // public class LoginEvent { // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/MVPBaseActivity.java // public abstract class MVPBaseActivity<V extends BaseView, T extends BasePresenterImpl<V>> extends BaseActivity implements BaseView { // protected T presenter; // // @SuppressWarnings("unchecked") // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // presenter = getInstance(this, 1); // presenter.attachView((V) this); // // super.onCreate(savedInstanceState); // } // // @Override // protected void onDestroy() { // if (presenter != null) { // presenter.detachView(); // } // super.onDestroy(); // } // // @Override // public Context getContext() { // return this; // } // // @Override // public <T> LifecycleTransformer<T> bindToLife() { // return this.<T>bindToLifecycle(); // } // // @SuppressWarnings("unchecked") // public <T> T getInstance(Object o, int i) { // try { // return ((Class<T>) ((ParameterizedType) (o.getClass().getGenericSuperclass())).getActualTypeArguments()[i]).newInstance(); // } catch (InstantiationException | IllegalAccessException | ClassCastException e) { // e.printStackTrace(); // } // return null; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/StringHelper.java // public static String trim(CharSequence input) { // return input.toString().trim(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/login/LoginActivity.java import org.greenrobot.eventbus.EventBus; import butterknife.BindView; import butterknife.OnClick; import moe.yukinoneko.diycode.R; import moe.yukinoneko.diycode.event.LoginEvent; import moe.yukinoneko.diycode.mvp.MVPBaseActivity; import static android.text.TextUtils.isEmpty; import static moe.yukinoneko.diycode.tool.StringHelper.trim; import android.app.ProgressDialog; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.design.widget.TextInputEditText; import android.support.design.widget.TextInputLayout; import android.text.Editable; import android.text.TextWatcher; import android.view.View; finish(); break; case R.id.button_sign_in: presenter.login(); break; } } @Override public String getUsername() { return trim(editUsername.getText()); } @Override public String getPassword() { return trim(editPassword.getText()); } @Override public void nameError() { usernameHint.setError(getString(R.string.username_non_null)); } @Override public void passwordError() { passwordHint.setError(getString(R.string.password_non_null)); } @Override public void LoginSuccessful() {
EventBus.getDefault().post(new LoginEvent());
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/topic/TopicsContract.java
// Path: app/src/main/java/moe/yukinoneko/diycode/list/ListBaseView.java // public interface ListBaseView extends BaseView { // // void setEnd(boolean end); // // void setRefresh(boolean refresh); // // void notifyLoadingStarted(); // // void notifyLoadingFinished(); // // void error(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/Topic.java // public class Topic { // @SerializedName("id") public int id; // 话题 id // @SerializedName("title") public String title; // 标题 // @SerializedName("created_at") public Date createdAt; // 创建时间 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // @SerializedName("replied_at") public Date repliedAt; // 最近一次回复时间 // @SerializedName("replies_count") public int repliesCount; // 回复总数量 // @SerializedName("node_name") public String nodeName; // 节点名称 // @SerializedName("node_id") public int nodeId; // 节点 id // @SerializedName("last_reply_user_id") public int lastReplyUserId; // 最近一次回复的用户 id // @SerializedName("last_reply_user_login") public String lastReplyUserLogin; // 最近一次回复的用户登录名 // @SerializedName("user") public User user; // 创建该话题的用户 // @SerializedName("deleted") public boolean deleted; // 是否已删除 // @SerializedName("excellent") public boolean excellent; // 是否加精 // @SerializedName("abilities") public Abilities abilities; // 当前用户对该话题拥有的权限 // @SerializedName("body") public String body; // 话题详情(Markdown) // @SerializedName("body_html") public String bodyHtml; // 话题详情(HTML) // @SerializedName("hits") public int hits; // 浏览次数 // @SerializedName("likes_count") public int likesCount; // 点赞数 // @SerializedName("suggested_at") public Date suggestedAt; // 置顶(推荐)时间 // @SerializedName("followed") public Boolean followed; // 是否关注 // @SerializedName("liked") public Boolean liked; // 是否喜欢 // @SerializedName("favorited") public Boolean favorited; // 是否收藏 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // }
import moe.yukinoneko.diycode.list.ListBaseView; import moe.yukinoneko.diycode.bean.Topic; import moe.yukinoneko.diycode.mvp.BasePresenter; import java.util.List;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.topic; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class TopicsContract { interface View extends ListBaseView {
// Path: app/src/main/java/moe/yukinoneko/diycode/list/ListBaseView.java // public interface ListBaseView extends BaseView { // // void setEnd(boolean end); // // void setRefresh(boolean refresh); // // void notifyLoadingStarted(); // // void notifyLoadingFinished(); // // void error(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/Topic.java // public class Topic { // @SerializedName("id") public int id; // 话题 id // @SerializedName("title") public String title; // 标题 // @SerializedName("created_at") public Date createdAt; // 创建时间 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // @SerializedName("replied_at") public Date repliedAt; // 最近一次回复时间 // @SerializedName("replies_count") public int repliesCount; // 回复总数量 // @SerializedName("node_name") public String nodeName; // 节点名称 // @SerializedName("node_id") public int nodeId; // 节点 id // @SerializedName("last_reply_user_id") public int lastReplyUserId; // 最近一次回复的用户 id // @SerializedName("last_reply_user_login") public String lastReplyUserLogin; // 最近一次回复的用户登录名 // @SerializedName("user") public User user; // 创建该话题的用户 // @SerializedName("deleted") public boolean deleted; // 是否已删除 // @SerializedName("excellent") public boolean excellent; // 是否加精 // @SerializedName("abilities") public Abilities abilities; // 当前用户对该话题拥有的权限 // @SerializedName("body") public String body; // 话题详情(Markdown) // @SerializedName("body_html") public String bodyHtml; // 话题详情(HTML) // @SerializedName("hits") public int hits; // 浏览次数 // @SerializedName("likes_count") public int likesCount; // 点赞数 // @SerializedName("suggested_at") public Date suggestedAt; // 置顶(推荐)时间 // @SerializedName("followed") public Boolean followed; // 是否关注 // @SerializedName("liked") public Boolean liked; // 是否喜欢 // @SerializedName("favorited") public Boolean favorited; // 是否收藏 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/topic/TopicsContract.java import moe.yukinoneko.diycode.list.ListBaseView; import moe.yukinoneko.diycode.bean.Topic; import moe.yukinoneko.diycode.mvp.BasePresenter; import java.util.List; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.topic; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class TopicsContract { interface View extends ListBaseView {
void updateTopicsList(List<Topic> topics);
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/topic/TopicsContract.java
// Path: app/src/main/java/moe/yukinoneko/diycode/list/ListBaseView.java // public interface ListBaseView extends BaseView { // // void setEnd(boolean end); // // void setRefresh(boolean refresh); // // void notifyLoadingStarted(); // // void notifyLoadingFinished(); // // void error(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/Topic.java // public class Topic { // @SerializedName("id") public int id; // 话题 id // @SerializedName("title") public String title; // 标题 // @SerializedName("created_at") public Date createdAt; // 创建时间 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // @SerializedName("replied_at") public Date repliedAt; // 最近一次回复时间 // @SerializedName("replies_count") public int repliesCount; // 回复总数量 // @SerializedName("node_name") public String nodeName; // 节点名称 // @SerializedName("node_id") public int nodeId; // 节点 id // @SerializedName("last_reply_user_id") public int lastReplyUserId; // 最近一次回复的用户 id // @SerializedName("last_reply_user_login") public String lastReplyUserLogin; // 最近一次回复的用户登录名 // @SerializedName("user") public User user; // 创建该话题的用户 // @SerializedName("deleted") public boolean deleted; // 是否已删除 // @SerializedName("excellent") public boolean excellent; // 是否加精 // @SerializedName("abilities") public Abilities abilities; // 当前用户对该话题拥有的权限 // @SerializedName("body") public String body; // 话题详情(Markdown) // @SerializedName("body_html") public String bodyHtml; // 话题详情(HTML) // @SerializedName("hits") public int hits; // 浏览次数 // @SerializedName("likes_count") public int likesCount; // 点赞数 // @SerializedName("suggested_at") public Date suggestedAt; // 置顶(推荐)时间 // @SerializedName("followed") public Boolean followed; // 是否关注 // @SerializedName("liked") public Boolean liked; // 是否喜欢 // @SerializedName("favorited") public Boolean favorited; // 是否收藏 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // }
import moe.yukinoneko.diycode.list.ListBaseView; import moe.yukinoneko.diycode.bean.Topic; import moe.yukinoneko.diycode.mvp.BasePresenter; import java.util.List;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.topic; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class TopicsContract { interface View extends ListBaseView { void updateTopicsList(List<Topic> topics); }
// Path: app/src/main/java/moe/yukinoneko/diycode/list/ListBaseView.java // public interface ListBaseView extends BaseView { // // void setEnd(boolean end); // // void setRefresh(boolean refresh); // // void notifyLoadingStarted(); // // void notifyLoadingFinished(); // // void error(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/Topic.java // public class Topic { // @SerializedName("id") public int id; // 话题 id // @SerializedName("title") public String title; // 标题 // @SerializedName("created_at") public Date createdAt; // 创建时间 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // @SerializedName("replied_at") public Date repliedAt; // 最近一次回复时间 // @SerializedName("replies_count") public int repliesCount; // 回复总数量 // @SerializedName("node_name") public String nodeName; // 节点名称 // @SerializedName("node_id") public int nodeId; // 节点 id // @SerializedName("last_reply_user_id") public int lastReplyUserId; // 最近一次回复的用户 id // @SerializedName("last_reply_user_login") public String lastReplyUserLogin; // 最近一次回复的用户登录名 // @SerializedName("user") public User user; // 创建该话题的用户 // @SerializedName("deleted") public boolean deleted; // 是否已删除 // @SerializedName("excellent") public boolean excellent; // 是否加精 // @SerializedName("abilities") public Abilities abilities; // 当前用户对该话题拥有的权限 // @SerializedName("body") public String body; // 话题详情(Markdown) // @SerializedName("body_html") public String bodyHtml; // 话题详情(HTML) // @SerializedName("hits") public int hits; // 浏览次数 // @SerializedName("likes_count") public int likesCount; // 点赞数 // @SerializedName("suggested_at") public Date suggestedAt; // 置顶(推荐)时间 // @SerializedName("followed") public Boolean followed; // 是否关注 // @SerializedName("liked") public Boolean liked; // 是否喜欢 // @SerializedName("favorited") public Boolean favorited; // 是否收藏 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/topic/TopicsContract.java import moe.yukinoneko.diycode.list.ListBaseView; import moe.yukinoneko.diycode.bean.Topic; import moe.yukinoneko.diycode.mvp.BasePresenter; import java.util.List; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.topic; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class TopicsContract { interface View extends ListBaseView { void updateTopicsList(List<Topic> topics); }
interface Presenter extends BasePresenter<View> {
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/topic/create/CreateTopicContract.java
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/Node.java // public class Node { // // @SerializedName("id") public int id; // 节点 id // @SerializedName("name") public String name; // 节点名 // @SerializedName("topics_count") public int topicsCount; // 话题数量 // @SerializedName("summary") public String summary; // 节点介绍 // @SerializedName("section_id") public int sectionId; // 分类 id // @SerializedName("sort") public int sort; // 排序 // @SerializedName("section_name") public String sectionName; // 分类名 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BaseView.java // public interface BaseView { // Context getContext(); // // <T> LifecycleTransformer<T> bindToLife(); // }
import java.io.File; import java.util.List; import moe.yukinoneko.diycode.bean.Node; import moe.yukinoneko.diycode.mvp.BasePresenter; import moe.yukinoneko.diycode.mvp.BaseView;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.topic.create; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class CreateTopicContract { interface View extends BaseView {
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/Node.java // public class Node { // // @SerializedName("id") public int id; // 节点 id // @SerializedName("name") public String name; // 节点名 // @SerializedName("topics_count") public int topicsCount; // 话题数量 // @SerializedName("summary") public String summary; // 节点介绍 // @SerializedName("section_id") public int sectionId; // 分类 id // @SerializedName("sort") public int sort; // 排序 // @SerializedName("section_name") public String sectionName; // 分类名 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BaseView.java // public interface BaseView { // Context getContext(); // // <T> LifecycleTransformer<T> bindToLife(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/topic/create/CreateTopicContract.java import java.io.File; import java.util.List; import moe.yukinoneko.diycode.bean.Node; import moe.yukinoneko.diycode.mvp.BasePresenter; import moe.yukinoneko.diycode.mvp.BaseView; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.topic.create; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class CreateTopicContract { interface View extends BaseView {
void updateNodes(List<Node> nodes);
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/topic/create/CreateTopicContract.java
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/Node.java // public class Node { // // @SerializedName("id") public int id; // 节点 id // @SerializedName("name") public String name; // 节点名 // @SerializedName("topics_count") public int topicsCount; // 话题数量 // @SerializedName("summary") public String summary; // 节点介绍 // @SerializedName("section_id") public int sectionId; // 分类 id // @SerializedName("sort") public int sort; // 排序 // @SerializedName("section_name") public String sectionName; // 分类名 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BaseView.java // public interface BaseView { // Context getContext(); // // <T> LifecycleTransformer<T> bindToLife(); // }
import java.io.File; import java.util.List; import moe.yukinoneko.diycode.bean.Node; import moe.yukinoneko.diycode.mvp.BasePresenter; import moe.yukinoneko.diycode.mvp.BaseView;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.topic.create; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class CreateTopicContract { interface View extends BaseView { void updateNodes(List<Node> nodes); int getNodeId(); String getTopicTitle(); String getContent(); void showProgress(boolean show); void titleError(); void contentError(); void uploadSuccessful(String imageUrl); void createSuccessful(); }
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/Node.java // public class Node { // // @SerializedName("id") public int id; // 节点 id // @SerializedName("name") public String name; // 节点名 // @SerializedName("topics_count") public int topicsCount; // 话题数量 // @SerializedName("summary") public String summary; // 节点介绍 // @SerializedName("section_id") public int sectionId; // 分类 id // @SerializedName("sort") public int sort; // 排序 // @SerializedName("section_name") public String sectionName; // 分类名 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BaseView.java // public interface BaseView { // Context getContext(); // // <T> LifecycleTransformer<T> bindToLife(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/topic/create/CreateTopicContract.java import java.io.File; import java.util.List; import moe.yukinoneko.diycode.bean.Node; import moe.yukinoneko.diycode.mvp.BasePresenter; import moe.yukinoneko.diycode.mvp.BaseView; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.topic.create; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class CreateTopicContract { interface View extends BaseView { void updateNodes(List<Node> nodes); int getNodeId(); String getTopicTitle(); String getContent(); void showProgress(boolean show); void titleError(); void contentError(); void uploadSuccessful(String imageUrl); void createSuccessful(); }
interface Presenter extends BasePresenter<View> {
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/notification/NotificationsContract.java
// Path: app/src/main/java/moe/yukinoneko/diycode/list/ListBaseView.java // public interface ListBaseView extends BaseView { // // void setEnd(boolean end); // // void setRefresh(boolean refresh); // // void notifyLoadingStarted(); // // void notifyLoadingFinished(); // // void error(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/Notification.java // public class Notification { // @SerializedName("id") public int id; // 通知 id // @SerializedName("type") public String type; // 类型 // @SerializedName("read") public Boolean read; // 是否已读 // @SerializedName("actor") public User actor; // 相关人员 // @SerializedName("mention_type") public String mentionType; // 提及类型 // @SerializedName("mention") public Reply mention; // 提及详情 // @SerializedName("topic") public Topic topic; // 话题 // @SerializedName("reply") public Reply reply; // 回复 // @SerializedName("node") public Node node; // 节点变更 // @SerializedName("created_at") public Date createdAt; // 创建时间 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // }
import moe.yukinoneko.diycode.list.ListBaseView; import moe.yukinoneko.diycode.bean.Notification; import moe.yukinoneko.diycode.mvp.BasePresenter; import java.util.List;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.notification; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class NotificationsContract { interface View extends ListBaseView {
// Path: app/src/main/java/moe/yukinoneko/diycode/list/ListBaseView.java // public interface ListBaseView extends BaseView { // // void setEnd(boolean end); // // void setRefresh(boolean refresh); // // void notifyLoadingStarted(); // // void notifyLoadingFinished(); // // void error(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/Notification.java // public class Notification { // @SerializedName("id") public int id; // 通知 id // @SerializedName("type") public String type; // 类型 // @SerializedName("read") public Boolean read; // 是否已读 // @SerializedName("actor") public User actor; // 相关人员 // @SerializedName("mention_type") public String mentionType; // 提及类型 // @SerializedName("mention") public Reply mention; // 提及详情 // @SerializedName("topic") public Topic topic; // 话题 // @SerializedName("reply") public Reply reply; // 回复 // @SerializedName("node") public Node node; // 节点变更 // @SerializedName("created_at") public Date createdAt; // 创建时间 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/notification/NotificationsContract.java import moe.yukinoneko.diycode.list.ListBaseView; import moe.yukinoneko.diycode.bean.Notification; import moe.yukinoneko.diycode.mvp.BasePresenter; import java.util.List; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.notification; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class NotificationsContract { interface View extends ListBaseView {
void updateNotificationsList(List<Notification> notifications);
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/notification/NotificationsContract.java
// Path: app/src/main/java/moe/yukinoneko/diycode/list/ListBaseView.java // public interface ListBaseView extends BaseView { // // void setEnd(boolean end); // // void setRefresh(boolean refresh); // // void notifyLoadingStarted(); // // void notifyLoadingFinished(); // // void error(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/Notification.java // public class Notification { // @SerializedName("id") public int id; // 通知 id // @SerializedName("type") public String type; // 类型 // @SerializedName("read") public Boolean read; // 是否已读 // @SerializedName("actor") public User actor; // 相关人员 // @SerializedName("mention_type") public String mentionType; // 提及类型 // @SerializedName("mention") public Reply mention; // 提及详情 // @SerializedName("topic") public Topic topic; // 话题 // @SerializedName("reply") public Reply reply; // 回复 // @SerializedName("node") public Node node; // 节点变更 // @SerializedName("created_at") public Date createdAt; // 创建时间 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // }
import moe.yukinoneko.diycode.list.ListBaseView; import moe.yukinoneko.diycode.bean.Notification; import moe.yukinoneko.diycode.mvp.BasePresenter; import java.util.List;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.notification; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class NotificationsContract { interface View extends ListBaseView { void updateNotificationsList(List<Notification> notifications); }
// Path: app/src/main/java/moe/yukinoneko/diycode/list/ListBaseView.java // public interface ListBaseView extends BaseView { // // void setEnd(boolean end); // // void setRefresh(boolean refresh); // // void notifyLoadingStarted(); // // void notifyLoadingFinished(); // // void error(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/Notification.java // public class Notification { // @SerializedName("id") public int id; // 通知 id // @SerializedName("type") public String type; // 类型 // @SerializedName("read") public Boolean read; // 是否已读 // @SerializedName("actor") public User actor; // 相关人员 // @SerializedName("mention_type") public String mentionType; // 提及类型 // @SerializedName("mention") public Reply mention; // 提及详情 // @SerializedName("topic") public Topic topic; // 话题 // @SerializedName("reply") public Reply reply; // 回复 // @SerializedName("node") public Node node; // 节点变更 // @SerializedName("created_at") public Date createdAt; // 创建时间 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/notification/NotificationsContract.java import moe.yukinoneko.diycode.list.ListBaseView; import moe.yukinoneko.diycode.bean.Notification; import moe.yukinoneko.diycode.mvp.BasePresenter; import java.util.List; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.notification; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class NotificationsContract { interface View extends ListBaseView { void updateNotificationsList(List<Notification> notifications); }
interface Presenter extends BasePresenter<View> {
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/news/create/CreateNewsActivity.java
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/NewsNode.java // public class NewsNode { // @SerializedName("id") public int id; // 新闻节点 id // @SerializedName("name") public String name; // 名称 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/MVPBaseActivity.java // public abstract class MVPBaseActivity<V extends BaseView, T extends BasePresenterImpl<V>> extends BaseActivity implements BaseView { // protected T presenter; // // @SuppressWarnings("unchecked") // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // presenter = getInstance(this, 1); // presenter.attachView((V) this); // // super.onCreate(savedInstanceState); // } // // @Override // protected void onDestroy() { // if (presenter != null) { // presenter.detachView(); // } // super.onDestroy(); // } // // @Override // public Context getContext() { // return this; // } // // @Override // public <T> LifecycleTransformer<T> bindToLife() { // return this.<T>bindToLifecycle(); // } // // @SuppressWarnings("unchecked") // public <T> T getInstance(Object o, int i) { // try { // return ((Class<T>) ((ParameterizedType) (o.getClass().getGenericSuperclass())).getActualTypeArguments()[i]).newInstance(); // } catch (InstantiationException | IllegalAccessException | ClassCastException e) { // e.printStackTrace(); // } // return null; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/StringHelper.java // public static String trim(CharSequence input) { // return input.toString().trim(); // }
import java.util.ArrayList; import java.util.List; import butterknife.BindView; import moe.yukinoneko.diycode.R; import moe.yukinoneko.diycode.bean.NewsNode; import moe.yukinoneko.diycode.mvp.MVPBaseActivity; import static moe.yukinoneko.diycode.tool.StringHelper.trim; import android.app.ProgressDialog; import android.os.Bundle; import android.support.v7.widget.AppCompatEditText; import android.support.v7.widget.AppCompatSpinner; import android.view.Menu; import android.view.MenuItem; import android.widget.ArrayAdapter; import com.kennyc.view.MultiStateView;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.news.create; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class CreateNewsActivity extends MVPBaseActivity<CreateNewsContract.View, CreateNewsPresenter> implements CreateNewsContract.View { @BindView(R.id.spinner_node) AppCompatSpinner spinnerNode; @BindView(R.id.edit_title) AppCompatEditText editTitle; @BindView(R.id.edit_link) AppCompatEditText editLink; @BindView(R.id.multi_state_view) MultiStateView multiStateView; private ProgressDialog progressDialog;
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/NewsNode.java // public class NewsNode { // @SerializedName("id") public int id; // 新闻节点 id // @SerializedName("name") public String name; // 名称 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/MVPBaseActivity.java // public abstract class MVPBaseActivity<V extends BaseView, T extends BasePresenterImpl<V>> extends BaseActivity implements BaseView { // protected T presenter; // // @SuppressWarnings("unchecked") // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // presenter = getInstance(this, 1); // presenter.attachView((V) this); // // super.onCreate(savedInstanceState); // } // // @Override // protected void onDestroy() { // if (presenter != null) { // presenter.detachView(); // } // super.onDestroy(); // } // // @Override // public Context getContext() { // return this; // } // // @Override // public <T> LifecycleTransformer<T> bindToLife() { // return this.<T>bindToLifecycle(); // } // // @SuppressWarnings("unchecked") // public <T> T getInstance(Object o, int i) { // try { // return ((Class<T>) ((ParameterizedType) (o.getClass().getGenericSuperclass())).getActualTypeArguments()[i]).newInstance(); // } catch (InstantiationException | IllegalAccessException | ClassCastException e) { // e.printStackTrace(); // } // return null; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/StringHelper.java // public static String trim(CharSequence input) { // return input.toString().trim(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/news/create/CreateNewsActivity.java import java.util.ArrayList; import java.util.List; import butterknife.BindView; import moe.yukinoneko.diycode.R; import moe.yukinoneko.diycode.bean.NewsNode; import moe.yukinoneko.diycode.mvp.MVPBaseActivity; import static moe.yukinoneko.diycode.tool.StringHelper.trim; import android.app.ProgressDialog; import android.os.Bundle; import android.support.v7.widget.AppCompatEditText; import android.support.v7.widget.AppCompatSpinner; import android.view.Menu; import android.view.MenuItem; import android.widget.ArrayAdapter; import com.kennyc.view.MultiStateView; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.news.create; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class CreateNewsActivity extends MVPBaseActivity<CreateNewsContract.View, CreateNewsPresenter> implements CreateNewsContract.View { @BindView(R.id.spinner_node) AppCompatSpinner spinnerNode; @BindView(R.id.edit_title) AppCompatEditText editTitle; @BindView(R.id.edit_link) AppCompatEditText editLink; @BindView(R.id.multi_state_view) MultiStateView multiStateView; private ProgressDialog progressDialog;
private List<NewsNode> nodes;
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/news/create/CreateNewsActivity.java
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/NewsNode.java // public class NewsNode { // @SerializedName("id") public int id; // 新闻节点 id // @SerializedName("name") public String name; // 名称 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/MVPBaseActivity.java // public abstract class MVPBaseActivity<V extends BaseView, T extends BasePresenterImpl<V>> extends BaseActivity implements BaseView { // protected T presenter; // // @SuppressWarnings("unchecked") // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // presenter = getInstance(this, 1); // presenter.attachView((V) this); // // super.onCreate(savedInstanceState); // } // // @Override // protected void onDestroy() { // if (presenter != null) { // presenter.detachView(); // } // super.onDestroy(); // } // // @Override // public Context getContext() { // return this; // } // // @Override // public <T> LifecycleTransformer<T> bindToLife() { // return this.<T>bindToLifecycle(); // } // // @SuppressWarnings("unchecked") // public <T> T getInstance(Object o, int i) { // try { // return ((Class<T>) ((ParameterizedType) (o.getClass().getGenericSuperclass())).getActualTypeArguments()[i]).newInstance(); // } catch (InstantiationException | IllegalAccessException | ClassCastException e) { // e.printStackTrace(); // } // return null; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/StringHelper.java // public static String trim(CharSequence input) { // return input.toString().trim(); // }
import java.util.ArrayList; import java.util.List; import butterknife.BindView; import moe.yukinoneko.diycode.R; import moe.yukinoneko.diycode.bean.NewsNode; import moe.yukinoneko.diycode.mvp.MVPBaseActivity; import static moe.yukinoneko.diycode.tool.StringHelper.trim; import android.app.ProgressDialog; import android.os.Bundle; import android.support.v7.widget.AppCompatEditText; import android.support.v7.widget.AppCompatSpinner; import android.view.Menu; import android.view.MenuItem; import android.widget.ArrayAdapter; import com.kennyc.view.MultiStateView;
public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.send, menu); return super.onCreateOptionsMenu(menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.action_send) { presenter.newNews(nodes.get(spinnerNode.getSelectedItemPosition()).id); return true; } return super.onOptionsItemSelected(item); } @Override public void updateNodes(List<NewsNode> nodes) { multiStateView.setViewState(MultiStateView.VIEW_STATE_CONTENT); this.nodes = nodes; List<String> nodeNames = new ArrayList<>(); for (NewsNode node : nodes) { nodeNames.add(node.name); } ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, nodeNames); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerNode.setAdapter(adapter); } @Override public String getNewsTitle() {
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/NewsNode.java // public class NewsNode { // @SerializedName("id") public int id; // 新闻节点 id // @SerializedName("name") public String name; // 名称 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/MVPBaseActivity.java // public abstract class MVPBaseActivity<V extends BaseView, T extends BasePresenterImpl<V>> extends BaseActivity implements BaseView { // protected T presenter; // // @SuppressWarnings("unchecked") // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // presenter = getInstance(this, 1); // presenter.attachView((V) this); // // super.onCreate(savedInstanceState); // } // // @Override // protected void onDestroy() { // if (presenter != null) { // presenter.detachView(); // } // super.onDestroy(); // } // // @Override // public Context getContext() { // return this; // } // // @Override // public <T> LifecycleTransformer<T> bindToLife() { // return this.<T>bindToLifecycle(); // } // // @SuppressWarnings("unchecked") // public <T> T getInstance(Object o, int i) { // try { // return ((Class<T>) ((ParameterizedType) (o.getClass().getGenericSuperclass())).getActualTypeArguments()[i]).newInstance(); // } catch (InstantiationException | IllegalAccessException | ClassCastException e) { // e.printStackTrace(); // } // return null; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/StringHelper.java // public static String trim(CharSequence input) { // return input.toString().trim(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/news/create/CreateNewsActivity.java import java.util.ArrayList; import java.util.List; import butterknife.BindView; import moe.yukinoneko.diycode.R; import moe.yukinoneko.diycode.bean.NewsNode; import moe.yukinoneko.diycode.mvp.MVPBaseActivity; import static moe.yukinoneko.diycode.tool.StringHelper.trim; import android.app.ProgressDialog; import android.os.Bundle; import android.support.v7.widget.AppCompatEditText; import android.support.v7.widget.AppCompatSpinner; import android.view.Menu; import android.view.MenuItem; import android.widget.ArrayAdapter; import com.kennyc.view.MultiStateView; public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.send, menu); return super.onCreateOptionsMenu(menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.action_send) { presenter.newNews(nodes.get(spinnerNode.getSelectedItemPosition()).id); return true; } return super.onOptionsItemSelected(item); } @Override public void updateNodes(List<NewsNode> nodes) { multiStateView.setViewState(MultiStateView.VIEW_STATE_CONTENT); this.nodes = nodes; List<String> nodeNames = new ArrayList<>(); for (NewsNode node : nodes) { nodeNames.add(node.name); } ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, nodeNames); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerNode.setAdapter(adapter); } @Override public String getNewsTitle() {
return trim(editTitle.getText());
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/reply/create/CreateReplyContract.java
// Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BaseView.java // public interface BaseView { // Context getContext(); // // <T> LifecycleTransformer<T> bindToLife(); // }
import moe.yukinoneko.diycode.mvp.BasePresenter; import moe.yukinoneko.diycode.mvp.BaseView;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.reply.create; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class CreateReplyContract { interface View extends BaseView { String getContent(); void contentError(); void showProgress(boolean show); void createSuccessful(); }
// Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BaseView.java // public interface BaseView { // Context getContext(); // // <T> LifecycleTransformer<T> bindToLife(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/reply/create/CreateReplyContract.java import moe.yukinoneko.diycode.mvp.BasePresenter; import moe.yukinoneko.diycode.mvp.BaseView; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.reply.create; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class CreateReplyContract { interface View extends BaseView { String getContent(); void contentError(); void showProgress(boolean show); void createSuccessful(); }
interface Presenter extends BasePresenter<View> {
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/site/SitesContract.java
// Path: app/src/main/java/moe/yukinoneko/diycode/list/ListBaseView.java // public interface ListBaseView extends BaseView { // // void setEnd(boolean end); // // void setRefresh(boolean refresh); // // void notifyLoadingStarted(); // // void notifyLoadingFinished(); // // void error(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // }
import moe.yukinoneko.diycode.list.ListBaseView; import moe.yukinoneko.diycode.mvp.BasePresenter; import java.util.List;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.site; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class SitesContract { interface View extends ListBaseView { void updateSitesGrid(List<Object> sites); }
// Path: app/src/main/java/moe/yukinoneko/diycode/list/ListBaseView.java // public interface ListBaseView extends BaseView { // // void setEnd(boolean end); // // void setRefresh(boolean refresh); // // void notifyLoadingStarted(); // // void notifyLoadingFinished(); // // void error(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/site/SitesContract.java import moe.yukinoneko.diycode.list.ListBaseView; import moe.yukinoneko.diycode.mvp.BasePresenter; import java.util.List; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.site; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class SitesContract { interface View extends ListBaseView { void updateSitesGrid(List<Object> sites); }
interface Presenter extends BasePresenter<View> {
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/reply/RepliesContract.java
// Path: app/src/main/java/moe/yukinoneko/diycode/list/ListBaseView.java // public interface ListBaseView extends BaseView { // // void setEnd(boolean end); // // void setRefresh(boolean refresh); // // void notifyLoadingStarted(); // // void notifyLoadingFinished(); // // void error(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/Reply.java // public class Reply { // // @SerializedName("id") public int id; // 回复 id // @SerializedName("body_html") public String bodyHtml; // 回复内容详情(HTML) // @SerializedName("created_at") public Date createdAt; // 创建时间 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // @SerializedName("deleted") public boolean deleted; // 是否已经删除 // @SerializedName("user") public User user; // 创建该回复的用户 // @SerializedName("likes_count") public int likesCount; // 点赞数 // @SerializedName("abilities") public Abilities abilities; // 当前用户所拥有的权限 // @SerializedName("body") public String body; // 回复内容详情 // // // // topic 或 news 的 id // @SerializedName(value = "feedId", alternate = { "topic_id", "news_id" }) // public int feedId; // // // topic 或 news 的标题 // @SerializedName(value = "feedTitle", alternate = { "topic_title", "news_title" }) // public String feedTitle; // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // }
import moe.yukinoneko.diycode.list.ListBaseView; import moe.yukinoneko.diycode.bean.Reply; import moe.yukinoneko.diycode.mvp.BasePresenter; import java.util.List;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.reply; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class RepliesContract { interface View extends ListBaseView {
// Path: app/src/main/java/moe/yukinoneko/diycode/list/ListBaseView.java // public interface ListBaseView extends BaseView { // // void setEnd(boolean end); // // void setRefresh(boolean refresh); // // void notifyLoadingStarted(); // // void notifyLoadingFinished(); // // void error(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/Reply.java // public class Reply { // // @SerializedName("id") public int id; // 回复 id // @SerializedName("body_html") public String bodyHtml; // 回复内容详情(HTML) // @SerializedName("created_at") public Date createdAt; // 创建时间 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // @SerializedName("deleted") public boolean deleted; // 是否已经删除 // @SerializedName("user") public User user; // 创建该回复的用户 // @SerializedName("likes_count") public int likesCount; // 点赞数 // @SerializedName("abilities") public Abilities abilities; // 当前用户所拥有的权限 // @SerializedName("body") public String body; // 回复内容详情 // // // // topic 或 news 的 id // @SerializedName(value = "feedId", alternate = { "topic_id", "news_id" }) // public int feedId; // // // topic 或 news 的标题 // @SerializedName(value = "feedTitle", alternate = { "topic_title", "news_title" }) // public String feedTitle; // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/reply/RepliesContract.java import moe.yukinoneko.diycode.list.ListBaseView; import moe.yukinoneko.diycode.bean.Reply; import moe.yukinoneko.diycode.mvp.BasePresenter; import java.util.List; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.reply; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class RepliesContract { interface View extends ListBaseView {
void updateRepliesList(List<Reply> replies);
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/reply/RepliesContract.java
// Path: app/src/main/java/moe/yukinoneko/diycode/list/ListBaseView.java // public interface ListBaseView extends BaseView { // // void setEnd(boolean end); // // void setRefresh(boolean refresh); // // void notifyLoadingStarted(); // // void notifyLoadingFinished(); // // void error(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/Reply.java // public class Reply { // // @SerializedName("id") public int id; // 回复 id // @SerializedName("body_html") public String bodyHtml; // 回复内容详情(HTML) // @SerializedName("created_at") public Date createdAt; // 创建时间 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // @SerializedName("deleted") public boolean deleted; // 是否已经删除 // @SerializedName("user") public User user; // 创建该回复的用户 // @SerializedName("likes_count") public int likesCount; // 点赞数 // @SerializedName("abilities") public Abilities abilities; // 当前用户所拥有的权限 // @SerializedName("body") public String body; // 回复内容详情 // // // // topic 或 news 的 id // @SerializedName(value = "feedId", alternate = { "topic_id", "news_id" }) // public int feedId; // // // topic 或 news 的标题 // @SerializedName(value = "feedTitle", alternate = { "topic_title", "news_title" }) // public String feedTitle; // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // }
import moe.yukinoneko.diycode.list.ListBaseView; import moe.yukinoneko.diycode.bean.Reply; import moe.yukinoneko.diycode.mvp.BasePresenter; import java.util.List;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.reply; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class RepliesContract { interface View extends ListBaseView { void updateRepliesList(List<Reply> replies); }
// Path: app/src/main/java/moe/yukinoneko/diycode/list/ListBaseView.java // public interface ListBaseView extends BaseView { // // void setEnd(boolean end); // // void setRefresh(boolean refresh); // // void notifyLoadingStarted(); // // void notifyLoadingFinished(); // // void error(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/Reply.java // public class Reply { // // @SerializedName("id") public int id; // 回复 id // @SerializedName("body_html") public String bodyHtml; // 回复内容详情(HTML) // @SerializedName("created_at") public Date createdAt; // 创建时间 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // @SerializedName("deleted") public boolean deleted; // 是否已经删除 // @SerializedName("user") public User user; // 创建该回复的用户 // @SerializedName("likes_count") public int likesCount; // 点赞数 // @SerializedName("abilities") public Abilities abilities; // 当前用户所拥有的权限 // @SerializedName("body") public String body; // 回复内容详情 // // // // topic 或 news 的 id // @SerializedName(value = "feedId", alternate = { "topic_id", "news_id" }) // public int feedId; // // // topic 或 news 的标题 // @SerializedName(value = "feedTitle", alternate = { "topic_title", "news_title" }) // public String feedTitle; // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/reply/RepliesContract.java import moe.yukinoneko.diycode.list.ListBaseView; import moe.yukinoneko.diycode.bean.Reply; import moe.yukinoneko.diycode.mvp.BasePresenter; import java.util.List; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.reply; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class RepliesContract { interface View extends ListBaseView { void updateRepliesList(List<Reply> replies); }
interface Presenter extends BasePresenter<View> {
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/App.java
// Path: app/src/main/java/moe/yukinoneko/diycode/api/OAuth.java // public class OAuth { // // 认证类型 // public static final String GRANT_TYPE_LOGIN = "password"; // 密码 // public static final String GRANT_TYPE_REFRESH = "refresh_token"; // 刷新令牌 // // public static final String KEY_TOKEN = "Authorization"; // public static final String TOKEN_PREFIX = "Bearer "; // // public static String client_id; // 应用ID // public static String client_secret; // 私钥 // // public static void init(String clientId, String clientSecret) { // client_id = clientId; // client_secret = clientSecret; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/api/Secret.java // public class Secret { // static { // System.loadLibrary("secret"); // } // // public static native String getClientId(); // public static native String getSecret(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/UserHelper.java // public class UserHelper { // // private static final String TOKEN = "token"; // private static final String USER = "user"; // // private static SharedPreferences prefs; // // public static void init(Context context) { // prefs = new SecurePreferences(context.getApplicationContext()); // } // // public static void saveToken(Token token) { // prefs.edit().putString(TOKEN, GSON.toJson(token)).apply(); // } // // public static Token getToken() { // String tokenJson = prefs.getString(TOKEN, null); // if (tokenJson != null) { // return GSON.fromJson(tokenJson, Token.class); // } // return null; // } // // public static boolean isLogin() { // return null != getToken(); // } // // public static boolean hasUser() { // return null != getUser(); // } // // public static void saveUser(User user) { // prefs.edit().putString(USER, GSON.toJson(user)).apply(); // } // // public static User getUser() { // String userJson = prefs.getString(USER, null); // if (userJson != null) { // return GSON.fromJson(userJson, User.class); // } // return null; // } // // public static void logout() { // prefs.edit().remove(USER).remove(TOKEN).apply(); // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/ErrorHandler.java // public static Consumer<Throwable> errorConsumer(final Context context) { // return new Consumer<Throwable>() { // @Override public void accept(@NonNull Throwable throwable) { // String errorMessage = null; // if (throwable instanceof HttpException) { // HttpException httpException = (HttpException) throwable; // errorMessage = GSON.fromJson(httpException.response().errorBody().charStream(), Error.class).error; // } else if (throwable instanceof UnknownHostException) { // errorMessage = context.getString(R.string.tip_network_is_not_available); // } else { // errorMessage = throwable.getMessage(); // } // ToastHelper.showShort(context, errorMessage); // } // }; // }
import android.app.Application; import io.reactivex.plugins.RxJavaPlugins; import moe.yukinoneko.diycode.api.OAuth; import moe.yukinoneko.diycode.api.Secret; import moe.yukinoneko.diycode.tool.UserHelper; import static moe.yukinoneko.diycode.tool.ErrorHandler.errorConsumer;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode; /** * Created by SamuelGjk on 2017/3/23. */ public class App extends Application { @Override public void onCreate() { super.onCreate();
// Path: app/src/main/java/moe/yukinoneko/diycode/api/OAuth.java // public class OAuth { // // 认证类型 // public static final String GRANT_TYPE_LOGIN = "password"; // 密码 // public static final String GRANT_TYPE_REFRESH = "refresh_token"; // 刷新令牌 // // public static final String KEY_TOKEN = "Authorization"; // public static final String TOKEN_PREFIX = "Bearer "; // // public static String client_id; // 应用ID // public static String client_secret; // 私钥 // // public static void init(String clientId, String clientSecret) { // client_id = clientId; // client_secret = clientSecret; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/api/Secret.java // public class Secret { // static { // System.loadLibrary("secret"); // } // // public static native String getClientId(); // public static native String getSecret(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/UserHelper.java // public class UserHelper { // // private static final String TOKEN = "token"; // private static final String USER = "user"; // // private static SharedPreferences prefs; // // public static void init(Context context) { // prefs = new SecurePreferences(context.getApplicationContext()); // } // // public static void saveToken(Token token) { // prefs.edit().putString(TOKEN, GSON.toJson(token)).apply(); // } // // public static Token getToken() { // String tokenJson = prefs.getString(TOKEN, null); // if (tokenJson != null) { // return GSON.fromJson(tokenJson, Token.class); // } // return null; // } // // public static boolean isLogin() { // return null != getToken(); // } // // public static boolean hasUser() { // return null != getUser(); // } // // public static void saveUser(User user) { // prefs.edit().putString(USER, GSON.toJson(user)).apply(); // } // // public static User getUser() { // String userJson = prefs.getString(USER, null); // if (userJson != null) { // return GSON.fromJson(userJson, User.class); // } // return null; // } // // public static void logout() { // prefs.edit().remove(USER).remove(TOKEN).apply(); // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/ErrorHandler.java // public static Consumer<Throwable> errorConsumer(final Context context) { // return new Consumer<Throwable>() { // @Override public void accept(@NonNull Throwable throwable) { // String errorMessage = null; // if (throwable instanceof HttpException) { // HttpException httpException = (HttpException) throwable; // errorMessage = GSON.fromJson(httpException.response().errorBody().charStream(), Error.class).error; // } else if (throwable instanceof UnknownHostException) { // errorMessage = context.getString(R.string.tip_network_is_not_available); // } else { // errorMessage = throwable.getMessage(); // } // ToastHelper.showShort(context, errorMessage); // } // }; // } // Path: app/src/main/java/moe/yukinoneko/diycode/App.java import android.app.Application; import io.reactivex.plugins.RxJavaPlugins; import moe.yukinoneko.diycode.api.OAuth; import moe.yukinoneko.diycode.api.Secret; import moe.yukinoneko.diycode.tool.UserHelper; import static moe.yukinoneko.diycode.tool.ErrorHandler.errorConsumer; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode; /** * Created by SamuelGjk on 2017/3/23. */ public class App extends Application { @Override public void onCreate() { super.onCreate();
OAuth.init(Secret.getClientId(), Secret.getSecret());
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/App.java
// Path: app/src/main/java/moe/yukinoneko/diycode/api/OAuth.java // public class OAuth { // // 认证类型 // public static final String GRANT_TYPE_LOGIN = "password"; // 密码 // public static final String GRANT_TYPE_REFRESH = "refresh_token"; // 刷新令牌 // // public static final String KEY_TOKEN = "Authorization"; // public static final String TOKEN_PREFIX = "Bearer "; // // public static String client_id; // 应用ID // public static String client_secret; // 私钥 // // public static void init(String clientId, String clientSecret) { // client_id = clientId; // client_secret = clientSecret; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/api/Secret.java // public class Secret { // static { // System.loadLibrary("secret"); // } // // public static native String getClientId(); // public static native String getSecret(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/UserHelper.java // public class UserHelper { // // private static final String TOKEN = "token"; // private static final String USER = "user"; // // private static SharedPreferences prefs; // // public static void init(Context context) { // prefs = new SecurePreferences(context.getApplicationContext()); // } // // public static void saveToken(Token token) { // prefs.edit().putString(TOKEN, GSON.toJson(token)).apply(); // } // // public static Token getToken() { // String tokenJson = prefs.getString(TOKEN, null); // if (tokenJson != null) { // return GSON.fromJson(tokenJson, Token.class); // } // return null; // } // // public static boolean isLogin() { // return null != getToken(); // } // // public static boolean hasUser() { // return null != getUser(); // } // // public static void saveUser(User user) { // prefs.edit().putString(USER, GSON.toJson(user)).apply(); // } // // public static User getUser() { // String userJson = prefs.getString(USER, null); // if (userJson != null) { // return GSON.fromJson(userJson, User.class); // } // return null; // } // // public static void logout() { // prefs.edit().remove(USER).remove(TOKEN).apply(); // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/ErrorHandler.java // public static Consumer<Throwable> errorConsumer(final Context context) { // return new Consumer<Throwable>() { // @Override public void accept(@NonNull Throwable throwable) { // String errorMessage = null; // if (throwable instanceof HttpException) { // HttpException httpException = (HttpException) throwable; // errorMessage = GSON.fromJson(httpException.response().errorBody().charStream(), Error.class).error; // } else if (throwable instanceof UnknownHostException) { // errorMessage = context.getString(R.string.tip_network_is_not_available); // } else { // errorMessage = throwable.getMessage(); // } // ToastHelper.showShort(context, errorMessage); // } // }; // }
import android.app.Application; import io.reactivex.plugins.RxJavaPlugins; import moe.yukinoneko.diycode.api.OAuth; import moe.yukinoneko.diycode.api.Secret; import moe.yukinoneko.diycode.tool.UserHelper; import static moe.yukinoneko.diycode.tool.ErrorHandler.errorConsumer;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode; /** * Created by SamuelGjk on 2017/3/23. */ public class App extends Application { @Override public void onCreate() { super.onCreate();
// Path: app/src/main/java/moe/yukinoneko/diycode/api/OAuth.java // public class OAuth { // // 认证类型 // public static final String GRANT_TYPE_LOGIN = "password"; // 密码 // public static final String GRANT_TYPE_REFRESH = "refresh_token"; // 刷新令牌 // // public static final String KEY_TOKEN = "Authorization"; // public static final String TOKEN_PREFIX = "Bearer "; // // public static String client_id; // 应用ID // public static String client_secret; // 私钥 // // public static void init(String clientId, String clientSecret) { // client_id = clientId; // client_secret = clientSecret; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/api/Secret.java // public class Secret { // static { // System.loadLibrary("secret"); // } // // public static native String getClientId(); // public static native String getSecret(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/UserHelper.java // public class UserHelper { // // private static final String TOKEN = "token"; // private static final String USER = "user"; // // private static SharedPreferences prefs; // // public static void init(Context context) { // prefs = new SecurePreferences(context.getApplicationContext()); // } // // public static void saveToken(Token token) { // prefs.edit().putString(TOKEN, GSON.toJson(token)).apply(); // } // // public static Token getToken() { // String tokenJson = prefs.getString(TOKEN, null); // if (tokenJson != null) { // return GSON.fromJson(tokenJson, Token.class); // } // return null; // } // // public static boolean isLogin() { // return null != getToken(); // } // // public static boolean hasUser() { // return null != getUser(); // } // // public static void saveUser(User user) { // prefs.edit().putString(USER, GSON.toJson(user)).apply(); // } // // public static User getUser() { // String userJson = prefs.getString(USER, null); // if (userJson != null) { // return GSON.fromJson(userJson, User.class); // } // return null; // } // // public static void logout() { // prefs.edit().remove(USER).remove(TOKEN).apply(); // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/ErrorHandler.java // public static Consumer<Throwable> errorConsumer(final Context context) { // return new Consumer<Throwable>() { // @Override public void accept(@NonNull Throwable throwable) { // String errorMessage = null; // if (throwable instanceof HttpException) { // HttpException httpException = (HttpException) throwable; // errorMessage = GSON.fromJson(httpException.response().errorBody().charStream(), Error.class).error; // } else if (throwable instanceof UnknownHostException) { // errorMessage = context.getString(R.string.tip_network_is_not_available); // } else { // errorMessage = throwable.getMessage(); // } // ToastHelper.showShort(context, errorMessage); // } // }; // } // Path: app/src/main/java/moe/yukinoneko/diycode/App.java import android.app.Application; import io.reactivex.plugins.RxJavaPlugins; import moe.yukinoneko.diycode.api.OAuth; import moe.yukinoneko.diycode.api.Secret; import moe.yukinoneko.diycode.tool.UserHelper; import static moe.yukinoneko.diycode.tool.ErrorHandler.errorConsumer; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode; /** * Created by SamuelGjk on 2017/3/23. */ public class App extends Application { @Override public void onCreate() { super.onCreate();
OAuth.init(Secret.getClientId(), Secret.getSecret());
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/App.java
// Path: app/src/main/java/moe/yukinoneko/diycode/api/OAuth.java // public class OAuth { // // 认证类型 // public static final String GRANT_TYPE_LOGIN = "password"; // 密码 // public static final String GRANT_TYPE_REFRESH = "refresh_token"; // 刷新令牌 // // public static final String KEY_TOKEN = "Authorization"; // public static final String TOKEN_PREFIX = "Bearer "; // // public static String client_id; // 应用ID // public static String client_secret; // 私钥 // // public static void init(String clientId, String clientSecret) { // client_id = clientId; // client_secret = clientSecret; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/api/Secret.java // public class Secret { // static { // System.loadLibrary("secret"); // } // // public static native String getClientId(); // public static native String getSecret(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/UserHelper.java // public class UserHelper { // // private static final String TOKEN = "token"; // private static final String USER = "user"; // // private static SharedPreferences prefs; // // public static void init(Context context) { // prefs = new SecurePreferences(context.getApplicationContext()); // } // // public static void saveToken(Token token) { // prefs.edit().putString(TOKEN, GSON.toJson(token)).apply(); // } // // public static Token getToken() { // String tokenJson = prefs.getString(TOKEN, null); // if (tokenJson != null) { // return GSON.fromJson(tokenJson, Token.class); // } // return null; // } // // public static boolean isLogin() { // return null != getToken(); // } // // public static boolean hasUser() { // return null != getUser(); // } // // public static void saveUser(User user) { // prefs.edit().putString(USER, GSON.toJson(user)).apply(); // } // // public static User getUser() { // String userJson = prefs.getString(USER, null); // if (userJson != null) { // return GSON.fromJson(userJson, User.class); // } // return null; // } // // public static void logout() { // prefs.edit().remove(USER).remove(TOKEN).apply(); // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/ErrorHandler.java // public static Consumer<Throwable> errorConsumer(final Context context) { // return new Consumer<Throwable>() { // @Override public void accept(@NonNull Throwable throwable) { // String errorMessage = null; // if (throwable instanceof HttpException) { // HttpException httpException = (HttpException) throwable; // errorMessage = GSON.fromJson(httpException.response().errorBody().charStream(), Error.class).error; // } else if (throwable instanceof UnknownHostException) { // errorMessage = context.getString(R.string.tip_network_is_not_available); // } else { // errorMessage = throwable.getMessage(); // } // ToastHelper.showShort(context, errorMessage); // } // }; // }
import android.app.Application; import io.reactivex.plugins.RxJavaPlugins; import moe.yukinoneko.diycode.api.OAuth; import moe.yukinoneko.diycode.api.Secret; import moe.yukinoneko.diycode.tool.UserHelper; import static moe.yukinoneko.diycode.tool.ErrorHandler.errorConsumer;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode; /** * Created by SamuelGjk on 2017/3/23. */ public class App extends Application { @Override public void onCreate() { super.onCreate(); OAuth.init(Secret.getClientId(), Secret.getSecret());
// Path: app/src/main/java/moe/yukinoneko/diycode/api/OAuth.java // public class OAuth { // // 认证类型 // public static final String GRANT_TYPE_LOGIN = "password"; // 密码 // public static final String GRANT_TYPE_REFRESH = "refresh_token"; // 刷新令牌 // // public static final String KEY_TOKEN = "Authorization"; // public static final String TOKEN_PREFIX = "Bearer "; // // public static String client_id; // 应用ID // public static String client_secret; // 私钥 // // public static void init(String clientId, String clientSecret) { // client_id = clientId; // client_secret = clientSecret; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/api/Secret.java // public class Secret { // static { // System.loadLibrary("secret"); // } // // public static native String getClientId(); // public static native String getSecret(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/UserHelper.java // public class UserHelper { // // private static final String TOKEN = "token"; // private static final String USER = "user"; // // private static SharedPreferences prefs; // // public static void init(Context context) { // prefs = new SecurePreferences(context.getApplicationContext()); // } // // public static void saveToken(Token token) { // prefs.edit().putString(TOKEN, GSON.toJson(token)).apply(); // } // // public static Token getToken() { // String tokenJson = prefs.getString(TOKEN, null); // if (tokenJson != null) { // return GSON.fromJson(tokenJson, Token.class); // } // return null; // } // // public static boolean isLogin() { // return null != getToken(); // } // // public static boolean hasUser() { // return null != getUser(); // } // // public static void saveUser(User user) { // prefs.edit().putString(USER, GSON.toJson(user)).apply(); // } // // public static User getUser() { // String userJson = prefs.getString(USER, null); // if (userJson != null) { // return GSON.fromJson(userJson, User.class); // } // return null; // } // // public static void logout() { // prefs.edit().remove(USER).remove(TOKEN).apply(); // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/ErrorHandler.java // public static Consumer<Throwable> errorConsumer(final Context context) { // return new Consumer<Throwable>() { // @Override public void accept(@NonNull Throwable throwable) { // String errorMessage = null; // if (throwable instanceof HttpException) { // HttpException httpException = (HttpException) throwable; // errorMessage = GSON.fromJson(httpException.response().errorBody().charStream(), Error.class).error; // } else if (throwable instanceof UnknownHostException) { // errorMessage = context.getString(R.string.tip_network_is_not_available); // } else { // errorMessage = throwable.getMessage(); // } // ToastHelper.showShort(context, errorMessage); // } // }; // } // Path: app/src/main/java/moe/yukinoneko/diycode/App.java import android.app.Application; import io.reactivex.plugins.RxJavaPlugins; import moe.yukinoneko.diycode.api.OAuth; import moe.yukinoneko.diycode.api.Secret; import moe.yukinoneko.diycode.tool.UserHelper; import static moe.yukinoneko.diycode.tool.ErrorHandler.errorConsumer; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode; /** * Created by SamuelGjk on 2017/3/23. */ public class App extends Application { @Override public void onCreate() { super.onCreate(); OAuth.init(Secret.getClientId(), Secret.getSecret());
UserHelper.init(this);
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/App.java
// Path: app/src/main/java/moe/yukinoneko/diycode/api/OAuth.java // public class OAuth { // // 认证类型 // public static final String GRANT_TYPE_LOGIN = "password"; // 密码 // public static final String GRANT_TYPE_REFRESH = "refresh_token"; // 刷新令牌 // // public static final String KEY_TOKEN = "Authorization"; // public static final String TOKEN_PREFIX = "Bearer "; // // public static String client_id; // 应用ID // public static String client_secret; // 私钥 // // public static void init(String clientId, String clientSecret) { // client_id = clientId; // client_secret = clientSecret; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/api/Secret.java // public class Secret { // static { // System.loadLibrary("secret"); // } // // public static native String getClientId(); // public static native String getSecret(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/UserHelper.java // public class UserHelper { // // private static final String TOKEN = "token"; // private static final String USER = "user"; // // private static SharedPreferences prefs; // // public static void init(Context context) { // prefs = new SecurePreferences(context.getApplicationContext()); // } // // public static void saveToken(Token token) { // prefs.edit().putString(TOKEN, GSON.toJson(token)).apply(); // } // // public static Token getToken() { // String tokenJson = prefs.getString(TOKEN, null); // if (tokenJson != null) { // return GSON.fromJson(tokenJson, Token.class); // } // return null; // } // // public static boolean isLogin() { // return null != getToken(); // } // // public static boolean hasUser() { // return null != getUser(); // } // // public static void saveUser(User user) { // prefs.edit().putString(USER, GSON.toJson(user)).apply(); // } // // public static User getUser() { // String userJson = prefs.getString(USER, null); // if (userJson != null) { // return GSON.fromJson(userJson, User.class); // } // return null; // } // // public static void logout() { // prefs.edit().remove(USER).remove(TOKEN).apply(); // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/ErrorHandler.java // public static Consumer<Throwable> errorConsumer(final Context context) { // return new Consumer<Throwable>() { // @Override public void accept(@NonNull Throwable throwable) { // String errorMessage = null; // if (throwable instanceof HttpException) { // HttpException httpException = (HttpException) throwable; // errorMessage = GSON.fromJson(httpException.response().errorBody().charStream(), Error.class).error; // } else if (throwable instanceof UnknownHostException) { // errorMessage = context.getString(R.string.tip_network_is_not_available); // } else { // errorMessage = throwable.getMessage(); // } // ToastHelper.showShort(context, errorMessage); // } // }; // }
import android.app.Application; import io.reactivex.plugins.RxJavaPlugins; import moe.yukinoneko.diycode.api.OAuth; import moe.yukinoneko.diycode.api.Secret; import moe.yukinoneko.diycode.tool.UserHelper; import static moe.yukinoneko.diycode.tool.ErrorHandler.errorConsumer;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode; /** * Created by SamuelGjk on 2017/3/23. */ public class App extends Application { @Override public void onCreate() { super.onCreate(); OAuth.init(Secret.getClientId(), Secret.getSecret()); UserHelper.init(this);
// Path: app/src/main/java/moe/yukinoneko/diycode/api/OAuth.java // public class OAuth { // // 认证类型 // public static final String GRANT_TYPE_LOGIN = "password"; // 密码 // public static final String GRANT_TYPE_REFRESH = "refresh_token"; // 刷新令牌 // // public static final String KEY_TOKEN = "Authorization"; // public static final String TOKEN_PREFIX = "Bearer "; // // public static String client_id; // 应用ID // public static String client_secret; // 私钥 // // public static void init(String clientId, String clientSecret) { // client_id = clientId; // client_secret = clientSecret; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/api/Secret.java // public class Secret { // static { // System.loadLibrary("secret"); // } // // public static native String getClientId(); // public static native String getSecret(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/UserHelper.java // public class UserHelper { // // private static final String TOKEN = "token"; // private static final String USER = "user"; // // private static SharedPreferences prefs; // // public static void init(Context context) { // prefs = new SecurePreferences(context.getApplicationContext()); // } // // public static void saveToken(Token token) { // prefs.edit().putString(TOKEN, GSON.toJson(token)).apply(); // } // // public static Token getToken() { // String tokenJson = prefs.getString(TOKEN, null); // if (tokenJson != null) { // return GSON.fromJson(tokenJson, Token.class); // } // return null; // } // // public static boolean isLogin() { // return null != getToken(); // } // // public static boolean hasUser() { // return null != getUser(); // } // // public static void saveUser(User user) { // prefs.edit().putString(USER, GSON.toJson(user)).apply(); // } // // public static User getUser() { // String userJson = prefs.getString(USER, null); // if (userJson != null) { // return GSON.fromJson(userJson, User.class); // } // return null; // } // // public static void logout() { // prefs.edit().remove(USER).remove(TOKEN).apply(); // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/ErrorHandler.java // public static Consumer<Throwable> errorConsumer(final Context context) { // return new Consumer<Throwable>() { // @Override public void accept(@NonNull Throwable throwable) { // String errorMessage = null; // if (throwable instanceof HttpException) { // HttpException httpException = (HttpException) throwable; // errorMessage = GSON.fromJson(httpException.response().errorBody().charStream(), Error.class).error; // } else if (throwable instanceof UnknownHostException) { // errorMessage = context.getString(R.string.tip_network_is_not_available); // } else { // errorMessage = throwable.getMessage(); // } // ToastHelper.showShort(context, errorMessage); // } // }; // } // Path: app/src/main/java/moe/yukinoneko/diycode/App.java import android.app.Application; import io.reactivex.plugins.RxJavaPlugins; import moe.yukinoneko.diycode.api.OAuth; import moe.yukinoneko.diycode.api.Secret; import moe.yukinoneko.diycode.tool.UserHelper; import static moe.yukinoneko.diycode.tool.ErrorHandler.errorConsumer; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode; /** * Created by SamuelGjk on 2017/3/23. */ public class App extends Application { @Override public void onCreate() { super.onCreate(); OAuth.init(Secret.getClientId(), Secret.getSecret()); UserHelper.init(this);
RxJavaPlugins.setErrorHandler(errorConsumer(this));
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/favorites/FavoritesContract.java
// Path: app/src/main/java/moe/yukinoneko/diycode/list/ListBaseView.java // public interface ListBaseView extends BaseView { // // void setEnd(boolean end); // // void setRefresh(boolean refresh); // // void notifyLoadingStarted(); // // void notifyLoadingFinished(); // // void error(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/Topic.java // public class Topic { // @SerializedName("id") public int id; // 话题 id // @SerializedName("title") public String title; // 标题 // @SerializedName("created_at") public Date createdAt; // 创建时间 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // @SerializedName("replied_at") public Date repliedAt; // 最近一次回复时间 // @SerializedName("replies_count") public int repliesCount; // 回复总数量 // @SerializedName("node_name") public String nodeName; // 节点名称 // @SerializedName("node_id") public int nodeId; // 节点 id // @SerializedName("last_reply_user_id") public int lastReplyUserId; // 最近一次回复的用户 id // @SerializedName("last_reply_user_login") public String lastReplyUserLogin; // 最近一次回复的用户登录名 // @SerializedName("user") public User user; // 创建该话题的用户 // @SerializedName("deleted") public boolean deleted; // 是否已删除 // @SerializedName("excellent") public boolean excellent; // 是否加精 // @SerializedName("abilities") public Abilities abilities; // 当前用户对该话题拥有的权限 // @SerializedName("body") public String body; // 话题详情(Markdown) // @SerializedName("body_html") public String bodyHtml; // 话题详情(HTML) // @SerializedName("hits") public int hits; // 浏览次数 // @SerializedName("likes_count") public int likesCount; // 点赞数 // @SerializedName("suggested_at") public Date suggestedAt; // 置顶(推荐)时间 // @SerializedName("followed") public Boolean followed; // 是否关注 // @SerializedName("liked") public Boolean liked; // 是否喜欢 // @SerializedName("favorited") public Boolean favorited; // 是否收藏 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // }
import moe.yukinoneko.diycode.list.ListBaseView; import moe.yukinoneko.diycode.bean.Topic; import moe.yukinoneko.diycode.mvp.BasePresenter; import java.util.List;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.favorites; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class FavoritesContract { interface View extends ListBaseView {
// Path: app/src/main/java/moe/yukinoneko/diycode/list/ListBaseView.java // public interface ListBaseView extends BaseView { // // void setEnd(boolean end); // // void setRefresh(boolean refresh); // // void notifyLoadingStarted(); // // void notifyLoadingFinished(); // // void error(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/Topic.java // public class Topic { // @SerializedName("id") public int id; // 话题 id // @SerializedName("title") public String title; // 标题 // @SerializedName("created_at") public Date createdAt; // 创建时间 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // @SerializedName("replied_at") public Date repliedAt; // 最近一次回复时间 // @SerializedName("replies_count") public int repliesCount; // 回复总数量 // @SerializedName("node_name") public String nodeName; // 节点名称 // @SerializedName("node_id") public int nodeId; // 节点 id // @SerializedName("last_reply_user_id") public int lastReplyUserId; // 最近一次回复的用户 id // @SerializedName("last_reply_user_login") public String lastReplyUserLogin; // 最近一次回复的用户登录名 // @SerializedName("user") public User user; // 创建该话题的用户 // @SerializedName("deleted") public boolean deleted; // 是否已删除 // @SerializedName("excellent") public boolean excellent; // 是否加精 // @SerializedName("abilities") public Abilities abilities; // 当前用户对该话题拥有的权限 // @SerializedName("body") public String body; // 话题详情(Markdown) // @SerializedName("body_html") public String bodyHtml; // 话题详情(HTML) // @SerializedName("hits") public int hits; // 浏览次数 // @SerializedName("likes_count") public int likesCount; // 点赞数 // @SerializedName("suggested_at") public Date suggestedAt; // 置顶(推荐)时间 // @SerializedName("followed") public Boolean followed; // 是否关注 // @SerializedName("liked") public Boolean liked; // 是否喜欢 // @SerializedName("favorited") public Boolean favorited; // 是否收藏 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/favorites/FavoritesContract.java import moe.yukinoneko.diycode.list.ListBaseView; import moe.yukinoneko.diycode.bean.Topic; import moe.yukinoneko.diycode.mvp.BasePresenter; import java.util.List; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.favorites; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class FavoritesContract { interface View extends ListBaseView {
void updateFavoritesList(List<Topic> topics);
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/favorites/FavoritesContract.java
// Path: app/src/main/java/moe/yukinoneko/diycode/list/ListBaseView.java // public interface ListBaseView extends BaseView { // // void setEnd(boolean end); // // void setRefresh(boolean refresh); // // void notifyLoadingStarted(); // // void notifyLoadingFinished(); // // void error(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/Topic.java // public class Topic { // @SerializedName("id") public int id; // 话题 id // @SerializedName("title") public String title; // 标题 // @SerializedName("created_at") public Date createdAt; // 创建时间 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // @SerializedName("replied_at") public Date repliedAt; // 最近一次回复时间 // @SerializedName("replies_count") public int repliesCount; // 回复总数量 // @SerializedName("node_name") public String nodeName; // 节点名称 // @SerializedName("node_id") public int nodeId; // 节点 id // @SerializedName("last_reply_user_id") public int lastReplyUserId; // 最近一次回复的用户 id // @SerializedName("last_reply_user_login") public String lastReplyUserLogin; // 最近一次回复的用户登录名 // @SerializedName("user") public User user; // 创建该话题的用户 // @SerializedName("deleted") public boolean deleted; // 是否已删除 // @SerializedName("excellent") public boolean excellent; // 是否加精 // @SerializedName("abilities") public Abilities abilities; // 当前用户对该话题拥有的权限 // @SerializedName("body") public String body; // 话题详情(Markdown) // @SerializedName("body_html") public String bodyHtml; // 话题详情(HTML) // @SerializedName("hits") public int hits; // 浏览次数 // @SerializedName("likes_count") public int likesCount; // 点赞数 // @SerializedName("suggested_at") public Date suggestedAt; // 置顶(推荐)时间 // @SerializedName("followed") public Boolean followed; // 是否关注 // @SerializedName("liked") public Boolean liked; // 是否喜欢 // @SerializedName("favorited") public Boolean favorited; // 是否收藏 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // }
import moe.yukinoneko.diycode.list.ListBaseView; import moe.yukinoneko.diycode.bean.Topic; import moe.yukinoneko.diycode.mvp.BasePresenter; import java.util.List;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.favorites; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class FavoritesContract { interface View extends ListBaseView { void updateFavoritesList(List<Topic> topics); }
// Path: app/src/main/java/moe/yukinoneko/diycode/list/ListBaseView.java // public interface ListBaseView extends BaseView { // // void setEnd(boolean end); // // void setRefresh(boolean refresh); // // void notifyLoadingStarted(); // // void notifyLoadingFinished(); // // void error(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/Topic.java // public class Topic { // @SerializedName("id") public int id; // 话题 id // @SerializedName("title") public String title; // 标题 // @SerializedName("created_at") public Date createdAt; // 创建时间 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // @SerializedName("replied_at") public Date repliedAt; // 最近一次回复时间 // @SerializedName("replies_count") public int repliesCount; // 回复总数量 // @SerializedName("node_name") public String nodeName; // 节点名称 // @SerializedName("node_id") public int nodeId; // 节点 id // @SerializedName("last_reply_user_id") public int lastReplyUserId; // 最近一次回复的用户 id // @SerializedName("last_reply_user_login") public String lastReplyUserLogin; // 最近一次回复的用户登录名 // @SerializedName("user") public User user; // 创建该话题的用户 // @SerializedName("deleted") public boolean deleted; // 是否已删除 // @SerializedName("excellent") public boolean excellent; // 是否加精 // @SerializedName("abilities") public Abilities abilities; // 当前用户对该话题拥有的权限 // @SerializedName("body") public String body; // 话题详情(Markdown) // @SerializedName("body_html") public String bodyHtml; // 话题详情(HTML) // @SerializedName("hits") public int hits; // 浏览次数 // @SerializedName("likes_count") public int likesCount; // 点赞数 // @SerializedName("suggested_at") public Date suggestedAt; // 置顶(推荐)时间 // @SerializedName("followed") public Boolean followed; // 是否关注 // @SerializedName("liked") public Boolean liked; // 是否喜欢 // @SerializedName("favorited") public Boolean favorited; // 是否收藏 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/favorites/FavoritesContract.java import moe.yukinoneko.diycode.list.ListBaseView; import moe.yukinoneko.diycode.bean.Topic; import moe.yukinoneko.diycode.mvp.BasePresenter; import java.util.List; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.favorites; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class FavoritesContract { interface View extends ListBaseView { void updateFavoritesList(List<Topic> topics); }
interface Presenter extends BasePresenter<View> {
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/image/ImageActivity.java
// Path: app/src/main/java/moe/yukinoneko/diycode/base/BaseActivity.java // public abstract class BaseActivity extends RxAppCompatActivity { // // protected Unbinder unbinder; // // @Nullable // @BindView(R.id.toolbar) // protected Toolbar toolbar; // // @BindColor(R.color.navigation) // protected int navigationColor; // // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(provideContentViewId()); // // unbinder = ButterKnife.bind(this); // // if (toolbar != null) { // setSupportActionBar(toolbar); // if (getSupportActionBar() != null) { // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // } // } // // @Override // protected void onPostCreate(@Nullable Bundle savedInstanceState) { // super.onPostCreate(savedInstanceState); // setNavigationIconColor(navigationColor); // } // // @Override // public boolean onOptionsItemSelected(MenuItem item) { // if (item.getItemId() == android.R.id.home) { // finish(); // return true; // } // return super.onOptionsItemSelected(item); // } // // @Override // protected void onDestroy() { // super.onDestroy(); // // if (unbinder != null) { // unbinder.unbind(); // } // } // // protected abstract int provideContentViewId(); // // protected void setToolBarTitle(CharSequence title) { // if (toolbar != null) { // toolbar.setTitle(title); // } // } // // protected void setDisplayShowTitleEnabled(boolean enabled) { // ActionBar actionBar = getSupportActionBar(); // if (actionBar != null) { // actionBar.setDisplayShowTitleEnabled(enabled); // } // } // // protected void setNavigationIconColor(@ColorInt int color) { // if (toolbar != null) { // Drawable icon = toolbar.getNavigationIcon(); // if (icon != null) { // DrawableCompat.setTint(icon, color); // } // } // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/ImageLoadHelper.java // public class ImageLoadHelper { // // public static void loadImage(Context context, String url, ImageView imageView, @Nullable RequestListener<String, GlideDrawable> listener) { // Glide.with(context).load(url).diskCacheStrategy(DiskCacheStrategy.SOURCE).listener(listener).into(imageView); // } // // public static void loadAvatar(Context context, String url, ImageView imageView) { // Glide.with(context).load(url).placeholder(R.mipmap.default_avatar).dontAnimate().into(imageView); // } // }
import com.github.chrisbanes.photoview.PhotoView; import butterknife.BindView; import moe.yukinoneko.diycode.R; import moe.yukinoneko.diycode.base.BaseActivity; import moe.yukinoneko.diycode.tool.ImageLoadHelper; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.ProgressBar; import com.bumptech.glide.load.resource.drawable.GlideDrawable; import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.target.Target;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.image; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class ImageActivity extends BaseActivity { private static final String EXTRA_IMAGE_URL = "extra_image_url"; @BindView(R.id.photo_view) PhotoView photoView; @BindView(R.id.progress_bar) ProgressBar progressBar; public static void launch(Context context, String imageUrl) { Intent intent = new Intent(context, ImageActivity.class); intent.putExtra(EXTRA_IMAGE_URL, imageUrl); context.startActivity(intent); } @Override protected int provideContentViewId() { return R.layout.activity_image; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); photoView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } });
// Path: app/src/main/java/moe/yukinoneko/diycode/base/BaseActivity.java // public abstract class BaseActivity extends RxAppCompatActivity { // // protected Unbinder unbinder; // // @Nullable // @BindView(R.id.toolbar) // protected Toolbar toolbar; // // @BindColor(R.color.navigation) // protected int navigationColor; // // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(provideContentViewId()); // // unbinder = ButterKnife.bind(this); // // if (toolbar != null) { // setSupportActionBar(toolbar); // if (getSupportActionBar() != null) { // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // } // } // // @Override // protected void onPostCreate(@Nullable Bundle savedInstanceState) { // super.onPostCreate(savedInstanceState); // setNavigationIconColor(navigationColor); // } // // @Override // public boolean onOptionsItemSelected(MenuItem item) { // if (item.getItemId() == android.R.id.home) { // finish(); // return true; // } // return super.onOptionsItemSelected(item); // } // // @Override // protected void onDestroy() { // super.onDestroy(); // // if (unbinder != null) { // unbinder.unbind(); // } // } // // protected abstract int provideContentViewId(); // // protected void setToolBarTitle(CharSequence title) { // if (toolbar != null) { // toolbar.setTitle(title); // } // } // // protected void setDisplayShowTitleEnabled(boolean enabled) { // ActionBar actionBar = getSupportActionBar(); // if (actionBar != null) { // actionBar.setDisplayShowTitleEnabled(enabled); // } // } // // protected void setNavigationIconColor(@ColorInt int color) { // if (toolbar != null) { // Drawable icon = toolbar.getNavigationIcon(); // if (icon != null) { // DrawableCompat.setTint(icon, color); // } // } // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/ImageLoadHelper.java // public class ImageLoadHelper { // // public static void loadImage(Context context, String url, ImageView imageView, @Nullable RequestListener<String, GlideDrawable> listener) { // Glide.with(context).load(url).diskCacheStrategy(DiskCacheStrategy.SOURCE).listener(listener).into(imageView); // } // // public static void loadAvatar(Context context, String url, ImageView imageView) { // Glide.with(context).load(url).placeholder(R.mipmap.default_avatar).dontAnimate().into(imageView); // } // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/image/ImageActivity.java import com.github.chrisbanes.photoview.PhotoView; import butterknife.BindView; import moe.yukinoneko.diycode.R; import moe.yukinoneko.diycode.base.BaseActivity; import moe.yukinoneko.diycode.tool.ImageLoadHelper; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.ProgressBar; import com.bumptech.glide.load.resource.drawable.GlideDrawable; import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.target.Target; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.image; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class ImageActivity extends BaseActivity { private static final String EXTRA_IMAGE_URL = "extra_image_url"; @BindView(R.id.photo_view) PhotoView photoView; @BindView(R.id.progress_bar) ProgressBar progressBar; public static void launch(Context context, String imageUrl) { Intent intent = new Intent(context, ImageActivity.class); intent.putExtra(EXTRA_IMAGE_URL, imageUrl); context.startActivity(intent); } @Override protected int provideContentViewId() { return R.layout.activity_image; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); photoView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } });
ImageLoadHelper.loadImage(this, getIntent().getStringExtra(EXTRA_IMAGE_URL), photoView, new RequestListener<String, GlideDrawable>() {
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/topic/details/TopicDetailsContract.java
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/Like.java // public class Like { // @SerializedName("obj_type") public String objType; // 点赞对象类型 // @SerializedName("obj_id") public int objId; // 点赞对象 id // @SerializedName("count") public int count; // 点赞数 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/Topic.java // public class Topic { // @SerializedName("id") public int id; // 话题 id // @SerializedName("title") public String title; // 标题 // @SerializedName("created_at") public Date createdAt; // 创建时间 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // @SerializedName("replied_at") public Date repliedAt; // 最近一次回复时间 // @SerializedName("replies_count") public int repliesCount; // 回复总数量 // @SerializedName("node_name") public String nodeName; // 节点名称 // @SerializedName("node_id") public int nodeId; // 节点 id // @SerializedName("last_reply_user_id") public int lastReplyUserId; // 最近一次回复的用户 id // @SerializedName("last_reply_user_login") public String lastReplyUserLogin; // 最近一次回复的用户登录名 // @SerializedName("user") public User user; // 创建该话题的用户 // @SerializedName("deleted") public boolean deleted; // 是否已删除 // @SerializedName("excellent") public boolean excellent; // 是否加精 // @SerializedName("abilities") public Abilities abilities; // 当前用户对该话题拥有的权限 // @SerializedName("body") public String body; // 话题详情(Markdown) // @SerializedName("body_html") public String bodyHtml; // 话题详情(HTML) // @SerializedName("hits") public int hits; // 浏览次数 // @SerializedName("likes_count") public int likesCount; // 点赞数 // @SerializedName("suggested_at") public Date suggestedAt; // 置顶(推荐)时间 // @SerializedName("followed") public Boolean followed; // 是否关注 // @SerializedName("liked") public Boolean liked; // 是否喜欢 // @SerializedName("favorited") public Boolean favorited; // 是否收藏 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BaseView.java // public interface BaseView { // Context getContext(); // // <T> LifecycleTransformer<T> bindToLife(); // }
import moe.yukinoneko.diycode.mvp.BasePresenter; import moe.yukinoneko.diycode.mvp.BaseView; import moe.yukinoneko.diycode.bean.Like; import moe.yukinoneko.diycode.bean.Topic;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.topic.details; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class TopicDetailsContract { interface View extends BaseView {
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/Like.java // public class Like { // @SerializedName("obj_type") public String objType; // 点赞对象类型 // @SerializedName("obj_id") public int objId; // 点赞对象 id // @SerializedName("count") public int count; // 点赞数 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/Topic.java // public class Topic { // @SerializedName("id") public int id; // 话题 id // @SerializedName("title") public String title; // 标题 // @SerializedName("created_at") public Date createdAt; // 创建时间 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // @SerializedName("replied_at") public Date repliedAt; // 最近一次回复时间 // @SerializedName("replies_count") public int repliesCount; // 回复总数量 // @SerializedName("node_name") public String nodeName; // 节点名称 // @SerializedName("node_id") public int nodeId; // 节点 id // @SerializedName("last_reply_user_id") public int lastReplyUserId; // 最近一次回复的用户 id // @SerializedName("last_reply_user_login") public String lastReplyUserLogin; // 最近一次回复的用户登录名 // @SerializedName("user") public User user; // 创建该话题的用户 // @SerializedName("deleted") public boolean deleted; // 是否已删除 // @SerializedName("excellent") public boolean excellent; // 是否加精 // @SerializedName("abilities") public Abilities abilities; // 当前用户对该话题拥有的权限 // @SerializedName("body") public String body; // 话题详情(Markdown) // @SerializedName("body_html") public String bodyHtml; // 话题详情(HTML) // @SerializedName("hits") public int hits; // 浏览次数 // @SerializedName("likes_count") public int likesCount; // 点赞数 // @SerializedName("suggested_at") public Date suggestedAt; // 置顶(推荐)时间 // @SerializedName("followed") public Boolean followed; // 是否关注 // @SerializedName("liked") public Boolean liked; // 是否喜欢 // @SerializedName("favorited") public Boolean favorited; // 是否收藏 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BaseView.java // public interface BaseView { // Context getContext(); // // <T> LifecycleTransformer<T> bindToLife(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/topic/details/TopicDetailsContract.java import moe.yukinoneko.diycode.mvp.BasePresenter; import moe.yukinoneko.diycode.mvp.BaseView; import moe.yukinoneko.diycode.bean.Like; import moe.yukinoneko.diycode.bean.Topic; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.topic.details; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class TopicDetailsContract { interface View extends BaseView {
void updateTopicContent(Topic topic);
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/topic/details/TopicDetailsContract.java
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/Like.java // public class Like { // @SerializedName("obj_type") public String objType; // 点赞对象类型 // @SerializedName("obj_id") public int objId; // 点赞对象 id // @SerializedName("count") public int count; // 点赞数 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/Topic.java // public class Topic { // @SerializedName("id") public int id; // 话题 id // @SerializedName("title") public String title; // 标题 // @SerializedName("created_at") public Date createdAt; // 创建时间 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // @SerializedName("replied_at") public Date repliedAt; // 最近一次回复时间 // @SerializedName("replies_count") public int repliesCount; // 回复总数量 // @SerializedName("node_name") public String nodeName; // 节点名称 // @SerializedName("node_id") public int nodeId; // 节点 id // @SerializedName("last_reply_user_id") public int lastReplyUserId; // 最近一次回复的用户 id // @SerializedName("last_reply_user_login") public String lastReplyUserLogin; // 最近一次回复的用户登录名 // @SerializedName("user") public User user; // 创建该话题的用户 // @SerializedName("deleted") public boolean deleted; // 是否已删除 // @SerializedName("excellent") public boolean excellent; // 是否加精 // @SerializedName("abilities") public Abilities abilities; // 当前用户对该话题拥有的权限 // @SerializedName("body") public String body; // 话题详情(Markdown) // @SerializedName("body_html") public String bodyHtml; // 话题详情(HTML) // @SerializedName("hits") public int hits; // 浏览次数 // @SerializedName("likes_count") public int likesCount; // 点赞数 // @SerializedName("suggested_at") public Date suggestedAt; // 置顶(推荐)时间 // @SerializedName("followed") public Boolean followed; // 是否关注 // @SerializedName("liked") public Boolean liked; // 是否喜欢 // @SerializedName("favorited") public Boolean favorited; // 是否收藏 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BaseView.java // public interface BaseView { // Context getContext(); // // <T> LifecycleTransformer<T> bindToLife(); // }
import moe.yukinoneko.diycode.mvp.BasePresenter; import moe.yukinoneko.diycode.mvp.BaseView; import moe.yukinoneko.diycode.bean.Like; import moe.yukinoneko.diycode.bean.Topic;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.topic.details; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class TopicDetailsContract { interface View extends BaseView { void updateTopicContent(Topic topic); void updateFavoriteState(boolean favorited);
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/Like.java // public class Like { // @SerializedName("obj_type") public String objType; // 点赞对象类型 // @SerializedName("obj_id") public int objId; // 点赞对象 id // @SerializedName("count") public int count; // 点赞数 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/Topic.java // public class Topic { // @SerializedName("id") public int id; // 话题 id // @SerializedName("title") public String title; // 标题 // @SerializedName("created_at") public Date createdAt; // 创建时间 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // @SerializedName("replied_at") public Date repliedAt; // 最近一次回复时间 // @SerializedName("replies_count") public int repliesCount; // 回复总数量 // @SerializedName("node_name") public String nodeName; // 节点名称 // @SerializedName("node_id") public int nodeId; // 节点 id // @SerializedName("last_reply_user_id") public int lastReplyUserId; // 最近一次回复的用户 id // @SerializedName("last_reply_user_login") public String lastReplyUserLogin; // 最近一次回复的用户登录名 // @SerializedName("user") public User user; // 创建该话题的用户 // @SerializedName("deleted") public boolean deleted; // 是否已删除 // @SerializedName("excellent") public boolean excellent; // 是否加精 // @SerializedName("abilities") public Abilities abilities; // 当前用户对该话题拥有的权限 // @SerializedName("body") public String body; // 话题详情(Markdown) // @SerializedName("body_html") public String bodyHtml; // 话题详情(HTML) // @SerializedName("hits") public int hits; // 浏览次数 // @SerializedName("likes_count") public int likesCount; // 点赞数 // @SerializedName("suggested_at") public Date suggestedAt; // 置顶(推荐)时间 // @SerializedName("followed") public Boolean followed; // 是否关注 // @SerializedName("liked") public Boolean liked; // 是否喜欢 // @SerializedName("favorited") public Boolean favorited; // 是否收藏 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BaseView.java // public interface BaseView { // Context getContext(); // // <T> LifecycleTransformer<T> bindToLife(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/topic/details/TopicDetailsContract.java import moe.yukinoneko.diycode.mvp.BasePresenter; import moe.yukinoneko.diycode.mvp.BaseView; import moe.yukinoneko.diycode.bean.Like; import moe.yukinoneko.diycode.bean.Topic; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.topic.details; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class TopicDetailsContract { interface View extends BaseView { void updateTopicContent(Topic topic); void updateFavoriteState(boolean favorited);
void updateLikeState(boolean liked, Like like);
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/topic/details/TopicDetailsContract.java
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/Like.java // public class Like { // @SerializedName("obj_type") public String objType; // 点赞对象类型 // @SerializedName("obj_id") public int objId; // 点赞对象 id // @SerializedName("count") public int count; // 点赞数 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/Topic.java // public class Topic { // @SerializedName("id") public int id; // 话题 id // @SerializedName("title") public String title; // 标题 // @SerializedName("created_at") public Date createdAt; // 创建时间 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // @SerializedName("replied_at") public Date repliedAt; // 最近一次回复时间 // @SerializedName("replies_count") public int repliesCount; // 回复总数量 // @SerializedName("node_name") public String nodeName; // 节点名称 // @SerializedName("node_id") public int nodeId; // 节点 id // @SerializedName("last_reply_user_id") public int lastReplyUserId; // 最近一次回复的用户 id // @SerializedName("last_reply_user_login") public String lastReplyUserLogin; // 最近一次回复的用户登录名 // @SerializedName("user") public User user; // 创建该话题的用户 // @SerializedName("deleted") public boolean deleted; // 是否已删除 // @SerializedName("excellent") public boolean excellent; // 是否加精 // @SerializedName("abilities") public Abilities abilities; // 当前用户对该话题拥有的权限 // @SerializedName("body") public String body; // 话题详情(Markdown) // @SerializedName("body_html") public String bodyHtml; // 话题详情(HTML) // @SerializedName("hits") public int hits; // 浏览次数 // @SerializedName("likes_count") public int likesCount; // 点赞数 // @SerializedName("suggested_at") public Date suggestedAt; // 置顶(推荐)时间 // @SerializedName("followed") public Boolean followed; // 是否关注 // @SerializedName("liked") public Boolean liked; // 是否喜欢 // @SerializedName("favorited") public Boolean favorited; // 是否收藏 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BaseView.java // public interface BaseView { // Context getContext(); // // <T> LifecycleTransformer<T> bindToLife(); // }
import moe.yukinoneko.diycode.mvp.BasePresenter; import moe.yukinoneko.diycode.mvp.BaseView; import moe.yukinoneko.diycode.bean.Like; import moe.yukinoneko.diycode.bean.Topic;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.topic.details; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class TopicDetailsContract { interface View extends BaseView { void updateTopicContent(Topic topic); void updateFavoriteState(boolean favorited); void updateLikeState(boolean liked, Like like); void error(); }
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/Like.java // public class Like { // @SerializedName("obj_type") public String objType; // 点赞对象类型 // @SerializedName("obj_id") public int objId; // 点赞对象 id // @SerializedName("count") public int count; // 点赞数 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/Topic.java // public class Topic { // @SerializedName("id") public int id; // 话题 id // @SerializedName("title") public String title; // 标题 // @SerializedName("created_at") public Date createdAt; // 创建时间 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // @SerializedName("replied_at") public Date repliedAt; // 最近一次回复时间 // @SerializedName("replies_count") public int repliesCount; // 回复总数量 // @SerializedName("node_name") public String nodeName; // 节点名称 // @SerializedName("node_id") public int nodeId; // 节点 id // @SerializedName("last_reply_user_id") public int lastReplyUserId; // 最近一次回复的用户 id // @SerializedName("last_reply_user_login") public String lastReplyUserLogin; // 最近一次回复的用户登录名 // @SerializedName("user") public User user; // 创建该话题的用户 // @SerializedName("deleted") public boolean deleted; // 是否已删除 // @SerializedName("excellent") public boolean excellent; // 是否加精 // @SerializedName("abilities") public Abilities abilities; // 当前用户对该话题拥有的权限 // @SerializedName("body") public String body; // 话题详情(Markdown) // @SerializedName("body_html") public String bodyHtml; // 话题详情(HTML) // @SerializedName("hits") public int hits; // 浏览次数 // @SerializedName("likes_count") public int likesCount; // 点赞数 // @SerializedName("suggested_at") public Date suggestedAt; // 置顶(推荐)时间 // @SerializedName("followed") public Boolean followed; // 是否关注 // @SerializedName("liked") public Boolean liked; // 是否喜欢 // @SerializedName("favorited") public Boolean favorited; // 是否收藏 // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BaseView.java // public interface BaseView { // Context getContext(); // // <T> LifecycleTransformer<T> bindToLife(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/topic/details/TopicDetailsContract.java import moe.yukinoneko.diycode.mvp.BasePresenter; import moe.yukinoneko.diycode.mvp.BaseView; import moe.yukinoneko.diycode.bean.Like; import moe.yukinoneko.diycode.bean.Topic; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.topic.details; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class TopicDetailsContract { interface View extends BaseView { void updateTopicContent(Topic topic); void updateFavoriteState(boolean favorited); void updateLikeState(boolean liked, Like like); void error(); }
interface Presenter extends BasePresenter<View> {
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/main/MainContract.java
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/User.java // public class User implements Parcelable { // @SerializedName("id") public int id; // 用户 id // @SerializedName("login") public String login; // 用户名 // @SerializedName("name") public String name; // 昵称 // @SerializedName("avatar_url") public String avatarUrl; // 头像链接 // @SerializedName("location") public String location; // 城市 // @SerializedName("company") public String company; // 公司 // @SerializedName("twitter") public String twitter; // twitter // @SerializedName("website") public String website; // 网站地址 // @SerializedName("bio") public String bio; // 个人介绍 // @SerializedName("tagline") public String tagline; // 签名 // @SerializedName("github") public String github; // github // @SerializedName("created_at") public String createdAt; // 创建时间 // @SerializedName("email") public String email; // email // @SerializedName("topics_count") public int topicsCount; // 话题数量 // @SerializedName("replies_count") public int repliesCount; // 回复数量 // @SerializedName("following_count") public int followingCount; // 关注人数 // @SerializedName("followers_count") public int followersCount; // 粉丝人数 // @SerializedName("favorites_count") public int favoritesCount; // 收藏数 // @SerializedName("level") public String level; // 等级 // @SerializedName("level_name") public String levelName; // 等级名称 // // protected User(Parcel in) { // id = in.readInt(); // login = in.readString(); // name = in.readString(); // avatarUrl = in.readString(); // location = in.readString(); // company = in.readString(); // twitter = in.readString(); // website = in.readString(); // bio = in.readString(); // tagline = in.readString(); // github = in.readString(); // createdAt = in.readString(); // email = in.readString(); // topicsCount = in.readInt(); // repliesCount = in.readInt(); // followingCount = in.readInt(); // followersCount = in.readInt(); // favoritesCount = in.readInt(); // level = in.readString(); // levelName = in.readString(); // } // // public static final Creator<User> CREATOR = new Creator<User>() { // @Override // public User createFromParcel(Parcel in) { // return new User(in); // } // // @Override // public User[] newArray(int size) { // return new User[size]; // } // }; // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeInt(id); // dest.writeString(login); // dest.writeString(name); // dest.writeString(avatarUrl); // dest.writeString(location); // dest.writeString(company); // dest.writeString(twitter); // dest.writeString(website); // dest.writeString(bio); // dest.writeString(tagline); // dest.writeString(github); // dest.writeString(createdAt); // dest.writeString(email); // dest.writeInt(topicsCount); // dest.writeInt(repliesCount); // dest.writeInt(followingCount); // dest.writeInt(followersCount); // dest.writeInt(favoritesCount); // dest.writeString(level); // dest.writeString(levelName); // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BaseView.java // public interface BaseView { // Context getContext(); // // <T> LifecycleTransformer<T> bindToLife(); // }
import moe.yukinoneko.diycode.mvp.BaseView; import moe.yukinoneko.diycode.bean.User; import moe.yukinoneko.diycode.mvp.BasePresenter;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.main; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class MainContract { interface View extends BaseView {
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/User.java // public class User implements Parcelable { // @SerializedName("id") public int id; // 用户 id // @SerializedName("login") public String login; // 用户名 // @SerializedName("name") public String name; // 昵称 // @SerializedName("avatar_url") public String avatarUrl; // 头像链接 // @SerializedName("location") public String location; // 城市 // @SerializedName("company") public String company; // 公司 // @SerializedName("twitter") public String twitter; // twitter // @SerializedName("website") public String website; // 网站地址 // @SerializedName("bio") public String bio; // 个人介绍 // @SerializedName("tagline") public String tagline; // 签名 // @SerializedName("github") public String github; // github // @SerializedName("created_at") public String createdAt; // 创建时间 // @SerializedName("email") public String email; // email // @SerializedName("topics_count") public int topicsCount; // 话题数量 // @SerializedName("replies_count") public int repliesCount; // 回复数量 // @SerializedName("following_count") public int followingCount; // 关注人数 // @SerializedName("followers_count") public int followersCount; // 粉丝人数 // @SerializedName("favorites_count") public int favoritesCount; // 收藏数 // @SerializedName("level") public String level; // 等级 // @SerializedName("level_name") public String levelName; // 等级名称 // // protected User(Parcel in) { // id = in.readInt(); // login = in.readString(); // name = in.readString(); // avatarUrl = in.readString(); // location = in.readString(); // company = in.readString(); // twitter = in.readString(); // website = in.readString(); // bio = in.readString(); // tagline = in.readString(); // github = in.readString(); // createdAt = in.readString(); // email = in.readString(); // topicsCount = in.readInt(); // repliesCount = in.readInt(); // followingCount = in.readInt(); // followersCount = in.readInt(); // favoritesCount = in.readInt(); // level = in.readString(); // levelName = in.readString(); // } // // public static final Creator<User> CREATOR = new Creator<User>() { // @Override // public User createFromParcel(Parcel in) { // return new User(in); // } // // @Override // public User[] newArray(int size) { // return new User[size]; // } // }; // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeInt(id); // dest.writeString(login); // dest.writeString(name); // dest.writeString(avatarUrl); // dest.writeString(location); // dest.writeString(company); // dest.writeString(twitter); // dest.writeString(website); // dest.writeString(bio); // dest.writeString(tagline); // dest.writeString(github); // dest.writeString(createdAt); // dest.writeString(email); // dest.writeInt(topicsCount); // dest.writeInt(repliesCount); // dest.writeInt(followingCount); // dest.writeInt(followersCount); // dest.writeInt(favoritesCount); // dest.writeString(level); // dest.writeString(levelName); // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BaseView.java // public interface BaseView { // Context getContext(); // // <T> LifecycleTransformer<T> bindToLife(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/main/MainContract.java import moe.yukinoneko.diycode.mvp.BaseView; import moe.yukinoneko.diycode.bean.User; import moe.yukinoneko.diycode.mvp.BasePresenter; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.main; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class MainContract { interface View extends BaseView {
void updateMe(User me);
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/main/MainContract.java
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/User.java // public class User implements Parcelable { // @SerializedName("id") public int id; // 用户 id // @SerializedName("login") public String login; // 用户名 // @SerializedName("name") public String name; // 昵称 // @SerializedName("avatar_url") public String avatarUrl; // 头像链接 // @SerializedName("location") public String location; // 城市 // @SerializedName("company") public String company; // 公司 // @SerializedName("twitter") public String twitter; // twitter // @SerializedName("website") public String website; // 网站地址 // @SerializedName("bio") public String bio; // 个人介绍 // @SerializedName("tagline") public String tagline; // 签名 // @SerializedName("github") public String github; // github // @SerializedName("created_at") public String createdAt; // 创建时间 // @SerializedName("email") public String email; // email // @SerializedName("topics_count") public int topicsCount; // 话题数量 // @SerializedName("replies_count") public int repliesCount; // 回复数量 // @SerializedName("following_count") public int followingCount; // 关注人数 // @SerializedName("followers_count") public int followersCount; // 粉丝人数 // @SerializedName("favorites_count") public int favoritesCount; // 收藏数 // @SerializedName("level") public String level; // 等级 // @SerializedName("level_name") public String levelName; // 等级名称 // // protected User(Parcel in) { // id = in.readInt(); // login = in.readString(); // name = in.readString(); // avatarUrl = in.readString(); // location = in.readString(); // company = in.readString(); // twitter = in.readString(); // website = in.readString(); // bio = in.readString(); // tagline = in.readString(); // github = in.readString(); // createdAt = in.readString(); // email = in.readString(); // topicsCount = in.readInt(); // repliesCount = in.readInt(); // followingCount = in.readInt(); // followersCount = in.readInt(); // favoritesCount = in.readInt(); // level = in.readString(); // levelName = in.readString(); // } // // public static final Creator<User> CREATOR = new Creator<User>() { // @Override // public User createFromParcel(Parcel in) { // return new User(in); // } // // @Override // public User[] newArray(int size) { // return new User[size]; // } // }; // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeInt(id); // dest.writeString(login); // dest.writeString(name); // dest.writeString(avatarUrl); // dest.writeString(location); // dest.writeString(company); // dest.writeString(twitter); // dest.writeString(website); // dest.writeString(bio); // dest.writeString(tagline); // dest.writeString(github); // dest.writeString(createdAt); // dest.writeString(email); // dest.writeInt(topicsCount); // dest.writeInt(repliesCount); // dest.writeInt(followingCount); // dest.writeInt(followersCount); // dest.writeInt(favoritesCount); // dest.writeString(level); // dest.writeString(levelName); // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BaseView.java // public interface BaseView { // Context getContext(); // // <T> LifecycleTransformer<T> bindToLife(); // }
import moe.yukinoneko.diycode.mvp.BaseView; import moe.yukinoneko.diycode.bean.User; import moe.yukinoneko.diycode.mvp.BasePresenter;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.main; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class MainContract { interface View extends BaseView { void updateMe(User me); }
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/User.java // public class User implements Parcelable { // @SerializedName("id") public int id; // 用户 id // @SerializedName("login") public String login; // 用户名 // @SerializedName("name") public String name; // 昵称 // @SerializedName("avatar_url") public String avatarUrl; // 头像链接 // @SerializedName("location") public String location; // 城市 // @SerializedName("company") public String company; // 公司 // @SerializedName("twitter") public String twitter; // twitter // @SerializedName("website") public String website; // 网站地址 // @SerializedName("bio") public String bio; // 个人介绍 // @SerializedName("tagline") public String tagline; // 签名 // @SerializedName("github") public String github; // github // @SerializedName("created_at") public String createdAt; // 创建时间 // @SerializedName("email") public String email; // email // @SerializedName("topics_count") public int topicsCount; // 话题数量 // @SerializedName("replies_count") public int repliesCount; // 回复数量 // @SerializedName("following_count") public int followingCount; // 关注人数 // @SerializedName("followers_count") public int followersCount; // 粉丝人数 // @SerializedName("favorites_count") public int favoritesCount; // 收藏数 // @SerializedName("level") public String level; // 等级 // @SerializedName("level_name") public String levelName; // 等级名称 // // protected User(Parcel in) { // id = in.readInt(); // login = in.readString(); // name = in.readString(); // avatarUrl = in.readString(); // location = in.readString(); // company = in.readString(); // twitter = in.readString(); // website = in.readString(); // bio = in.readString(); // tagline = in.readString(); // github = in.readString(); // createdAt = in.readString(); // email = in.readString(); // topicsCount = in.readInt(); // repliesCount = in.readInt(); // followingCount = in.readInt(); // followersCount = in.readInt(); // favoritesCount = in.readInt(); // level = in.readString(); // levelName = in.readString(); // } // // public static final Creator<User> CREATOR = new Creator<User>() { // @Override // public User createFromParcel(Parcel in) { // return new User(in); // } // // @Override // public User[] newArray(int size) { // return new User[size]; // } // }; // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeInt(id); // dest.writeString(login); // dest.writeString(name); // dest.writeString(avatarUrl); // dest.writeString(location); // dest.writeString(company); // dest.writeString(twitter); // dest.writeString(website); // dest.writeString(bio); // dest.writeString(tagline); // dest.writeString(github); // dest.writeString(createdAt); // dest.writeString(email); // dest.writeInt(topicsCount); // dest.writeInt(repliesCount); // dest.writeInt(followingCount); // dest.writeInt(followersCount); // dest.writeInt(favoritesCount); // dest.writeString(level); // dest.writeString(levelName); // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BaseView.java // public interface BaseView { // Context getContext(); // // <T> LifecycleTransformer<T> bindToLife(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/main/MainContract.java import moe.yukinoneko.diycode.mvp.BaseView; import moe.yukinoneko.diycode.bean.User; import moe.yukinoneko.diycode.mvp.BasePresenter; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.main; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class MainContract { interface View extends BaseView { void updateMe(User me); }
interface Presenter extends BasePresenter<View> {
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/login/LoginContract.java
// Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BaseView.java // public interface BaseView { // Context getContext(); // // <T> LifecycleTransformer<T> bindToLife(); // }
import moe.yukinoneko.diycode.mvp.BasePresenter; import moe.yukinoneko.diycode.mvp.BaseView;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.login; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class LoginContract { interface View extends BaseView { String getUsername(); String getPassword(); void nameError(); void passwordError(); void LoginSuccessful(); void showProgress(boolean show); }
// Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BaseView.java // public interface BaseView { // Context getContext(); // // <T> LifecycleTransformer<T> bindToLife(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/login/LoginContract.java import moe.yukinoneko.diycode.mvp.BasePresenter; import moe.yukinoneko.diycode.mvp.BaseView; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.login; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class LoginContract { interface View extends BaseView { String getUsername(); String getPassword(); void nameError(); void passwordError(); void LoginSuccessful(); void showProgress(boolean show); }
interface Presenter extends BasePresenter<View> {
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/site/SitesGridAdapter.java
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/Sites.java // public class Sites { // // @SerializedName("name") public String name; // @SerializedName("id") public int id; // @SerializedName("sites") public List<Site> sites; // // public static class Site { // @SerializedName("name") public String name; // @SerializedName("url") public String url; // @SerializedName("avatar_url") public String avatarUrl; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/list/BaseRecyclerListAdapter.java // public abstract class BaseRecyclerListAdapter<T, VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<VH> { // protected List<T> data = new ArrayList<>(); // // @Override // public int getItemCount() { // return data.size(); // } // // public List<T> getData() { // return data; // } // // @UiThread // public void setData(List<T> data) { // this.data.clear(); // this.data.addAll(data); // // notifyDataSetChanged(); // } // // public T getItem(int position) { // return data.get(position); // } // // @UiThread // public BaseRecyclerListAdapter<T, VH> add(@NonNull T item) { // data.add(item); // notifyItemInserted(data.size() - 1); // return this; // } // // @UiThread // public BaseRecyclerListAdapter<T, VH> addAll(@NonNull Collection<T> items) { // data.addAll(items); // notifyItemRangeInserted(data.size() - items.size(), items.size()); // return this; // } // // @UiThread // public BaseRecyclerListAdapter<T, VH> add(int position, @NonNull T item) { // data.add(position, item); // notifyItemInserted(position); // return this; // } // // @UiThread // public BaseRecyclerListAdapter<T, VH> remove(int position) { // data.remove(position); // notifyItemRemoved(position); // return this; // } // // @UiThread // public BaseRecyclerListAdapter<T, VH> remove(@NonNull T item) { // return remove(data.indexOf(item)); // } // // @UiThread // public BaseRecyclerListAdapter<T, VH> clear() { // data.clear(); // notifyDataSetChanged(); // return this; // } // // public boolean isEmpty() { // return data == null || data.isEmpty(); // } // // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/ImageLoadHelper.java // public class ImageLoadHelper { // // public static void loadImage(Context context, String url, ImageView imageView, @Nullable RequestListener<String, GlideDrawable> listener) { // Glide.with(context).load(url).diskCacheStrategy(DiskCacheStrategy.SOURCE).listener(listener).into(imageView); // } // // public static void loadAvatar(Context context, String url, ImageView imageView) { // Glide.with(context).load(url).placeholder(R.mipmap.default_avatar).dontAnimate().into(imageView); // } // }
import butterknife.ButterKnife; import moe.yukinoneko.diycode.R; import moe.yukinoneko.diycode.bean.Sites; import moe.yukinoneko.diycode.list.BaseRecyclerListAdapter; import moe.yukinoneko.diycode.tool.ImageLoadHelper; import android.content.Intent; import android.net.Uri; import android.support.v7.widget.AppCompatImageView; import android.support.v7.widget.AppCompatTextView; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import butterknife.BindView;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.site; /** * Created by SamuelGjk on 2017/4/27. */ public class SitesGridAdapter extends BaseRecyclerListAdapter<Object, RecyclerView.ViewHolder> { private static final int VIEW_TYPE_CATEGORY = 10000; private static final int VIEW_TYPE_SITE = 10001; @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { LayoutInflater inflater = LayoutInflater.from(parent.getContext()); if (VIEW_TYPE_CATEGORY == viewType) { return new SitesViewHolder(inflater.inflate(R.layout.item_sites, parent, false)); } else { return new SiteViewHolder(inflater.inflate(R.layout.item_site, parent, false)); } } @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof SitesViewHolder) {
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/Sites.java // public class Sites { // // @SerializedName("name") public String name; // @SerializedName("id") public int id; // @SerializedName("sites") public List<Site> sites; // // public static class Site { // @SerializedName("name") public String name; // @SerializedName("url") public String url; // @SerializedName("avatar_url") public String avatarUrl; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/list/BaseRecyclerListAdapter.java // public abstract class BaseRecyclerListAdapter<T, VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<VH> { // protected List<T> data = new ArrayList<>(); // // @Override // public int getItemCount() { // return data.size(); // } // // public List<T> getData() { // return data; // } // // @UiThread // public void setData(List<T> data) { // this.data.clear(); // this.data.addAll(data); // // notifyDataSetChanged(); // } // // public T getItem(int position) { // return data.get(position); // } // // @UiThread // public BaseRecyclerListAdapter<T, VH> add(@NonNull T item) { // data.add(item); // notifyItemInserted(data.size() - 1); // return this; // } // // @UiThread // public BaseRecyclerListAdapter<T, VH> addAll(@NonNull Collection<T> items) { // data.addAll(items); // notifyItemRangeInserted(data.size() - items.size(), items.size()); // return this; // } // // @UiThread // public BaseRecyclerListAdapter<T, VH> add(int position, @NonNull T item) { // data.add(position, item); // notifyItemInserted(position); // return this; // } // // @UiThread // public BaseRecyclerListAdapter<T, VH> remove(int position) { // data.remove(position); // notifyItemRemoved(position); // return this; // } // // @UiThread // public BaseRecyclerListAdapter<T, VH> remove(@NonNull T item) { // return remove(data.indexOf(item)); // } // // @UiThread // public BaseRecyclerListAdapter<T, VH> clear() { // data.clear(); // notifyDataSetChanged(); // return this; // } // // public boolean isEmpty() { // return data == null || data.isEmpty(); // } // // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/ImageLoadHelper.java // public class ImageLoadHelper { // // public static void loadImage(Context context, String url, ImageView imageView, @Nullable RequestListener<String, GlideDrawable> listener) { // Glide.with(context).load(url).diskCacheStrategy(DiskCacheStrategy.SOURCE).listener(listener).into(imageView); // } // // public static void loadAvatar(Context context, String url, ImageView imageView) { // Glide.with(context).load(url).placeholder(R.mipmap.default_avatar).dontAnimate().into(imageView); // } // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/site/SitesGridAdapter.java import butterknife.ButterKnife; import moe.yukinoneko.diycode.R; import moe.yukinoneko.diycode.bean.Sites; import moe.yukinoneko.diycode.list.BaseRecyclerListAdapter; import moe.yukinoneko.diycode.tool.ImageLoadHelper; import android.content.Intent; import android.net.Uri; import android.support.v7.widget.AppCompatImageView; import android.support.v7.widget.AppCompatTextView; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import butterknife.BindView; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.site; /** * Created by SamuelGjk on 2017/4/27. */ public class SitesGridAdapter extends BaseRecyclerListAdapter<Object, RecyclerView.ViewHolder> { private static final int VIEW_TYPE_CATEGORY = 10000; private static final int VIEW_TYPE_SITE = 10001; @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { LayoutInflater inflater = LayoutInflater.from(parent.getContext()); if (VIEW_TYPE_CATEGORY == viewType) { return new SitesViewHolder(inflater.inflate(R.layout.item_sites, parent, false)); } else { return new SiteViewHolder(inflater.inflate(R.layout.item_site, parent, false)); } } @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof SitesViewHolder) {
((SitesViewHolder) holder).sitesCategory.setText(((Sites) data.get(position)).name);
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/site/SitesGridAdapter.java
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/Sites.java // public class Sites { // // @SerializedName("name") public String name; // @SerializedName("id") public int id; // @SerializedName("sites") public List<Site> sites; // // public static class Site { // @SerializedName("name") public String name; // @SerializedName("url") public String url; // @SerializedName("avatar_url") public String avatarUrl; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/list/BaseRecyclerListAdapter.java // public abstract class BaseRecyclerListAdapter<T, VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<VH> { // protected List<T> data = new ArrayList<>(); // // @Override // public int getItemCount() { // return data.size(); // } // // public List<T> getData() { // return data; // } // // @UiThread // public void setData(List<T> data) { // this.data.clear(); // this.data.addAll(data); // // notifyDataSetChanged(); // } // // public T getItem(int position) { // return data.get(position); // } // // @UiThread // public BaseRecyclerListAdapter<T, VH> add(@NonNull T item) { // data.add(item); // notifyItemInserted(data.size() - 1); // return this; // } // // @UiThread // public BaseRecyclerListAdapter<T, VH> addAll(@NonNull Collection<T> items) { // data.addAll(items); // notifyItemRangeInserted(data.size() - items.size(), items.size()); // return this; // } // // @UiThread // public BaseRecyclerListAdapter<T, VH> add(int position, @NonNull T item) { // data.add(position, item); // notifyItemInserted(position); // return this; // } // // @UiThread // public BaseRecyclerListAdapter<T, VH> remove(int position) { // data.remove(position); // notifyItemRemoved(position); // return this; // } // // @UiThread // public BaseRecyclerListAdapter<T, VH> remove(@NonNull T item) { // return remove(data.indexOf(item)); // } // // @UiThread // public BaseRecyclerListAdapter<T, VH> clear() { // data.clear(); // notifyDataSetChanged(); // return this; // } // // public boolean isEmpty() { // return data == null || data.isEmpty(); // } // // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/ImageLoadHelper.java // public class ImageLoadHelper { // // public static void loadImage(Context context, String url, ImageView imageView, @Nullable RequestListener<String, GlideDrawable> listener) { // Glide.with(context).load(url).diskCacheStrategy(DiskCacheStrategy.SOURCE).listener(listener).into(imageView); // } // // public static void loadAvatar(Context context, String url, ImageView imageView) { // Glide.with(context).load(url).placeholder(R.mipmap.default_avatar).dontAnimate().into(imageView); // } // }
import butterknife.ButterKnife; import moe.yukinoneko.diycode.R; import moe.yukinoneko.diycode.bean.Sites; import moe.yukinoneko.diycode.list.BaseRecyclerListAdapter; import moe.yukinoneko.diycode.tool.ImageLoadHelper; import android.content.Intent; import android.net.Uri; import android.support.v7.widget.AppCompatImageView; import android.support.v7.widget.AppCompatTextView; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import butterknife.BindView;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.site; /** * Created by SamuelGjk on 2017/4/27. */ public class SitesGridAdapter extends BaseRecyclerListAdapter<Object, RecyclerView.ViewHolder> { private static final int VIEW_TYPE_CATEGORY = 10000; private static final int VIEW_TYPE_SITE = 10001; @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { LayoutInflater inflater = LayoutInflater.from(parent.getContext()); if (VIEW_TYPE_CATEGORY == viewType) { return new SitesViewHolder(inflater.inflate(R.layout.item_sites, parent, false)); } else { return new SiteViewHolder(inflater.inflate(R.layout.item_site, parent, false)); } } @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof SitesViewHolder) { ((SitesViewHolder) holder).sitesCategory.setText(((Sites) data.get(position)).name); } else { SiteViewHolder siteViewHolder = (SiteViewHolder) holder; Sites.Site site = (Sites.Site) data.get(position); siteViewHolder.url = site.url;
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/Sites.java // public class Sites { // // @SerializedName("name") public String name; // @SerializedName("id") public int id; // @SerializedName("sites") public List<Site> sites; // // public static class Site { // @SerializedName("name") public String name; // @SerializedName("url") public String url; // @SerializedName("avatar_url") public String avatarUrl; // } // } // // Path: app/src/main/java/moe/yukinoneko/diycode/list/BaseRecyclerListAdapter.java // public abstract class BaseRecyclerListAdapter<T, VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<VH> { // protected List<T> data = new ArrayList<>(); // // @Override // public int getItemCount() { // return data.size(); // } // // public List<T> getData() { // return data; // } // // @UiThread // public void setData(List<T> data) { // this.data.clear(); // this.data.addAll(data); // // notifyDataSetChanged(); // } // // public T getItem(int position) { // return data.get(position); // } // // @UiThread // public BaseRecyclerListAdapter<T, VH> add(@NonNull T item) { // data.add(item); // notifyItemInserted(data.size() - 1); // return this; // } // // @UiThread // public BaseRecyclerListAdapter<T, VH> addAll(@NonNull Collection<T> items) { // data.addAll(items); // notifyItemRangeInserted(data.size() - items.size(), items.size()); // return this; // } // // @UiThread // public BaseRecyclerListAdapter<T, VH> add(int position, @NonNull T item) { // data.add(position, item); // notifyItemInserted(position); // return this; // } // // @UiThread // public BaseRecyclerListAdapter<T, VH> remove(int position) { // data.remove(position); // notifyItemRemoved(position); // return this; // } // // @UiThread // public BaseRecyclerListAdapter<T, VH> remove(@NonNull T item) { // return remove(data.indexOf(item)); // } // // @UiThread // public BaseRecyclerListAdapter<T, VH> clear() { // data.clear(); // notifyDataSetChanged(); // return this; // } // // public boolean isEmpty() { // return data == null || data.isEmpty(); // } // // } // // Path: app/src/main/java/moe/yukinoneko/diycode/tool/ImageLoadHelper.java // public class ImageLoadHelper { // // public static void loadImage(Context context, String url, ImageView imageView, @Nullable RequestListener<String, GlideDrawable> listener) { // Glide.with(context).load(url).diskCacheStrategy(DiskCacheStrategy.SOURCE).listener(listener).into(imageView); // } // // public static void loadAvatar(Context context, String url, ImageView imageView) { // Glide.with(context).load(url).placeholder(R.mipmap.default_avatar).dontAnimate().into(imageView); // } // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/site/SitesGridAdapter.java import butterknife.ButterKnife; import moe.yukinoneko.diycode.R; import moe.yukinoneko.diycode.bean.Sites; import moe.yukinoneko.diycode.list.BaseRecyclerListAdapter; import moe.yukinoneko.diycode.tool.ImageLoadHelper; import android.content.Intent; import android.net.Uri; import android.support.v7.widget.AppCompatImageView; import android.support.v7.widget.AppCompatTextView; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import butterknife.BindView; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.site; /** * Created by SamuelGjk on 2017/4/27. */ public class SitesGridAdapter extends BaseRecyclerListAdapter<Object, RecyclerView.ViewHolder> { private static final int VIEW_TYPE_CATEGORY = 10000; private static final int VIEW_TYPE_SITE = 10001; @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { LayoutInflater inflater = LayoutInflater.from(parent.getContext()); if (VIEW_TYPE_CATEGORY == viewType) { return new SitesViewHolder(inflater.inflate(R.layout.item_sites, parent, false)); } else { return new SiteViewHolder(inflater.inflate(R.layout.item_site, parent, false)); } } @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof SitesViewHolder) { ((SitesViewHolder) holder).sitesCategory.setText(((Sites) data.get(position)).name); } else { SiteViewHolder siteViewHolder = (SiteViewHolder) holder; Sites.Site site = (Sites.Site) data.get(position); siteViewHolder.url = site.url;
ImageLoadHelper.loadImage(
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/news/NewsContract.java
// Path: app/src/main/java/moe/yukinoneko/diycode/list/ListBaseView.java // public interface ListBaseView extends BaseView { // // void setEnd(boolean end); // // void setRefresh(boolean refresh); // // void notifyLoadingStarted(); // // void notifyLoadingFinished(); // // void error(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/News.java // public class News implements Parcelable { // // @SerializedName("id") public int id; // 新闻 id // @SerializedName("title") public String title; // 标题 // @SerializedName("created_at") public Date createdAt; // 创建时间 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // @SerializedName("user") public User user; // 创建该话题的用户 // @SerializedName("node_name") public String nodeName; // 节点名称 // @SerializedName("node_id") public int nodeId; // 节点 id // @SerializedName("last_reply_user_id") public int lastReplyUserId; // 最近一次回复的用户 id // @SerializedName("last_reply_user_login") public String lastReplyUserLogin; // 最近一次回复的用户登录名 // @SerializedName("replied_at") public Date repliedAt; // 最近一次回复时间 // @SerializedName("replies_count") public int repliesCount; // 回复总数量 // @SerializedName("address") public String address; // 具体地址 // // protected News(Parcel in) { // id = in.readInt(); // title = in.readString(); // user = in.readParcelable(User.class.getClassLoader()); // nodeName = in.readString(); // nodeId = in.readInt(); // lastReplyUserId = in.readInt(); // lastReplyUserLogin = in.readString(); // repliesCount = in.readInt(); // address = in.readString(); // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeInt(id); // dest.writeString(title); // dest.writeParcelable(user, flags); // dest.writeString(nodeName); // dest.writeInt(nodeId); // dest.writeInt(lastReplyUserId); // dest.writeString(lastReplyUserLogin); // dest.writeInt(repliesCount); // dest.writeString(address); // } // // @Override // public int describeContents() { // return 0; // } // // public static final Creator<News> CREATOR = new Creator<News>() { // @Override // public News createFromParcel(Parcel in) { // return new News(in); // } // // @Override // public News[] newArray(int size) { // return new News[size]; // } // }; // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // }
import moe.yukinoneko.diycode.list.ListBaseView; import moe.yukinoneko.diycode.bean.News; import moe.yukinoneko.diycode.mvp.BasePresenter; import java.util.List;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.news; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class NewsContract { interface View extends ListBaseView {
// Path: app/src/main/java/moe/yukinoneko/diycode/list/ListBaseView.java // public interface ListBaseView extends BaseView { // // void setEnd(boolean end); // // void setRefresh(boolean refresh); // // void notifyLoadingStarted(); // // void notifyLoadingFinished(); // // void error(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/News.java // public class News implements Parcelable { // // @SerializedName("id") public int id; // 新闻 id // @SerializedName("title") public String title; // 标题 // @SerializedName("created_at") public Date createdAt; // 创建时间 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // @SerializedName("user") public User user; // 创建该话题的用户 // @SerializedName("node_name") public String nodeName; // 节点名称 // @SerializedName("node_id") public int nodeId; // 节点 id // @SerializedName("last_reply_user_id") public int lastReplyUserId; // 最近一次回复的用户 id // @SerializedName("last_reply_user_login") public String lastReplyUserLogin; // 最近一次回复的用户登录名 // @SerializedName("replied_at") public Date repliedAt; // 最近一次回复时间 // @SerializedName("replies_count") public int repliesCount; // 回复总数量 // @SerializedName("address") public String address; // 具体地址 // // protected News(Parcel in) { // id = in.readInt(); // title = in.readString(); // user = in.readParcelable(User.class.getClassLoader()); // nodeName = in.readString(); // nodeId = in.readInt(); // lastReplyUserId = in.readInt(); // lastReplyUserLogin = in.readString(); // repliesCount = in.readInt(); // address = in.readString(); // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeInt(id); // dest.writeString(title); // dest.writeParcelable(user, flags); // dest.writeString(nodeName); // dest.writeInt(nodeId); // dest.writeInt(lastReplyUserId); // dest.writeString(lastReplyUserLogin); // dest.writeInt(repliesCount); // dest.writeString(address); // } // // @Override // public int describeContents() { // return 0; // } // // public static final Creator<News> CREATOR = new Creator<News>() { // @Override // public News createFromParcel(Parcel in) { // return new News(in); // } // // @Override // public News[] newArray(int size) { // return new News[size]; // } // }; // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/news/NewsContract.java import moe.yukinoneko.diycode.list.ListBaseView; import moe.yukinoneko.diycode.bean.News; import moe.yukinoneko.diycode.mvp.BasePresenter; import java.util.List; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.news; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class NewsContract { interface View extends ListBaseView {
void updateNewsList(List<News> newses);
SamuelGjk/DiyCode
app/src/main/java/moe/yukinoneko/diycode/module/news/NewsContract.java
// Path: app/src/main/java/moe/yukinoneko/diycode/list/ListBaseView.java // public interface ListBaseView extends BaseView { // // void setEnd(boolean end); // // void setRefresh(boolean refresh); // // void notifyLoadingStarted(); // // void notifyLoadingFinished(); // // void error(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/News.java // public class News implements Parcelable { // // @SerializedName("id") public int id; // 新闻 id // @SerializedName("title") public String title; // 标题 // @SerializedName("created_at") public Date createdAt; // 创建时间 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // @SerializedName("user") public User user; // 创建该话题的用户 // @SerializedName("node_name") public String nodeName; // 节点名称 // @SerializedName("node_id") public int nodeId; // 节点 id // @SerializedName("last_reply_user_id") public int lastReplyUserId; // 最近一次回复的用户 id // @SerializedName("last_reply_user_login") public String lastReplyUserLogin; // 最近一次回复的用户登录名 // @SerializedName("replied_at") public Date repliedAt; // 最近一次回复时间 // @SerializedName("replies_count") public int repliesCount; // 回复总数量 // @SerializedName("address") public String address; // 具体地址 // // protected News(Parcel in) { // id = in.readInt(); // title = in.readString(); // user = in.readParcelable(User.class.getClassLoader()); // nodeName = in.readString(); // nodeId = in.readInt(); // lastReplyUserId = in.readInt(); // lastReplyUserLogin = in.readString(); // repliesCount = in.readInt(); // address = in.readString(); // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeInt(id); // dest.writeString(title); // dest.writeParcelable(user, flags); // dest.writeString(nodeName); // dest.writeInt(nodeId); // dest.writeInt(lastReplyUserId); // dest.writeString(lastReplyUserLogin); // dest.writeInt(repliesCount); // dest.writeString(address); // } // // @Override // public int describeContents() { // return 0; // } // // public static final Creator<News> CREATOR = new Creator<News>() { // @Override // public News createFromParcel(Parcel in) { // return new News(in); // } // // @Override // public News[] newArray(int size) { // return new News[size]; // } // }; // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // }
import moe.yukinoneko.diycode.list.ListBaseView; import moe.yukinoneko.diycode.bean.News; import moe.yukinoneko.diycode.mvp.BasePresenter; import java.util.List;
/* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.news; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class NewsContract { interface View extends ListBaseView { void updateNewsList(List<News> newses); }
// Path: app/src/main/java/moe/yukinoneko/diycode/list/ListBaseView.java // public interface ListBaseView extends BaseView { // // void setEnd(boolean end); // // void setRefresh(boolean refresh); // // void notifyLoadingStarted(); // // void notifyLoadingFinished(); // // void error(); // } // // Path: app/src/main/java/moe/yukinoneko/diycode/bean/News.java // public class News implements Parcelable { // // @SerializedName("id") public int id; // 新闻 id // @SerializedName("title") public String title; // 标题 // @SerializedName("created_at") public Date createdAt; // 创建时间 // @SerializedName("updated_at") public Date updatedAt; // 更新时间 // @SerializedName("user") public User user; // 创建该话题的用户 // @SerializedName("node_name") public String nodeName; // 节点名称 // @SerializedName("node_id") public int nodeId; // 节点 id // @SerializedName("last_reply_user_id") public int lastReplyUserId; // 最近一次回复的用户 id // @SerializedName("last_reply_user_login") public String lastReplyUserLogin; // 最近一次回复的用户登录名 // @SerializedName("replied_at") public Date repliedAt; // 最近一次回复时间 // @SerializedName("replies_count") public int repliesCount; // 回复总数量 // @SerializedName("address") public String address; // 具体地址 // // protected News(Parcel in) { // id = in.readInt(); // title = in.readString(); // user = in.readParcelable(User.class.getClassLoader()); // nodeName = in.readString(); // nodeId = in.readInt(); // lastReplyUserId = in.readInt(); // lastReplyUserLogin = in.readString(); // repliesCount = in.readInt(); // address = in.readString(); // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeInt(id); // dest.writeString(title); // dest.writeParcelable(user, flags); // dest.writeString(nodeName); // dest.writeInt(nodeId); // dest.writeInt(lastReplyUserId); // dest.writeString(lastReplyUserLogin); // dest.writeInt(repliesCount); // dest.writeString(address); // } // // @Override // public int describeContents() { // return 0; // } // // public static final Creator<News> CREATOR = new Creator<News>() { // @Override // public News createFromParcel(Parcel in) { // return new News(in); // } // // @Override // public News[] newArray(int size) { // return new News[size]; // } // }; // } // // Path: app/src/main/java/moe/yukinoneko/diycode/mvp/BasePresenter.java // public interface BasePresenter<V extends BaseView> { // void attachView(V view); // // void detachView(); // } // Path: app/src/main/java/moe/yukinoneko/diycode/module/news/NewsContract.java import moe.yukinoneko.diycode.list.ListBaseView; import moe.yukinoneko.diycode.bean.News; import moe.yukinoneko.diycode.mvp.BasePresenter; import java.util.List; /* * Copyright (c) 2017 SamuelGjk <samuel.alva@outlook.com> * * This file is part of DiyCode * * DiyCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DiyCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DiyCode. If not, see <http://www.gnu.org/licenses/>. */ package moe.yukinoneko.diycode.module.news; /** * MVPPlugin * 邮箱 784787081@qq.com */ public class NewsContract { interface View extends ListBaseView { void updateNewsList(List<News> newses); }
interface Presenter extends BasePresenter<View> {
nimble-platform/identity-service
identity-service/src/test/java/eu/nimble/core/infrastructure/identity/TestUtils.java
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/config/NimbleConfigurationProperties.java // @Component // @Configuration // @EnableConfigurationProperties // @ConfigurationProperties(prefix = "nimble") // public class NimbleConfigurationProperties { // // private LanguageID defaultLanguageID = LanguageID.ENGLISH; // // public LanguageID getDefaultLanguageID() { // return defaultLanguageID; // } // // public void setDefaultLanguageID(String defaultLanguageID) { // this.defaultLanguageID = LanguageID.valueOf(defaultLanguageID); // } // // public enum LanguageID { // @JsonProperty("en") // ENGLISH("en"), // @JsonProperty("es") // SPANISH("es"), // @JsonProperty("de") // GERMAN("de"), // @JsonProperty("tr") // TURKISH("tr"), // @JsonProperty("sv") // SWEDISH("sv"), // @JsonProperty("it") // ITALIAN("it"); // // private final String id; // // LanguageID(final String id) { // this.id = id; // } // // @Override // public String toString() { // return id; // } // // public static LanguageID fromString(String identifier) { // return Arrays.stream(LanguageID.values()).filter(l -> l.id.equals(identifier)).findFirst().orElse(null); // } // } // }
import eu.nimble.core.infrastructure.identity.config.NimbleConfigurationProperties; import eu.nimble.core.infrastructure.identity.entity.dto.*; import eu.nimble.service.model.ubl.commonaggregatecomponents.PersonType; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import static eu.nimble.core.infrastructure.identity.config.NimbleConfigurationProperties.LanguageID.ENGLISH;
package eu.nimble.core.infrastructure.identity; /** * Created by Johannes Innerbichler on 2019-02-01. */ public class TestUtils { public static final String JSON_DATE_FORMAT = "yyyy-MM-dd"; public static CompanyRegistration createCompanyRegistration(String legalName, PersonType user) {
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/config/NimbleConfigurationProperties.java // @Component // @Configuration // @EnableConfigurationProperties // @ConfigurationProperties(prefix = "nimble") // public class NimbleConfigurationProperties { // // private LanguageID defaultLanguageID = LanguageID.ENGLISH; // // public LanguageID getDefaultLanguageID() { // return defaultLanguageID; // } // // public void setDefaultLanguageID(String defaultLanguageID) { // this.defaultLanguageID = LanguageID.valueOf(defaultLanguageID); // } // // public enum LanguageID { // @JsonProperty("en") // ENGLISH("en"), // @JsonProperty("es") // SPANISH("es"), // @JsonProperty("de") // GERMAN("de"), // @JsonProperty("tr") // TURKISH("tr"), // @JsonProperty("sv") // SWEDISH("sv"), // @JsonProperty("it") // ITALIAN("it"); // // private final String id; // // LanguageID(final String id) { // this.id = id; // } // // @Override // public String toString() { // return id; // } // // public static LanguageID fromString(String identifier) { // return Arrays.stream(LanguageID.values()).filter(l -> l.id.equals(identifier)).findFirst().orElse(null); // } // } // } // Path: identity-service/src/test/java/eu/nimble/core/infrastructure/identity/TestUtils.java import eu.nimble.core.infrastructure.identity.config.NimbleConfigurationProperties; import eu.nimble.core.infrastructure.identity.entity.dto.*; import eu.nimble.service.model.ubl.commonaggregatecomponents.PersonType; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import static eu.nimble.core.infrastructure.identity.config.NimbleConfigurationProperties.LanguageID.ENGLISH; package eu.nimble.core.infrastructure.identity; /** * Created by Johannes Innerbichler on 2019-02-01. */ public class TestUtils { public static final String JSON_DATE_FORMAT = "yyyy-MM-dd"; public static CompanyRegistration createCompanyRegistration(String legalName, PersonType user) {
HashMap<NimbleConfigurationProperties.LanguageID, String> industrySectors = new HashMap<>();
nimble-platform/identity-service
identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/dto/FrontEndUser.java
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/config/NimbleConfigurationProperties.java // @Component // @Configuration // @EnableConfigurationProperties // @ConfigurationProperties(prefix = "nimble") // public class NimbleConfigurationProperties { // // private LanguageID defaultLanguageID = LanguageID.ENGLISH; // // public LanguageID getDefaultLanguageID() { // return defaultLanguageID; // } // // public void setDefaultLanguageID(String defaultLanguageID) { // this.defaultLanguageID = LanguageID.valueOf(defaultLanguageID); // } // // public enum LanguageID { // @JsonProperty("en") // ENGLISH("en"), // @JsonProperty("es") // SPANISH("es"), // @JsonProperty("de") // GERMAN("de"), // @JsonProperty("tr") // TURKISH("tr"), // @JsonProperty("sv") // SWEDISH("sv"), // @JsonProperty("it") // ITALIAN("it"); // // private final String id; // // LanguageID(final String id) { // this.id = id; // } // // @Override // public String toString() { // return id; // } // // public static LanguageID fromString(String identifier) { // return Arrays.stream(LanguageID.values()).filter(l -> l.id.equals(identifier)).findFirst().orElse(null); // } // } // }
import eu.nimble.core.infrastructure.identity.config.NimbleConfigurationProperties; import org.joda.time.LocalDate; import java.util.Map;
package eu.nimble.core.infrastructure.identity.entity.dto; public class FrontEndUser { private String username = null; private String firstname = null; private String lastname = null; private String email = null; private LocalDate dateOfBirth = null; private String placeOBirth = null; private String phoneNumber = null; private Long userID = null; private String companyID = null;
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/config/NimbleConfigurationProperties.java // @Component // @Configuration // @EnableConfigurationProperties // @ConfigurationProperties(prefix = "nimble") // public class NimbleConfigurationProperties { // // private LanguageID defaultLanguageID = LanguageID.ENGLISH; // // public LanguageID getDefaultLanguageID() { // return defaultLanguageID; // } // // public void setDefaultLanguageID(String defaultLanguageID) { // this.defaultLanguageID = LanguageID.valueOf(defaultLanguageID); // } // // public enum LanguageID { // @JsonProperty("en") // ENGLISH("en"), // @JsonProperty("es") // SPANISH("es"), // @JsonProperty("de") // GERMAN("de"), // @JsonProperty("tr") // TURKISH("tr"), // @JsonProperty("sv") // SWEDISH("sv"), // @JsonProperty("it") // ITALIAN("it"); // // private final String id; // // LanguageID(final String id) { // this.id = id; // } // // @Override // public String toString() { // return id; // } // // public static LanguageID fromString(String identifier) { // return Arrays.stream(LanguageID.values()).filter(l -> l.id.equals(identifier)).findFirst().orElse(null); // } // } // } // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/dto/FrontEndUser.java import eu.nimble.core.infrastructure.identity.config.NimbleConfigurationProperties; import org.joda.time.LocalDate; import java.util.Map; package eu.nimble.core.infrastructure.identity.entity.dto; public class FrontEndUser { private String username = null; private String firstname = null; private String lastname = null; private String email = null; private LocalDate dateOfBirth = null; private String placeOBirth = null; private String phoneNumber = null; private Long userID = null; private String companyID = null;
private Map<NimbleConfigurationProperties.LanguageID, String> companyName = null;
nimble-platform/identity-service
identity-service/src/main/java/eu/nimble/core/infrastructure/identity/utils/UblAdapter.java
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/config/NimbleConfigurationProperties.java // @Component // @Configuration // @EnableConfigurationProperties // @ConfigurationProperties(prefix = "nimble") // public class NimbleConfigurationProperties { // // private LanguageID defaultLanguageID = LanguageID.ENGLISH; // // public LanguageID getDefaultLanguageID() { // return defaultLanguageID; // } // // public void setDefaultLanguageID(String defaultLanguageID) { // this.defaultLanguageID = LanguageID.valueOf(defaultLanguageID); // } // // public enum LanguageID { // @JsonProperty("en") // ENGLISH("en"), // @JsonProperty("es") // SPANISH("es"), // @JsonProperty("de") // GERMAN("de"), // @JsonProperty("tr") // TURKISH("tr"), // @JsonProperty("sv") // SWEDISH("sv"), // @JsonProperty("it") // ITALIAN("it"); // // private final String id; // // LanguageID(final String id) { // this.id = id; // } // // @Override // public String toString() { // return id; // } // // public static LanguageID fromString(String identifier) { // return Arrays.stream(LanguageID.values()).filter(l -> l.id.equals(identifier)).findFirst().orElse(null); // } // } // } // // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/UaaUser.java // @Entity // public class UaaUser implements Serializable { // // @Id // @Column(nullable = false, unique = true) // private String externalID; // // private String username; // // @OneToOne // private PersonType ublPerson; // // @ColumnDefault("false") // private Boolean showWelcomeInfo = false; // // public UaaUser() { // } // // public UaaUser(String username, PersonType ublPerson, String externalID) { // this.username = username; // this.ublPerson = ublPerson; // this.externalID = externalID; // this.showWelcomeInfo = true; // } // // public String getUsername() { // return username; // } // // public String getExternalID() { // return externalID; // } // // public PersonType getUBLPerson() { // return this.ublPerson; // } // // public Boolean getShowWelcomeInfo() { // return showWelcomeInfo; // } // // public void setShowWelcomeInfo(Boolean showWelcomeInfo) { // this.showWelcomeInfo = showWelcomeInfo; // } // }
import com.google.common.base.Strings; import eu.nimble.core.infrastructure.identity.config.NimbleConfigurationProperties; import eu.nimble.core.infrastructure.identity.entity.UaaUser; import eu.nimble.core.infrastructure.identity.entity.dto.*; import eu.nimble.service.model.ubl.commonaggregatecomponents.*; import eu.nimble.service.model.ubl.commonbasiccomponents.BinaryObjectType; import eu.nimble.service.model.ubl.commonbasiccomponents.CodeType; import eu.nimble.service.model.ubl.commonbasiccomponents.QuantityType; import eu.nimble.service.model.ubl.commonbasiccomponents.TextType; import eu.nimble.service.model.ubl.extension.QualityIndicatorParameter; import org.apache.commons.lang3.StringUtils; import java.math.BigDecimal; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors;
CoordinateType coordinateType = new CoordinateType(); coordinateType.setLatitude(dtoAddress.getLocationLatitude()); coordinateType.setLongitude(dtoAddress.getLocationLongitude()); ublAddress.setCoordinate(coordinateType); CountryType country = new CountryType(); CodeType codeType = new CodeType(); codeType.setValue(dtoAddress.getCountry()); country.setIdentificationCode(codeType); ublAddress.setCountry(country); return ublAddress; } public static CompanyDetails adaptCompanyDetails(PartyType party, QualifyingPartyType qualifyingParty) { CompanyDetails companyDetails = new CompanyDetails(); companyDetails.setBrandName(UblAdapter.adaptTextType(party.getBrandName())); companyDetails.setLegalName(UblAdapter.adaptPartyNames(party.getPartyName())); companyDetails.setVatNumber(party.getPartyTaxScheme() .stream() .filter(scheme -> scheme != null && scheme.getTaxScheme() != null && scheme.getTaxScheme().getTaxTypeCode() != null) .filter(scheme -> VAT_TAX_TYPE_CODE.equals(scheme.getTaxScheme().getTaxTypeCode().getName())) .filter(scheme -> scheme.getTaxScheme().getTaxTypeCode().getValue() != null) .map(scheme -> scheme.getTaxScheme().getTaxTypeCode().getValue()) .findFirst().orElse(null)); companyDetails.setAddress(adaptAddress(party.getPostalAddress())); companyDetails.setProcessIds(new ArrayList<>(party.getProcessID()));
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/config/NimbleConfigurationProperties.java // @Component // @Configuration // @EnableConfigurationProperties // @ConfigurationProperties(prefix = "nimble") // public class NimbleConfigurationProperties { // // private LanguageID defaultLanguageID = LanguageID.ENGLISH; // // public LanguageID getDefaultLanguageID() { // return defaultLanguageID; // } // // public void setDefaultLanguageID(String defaultLanguageID) { // this.defaultLanguageID = LanguageID.valueOf(defaultLanguageID); // } // // public enum LanguageID { // @JsonProperty("en") // ENGLISH("en"), // @JsonProperty("es") // SPANISH("es"), // @JsonProperty("de") // GERMAN("de"), // @JsonProperty("tr") // TURKISH("tr"), // @JsonProperty("sv") // SWEDISH("sv"), // @JsonProperty("it") // ITALIAN("it"); // // private final String id; // // LanguageID(final String id) { // this.id = id; // } // // @Override // public String toString() { // return id; // } // // public static LanguageID fromString(String identifier) { // return Arrays.stream(LanguageID.values()).filter(l -> l.id.equals(identifier)).findFirst().orElse(null); // } // } // } // // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/UaaUser.java // @Entity // public class UaaUser implements Serializable { // // @Id // @Column(nullable = false, unique = true) // private String externalID; // // private String username; // // @OneToOne // private PersonType ublPerson; // // @ColumnDefault("false") // private Boolean showWelcomeInfo = false; // // public UaaUser() { // } // // public UaaUser(String username, PersonType ublPerson, String externalID) { // this.username = username; // this.ublPerson = ublPerson; // this.externalID = externalID; // this.showWelcomeInfo = true; // } // // public String getUsername() { // return username; // } // // public String getExternalID() { // return externalID; // } // // public PersonType getUBLPerson() { // return this.ublPerson; // } // // public Boolean getShowWelcomeInfo() { // return showWelcomeInfo; // } // // public void setShowWelcomeInfo(Boolean showWelcomeInfo) { // this.showWelcomeInfo = showWelcomeInfo; // } // } // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/utils/UblAdapter.java import com.google.common.base.Strings; import eu.nimble.core.infrastructure.identity.config.NimbleConfigurationProperties; import eu.nimble.core.infrastructure.identity.entity.UaaUser; import eu.nimble.core.infrastructure.identity.entity.dto.*; import eu.nimble.service.model.ubl.commonaggregatecomponents.*; import eu.nimble.service.model.ubl.commonbasiccomponents.BinaryObjectType; import eu.nimble.service.model.ubl.commonbasiccomponents.CodeType; import eu.nimble.service.model.ubl.commonbasiccomponents.QuantityType; import eu.nimble.service.model.ubl.commonbasiccomponents.TextType; import eu.nimble.service.model.ubl.extension.QualityIndicatorParameter; import org.apache.commons.lang3.StringUtils; import java.math.BigDecimal; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; CoordinateType coordinateType = new CoordinateType(); coordinateType.setLatitude(dtoAddress.getLocationLatitude()); coordinateType.setLongitude(dtoAddress.getLocationLongitude()); ublAddress.setCoordinate(coordinateType); CountryType country = new CountryType(); CodeType codeType = new CodeType(); codeType.setValue(dtoAddress.getCountry()); country.setIdentificationCode(codeType); ublAddress.setCountry(country); return ublAddress; } public static CompanyDetails adaptCompanyDetails(PartyType party, QualifyingPartyType qualifyingParty) { CompanyDetails companyDetails = new CompanyDetails(); companyDetails.setBrandName(UblAdapter.adaptTextType(party.getBrandName())); companyDetails.setLegalName(UblAdapter.adaptPartyNames(party.getPartyName())); companyDetails.setVatNumber(party.getPartyTaxScheme() .stream() .filter(scheme -> scheme != null && scheme.getTaxScheme() != null && scheme.getTaxScheme().getTaxTypeCode() != null) .filter(scheme -> VAT_TAX_TYPE_CODE.equals(scheme.getTaxScheme().getTaxTypeCode().getName())) .filter(scheme -> scheme.getTaxScheme().getTaxTypeCode().getValue() != null) .map(scheme -> scheme.getTaxScheme().getTaxTypeCode().getValue()) .findFirst().orElse(null)); companyDetails.setAddress(adaptAddress(party.getPostalAddress())); companyDetails.setProcessIds(new ArrayList<>(party.getProcessID()));
Map< NimbleConfigurationProperties.LanguageID, String> industrySectors = party.getIndustrySector().stream()
nimble-platform/identity-service
identity-service/src/main/java/eu/nimble/core/infrastructure/identity/utils/UblAdapter.java
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/config/NimbleConfigurationProperties.java // @Component // @Configuration // @EnableConfigurationProperties // @ConfigurationProperties(prefix = "nimble") // public class NimbleConfigurationProperties { // // private LanguageID defaultLanguageID = LanguageID.ENGLISH; // // public LanguageID getDefaultLanguageID() { // return defaultLanguageID; // } // // public void setDefaultLanguageID(String defaultLanguageID) { // this.defaultLanguageID = LanguageID.valueOf(defaultLanguageID); // } // // public enum LanguageID { // @JsonProperty("en") // ENGLISH("en"), // @JsonProperty("es") // SPANISH("es"), // @JsonProperty("de") // GERMAN("de"), // @JsonProperty("tr") // TURKISH("tr"), // @JsonProperty("sv") // SWEDISH("sv"), // @JsonProperty("it") // ITALIAN("it"); // // private final String id; // // LanguageID(final String id) { // this.id = id; // } // // @Override // public String toString() { // return id; // } // // public static LanguageID fromString(String identifier) { // return Arrays.stream(LanguageID.values()).filter(l -> l.id.equals(identifier)).findFirst().orElse(null); // } // } // } // // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/UaaUser.java // @Entity // public class UaaUser implements Serializable { // // @Id // @Column(nullable = false, unique = true) // private String externalID; // // private String username; // // @OneToOne // private PersonType ublPerson; // // @ColumnDefault("false") // private Boolean showWelcomeInfo = false; // // public UaaUser() { // } // // public UaaUser(String username, PersonType ublPerson, String externalID) { // this.username = username; // this.ublPerson = ublPerson; // this.externalID = externalID; // this.showWelcomeInfo = true; // } // // public String getUsername() { // return username; // } // // public String getExternalID() { // return externalID; // } // // public PersonType getUBLPerson() { // return this.ublPerson; // } // // public Boolean getShowWelcomeInfo() { // return showWelcomeInfo; // } // // public void setShowWelcomeInfo(Boolean showWelcomeInfo) { // this.showWelcomeInfo = showWelcomeInfo; // } // }
import com.google.common.base.Strings; import eu.nimble.core.infrastructure.identity.config.NimbleConfigurationProperties; import eu.nimble.core.infrastructure.identity.entity.UaaUser; import eu.nimble.core.infrastructure.identity.entity.dto.*; import eu.nimble.service.model.ubl.commonaggregatecomponents.*; import eu.nimble.service.model.ubl.commonbasiccomponents.BinaryObjectType; import eu.nimble.service.model.ubl.commonbasiccomponents.CodeType; import eu.nimble.service.model.ubl.commonbasiccomponents.QuantityType; import eu.nimble.service.model.ubl.commonbasiccomponents.TextType; import eu.nimble.service.model.ubl.extension.QualityIndicatorParameter; import org.apache.commons.lang3.StringUtils; import java.math.BigDecimal; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors;
PaymentMeansType ublPaymentMeans = new PaymentMeansType(); ublPaymentMeans.setInstructionNote(UblAdapter.adaptTextType(dtoPaymentMeans.getInstructionNote())); return ublPaymentMeans; } public static PaymentMeans adaptPaymentMeans(PaymentMeansType ublPaymentMeans) { if (ublPaymentMeans == null) return new PaymentMeans(); PaymentMeans dtoPaymentMeans = new PaymentMeans(); dtoPaymentMeans.setInstructionNote(UblAdapter.adaptTextType(ublPaymentMeans.getInstructionNote())); return dtoPaymentMeans; } public static PartyIdentificationType adaptPartyIdentifier(String identifier) { PartyIdentificationType partyIdentificationType = new PartyIdentificationType(); partyIdentificationType.setID(identifier); return partyIdentificationType; } public static String adaptPartyIdentifier(PartyIdentificationType partyIdentification) { return partyIdentification.getID(); } public static String adaptPartyIdentifier(PartyType partyType) { return adaptPartyIdentifier(Objects.requireNonNull(partyType.getPartyIdentification().stream().findFirst().orElse(null))); }
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/config/NimbleConfigurationProperties.java // @Component // @Configuration // @EnableConfigurationProperties // @ConfigurationProperties(prefix = "nimble") // public class NimbleConfigurationProperties { // // private LanguageID defaultLanguageID = LanguageID.ENGLISH; // // public LanguageID getDefaultLanguageID() { // return defaultLanguageID; // } // // public void setDefaultLanguageID(String defaultLanguageID) { // this.defaultLanguageID = LanguageID.valueOf(defaultLanguageID); // } // // public enum LanguageID { // @JsonProperty("en") // ENGLISH("en"), // @JsonProperty("es") // SPANISH("es"), // @JsonProperty("de") // GERMAN("de"), // @JsonProperty("tr") // TURKISH("tr"), // @JsonProperty("sv") // SWEDISH("sv"), // @JsonProperty("it") // ITALIAN("it"); // // private final String id; // // LanguageID(final String id) { // this.id = id; // } // // @Override // public String toString() { // return id; // } // // public static LanguageID fromString(String identifier) { // return Arrays.stream(LanguageID.values()).filter(l -> l.id.equals(identifier)).findFirst().orElse(null); // } // } // } // // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/UaaUser.java // @Entity // public class UaaUser implements Serializable { // // @Id // @Column(nullable = false, unique = true) // private String externalID; // // private String username; // // @OneToOne // private PersonType ublPerson; // // @ColumnDefault("false") // private Boolean showWelcomeInfo = false; // // public UaaUser() { // } // // public UaaUser(String username, PersonType ublPerson, String externalID) { // this.username = username; // this.ublPerson = ublPerson; // this.externalID = externalID; // this.showWelcomeInfo = true; // } // // public String getUsername() { // return username; // } // // public String getExternalID() { // return externalID; // } // // public PersonType getUBLPerson() { // return this.ublPerson; // } // // public Boolean getShowWelcomeInfo() { // return showWelcomeInfo; // } // // public void setShowWelcomeInfo(Boolean showWelcomeInfo) { // this.showWelcomeInfo = showWelcomeInfo; // } // } // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/utils/UblAdapter.java import com.google.common.base.Strings; import eu.nimble.core.infrastructure.identity.config.NimbleConfigurationProperties; import eu.nimble.core.infrastructure.identity.entity.UaaUser; import eu.nimble.core.infrastructure.identity.entity.dto.*; import eu.nimble.service.model.ubl.commonaggregatecomponents.*; import eu.nimble.service.model.ubl.commonbasiccomponents.BinaryObjectType; import eu.nimble.service.model.ubl.commonbasiccomponents.CodeType; import eu.nimble.service.model.ubl.commonbasiccomponents.QuantityType; import eu.nimble.service.model.ubl.commonbasiccomponents.TextType; import eu.nimble.service.model.ubl.extension.QualityIndicatorParameter; import org.apache.commons.lang3.StringUtils; import java.math.BigDecimal; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; PaymentMeansType ublPaymentMeans = new PaymentMeansType(); ublPaymentMeans.setInstructionNote(UblAdapter.adaptTextType(dtoPaymentMeans.getInstructionNote())); return ublPaymentMeans; } public static PaymentMeans adaptPaymentMeans(PaymentMeansType ublPaymentMeans) { if (ublPaymentMeans == null) return new PaymentMeans(); PaymentMeans dtoPaymentMeans = new PaymentMeans(); dtoPaymentMeans.setInstructionNote(UblAdapter.adaptTextType(ublPaymentMeans.getInstructionNote())); return dtoPaymentMeans; } public static PartyIdentificationType adaptPartyIdentifier(String identifier) { PartyIdentificationType partyIdentificationType = new PartyIdentificationType(); partyIdentificationType.setID(identifier); return partyIdentificationType; } public static String adaptPartyIdentifier(PartyIdentificationType partyIdentification) { return partyIdentification.getID(); } public static String adaptPartyIdentifier(PartyType partyType) { return adaptPartyIdentifier(Objects.requireNonNull(partyType.getPartyIdentification().stream().findFirst().orElse(null))); }
public static FrontEndUser adaptUser(UaaUser uaaUser, List<PartyType> companies) {
nimble-platform/identity-service
identity-service/src/test/java/eu/nimble/core/infrastructure/identity/config/KafkaTestConfiguration.java
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/messaging/KafkaReceiver.java // @Component // public class KafkaReceiver { // @KafkaListener(topics = "${nimble.kafka.topics.companyUpdates}", containerFactory = "companyUpdatesKafkaListenerContainerFactory") // public void receiveCompanyUpdates(ConsumerRecord<String, KafkaConfig.AuthorizedCompanyUpdate> consumerRecord) { // System.out.println("Receiver: " + consumerRecord.value().getCompanyId()); // } // }
import eu.nimble.core.infrastructure.identity.messaging.KafkaReceiver; import org.mockito.Mockito; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Profile; import java.io.IOException;
package eu.nimble.core.infrastructure.identity.config; /** * Created by Johannes Innerbichler on 09.10.18. */ @Profile("test") @TestConfiguration public class KafkaTestConfiguration { @Bean @Primary
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/messaging/KafkaReceiver.java // @Component // public class KafkaReceiver { // @KafkaListener(topics = "${nimble.kafka.topics.companyUpdates}", containerFactory = "companyUpdatesKafkaListenerContainerFactory") // public void receiveCompanyUpdates(ConsumerRecord<String, KafkaConfig.AuthorizedCompanyUpdate> consumerRecord) { // System.out.println("Receiver: " + consumerRecord.value().getCompanyId()); // } // } // Path: identity-service/src/test/java/eu/nimble/core/infrastructure/identity/config/KafkaTestConfiguration.java import eu.nimble.core.infrastructure.identity.messaging.KafkaReceiver; import org.mockito.Mockito; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Profile; import java.io.IOException; package eu.nimble.core.infrastructure.identity.config; /** * Created by Johannes Innerbichler on 09.10.18. */ @Profile("test") @TestConfiguration public class KafkaTestConfiguration { @Bean @Primary
public KafkaReceiver receiverResolver() {
nimble-platform/identity-service
identity-service/src/main/java/eu/nimble/core/infrastructure/identity/IdentityServiceApplication.java
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/UaaUser.java // @Entity // public class UaaUser implements Serializable { // // @Id // @Column(nullable = false, unique = true) // private String externalID; // // private String username; // // @OneToOne // private PersonType ublPerson; // // @ColumnDefault("false") // private Boolean showWelcomeInfo = false; // // public UaaUser() { // } // // public UaaUser(String username, PersonType ublPerson, String externalID) { // this.username = username; // this.ublPerson = ublPerson; // this.externalID = externalID; // this.showWelcomeInfo = true; // } // // public String getUsername() { // return username; // } // // public String getExternalID() { // return externalID; // } // // public PersonType getUBLPerson() { // return this.ublPerson; // } // // public Boolean getShowWelcomeInfo() { // return showWelcomeInfo; // } // // public void setShowWelcomeInfo(Boolean showWelcomeInfo) { // this.showWelcomeInfo = showWelcomeInfo; // } // }
import com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect; import eu.nimble.core.infrastructure.identity.entity.UaaUser; import eu.nimble.service.model.ubl.commonaggregatecomponents.PartyType; import eu.nimble.service.model.ubl.commonaggregatecomponents.PersonType; import eu.nimble.service.model.ubl.commonbasiccomponents.CodeType; import eu.nimble.utility.email.EmailService; import eu.nimble.utility.email.ThymeleafConfig; import eu.nimble.utility.persistence.binary.BinaryContentService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.web.support.SpringBootServletInitializer; import org.springframework.cache.annotation.EnableCaching; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.netflix.feign.EnableFeignClients; import org.springframework.cloud.netflix.hystrix.EnableHystrix; import org.springframework.context.annotation.*; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import javax.sql.DataSource;
package eu.nimble.core.infrastructure.identity; @Configuration @EnableDiscoveryClient @EnableHystrix @EnableFeignClients @SpringBootApplication @EnableScheduling @EnableJpaRepositories(basePackages = {"eu.nimble.core.infrastructure.identity"})
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/UaaUser.java // @Entity // public class UaaUser implements Serializable { // // @Id // @Column(nullable = false, unique = true) // private String externalID; // // private String username; // // @OneToOne // private PersonType ublPerson; // // @ColumnDefault("false") // private Boolean showWelcomeInfo = false; // // public UaaUser() { // } // // public UaaUser(String username, PersonType ublPerson, String externalID) { // this.username = username; // this.ublPerson = ublPerson; // this.externalID = externalID; // this.showWelcomeInfo = true; // } // // public String getUsername() { // return username; // } // // public String getExternalID() { // return externalID; // } // // public PersonType getUBLPerson() { // return this.ublPerson; // } // // public Boolean getShowWelcomeInfo() { // return showWelcomeInfo; // } // // public void setShowWelcomeInfo(Boolean showWelcomeInfo) { // this.showWelcomeInfo = showWelcomeInfo; // } // } // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/IdentityServiceApplication.java import com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect; import eu.nimble.core.infrastructure.identity.entity.UaaUser; import eu.nimble.service.model.ubl.commonaggregatecomponents.PartyType; import eu.nimble.service.model.ubl.commonaggregatecomponents.PersonType; import eu.nimble.service.model.ubl.commonbasiccomponents.CodeType; import eu.nimble.utility.email.EmailService; import eu.nimble.utility.email.ThymeleafConfig; import eu.nimble.utility.persistence.binary.BinaryContentService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.web.support.SpringBootServletInitializer; import org.springframework.cache.annotation.EnableCaching; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.netflix.feign.EnableFeignClients; import org.springframework.cloud.netflix.hystrix.EnableHystrix; import org.springframework.context.annotation.*; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import javax.sql.DataSource; package eu.nimble.core.infrastructure.identity; @Configuration @EnableDiscoveryClient @EnableHystrix @EnableFeignClients @SpringBootApplication @EnableScheduling @EnableJpaRepositories(basePackages = {"eu.nimble.core.infrastructure.identity"})
@EntityScan(basePackageClasses = {UaaUser.class, PartyType.class, PersonType.class, CodeType.class})
nimble-platform/identity-service
identity-service/src/main/java/eu/nimble/core/infrastructure/identity/system/dto/UserRegistration.java
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/dto/Credentials.java // public class Credentials { // // private String username = null; // // private String password = null; // // 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; // } // // @Override // public String toString() { // return "Credentials{" + "username='" + username + '\'' + ", password='*******" + '}'; // } // } // // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/dto/FrontEndUser.java // public class FrontEndUser { // private String username = null; // // private String firstname = null; // // private String lastname = null; // // private String email = null; // // private LocalDate dateOfBirth = null; // // private String placeOBirth = null; // // private String phoneNumber = null; // // private Long userID = null; // // private String companyID = null; // // private Map<NimbleConfigurationProperties.LanguageID, String> companyName = null; // // private String accessToken = null; // // private String rocketChatToken = null; // // private String rocketChatUsername = null; // // private String rocketChatUserID = null; // // private Boolean showWelcomeInfo = false; // // private String vat = null; // // public Map<NimbleConfigurationProperties.LanguageID, String> getCompanyName() { // return companyName; // } // // public void setCompanyName(Map<NimbleConfigurationProperties.LanguageID, String> companyName) { // this.companyName = companyName; // } // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getFirstname() { // return firstname; // } // // public void setFirstname(String firstname) { // this.firstname = firstname; // } // // public String getLastname() { // return lastname; // } // // public void setLastname(String lastname) { // this.lastname = lastname; // } // // public String getEmail() { // return email; // } // // public void setEmail(String email) { // this.email = email; // } // // public LocalDate getDateOfBirth() { // return dateOfBirth; // } // // public void setDateOfBirth(LocalDate dateOfBirth) { // this.dateOfBirth = dateOfBirth; // } // // public String getPlaceOBirth() { // return placeOBirth; // } // // public void setPlaceOBirth(String placeOBirth) { // this.placeOBirth = placeOBirth; // } // // public String getPhoneNumber() { // return phoneNumber; // } // // public void setPhoneNumber(String phoneNumber) { // this.phoneNumber = phoneNumber; // } // // public Long getUserID() { // return userID; // } // // public void setUserID(Long userID) { // this.userID = userID; // } // // public String getCompanyID() { // return companyID; // } // // public void setCompanyID(String companyID) { // this.companyID = companyID; // } // // public String getAccessToken() { // return accessToken; // } // // public void setAccessToken(String accessToken) { // this.accessToken = accessToken; // } // // public Boolean getShowWelcomeInfo() { // return showWelcomeInfo; // } // // public void setShowWelcomeInfo(Boolean showWelcomeInfo) { // this.showWelcomeInfo = showWelcomeInfo; // } // // public String getRocketChatToken() { // return rocketChatToken; // } // // public void setRocketChatToken(String rocketChatToken) { // this.rocketChatToken = rocketChatToken; // } // // public String getRocketChatUsername() { // return rocketChatUsername; // } // // public void setRocketChatUsername(String rocketChatUsername) { // this.rocketChatUsername = rocketChatUsername; // } // // public String getRocketChatUserID() { // return rocketChatUserID; // } // // public void setRocketChatUserID(String rocketChatUserID) { // this.rocketChatUserID = rocketChatUserID; // } // // public String getVat() { // return vat; // } // // public void setVat(String vat) { // this.vat = vat; // } // // @Override // public String toString() { // return "FrontEndUser{" + // "username='" + username + '\'' + // ", firstname='" + firstname + '\'' + // ", lastname='" + lastname + '\'' + // ", email='" + email + '\'' + // ", dateOfBirth=" + dateOfBirth + // ", placeOBirth='" + placeOBirth + '\'' + // ", phoneNumber='" + phoneNumber + '\'' + // ", userID=" + userID + // ", companyID='" + companyID + '\'' + // ", companyName='" + companyName + '\'' + // ", showWelcomeInfo=" + showWelcomeInfo + // ", vat='" + vat + '\'' + // '}'; // } // }
import eu.nimble.core.infrastructure.identity.entity.dto.Credentials; import eu.nimble.core.infrastructure.identity.entity.dto.FrontEndUser;
package eu.nimble.core.infrastructure.identity.system.dto; @SuppressWarnings("unused") public class UserRegistration {
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/dto/Credentials.java // public class Credentials { // // private String username = null; // // private String password = null; // // 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; // } // // @Override // public String toString() { // return "Credentials{" + "username='" + username + '\'' + ", password='*******" + '}'; // } // } // // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/dto/FrontEndUser.java // public class FrontEndUser { // private String username = null; // // private String firstname = null; // // private String lastname = null; // // private String email = null; // // private LocalDate dateOfBirth = null; // // private String placeOBirth = null; // // private String phoneNumber = null; // // private Long userID = null; // // private String companyID = null; // // private Map<NimbleConfigurationProperties.LanguageID, String> companyName = null; // // private String accessToken = null; // // private String rocketChatToken = null; // // private String rocketChatUsername = null; // // private String rocketChatUserID = null; // // private Boolean showWelcomeInfo = false; // // private String vat = null; // // public Map<NimbleConfigurationProperties.LanguageID, String> getCompanyName() { // return companyName; // } // // public void setCompanyName(Map<NimbleConfigurationProperties.LanguageID, String> companyName) { // this.companyName = companyName; // } // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getFirstname() { // return firstname; // } // // public void setFirstname(String firstname) { // this.firstname = firstname; // } // // public String getLastname() { // return lastname; // } // // public void setLastname(String lastname) { // this.lastname = lastname; // } // // public String getEmail() { // return email; // } // // public void setEmail(String email) { // this.email = email; // } // // public LocalDate getDateOfBirth() { // return dateOfBirth; // } // // public void setDateOfBirth(LocalDate dateOfBirth) { // this.dateOfBirth = dateOfBirth; // } // // public String getPlaceOBirth() { // return placeOBirth; // } // // public void setPlaceOBirth(String placeOBirth) { // this.placeOBirth = placeOBirth; // } // // public String getPhoneNumber() { // return phoneNumber; // } // // public void setPhoneNumber(String phoneNumber) { // this.phoneNumber = phoneNumber; // } // // public Long getUserID() { // return userID; // } // // public void setUserID(Long userID) { // this.userID = userID; // } // // public String getCompanyID() { // return companyID; // } // // public void setCompanyID(String companyID) { // this.companyID = companyID; // } // // public String getAccessToken() { // return accessToken; // } // // public void setAccessToken(String accessToken) { // this.accessToken = accessToken; // } // // public Boolean getShowWelcomeInfo() { // return showWelcomeInfo; // } // // public void setShowWelcomeInfo(Boolean showWelcomeInfo) { // this.showWelcomeInfo = showWelcomeInfo; // } // // public String getRocketChatToken() { // return rocketChatToken; // } // // public void setRocketChatToken(String rocketChatToken) { // this.rocketChatToken = rocketChatToken; // } // // public String getRocketChatUsername() { // return rocketChatUsername; // } // // public void setRocketChatUsername(String rocketChatUsername) { // this.rocketChatUsername = rocketChatUsername; // } // // public String getRocketChatUserID() { // return rocketChatUserID; // } // // public void setRocketChatUserID(String rocketChatUserID) { // this.rocketChatUserID = rocketChatUserID; // } // // public String getVat() { // return vat; // } // // public void setVat(String vat) { // this.vat = vat; // } // // @Override // public String toString() { // return "FrontEndUser{" + // "username='" + username + '\'' + // ", firstname='" + firstname + '\'' + // ", lastname='" + lastname + '\'' + // ", email='" + email + '\'' + // ", dateOfBirth=" + dateOfBirth + // ", placeOBirth='" + placeOBirth + '\'' + // ", phoneNumber='" + phoneNumber + '\'' + // ", userID=" + userID + // ", companyID='" + companyID + '\'' + // ", companyName='" + companyName + '\'' + // ", showWelcomeInfo=" + showWelcomeInfo + // ", vat='" + vat + '\'' + // '}'; // } // } // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/system/dto/UserRegistration.java import eu.nimble.core.infrastructure.identity.entity.dto.Credentials; import eu.nimble.core.infrastructure.identity.entity.dto.FrontEndUser; package eu.nimble.core.infrastructure.identity.system.dto; @SuppressWarnings("unused") public class UserRegistration {
private FrontEndUser user = null;
nimble-platform/identity-service
identity-service/src/main/java/eu/nimble/core/infrastructure/identity/system/dto/UserRegistration.java
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/dto/Credentials.java // public class Credentials { // // private String username = null; // // private String password = null; // // 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; // } // // @Override // public String toString() { // return "Credentials{" + "username='" + username + '\'' + ", password='*******" + '}'; // } // } // // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/dto/FrontEndUser.java // public class FrontEndUser { // private String username = null; // // private String firstname = null; // // private String lastname = null; // // private String email = null; // // private LocalDate dateOfBirth = null; // // private String placeOBirth = null; // // private String phoneNumber = null; // // private Long userID = null; // // private String companyID = null; // // private Map<NimbleConfigurationProperties.LanguageID, String> companyName = null; // // private String accessToken = null; // // private String rocketChatToken = null; // // private String rocketChatUsername = null; // // private String rocketChatUserID = null; // // private Boolean showWelcomeInfo = false; // // private String vat = null; // // public Map<NimbleConfigurationProperties.LanguageID, String> getCompanyName() { // return companyName; // } // // public void setCompanyName(Map<NimbleConfigurationProperties.LanguageID, String> companyName) { // this.companyName = companyName; // } // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getFirstname() { // return firstname; // } // // public void setFirstname(String firstname) { // this.firstname = firstname; // } // // public String getLastname() { // return lastname; // } // // public void setLastname(String lastname) { // this.lastname = lastname; // } // // public String getEmail() { // return email; // } // // public void setEmail(String email) { // this.email = email; // } // // public LocalDate getDateOfBirth() { // return dateOfBirth; // } // // public void setDateOfBirth(LocalDate dateOfBirth) { // this.dateOfBirth = dateOfBirth; // } // // public String getPlaceOBirth() { // return placeOBirth; // } // // public void setPlaceOBirth(String placeOBirth) { // this.placeOBirth = placeOBirth; // } // // public String getPhoneNumber() { // return phoneNumber; // } // // public void setPhoneNumber(String phoneNumber) { // this.phoneNumber = phoneNumber; // } // // public Long getUserID() { // return userID; // } // // public void setUserID(Long userID) { // this.userID = userID; // } // // public String getCompanyID() { // return companyID; // } // // public void setCompanyID(String companyID) { // this.companyID = companyID; // } // // public String getAccessToken() { // return accessToken; // } // // public void setAccessToken(String accessToken) { // this.accessToken = accessToken; // } // // public Boolean getShowWelcomeInfo() { // return showWelcomeInfo; // } // // public void setShowWelcomeInfo(Boolean showWelcomeInfo) { // this.showWelcomeInfo = showWelcomeInfo; // } // // public String getRocketChatToken() { // return rocketChatToken; // } // // public void setRocketChatToken(String rocketChatToken) { // this.rocketChatToken = rocketChatToken; // } // // public String getRocketChatUsername() { // return rocketChatUsername; // } // // public void setRocketChatUsername(String rocketChatUsername) { // this.rocketChatUsername = rocketChatUsername; // } // // public String getRocketChatUserID() { // return rocketChatUserID; // } // // public void setRocketChatUserID(String rocketChatUserID) { // this.rocketChatUserID = rocketChatUserID; // } // // public String getVat() { // return vat; // } // // public void setVat(String vat) { // this.vat = vat; // } // // @Override // public String toString() { // return "FrontEndUser{" + // "username='" + username + '\'' + // ", firstname='" + firstname + '\'' + // ", lastname='" + lastname + '\'' + // ", email='" + email + '\'' + // ", dateOfBirth=" + dateOfBirth + // ", placeOBirth='" + placeOBirth + '\'' + // ", phoneNumber='" + phoneNumber + '\'' + // ", userID=" + userID + // ", companyID='" + companyID + '\'' + // ", companyName='" + companyName + '\'' + // ", showWelcomeInfo=" + showWelcomeInfo + // ", vat='" + vat + '\'' + // '}'; // } // }
import eu.nimble.core.infrastructure.identity.entity.dto.Credentials; import eu.nimble.core.infrastructure.identity.entity.dto.FrontEndUser;
package eu.nimble.core.infrastructure.identity.system.dto; @SuppressWarnings("unused") public class UserRegistration { private FrontEndUser user = null;
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/dto/Credentials.java // public class Credentials { // // private String username = null; // // private String password = null; // // 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; // } // // @Override // public String toString() { // return "Credentials{" + "username='" + username + '\'' + ", password='*******" + '}'; // } // } // // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/dto/FrontEndUser.java // public class FrontEndUser { // private String username = null; // // private String firstname = null; // // private String lastname = null; // // private String email = null; // // private LocalDate dateOfBirth = null; // // private String placeOBirth = null; // // private String phoneNumber = null; // // private Long userID = null; // // private String companyID = null; // // private Map<NimbleConfigurationProperties.LanguageID, String> companyName = null; // // private String accessToken = null; // // private String rocketChatToken = null; // // private String rocketChatUsername = null; // // private String rocketChatUserID = null; // // private Boolean showWelcomeInfo = false; // // private String vat = null; // // public Map<NimbleConfigurationProperties.LanguageID, String> getCompanyName() { // return companyName; // } // // public void setCompanyName(Map<NimbleConfigurationProperties.LanguageID, String> companyName) { // this.companyName = companyName; // } // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getFirstname() { // return firstname; // } // // public void setFirstname(String firstname) { // this.firstname = firstname; // } // // public String getLastname() { // return lastname; // } // // public void setLastname(String lastname) { // this.lastname = lastname; // } // // public String getEmail() { // return email; // } // // public void setEmail(String email) { // this.email = email; // } // // public LocalDate getDateOfBirth() { // return dateOfBirth; // } // // public void setDateOfBirth(LocalDate dateOfBirth) { // this.dateOfBirth = dateOfBirth; // } // // public String getPlaceOBirth() { // return placeOBirth; // } // // public void setPlaceOBirth(String placeOBirth) { // this.placeOBirth = placeOBirth; // } // // public String getPhoneNumber() { // return phoneNumber; // } // // public void setPhoneNumber(String phoneNumber) { // this.phoneNumber = phoneNumber; // } // // public Long getUserID() { // return userID; // } // // public void setUserID(Long userID) { // this.userID = userID; // } // // public String getCompanyID() { // return companyID; // } // // public void setCompanyID(String companyID) { // this.companyID = companyID; // } // // public String getAccessToken() { // return accessToken; // } // // public void setAccessToken(String accessToken) { // this.accessToken = accessToken; // } // // public Boolean getShowWelcomeInfo() { // return showWelcomeInfo; // } // // public void setShowWelcomeInfo(Boolean showWelcomeInfo) { // this.showWelcomeInfo = showWelcomeInfo; // } // // public String getRocketChatToken() { // return rocketChatToken; // } // // public void setRocketChatToken(String rocketChatToken) { // this.rocketChatToken = rocketChatToken; // } // // public String getRocketChatUsername() { // return rocketChatUsername; // } // // public void setRocketChatUsername(String rocketChatUsername) { // this.rocketChatUsername = rocketChatUsername; // } // // public String getRocketChatUserID() { // return rocketChatUserID; // } // // public void setRocketChatUserID(String rocketChatUserID) { // this.rocketChatUserID = rocketChatUserID; // } // // public String getVat() { // return vat; // } // // public void setVat(String vat) { // this.vat = vat; // } // // @Override // public String toString() { // return "FrontEndUser{" + // "username='" + username + '\'' + // ", firstname='" + firstname + '\'' + // ", lastname='" + lastname + '\'' + // ", email='" + email + '\'' + // ", dateOfBirth=" + dateOfBirth + // ", placeOBirth='" + placeOBirth + '\'' + // ", phoneNumber='" + phoneNumber + '\'' + // ", userID=" + userID + // ", companyID='" + companyID + '\'' + // ", companyName='" + companyName + '\'' + // ", showWelcomeInfo=" + showWelcomeInfo + // ", vat='" + vat + '\'' + // '}'; // } // } // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/system/dto/UserRegistration.java import eu.nimble.core.infrastructure.identity.entity.dto.Credentials; import eu.nimble.core.infrastructure.identity.entity.dto.FrontEndUser; package eu.nimble.core.infrastructure.identity.system.dto; @SuppressWarnings("unused") public class UserRegistration { private FrontEndUser user = null;
private Credentials credentials = null;
nimble-platform/identity-service
identity-service/src/main/java/eu/nimble/core/infrastructure/identity/system/ubl/PaymentMeansController.java
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/repository/PaymentMeansRepository.java // public interface PaymentMeansRepository extends PagingAndSortingRepository<PaymentMeansType, Long> { // // @Modifying // @Transactional // @Query(value = "delete from payment_means_type where payment_means_party_type_hjid = ?1", nativeQuery = true) // void deleteByPartyID(Long partyID); // // }
import eu.nimble.core.infrastructure.identity.repository.PaymentMeansRepository; import eu.nimble.service.model.ubl.commonaggregatecomponents.PaymentMeansType; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*;
package eu.nimble.core.infrastructure.identity.system.ubl; /** * Created by Johannes Innerbichler on 28/06/17. */ @RequestMapping(value = "/payment-means", produces = MediaType.APPLICATION_JSON_VALUE) @Api(basePath = "/payment-means", value = "Payment Means", description = "Operations with Payment Means", produces = "application/json") @RestController public class PaymentMeansController { @Autowired
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/repository/PaymentMeansRepository.java // public interface PaymentMeansRepository extends PagingAndSortingRepository<PaymentMeansType, Long> { // // @Modifying // @Transactional // @Query(value = "delete from payment_means_type where payment_means_party_type_hjid = ?1", nativeQuery = true) // void deleteByPartyID(Long partyID); // // } // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/system/ubl/PaymentMeansController.java import eu.nimble.core.infrastructure.identity.repository.PaymentMeansRepository; import eu.nimble.service.model.ubl.commonaggregatecomponents.PaymentMeansType; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; package eu.nimble.core.infrastructure.identity.system.ubl; /** * Created by Johannes Innerbichler on 28/06/17. */ @RequestMapping(value = "/payment-means", produces = MediaType.APPLICATION_JSON_VALUE) @Api(basePath = "/payment-means", value = "Payment Means", description = "Operations with Payment Means", produces = "application/json") @RestController public class PaymentMeansController { @Autowired
private PaymentMeansRepository paymentMeansRepository;
nimble-platform/identity-service
identity-service/src/main/java/eu/nimble/core/infrastructure/identity/utils/SpringBridge.java
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/clients/IndexingClientController.java // @Service // @PropertySource("classpath:bootstrap.yml") // public class IndexingClientController { // // private IndexingClient nimbleIndexClient; // // private IndexingClient federatedIndexClient; // // private List<IndexingClient> clients; // // @Value("${nimble.indexing.url}") // private String nimbleIndexUrl; // // @Value("${federated-index-enabled}") // private boolean federatedIndexEnabled; // // @Value("${nimble.indexing.federated-index-url}") // private String federatedIndexUrl; // // @Value("${federated-index-platform-name}") // private String federatedIndexPlatformName; // // @Autowired // IndexingClientFallback indexingFallback; // // public String getFederatedIndexPlatformName() { // return federatedIndexPlatformName; // } // // public IndexingClientController() { // // } // // public IndexingClient getNimbleIndexClient() { // if (nimbleIndexClient == null) { // nimbleIndexClient = createIndexingClient(nimbleIndexUrl); // } // return nimbleIndexClient; // } // // // public IndexingClient getFederatedIndexClient() { // if (federatedIndexEnabled && federatedIndexClient == null) { // federatedIndexClient = createIndexingClient(federatedIndexUrl); // } // return federatedIndexClient; // } // // public List<IndexingClient> getClients() { // if (clients == null) { // clients = new ArrayList<IndexingClient>(); // clients.add(getNimbleIndexClient()); // if (federatedIndexEnabled) { // clients.add(getFederatedIndexClient()); // } // } // return clients; // } // // private IndexingClient createIndexingClient(String url) { // return HystrixFeign.builder().contract(new SpringMvcContract()) // .encoder(new JacksonEncoder()) // .decoder(new JacksonDecoder()) // .retryer(new Retryer.Default(1,100,3)) // .target(IndexingClient.class, url, indexingFallback); // } // // }
import eu.nimble.core.infrastructure.identity.clients.IndexingClientController; import org.springframework.beans.BeansException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.stereotype.Component;
package eu.nimble.core.infrastructure.identity.utils; @Component public class SpringBridge implements ApplicationContextAware { private static ApplicationContext applicationContext; @Autowired
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/clients/IndexingClientController.java // @Service // @PropertySource("classpath:bootstrap.yml") // public class IndexingClientController { // // private IndexingClient nimbleIndexClient; // // private IndexingClient federatedIndexClient; // // private List<IndexingClient> clients; // // @Value("${nimble.indexing.url}") // private String nimbleIndexUrl; // // @Value("${federated-index-enabled}") // private boolean federatedIndexEnabled; // // @Value("${nimble.indexing.federated-index-url}") // private String federatedIndexUrl; // // @Value("${federated-index-platform-name}") // private String federatedIndexPlatformName; // // @Autowired // IndexingClientFallback indexingFallback; // // public String getFederatedIndexPlatformName() { // return federatedIndexPlatformName; // } // // public IndexingClientController() { // // } // // public IndexingClient getNimbleIndexClient() { // if (nimbleIndexClient == null) { // nimbleIndexClient = createIndexingClient(nimbleIndexUrl); // } // return nimbleIndexClient; // } // // // public IndexingClient getFederatedIndexClient() { // if (federatedIndexEnabled && federatedIndexClient == null) { // federatedIndexClient = createIndexingClient(federatedIndexUrl); // } // return federatedIndexClient; // } // // public List<IndexingClient> getClients() { // if (clients == null) { // clients = new ArrayList<IndexingClient>(); // clients.add(getNimbleIndexClient()); // if (federatedIndexEnabled) { // clients.add(getFederatedIndexClient()); // } // } // return clients; // } // // private IndexingClient createIndexingClient(String url) { // return HystrixFeign.builder().contract(new SpringMvcContract()) // .encoder(new JacksonEncoder()) // .decoder(new JacksonDecoder()) // .retryer(new Retryer.Default(1,100,3)) // .target(IndexingClient.class, url, indexingFallback); // } // // } // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/utils/SpringBridge.java import eu.nimble.core.infrastructure.identity.clients.IndexingClientController; import org.springframework.beans.BeansException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.stereotype.Component; package eu.nimble.core.infrastructure.identity.utils; @Component public class SpringBridge implements ApplicationContextAware { private static ApplicationContext applicationContext; @Autowired
private IndexingClientController indexingClientController;
nimble-platform/identity-service
identity-service/src/main/java/eu/nimble/core/infrastructure/identity/utils/UblUtils.java
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/config/NimbleConfigurationProperties.java // @Component // @Configuration // @EnableConfigurationProperties // @ConfigurationProperties(prefix = "nimble") // public class NimbleConfigurationProperties { // // private LanguageID defaultLanguageID = LanguageID.ENGLISH; // // public LanguageID getDefaultLanguageID() { // return defaultLanguageID; // } // // public void setDefaultLanguageID(String defaultLanguageID) { // this.defaultLanguageID = LanguageID.valueOf(defaultLanguageID); // } // // public enum LanguageID { // @JsonProperty("en") // ENGLISH("en"), // @JsonProperty("es") // SPANISH("es"), // @JsonProperty("de") // GERMAN("de"), // @JsonProperty("tr") // TURKISH("tr"), // @JsonProperty("sv") // SWEDISH("sv"), // @JsonProperty("it") // ITALIAN("it"); // // private final String id; // // LanguageID(final String id) { // this.id = id; // } // // @Override // public String toString() { // return id; // } // // public static LanguageID fromString(String identifier) { // return Arrays.stream(LanguageID.values()).filter(l -> l.id.equals(identifier)).findFirst().orElse(null); // } // } // }
import com.google.common.collect.Sets; import eu.nimble.core.infrastructure.identity.config.NimbleConfigurationProperties; import eu.nimble.service.model.ubl.commonaggregatecomponents.PartyNameType; import eu.nimble.service.model.ubl.commonaggregatecomponents.PartyType; import eu.nimble.service.model.ubl.commonaggregatecomponents.QualityIndicatorType; import eu.nimble.service.model.ubl.commonbasiccomponents.TextType; import eu.nimble.service.model.ubl.extension.QualityIndicatorParameter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.lang.reflect.Field; import java.util.*; import java.util.stream.Collectors;
package eu.nimble.core.infrastructure.identity.utils; /** * Created by Johannes Innerbichler on 27/06/17. */ @Component public class UblUtils {
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/config/NimbleConfigurationProperties.java // @Component // @Configuration // @EnableConfigurationProperties // @ConfigurationProperties(prefix = "nimble") // public class NimbleConfigurationProperties { // // private LanguageID defaultLanguageID = LanguageID.ENGLISH; // // public LanguageID getDefaultLanguageID() { // return defaultLanguageID; // } // // public void setDefaultLanguageID(String defaultLanguageID) { // this.defaultLanguageID = LanguageID.valueOf(defaultLanguageID); // } // // public enum LanguageID { // @JsonProperty("en") // ENGLISH("en"), // @JsonProperty("es") // SPANISH("es"), // @JsonProperty("de") // GERMAN("de"), // @JsonProperty("tr") // TURKISH("tr"), // @JsonProperty("sv") // SWEDISH("sv"), // @JsonProperty("it") // ITALIAN("it"); // // private final String id; // // LanguageID(final String id) { // this.id = id; // } // // @Override // public String toString() { // return id; // } // // public static LanguageID fromString(String identifier) { // return Arrays.stream(LanguageID.values()).filter(l -> l.id.equals(identifier)).findFirst().orElse(null); // } // } // } // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/utils/UblUtils.java import com.google.common.collect.Sets; import eu.nimble.core.infrastructure.identity.config.NimbleConfigurationProperties; import eu.nimble.service.model.ubl.commonaggregatecomponents.PartyNameType; import eu.nimble.service.model.ubl.commonaggregatecomponents.PartyType; import eu.nimble.service.model.ubl.commonaggregatecomponents.QualityIndicatorType; import eu.nimble.service.model.ubl.commonbasiccomponents.TextType; import eu.nimble.service.model.ubl.extension.QualityIndicatorParameter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.lang.reflect.Field; import java.util.*; import java.util.stream.Collectors; package eu.nimble.core.infrastructure.identity.utils; /** * Created by Johannes Innerbichler on 27/06/17. */ @Component public class UblUtils {
@Autowired NimbleConfigurationProperties nimbleConfiguration;
nimble-platform/identity-service
identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/dto/DeliveryTerms.java
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/config/NimbleConfigurationProperties.java // @Component // @Configuration // @EnableConfigurationProperties // @ConfigurationProperties(prefix = "nimble") // public class NimbleConfigurationProperties { // // private LanguageID defaultLanguageID = LanguageID.ENGLISH; // // public LanguageID getDefaultLanguageID() { // return defaultLanguageID; // } // // public void setDefaultLanguageID(String defaultLanguageID) { // this.defaultLanguageID = LanguageID.valueOf(defaultLanguageID); // } // // public enum LanguageID { // @JsonProperty("en") // ENGLISH("en"), // @JsonProperty("es") // SPANISH("es"), // @JsonProperty("de") // GERMAN("de"), // @JsonProperty("tr") // TURKISH("tr"), // @JsonProperty("sv") // SWEDISH("sv"), // @JsonProperty("it") // ITALIAN("it"); // // private final String id; // // LanguageID(final String id) { // this.id = id; // } // // @Override // public String toString() { // return id; // } // // public static LanguageID fromString(String identifier) { // return Arrays.stream(LanguageID.values()).filter(l -> l.id.equals(identifier)).findFirst().orElse(null); // } // } // }
import com.fasterxml.jackson.annotation.JsonInclude; import eu.nimble.core.infrastructure.identity.config.NimbleConfigurationProperties; import java.util.Map;
package eu.nimble.core.infrastructure.identity.entity.dto; /** * Created by Johannes Innerbichler on 04/07/17. */ @SuppressWarnings("unused") @JsonInclude(JsonInclude.Include.ALWAYS) public class DeliveryTerms {
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/config/NimbleConfigurationProperties.java // @Component // @Configuration // @EnableConfigurationProperties // @ConfigurationProperties(prefix = "nimble") // public class NimbleConfigurationProperties { // // private LanguageID defaultLanguageID = LanguageID.ENGLISH; // // public LanguageID getDefaultLanguageID() { // return defaultLanguageID; // } // // public void setDefaultLanguageID(String defaultLanguageID) { // this.defaultLanguageID = LanguageID.valueOf(defaultLanguageID); // } // // public enum LanguageID { // @JsonProperty("en") // ENGLISH("en"), // @JsonProperty("es") // SPANISH("es"), // @JsonProperty("de") // GERMAN("de"), // @JsonProperty("tr") // TURKISH("tr"), // @JsonProperty("sv") // SWEDISH("sv"), // @JsonProperty("it") // ITALIAN("it"); // // private final String id; // // LanguageID(final String id) { // this.id = id; // } // // @Override // public String toString() { // return id; // } // // public static LanguageID fromString(String identifier) { // return Arrays.stream(LanguageID.values()).filter(l -> l.id.equals(identifier)).findFirst().orElse(null); // } // } // } // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/dto/DeliveryTerms.java import com.fasterxml.jackson.annotation.JsonInclude; import eu.nimble.core.infrastructure.identity.config.NimbleConfigurationProperties; import java.util.Map; package eu.nimble.core.infrastructure.identity.entity.dto; /** * Created by Johannes Innerbichler on 04/07/17. */ @SuppressWarnings("unused") @JsonInclude(JsonInclude.Include.ALWAYS) public class DeliveryTerms {
private Map<NimbleConfigurationProperties.LanguageID, String> specialTerms;
nimble-platform/identity-service
identity-service/src/main/java/eu/nimble/core/infrastructure/identity/messaging/KafkaReceiver.java
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/config/KafkaConfig.java // @Configuration // @EnableKafka // public class KafkaConfig { // // @Value("${spring.kafka.bootstrap-servers}") // private String bootstrapServers; // // @Value("${spring.kafka.properties.sasl.jaas.config}") // private String jaasConfig; // // @Value("${spring.kafka.consumer.group-id}") // private String consumerGroupId; // // @Bean // public Map<String, Object> producerConfigs() { // Map<String, Object> props = new HashMap<>(); // props.put(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); // if (StringUtils.isEmpty(jaasConfig) == false) { // props.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, "SASL_SSL"); // props.put("sasl.mechanism", "PLAIN"); // props.put("sasl.jaas.config", jaasConfig); // } // props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); // props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class); // return props; // } // // @Bean // public ProducerFactory<String, AuthorizedCompanyUpdate> producerFactory() { // return new DefaultKafkaProducerFactory<>(producerConfigs()); // } // // @Bean // public KafkaTemplate<String, AuthorizedCompanyUpdate> kafkaTemplate() { // return new KafkaTemplate<>(producerFactory()); // } // // @Bean // public Map<String, Object> consumerConfigs() { // Map<String, Object> props = new HashMap<>(); // props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); // if (StringUtils.isEmpty(jaasConfig) == false) { // props.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, "SASL_SSL"); // props.put("sasl.mechanism", "PLAIN"); // props.put("sasl.jaas.config", jaasConfig); // } // props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); // props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); // props.put(ConsumerConfig.GROUP_ID_CONFIG, consumerGroupId); // return props; // } // // @Bean // public ConsumerFactory<String, AuthorizedCompanyUpdate> companyUpdateConsumerFactory() { // return new DefaultKafkaConsumerFactory<>(consumerConfigs(), new StringDeserializer(), new JsonDeserializer<>(AuthorizedCompanyUpdate.class)); // } // // @Bean // public KafkaListenerContainerFactory<ConcurrentMessageListenerContainer<String, AuthorizedCompanyUpdate>> companyUpdatesKafkaListenerContainerFactory() { // ConcurrentKafkaListenerContainerFactory<String, AuthorizedCompanyUpdate> factory = new ConcurrentKafkaListenerContainerFactory<>(); // factory.setConsumerFactory(companyUpdateConsumerFactory()); // return factory; // } // // public static class AuthorizedCompanyUpdate { // private String companyId; // private String accessToken; // // public AuthorizedCompanyUpdate() { // } // // public AuthorizedCompanyUpdate(String companyId, String accessToken) { // this.companyId = companyId; // this.accessToken = accessToken; // } // // public String getCompanyId() { // return companyId; // } // // public void setCompanyId(String companyID) { // this.companyId = companyID; // } // // public String getAccessToken() { // return accessToken; // } // // public void setAccessToken(String accessToken) { // this.accessToken = accessToken; // } // } // }
import eu.nimble.core.infrastructure.identity.config.KafkaConfig; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.springframework.kafka.annotation.KafkaListener; import org.springframework.stereotype.Component;
package eu.nimble.core.infrastructure.identity.messaging; /** * Created by Johannes Innerbichler on 27.09.18. */ @Component public class KafkaReceiver { @KafkaListener(topics = "${nimble.kafka.topics.companyUpdates}", containerFactory = "companyUpdatesKafkaListenerContainerFactory")
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/config/KafkaConfig.java // @Configuration // @EnableKafka // public class KafkaConfig { // // @Value("${spring.kafka.bootstrap-servers}") // private String bootstrapServers; // // @Value("${spring.kafka.properties.sasl.jaas.config}") // private String jaasConfig; // // @Value("${spring.kafka.consumer.group-id}") // private String consumerGroupId; // // @Bean // public Map<String, Object> producerConfigs() { // Map<String, Object> props = new HashMap<>(); // props.put(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); // if (StringUtils.isEmpty(jaasConfig) == false) { // props.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, "SASL_SSL"); // props.put("sasl.mechanism", "PLAIN"); // props.put("sasl.jaas.config", jaasConfig); // } // props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); // props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class); // return props; // } // // @Bean // public ProducerFactory<String, AuthorizedCompanyUpdate> producerFactory() { // return new DefaultKafkaProducerFactory<>(producerConfigs()); // } // // @Bean // public KafkaTemplate<String, AuthorizedCompanyUpdate> kafkaTemplate() { // return new KafkaTemplate<>(producerFactory()); // } // // @Bean // public Map<String, Object> consumerConfigs() { // Map<String, Object> props = new HashMap<>(); // props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); // if (StringUtils.isEmpty(jaasConfig) == false) { // props.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, "SASL_SSL"); // props.put("sasl.mechanism", "PLAIN"); // props.put("sasl.jaas.config", jaasConfig); // } // props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); // props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); // props.put(ConsumerConfig.GROUP_ID_CONFIG, consumerGroupId); // return props; // } // // @Bean // public ConsumerFactory<String, AuthorizedCompanyUpdate> companyUpdateConsumerFactory() { // return new DefaultKafkaConsumerFactory<>(consumerConfigs(), new StringDeserializer(), new JsonDeserializer<>(AuthorizedCompanyUpdate.class)); // } // // @Bean // public KafkaListenerContainerFactory<ConcurrentMessageListenerContainer<String, AuthorizedCompanyUpdate>> companyUpdatesKafkaListenerContainerFactory() { // ConcurrentKafkaListenerContainerFactory<String, AuthorizedCompanyUpdate> factory = new ConcurrentKafkaListenerContainerFactory<>(); // factory.setConsumerFactory(companyUpdateConsumerFactory()); // return factory; // } // // public static class AuthorizedCompanyUpdate { // private String companyId; // private String accessToken; // // public AuthorizedCompanyUpdate() { // } // // public AuthorizedCompanyUpdate(String companyId, String accessToken) { // this.companyId = companyId; // this.accessToken = accessToken; // } // // public String getCompanyId() { // return companyId; // } // // public void setCompanyId(String companyID) { // this.companyId = companyID; // } // // public String getAccessToken() { // return accessToken; // } // // public void setAccessToken(String accessToken) { // this.accessToken = accessToken; // } // } // } // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/messaging/KafkaReceiver.java import eu.nimble.core.infrastructure.identity.config.KafkaConfig; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.springframework.kafka.annotation.KafkaListener; import org.springframework.stereotype.Component; package eu.nimble.core.infrastructure.identity.messaging; /** * Created by Johannes Innerbichler on 27.09.18. */ @Component public class KafkaReceiver { @KafkaListener(topics = "${nimble.kafka.topics.companyUpdates}", containerFactory = "companyUpdatesKafkaListenerContainerFactory")
public void receiveCompanyUpdates(ConsumerRecord<String, KafkaConfig.AuthorizedCompanyUpdate> consumerRecord) {
nimble-platform/identity-service
identity-service/src/main/java/eu/nimble/core/infrastructure/identity/repository/UserInvitationRepository.java
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/UaaUser.java // @Entity // public class UaaUser implements Serializable { // // @Id // @Column(nullable = false, unique = true) // private String externalID; // // private String username; // // @OneToOne // private PersonType ublPerson; // // @ColumnDefault("false") // private Boolean showWelcomeInfo = false; // // public UaaUser() { // } // // public UaaUser(String username, PersonType ublPerson, String externalID) { // this.username = username; // this.ublPerson = ublPerson; // this.externalID = externalID; // this.showWelcomeInfo = true; // } // // public String getUsername() { // return username; // } // // public String getExternalID() { // return externalID; // } // // public PersonType getUBLPerson() { // return this.ublPerson; // } // // public Boolean getShowWelcomeInfo() { // return showWelcomeInfo; // } // // public void setShowWelcomeInfo(Boolean showWelcomeInfo) { // this.showWelcomeInfo = showWelcomeInfo; // } // } // // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/UserInvitation.java // @Entity // @Table(uniqueConstraints = { // @UniqueConstraint(columnNames = {"email", "companyId"}) // }) // public class UserInvitation { // // @Id // @JsonIgnore // @GeneratedValue // long id; // // @Email // @NotBlank // @JsonProperty(required = true) // private String email; // // @NotBlank // @JsonProperty(required = true) // private String companyId; // // @Column // @ElementCollection(targetClass = String.class) // private List<String> roleIDs; // // @ManyToOne // @JsonIgnore // private UaaUser sender; // // private Boolean isPending; // // protected UserInvitation() { // // no-args constructor required by JPA spec // // this one is protected since it shouldn't be used directly // } // // public UserInvitation(String email, String companyId, List<String> roleIDs, UaaUser sender) { // this(email, companyId, roleIDs, sender, true); // } // // public UserInvitation(String email, String companyId, List<String> roleIDs, UaaUser sender, Boolean isPending) { // this.email = email; // this.companyId = companyId; // this.sender = sender; // this.roleIDs = roleIDs; // // this.isPending = isPending; // } // // public String getEmail() { // return email; // } // // public void setEmail(String email) { // this.email = email; // } // // public String getCompanyId() { // return companyId; // } // // public void setCompanyId(String companyId) { // this.companyId = companyId; // } // // public List<String> getRoleIDs() { // return roleIDs; // } // // public void setRoleIDs(List<String> roleIDs) { // this.roleIDs = roleIDs; // } // // public UaaUser getSender() { // return sender; // } // // public void setSender(UaaUser sender) { // this.sender = sender; // } // // public Boolean getPending() { // return isPending; // } // // public void setPending(Boolean pending) { // isPending = pending; // } // }
import eu.nimble.core.infrastructure.identity.entity.UaaUser; import eu.nimble.core.infrastructure.identity.entity.UserInvitation; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.transaction.annotation.Transactional; import java.util.List;
package eu.nimble.core.infrastructure.identity.repository; @SuppressWarnings("unused") public interface UserInvitationRepository extends PagingAndSortingRepository<UserInvitation, Long> { Page<UserInvitation> findAll(Pageable pageable); List<UserInvitation> findByEmail(String email); List<UserInvitation> findByCompanyId(String companyId);
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/UaaUser.java // @Entity // public class UaaUser implements Serializable { // // @Id // @Column(nullable = false, unique = true) // private String externalID; // // private String username; // // @OneToOne // private PersonType ublPerson; // // @ColumnDefault("false") // private Boolean showWelcomeInfo = false; // // public UaaUser() { // } // // public UaaUser(String username, PersonType ublPerson, String externalID) { // this.username = username; // this.ublPerson = ublPerson; // this.externalID = externalID; // this.showWelcomeInfo = true; // } // // public String getUsername() { // return username; // } // // public String getExternalID() { // return externalID; // } // // public PersonType getUBLPerson() { // return this.ublPerson; // } // // public Boolean getShowWelcomeInfo() { // return showWelcomeInfo; // } // // public void setShowWelcomeInfo(Boolean showWelcomeInfo) { // this.showWelcomeInfo = showWelcomeInfo; // } // } // // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/UserInvitation.java // @Entity // @Table(uniqueConstraints = { // @UniqueConstraint(columnNames = {"email", "companyId"}) // }) // public class UserInvitation { // // @Id // @JsonIgnore // @GeneratedValue // long id; // // @Email // @NotBlank // @JsonProperty(required = true) // private String email; // // @NotBlank // @JsonProperty(required = true) // private String companyId; // // @Column // @ElementCollection(targetClass = String.class) // private List<String> roleIDs; // // @ManyToOne // @JsonIgnore // private UaaUser sender; // // private Boolean isPending; // // protected UserInvitation() { // // no-args constructor required by JPA spec // // this one is protected since it shouldn't be used directly // } // // public UserInvitation(String email, String companyId, List<String> roleIDs, UaaUser sender) { // this(email, companyId, roleIDs, sender, true); // } // // public UserInvitation(String email, String companyId, List<String> roleIDs, UaaUser sender, Boolean isPending) { // this.email = email; // this.companyId = companyId; // this.sender = sender; // this.roleIDs = roleIDs; // // this.isPending = isPending; // } // // public String getEmail() { // return email; // } // // public void setEmail(String email) { // this.email = email; // } // // public String getCompanyId() { // return companyId; // } // // public void setCompanyId(String companyId) { // this.companyId = companyId; // } // // public List<String> getRoleIDs() { // return roleIDs; // } // // public void setRoleIDs(List<String> roleIDs) { // this.roleIDs = roleIDs; // } // // public UaaUser getSender() { // return sender; // } // // public void setSender(UaaUser sender) { // this.sender = sender; // } // // public Boolean getPending() { // return isPending; // } // // public void setPending(Boolean pending) { // isPending = pending; // } // } // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/repository/UserInvitationRepository.java import eu.nimble.core.infrastructure.identity.entity.UaaUser; import eu.nimble.core.infrastructure.identity.entity.UserInvitation; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.transaction.annotation.Transactional; import java.util.List; package eu.nimble.core.infrastructure.identity.repository; @SuppressWarnings("unused") public interface UserInvitationRepository extends PagingAndSortingRepository<UserInvitation, Long> { Page<UserInvitation> findAll(Pageable pageable); List<UserInvitation> findByEmail(String email); List<UserInvitation> findByCompanyId(String companyId);
List<UserInvitation> findBySender(UaaUser sender);
nimble-platform/identity-service
identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/dto/PaymentMeans.java
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/config/NimbleConfigurationProperties.java // @Component // @Configuration // @EnableConfigurationProperties // @ConfigurationProperties(prefix = "nimble") // public class NimbleConfigurationProperties { // // private LanguageID defaultLanguageID = LanguageID.ENGLISH; // // public LanguageID getDefaultLanguageID() { // return defaultLanguageID; // } // // public void setDefaultLanguageID(String defaultLanguageID) { // this.defaultLanguageID = LanguageID.valueOf(defaultLanguageID); // } // // public enum LanguageID { // @JsonProperty("en") // ENGLISH("en"), // @JsonProperty("es") // SPANISH("es"), // @JsonProperty("de") // GERMAN("de"), // @JsonProperty("tr") // TURKISH("tr"), // @JsonProperty("sv") // SWEDISH("sv"), // @JsonProperty("it") // ITALIAN("it"); // // private final String id; // // LanguageID(final String id) { // this.id = id; // } // // @Override // public String toString() { // return id; // } // // public static LanguageID fromString(String identifier) { // return Arrays.stream(LanguageID.values()).filter(l -> l.id.equals(identifier)).findFirst().orElse(null); // } // } // }
import com.fasterxml.jackson.annotation.JsonInclude; import eu.nimble.core.infrastructure.identity.config.NimbleConfigurationProperties; import java.util.Map;
package eu.nimble.core.infrastructure.identity.entity.dto; /** * Created by Johannes Innerbichler on 06/07/17. */ @SuppressWarnings("unused") @JsonInclude(JsonInclude.Include.ALWAYS) public class PaymentMeans {
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/config/NimbleConfigurationProperties.java // @Component // @Configuration // @EnableConfigurationProperties // @ConfigurationProperties(prefix = "nimble") // public class NimbleConfigurationProperties { // // private LanguageID defaultLanguageID = LanguageID.ENGLISH; // // public LanguageID getDefaultLanguageID() { // return defaultLanguageID; // } // // public void setDefaultLanguageID(String defaultLanguageID) { // this.defaultLanguageID = LanguageID.valueOf(defaultLanguageID); // } // // public enum LanguageID { // @JsonProperty("en") // ENGLISH("en"), // @JsonProperty("es") // SPANISH("es"), // @JsonProperty("de") // GERMAN("de"), // @JsonProperty("tr") // TURKISH("tr"), // @JsonProperty("sv") // SWEDISH("sv"), // @JsonProperty("it") // ITALIAN("it"); // // private final String id; // // LanguageID(final String id) { // this.id = id; // } // // @Override // public String toString() { // return id; // } // // public static LanguageID fromString(String identifier) { // return Arrays.stream(LanguageID.values()).filter(l -> l.id.equals(identifier)).findFirst().orElse(null); // } // } // } // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/dto/PaymentMeans.java import com.fasterxml.jackson.annotation.JsonInclude; import eu.nimble.core.infrastructure.identity.config.NimbleConfigurationProperties; import java.util.Map; package eu.nimble.core.infrastructure.identity.entity.dto; /** * Created by Johannes Innerbichler on 06/07/17. */ @SuppressWarnings("unused") @JsonInclude(JsonInclude.Include.ALWAYS) public class PaymentMeans {
private Map<NimbleConfigurationProperties.LanguageID, String> instructionNote;
nimble-platform/identity-service
identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/dto/CompanyDetails.java
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/config/NimbleConfigurationProperties.java // public enum LanguageID { // @JsonProperty("en") // ENGLISH("en"), // @JsonProperty("es") // SPANISH("es"), // @JsonProperty("de") // GERMAN("de"), // @JsonProperty("tr") // TURKISH("tr"), // @JsonProperty("sv") // SWEDISH("sv"), // @JsonProperty("it") // ITALIAN("it"); // // private final String id; // // LanguageID(final String id) { // this.id = id; // } // // @Override // public String toString() { // return id; // } // // public static LanguageID fromString(String identifier) { // return Arrays.stream(LanguageID.values()).filter(l -> l.id.equals(identifier)).findFirst().orElse(null); // } // }
import eu.nimble.core.infrastructure.identity.config.NimbleConfigurationProperties.LanguageID; import eu.nimble.service.model.ubl.commonaggregatecomponents.PersonType; import io.swagger.annotations.ApiModelProperty; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;
package eu.nimble.core.infrastructure.identity.entity.dto; /** * Created by Johannes Innerbichler on 25.09.18. */ public class CompanyDetails { @ApiModelProperty(value = "Trade name name of the company")
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/config/NimbleConfigurationProperties.java // public enum LanguageID { // @JsonProperty("en") // ENGLISH("en"), // @JsonProperty("es") // SPANISH("es"), // @JsonProperty("de") // GERMAN("de"), // @JsonProperty("tr") // TURKISH("tr"), // @JsonProperty("sv") // SWEDISH("sv"), // @JsonProperty("it") // ITALIAN("it"); // // private final String id; // // LanguageID(final String id) { // this.id = id; // } // // @Override // public String toString() { // return id; // } // // public static LanguageID fromString(String identifier) { // return Arrays.stream(LanguageID.values()).filter(l -> l.id.equals(identifier)).findFirst().orElse(null); // } // } // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/dto/CompanyDetails.java import eu.nimble.core.infrastructure.identity.config.NimbleConfigurationProperties.LanguageID; import eu.nimble.service.model.ubl.commonaggregatecomponents.PersonType; import io.swagger.annotations.ApiModelProperty; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; package eu.nimble.core.infrastructure.identity.entity.dto; /** * Created by Johannes Innerbichler on 25.09.18. */ public class CompanyDetails { @ApiModelProperty(value = "Trade name name of the company")
private Map<LanguageID, String> brandName = null;
nimble-platform/identity-service
identity-service/src/main/java/eu/nimble/core/infrastructure/identity/messaging/KafkaSender.java
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/config/KafkaConfig.java // public static class AuthorizedCompanyUpdate { // private String companyId; // private String accessToken; // // public AuthorizedCompanyUpdate() { // } // // public AuthorizedCompanyUpdate(String companyId, String accessToken) { // this.companyId = companyId; // this.accessToken = accessToken; // } // // public String getCompanyId() { // return companyId; // } // // public void setCompanyId(String companyID) { // this.companyId = companyID; // } // // public String getAccessToken() { // return accessToken; // } // // public void setAccessToken(String accessToken) { // this.accessToken = accessToken; // } // }
import eu.nimble.core.infrastructure.identity.config.KafkaConfig.AuthorizedCompanyUpdate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.kafka.core.KafkaTemplate; import org.springframework.stereotype.Component;
package eu.nimble.core.infrastructure.identity.messaging; /** * Created by Johannes Innerbichler on 27.09.18. */ @Component public class KafkaSender { @Value("${nimble.kafka.topics.companyUpdates}") private String companyUpdatesTopic; @Value("${nimble.kafka.topics.ratingsUpdates}") private String ratingsUpdatesTopic; @Autowired
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/config/KafkaConfig.java // public static class AuthorizedCompanyUpdate { // private String companyId; // private String accessToken; // // public AuthorizedCompanyUpdate() { // } // // public AuthorizedCompanyUpdate(String companyId, String accessToken) { // this.companyId = companyId; // this.accessToken = accessToken; // } // // public String getCompanyId() { // return companyId; // } // // public void setCompanyId(String companyID) { // this.companyId = companyID; // } // // public String getAccessToken() { // return accessToken; // } // // public void setAccessToken(String accessToken) { // this.accessToken = accessToken; // } // } // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/messaging/KafkaSender.java import eu.nimble.core.infrastructure.identity.config.KafkaConfig.AuthorizedCompanyUpdate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.kafka.core.KafkaTemplate; import org.springframework.stereotype.Component; package eu.nimble.core.infrastructure.identity.messaging; /** * Created by Johannes Innerbichler on 27.09.18. */ @Component public class KafkaSender { @Value("${nimble.kafka.topics.companyUpdates}") private String companyUpdatesTopic; @Value("${nimble.kafka.topics.ratingsUpdates}") private String ratingsUpdatesTopic; @Autowired
private KafkaTemplate<String, AuthorizedCompanyUpdate> kafkaTemplate;
nimble-platform/identity-service
identity-service/src/main/java/eu/nimble/core/infrastructure/identity/service/CertificateService.java
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/repository/CertificateRepository.java // public interface CertificateRepository extends PagingAndSortingRepository<CertificateType, Long> { // }
import eu.nimble.core.infrastructure.identity.repository.CertificateRepository; import eu.nimble.service.model.ubl.commonaggregatecomponents.CertificateType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional;
package eu.nimble.core.infrastructure.identity.service; /** * Created by Johannes Innerbichler on 08.08.18. */ @Service public class CertificateService { @Autowired
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/repository/CertificateRepository.java // public interface CertificateRepository extends PagingAndSortingRepository<CertificateType, Long> { // } // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/service/CertificateService.java import eu.nimble.core.infrastructure.identity.repository.CertificateRepository; import eu.nimble.service.model.ubl.commonaggregatecomponents.CertificateType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; package eu.nimble.core.infrastructure.identity.service; /** * Created by Johannes Innerbichler on 08.08.18. */ @Service public class CertificateService { @Autowired
private CertificateRepository certificateRepository;
nimble-platform/identity-service
identity-service/src/main/java/eu/nimble/core/infrastructure/identity/system/ubl/DeliveryTermsController.java
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/repository/DeliveryTermsRepository.java // public interface DeliveryTermsRepository extends PagingAndSortingRepository<DeliveryTermsType, Long> { // // @Modifying // @Transactional // @Query(value = "delete from delivery_terms_type where delivery_terms_party_type_hj_0 = ?1", nativeQuery = true) // void deleteByPartyID(Long partyID); // }
import eu.nimble.core.infrastructure.identity.repository.DeliveryTermsRepository; import eu.nimble.service.model.ubl.commonaggregatecomponents.DeliveryTermsType; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*;
package eu.nimble.core.infrastructure.identity.system.ubl; @RestController @RequestMapping("/delivery-terms") public class DeliveryTermsController { @Autowired
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/repository/DeliveryTermsRepository.java // public interface DeliveryTermsRepository extends PagingAndSortingRepository<DeliveryTermsType, Long> { // // @Modifying // @Transactional // @Query(value = "delete from delivery_terms_type where delivery_terms_party_type_hj_0 = ?1", nativeQuery = true) // void deleteByPartyID(Long partyID); // } // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/system/ubl/DeliveryTermsController.java import eu.nimble.core.infrastructure.identity.repository.DeliveryTermsRepository; import eu.nimble.service.model.ubl.commonaggregatecomponents.DeliveryTermsType; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; package eu.nimble.core.infrastructure.identity.system.ubl; @RestController @RequestMapping("/delivery-terms") public class DeliveryTermsController { @Autowired
private DeliveryTermsRepository deliveryRepo;
nimble-platform/identity-service
identity-service/src/main/java/eu/nimble/core/infrastructure/identity/service/FederationService.java
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/constants/GlobalConstants.java // public class GlobalConstants { // // public static final String PARTY_NAME_STRING = "partyName"; // public static final String ASCENDING_STRING = "asc"; // public static final String DESCENDING_STRING = "desc"; // public static final String JWT_SUBJECT_ATTRIBUTE_STRING = "sub"; // public static final String JWT_EXPIRY_ATTRIBUTE_STRING = "exp"; // public static final String JWT_TYPE_ATTRIBUTE_STRING = "type"; // public static final String EMAIL_STRING = "email"; // public static final String USER_NAME_STRING = "username"; // // // OAUTH Related Constants // public static final String CLIENT_CREDENTIALS_FLOW = "client_credentials"; // public static final String AUTHORIZATION_CODE_FLOW = "authorization_code"; // public static final String REFRESH_TOKEN_FLOW = "refresh_token"; // // } // // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/system/dto/oauth/Token.java // public class Token { // // private String access_token = null; // private String expires_in = null; // private String refresh_expires_in = null; // private String refresh_token = null; // private String token_type = null; // private String id_token = null; // private String session_state = null; // private String scope = null; // private String code = null; // private String redirect_URL = null; // // public String getAccess_token() { // return access_token; // } // // public void setAccess_token(String access_token) { // this.access_token = access_token; // } // // public String getExpires_in() { // return expires_in; // } // // public void setExpires_in(String expires_in) { // this.expires_in = expires_in; // } // // public String getRefresh_expires_in() { // return refresh_expires_in; // } // // public void setRefresh_expires_in(String refresh_expires_in) { // this.refresh_expires_in = refresh_expires_in; // } // // public String getRefresh_token() { // return refresh_token; // } // // public void setRefresh_token(String refresh_token) { // this.refresh_token = refresh_token; // } // // public String getToken_type() { // return token_type; // } // // public void setToken_type(String token_type) { // this.token_type = token_type; // } // // public String getId_token() { // return id_token; // } // // public void setId_token(String id_token) { // this.id_token = id_token; // } // // public String getSession_state() { // return session_state; // } // // public void setSession_state(String session_state) { // this.session_state = session_state; // } // // public String getScope() { // return scope; // } // // public void setScope(String scope) { // this.scope = scope; // } // // public String getCode() { // return code; // } // // public void setCode(String code) { // this.code = code; // } // // public String getRedirect_URL() { // return redirect_URL; // } // // public void setRedirect_URL(String redirect_URL) { // this.redirect_URL = redirect_URL; // } // }
import com.auth0.jwt.JWT; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; import eu.nimble.core.infrastructure.identity.constants.GlobalConstants; import eu.nimble.core.infrastructure.identity.system.dto.oauth.Token; import org.keycloak.representations.idm.UserRepresentation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.RestTemplate; import java.util.List;
package eu.nimble.core.infrastructure.identity.service; @Service public class FederationService { private final Logger logger = LoggerFactory.getLogger(FederationService.class); @Value("${nimble.oauth.federationClient.accessTokenUri}") private String accessTokenUri; @Value("${nimble.oauth.federationClient.clientId}") private String clientId; @Value("${nimble.oauth.federationClient.clientSecret}") private String clientSecret; @Value("${nimble.oauth.federationClient.redirectUri}") private String redirectUri; @Value("${nimble.oauth.eFactoryClient.clientId}") private String eFactoryClientId; @Value("${nimble.oauth.eFactoryClient.clientSecret}") private String eFactoryClientSecret; @Value("${nimble.oauth.eFactoryClient.accessTokenUri}") private String eFactoryAccessTokenUri; @Value("${nimble.oauth.eFactoryClient.userDetailsUri}") private String eFactoryUserDetailsUri;
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/constants/GlobalConstants.java // public class GlobalConstants { // // public static final String PARTY_NAME_STRING = "partyName"; // public static final String ASCENDING_STRING = "asc"; // public static final String DESCENDING_STRING = "desc"; // public static final String JWT_SUBJECT_ATTRIBUTE_STRING = "sub"; // public static final String JWT_EXPIRY_ATTRIBUTE_STRING = "exp"; // public static final String JWT_TYPE_ATTRIBUTE_STRING = "type"; // public static final String EMAIL_STRING = "email"; // public static final String USER_NAME_STRING = "username"; // // // OAUTH Related Constants // public static final String CLIENT_CREDENTIALS_FLOW = "client_credentials"; // public static final String AUTHORIZATION_CODE_FLOW = "authorization_code"; // public static final String REFRESH_TOKEN_FLOW = "refresh_token"; // // } // // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/system/dto/oauth/Token.java // public class Token { // // private String access_token = null; // private String expires_in = null; // private String refresh_expires_in = null; // private String refresh_token = null; // private String token_type = null; // private String id_token = null; // private String session_state = null; // private String scope = null; // private String code = null; // private String redirect_URL = null; // // public String getAccess_token() { // return access_token; // } // // public void setAccess_token(String access_token) { // this.access_token = access_token; // } // // public String getExpires_in() { // return expires_in; // } // // public void setExpires_in(String expires_in) { // this.expires_in = expires_in; // } // // public String getRefresh_expires_in() { // return refresh_expires_in; // } // // public void setRefresh_expires_in(String refresh_expires_in) { // this.refresh_expires_in = refresh_expires_in; // } // // public String getRefresh_token() { // return refresh_token; // } // // public void setRefresh_token(String refresh_token) { // this.refresh_token = refresh_token; // } // // public String getToken_type() { // return token_type; // } // // public void setToken_type(String token_type) { // this.token_type = token_type; // } // // public String getId_token() { // return id_token; // } // // public void setId_token(String id_token) { // this.id_token = id_token; // } // // public String getSession_state() { // return session_state; // } // // public void setSession_state(String session_state) { // this.session_state = session_state; // } // // public String getScope() { // return scope; // } // // public void setScope(String scope) { // this.scope = scope; // } // // public String getCode() { // return code; // } // // public void setCode(String code) { // this.code = code; // } // // public String getRedirect_URL() { // return redirect_URL; // } // // public void setRedirect_URL(String redirect_URL) { // this.redirect_URL = redirect_URL; // } // } // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/service/FederationService.java import com.auth0.jwt.JWT; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; import eu.nimble.core.infrastructure.identity.constants.GlobalConstants; import eu.nimble.core.infrastructure.identity.system.dto.oauth.Token; import org.keycloak.representations.idm.UserRepresentation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.RestTemplate; import java.util.List; package eu.nimble.core.infrastructure.identity.service; @Service public class FederationService { private final Logger logger = LoggerFactory.getLogger(FederationService.class); @Value("${nimble.oauth.federationClient.accessTokenUri}") private String accessTokenUri; @Value("${nimble.oauth.federationClient.clientId}") private String clientId; @Value("${nimble.oauth.federationClient.clientSecret}") private String clientSecret; @Value("${nimble.oauth.federationClient.redirectUri}") private String redirectUri; @Value("${nimble.oauth.eFactoryClient.clientId}") private String eFactoryClientId; @Value("${nimble.oauth.eFactoryClient.clientSecret}") private String eFactoryClientSecret; @Value("${nimble.oauth.eFactoryClient.accessTokenUri}") private String eFactoryAccessTokenUri; @Value("${nimble.oauth.eFactoryClient.userDetailsUri}") private String eFactoryUserDetailsUri;
public Token exchangeToken(String trustedToken) {
nimble-platform/identity-service
identity-service/src/main/java/eu/nimble/core/infrastructure/identity/service/FederationService.java
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/constants/GlobalConstants.java // public class GlobalConstants { // // public static final String PARTY_NAME_STRING = "partyName"; // public static final String ASCENDING_STRING = "asc"; // public static final String DESCENDING_STRING = "desc"; // public static final String JWT_SUBJECT_ATTRIBUTE_STRING = "sub"; // public static final String JWT_EXPIRY_ATTRIBUTE_STRING = "exp"; // public static final String JWT_TYPE_ATTRIBUTE_STRING = "type"; // public static final String EMAIL_STRING = "email"; // public static final String USER_NAME_STRING = "username"; // // // OAUTH Related Constants // public static final String CLIENT_CREDENTIALS_FLOW = "client_credentials"; // public static final String AUTHORIZATION_CODE_FLOW = "authorization_code"; // public static final String REFRESH_TOKEN_FLOW = "refresh_token"; // // } // // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/system/dto/oauth/Token.java // public class Token { // // private String access_token = null; // private String expires_in = null; // private String refresh_expires_in = null; // private String refresh_token = null; // private String token_type = null; // private String id_token = null; // private String session_state = null; // private String scope = null; // private String code = null; // private String redirect_URL = null; // // public String getAccess_token() { // return access_token; // } // // public void setAccess_token(String access_token) { // this.access_token = access_token; // } // // public String getExpires_in() { // return expires_in; // } // // public void setExpires_in(String expires_in) { // this.expires_in = expires_in; // } // // public String getRefresh_expires_in() { // return refresh_expires_in; // } // // public void setRefresh_expires_in(String refresh_expires_in) { // this.refresh_expires_in = refresh_expires_in; // } // // public String getRefresh_token() { // return refresh_token; // } // // public void setRefresh_token(String refresh_token) { // this.refresh_token = refresh_token; // } // // public String getToken_type() { // return token_type; // } // // public void setToken_type(String token_type) { // this.token_type = token_type; // } // // public String getId_token() { // return id_token; // } // // public void setId_token(String id_token) { // this.id_token = id_token; // } // // public String getSession_state() { // return session_state; // } // // public void setSession_state(String session_state) { // this.session_state = session_state; // } // // public String getScope() { // return scope; // } // // public void setScope(String scope) { // this.scope = scope; // } // // public String getCode() { // return code; // } // // public void setCode(String code) { // this.code = code; // } // // public String getRedirect_URL() { // return redirect_URL; // } // // public void setRedirect_URL(String redirect_URL) { // this.redirect_URL = redirect_URL; // } // }
import com.auth0.jwt.JWT; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; import eu.nimble.core.infrastructure.identity.constants.GlobalConstants; import eu.nimble.core.infrastructure.identity.system.dto.oauth.Token; import org.keycloak.representations.idm.UserRepresentation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.RestTemplate; import java.util.List;
package eu.nimble.core.infrastructure.identity.service; @Service public class FederationService { private final Logger logger = LoggerFactory.getLogger(FederationService.class); @Value("${nimble.oauth.federationClient.accessTokenUri}") private String accessTokenUri; @Value("${nimble.oauth.federationClient.clientId}") private String clientId; @Value("${nimble.oauth.federationClient.clientSecret}") private String clientSecret; @Value("${nimble.oauth.federationClient.redirectUri}") private String redirectUri; @Value("${nimble.oauth.eFactoryClient.clientId}") private String eFactoryClientId; @Value("${nimble.oauth.eFactoryClient.clientSecret}") private String eFactoryClientSecret; @Value("${nimble.oauth.eFactoryClient.accessTokenUri}") private String eFactoryAccessTokenUri; @Value("${nimble.oauth.eFactoryClient.userDetailsUri}") private String eFactoryUserDetailsUri; public Token exchangeToken(String trustedToken) { // TODO verify the signature
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/constants/GlobalConstants.java // public class GlobalConstants { // // public static final String PARTY_NAME_STRING = "partyName"; // public static final String ASCENDING_STRING = "asc"; // public static final String DESCENDING_STRING = "desc"; // public static final String JWT_SUBJECT_ATTRIBUTE_STRING = "sub"; // public static final String JWT_EXPIRY_ATTRIBUTE_STRING = "exp"; // public static final String JWT_TYPE_ATTRIBUTE_STRING = "type"; // public static final String EMAIL_STRING = "email"; // public static final String USER_NAME_STRING = "username"; // // // OAUTH Related Constants // public static final String CLIENT_CREDENTIALS_FLOW = "client_credentials"; // public static final String AUTHORIZATION_CODE_FLOW = "authorization_code"; // public static final String REFRESH_TOKEN_FLOW = "refresh_token"; // // } // // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/system/dto/oauth/Token.java // public class Token { // // private String access_token = null; // private String expires_in = null; // private String refresh_expires_in = null; // private String refresh_token = null; // private String token_type = null; // private String id_token = null; // private String session_state = null; // private String scope = null; // private String code = null; // private String redirect_URL = null; // // public String getAccess_token() { // return access_token; // } // // public void setAccess_token(String access_token) { // this.access_token = access_token; // } // // public String getExpires_in() { // return expires_in; // } // // public void setExpires_in(String expires_in) { // this.expires_in = expires_in; // } // // public String getRefresh_expires_in() { // return refresh_expires_in; // } // // public void setRefresh_expires_in(String refresh_expires_in) { // this.refresh_expires_in = refresh_expires_in; // } // // public String getRefresh_token() { // return refresh_token; // } // // public void setRefresh_token(String refresh_token) { // this.refresh_token = refresh_token; // } // // public String getToken_type() { // return token_type; // } // // public void setToken_type(String token_type) { // this.token_type = token_type; // } // // public String getId_token() { // return id_token; // } // // public void setId_token(String id_token) { // this.id_token = id_token; // } // // public String getSession_state() { // return session_state; // } // // public void setSession_state(String session_state) { // this.session_state = session_state; // } // // public String getScope() { // return scope; // } // // public void setScope(String scope) { // this.scope = scope; // } // // public String getCode() { // return code; // } // // public void setCode(String code) { // this.code = code; // } // // public String getRedirect_URL() { // return redirect_URL; // } // // public void setRedirect_URL(String redirect_URL) { // this.redirect_URL = redirect_URL; // } // } // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/service/FederationService.java import com.auth0.jwt.JWT; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; import eu.nimble.core.infrastructure.identity.constants.GlobalConstants; import eu.nimble.core.infrastructure.identity.system.dto.oauth.Token; import org.keycloak.representations.idm.UserRepresentation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.RestTemplate; import java.util.List; package eu.nimble.core.infrastructure.identity.service; @Service public class FederationService { private final Logger logger = LoggerFactory.getLogger(FederationService.class); @Value("${nimble.oauth.federationClient.accessTokenUri}") private String accessTokenUri; @Value("${nimble.oauth.federationClient.clientId}") private String clientId; @Value("${nimble.oauth.federationClient.clientSecret}") private String clientSecret; @Value("${nimble.oauth.federationClient.redirectUri}") private String redirectUri; @Value("${nimble.oauth.eFactoryClient.clientId}") private String eFactoryClientId; @Value("${nimble.oauth.eFactoryClient.clientSecret}") private String eFactoryClientSecret; @Value("${nimble.oauth.eFactoryClient.accessTokenUri}") private String eFactoryAccessTokenUri; @Value("${nimble.oauth.eFactoryClient.userDetailsUri}") private String eFactoryUserDetailsUri; public Token exchangeToken(String trustedToken) { // TODO verify the signature
long exp = JWT.decode(trustedToken).getClaim(GlobalConstants.JWT_EXPIRY_ATTRIBUTE_STRING).asLong();
nimble-platform/identity-service
identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/dto/CompanyDescription.java
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/config/NimbleConfigurationProperties.java // @Component // @Configuration // @EnableConfigurationProperties // @ConfigurationProperties(prefix = "nimble") // public class NimbleConfigurationProperties { // // private LanguageID defaultLanguageID = LanguageID.ENGLISH; // // public LanguageID getDefaultLanguageID() { // return defaultLanguageID; // } // // public void setDefaultLanguageID(String defaultLanguageID) { // this.defaultLanguageID = LanguageID.valueOf(defaultLanguageID); // } // // public enum LanguageID { // @JsonProperty("en") // ENGLISH("en"), // @JsonProperty("es") // SPANISH("es"), // @JsonProperty("de") // GERMAN("de"), // @JsonProperty("tr") // TURKISH("tr"), // @JsonProperty("sv") // SWEDISH("sv"), // @JsonProperty("it") // ITALIAN("it"); // // private final String id; // // LanguageID(final String id) { // this.id = id; // } // // @Override // public String toString() { // return id; // } // // public static LanguageID fromString(String identifier) { // return Arrays.stream(LanguageID.values()).filter(l -> l.id.equals(identifier)).findFirst().orElse(null); // } // } // }
import eu.nimble.core.infrastructure.identity.config.NimbleConfigurationProperties; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;
package eu.nimble.core.infrastructure.identity.entity.dto; /** * Created by Johannes Innerbichler on 25.09.18. */ @ApiModel(value = "CompanyDescription") public class CompanyDescription { @ApiModelProperty(value = "Statement of the company")
// Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/config/NimbleConfigurationProperties.java // @Component // @Configuration // @EnableConfigurationProperties // @ConfigurationProperties(prefix = "nimble") // public class NimbleConfigurationProperties { // // private LanguageID defaultLanguageID = LanguageID.ENGLISH; // // public LanguageID getDefaultLanguageID() { // return defaultLanguageID; // } // // public void setDefaultLanguageID(String defaultLanguageID) { // this.defaultLanguageID = LanguageID.valueOf(defaultLanguageID); // } // // public enum LanguageID { // @JsonProperty("en") // ENGLISH("en"), // @JsonProperty("es") // SPANISH("es"), // @JsonProperty("de") // GERMAN("de"), // @JsonProperty("tr") // TURKISH("tr"), // @JsonProperty("sv") // SWEDISH("sv"), // @JsonProperty("it") // ITALIAN("it"); // // private final String id; // // LanguageID(final String id) { // this.id = id; // } // // @Override // public String toString() { // return id; // } // // public static LanguageID fromString(String identifier) { // return Arrays.stream(LanguageID.values()).filter(l -> l.id.equals(identifier)).findFirst().orElse(null); // } // } // } // Path: identity-service/src/main/java/eu/nimble/core/infrastructure/identity/entity/dto/CompanyDescription.java import eu.nimble.core.infrastructure.identity.config.NimbleConfigurationProperties; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; package eu.nimble.core.infrastructure.identity.entity.dto; /** * Created by Johannes Innerbichler on 25.09.18. */ @ApiModel(value = "CompanyDescription") public class CompanyDescription { @ApiModelProperty(value = "Statement of the company")
private Map<NimbleConfigurationProperties.LanguageID, String> companyStatement = new HashMap<>();
idega/is.idega.idegaweb.egov.company
src/java/is/idega/idegaweb/egov/company/presentation/handler/CompanyApplicationTypeSelector.java
// Path: src/java/is/idega/idegaweb/egov/company/EgovCompanyConstants.java // public class EgovCompanyConstants { // // private EgovCompanyConstants() {} // // public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.company"; // // public static final String COMPANY_SUPER_ADMIN_ROLE = "company_super_admin"; // public static final String COMPANY_ADMIN_ROLE = "company_admin"; // public static final String COMPANY_EMPLOYEE_ROLE = "company_staff"; // // public static final List<String> ALL_COMPANY_ROLES = Collections.unmodifiableList(Arrays.asList( // StandardRoles.ROLE_KEY_COMPANY, // COMPANY_SUPER_ADMIN_ROLE, // COMPANY_ADMIN_ROLE, // COMPANY_EMPLOYEE_ROLE // )); // // public static final String GROUP_TYPE_COMPANY_ADMINS = "iw_company_admins_group"; // public static final String GROUP_TYPE_COMPANY_STAFF = "iw_company_staff_group"; // public static final List<String> ALL_COMPANY_TYPES = Collections.unmodifiableList(Arrays.asList( // CompanyConstants.GROUP_TYPE_COMPANY, // GROUP_TYPE_COMPANY_ADMINS, // GROUP_TYPE_COMPANY_STAFF // )); // // public static final String CASE_CODE_KEY = "COMPORT"; // // public static final String CONTENT_CODE_REQUEST_INFORMATION = "prm_company_code_request_information"; // // public static final Integer APPLICATION_TYPE_APPROVED = 0; // public static final Integer APPLICATION_TYPE_REJECTED = 1; // public static final Integer APPLICATION_TYPE_UNHANDLED = 2; // // public static final String USER_LOGIN_METADATA = "userLoginEnabledMetaDataForCompanyPortal"; // // public static final String COMPANY_PORTAL_ROOT_GROUP = "Company Portal"; // public static final String COMPANY_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Admins"; // public static final String COMPANY_SUPER_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Super Admins"; // // public static final String COMPANY_PORTAL_HOME_PAGE_APPLICATION_PROPERTY = "companyPortalHomePage"; // public static final String COMPANY_STAFF_HOME_PAGE_APPLICATION_PROPERTY = "companyStaffHomePage"; // // public static final String COMPANY_PORTAL_CURRENT_COMPANY_ATTRIBUTE = "companyPortalCurrentCompanyId"; // // public static final String COMPANY_PERSONAL_ID_METADATA = "COMPANY_PERSONAL_ID"; // }
import is.idega.idegaweb.egov.company.EgovCompanyConstants; import java.util.List; import com.idega.core.builder.presentation.ICPropertyHandler; import com.idega.idegaweb.IWResourceBundle; import com.idega.presentation.IWContext; import com.idega.presentation.PresentationObject; import com.idega.presentation.ui.DropdownMenu; import com.idega.presentation.ui.SelectOption; import com.idega.util.StringUtil;
package is.idega.idegaweb.egov.company.presentation.handler; public class CompanyApplicationTypeSelector implements ICPropertyHandler { public List<?> getDefaultHandlerTypes() { return null; } public PresentationObject getHandlerObject(String name, String stringValue, IWContext iwc, boolean oldGenerationHandler, String instanceId, String method) {
// Path: src/java/is/idega/idegaweb/egov/company/EgovCompanyConstants.java // public class EgovCompanyConstants { // // private EgovCompanyConstants() {} // // public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.company"; // // public static final String COMPANY_SUPER_ADMIN_ROLE = "company_super_admin"; // public static final String COMPANY_ADMIN_ROLE = "company_admin"; // public static final String COMPANY_EMPLOYEE_ROLE = "company_staff"; // // public static final List<String> ALL_COMPANY_ROLES = Collections.unmodifiableList(Arrays.asList( // StandardRoles.ROLE_KEY_COMPANY, // COMPANY_SUPER_ADMIN_ROLE, // COMPANY_ADMIN_ROLE, // COMPANY_EMPLOYEE_ROLE // )); // // public static final String GROUP_TYPE_COMPANY_ADMINS = "iw_company_admins_group"; // public static final String GROUP_TYPE_COMPANY_STAFF = "iw_company_staff_group"; // public static final List<String> ALL_COMPANY_TYPES = Collections.unmodifiableList(Arrays.asList( // CompanyConstants.GROUP_TYPE_COMPANY, // GROUP_TYPE_COMPANY_ADMINS, // GROUP_TYPE_COMPANY_STAFF // )); // // public static final String CASE_CODE_KEY = "COMPORT"; // // public static final String CONTENT_CODE_REQUEST_INFORMATION = "prm_company_code_request_information"; // // public static final Integer APPLICATION_TYPE_APPROVED = 0; // public static final Integer APPLICATION_TYPE_REJECTED = 1; // public static final Integer APPLICATION_TYPE_UNHANDLED = 2; // // public static final String USER_LOGIN_METADATA = "userLoginEnabledMetaDataForCompanyPortal"; // // public static final String COMPANY_PORTAL_ROOT_GROUP = "Company Portal"; // public static final String COMPANY_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Admins"; // public static final String COMPANY_SUPER_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Super Admins"; // // public static final String COMPANY_PORTAL_HOME_PAGE_APPLICATION_PROPERTY = "companyPortalHomePage"; // public static final String COMPANY_STAFF_HOME_PAGE_APPLICATION_PROPERTY = "companyStaffHomePage"; // // public static final String COMPANY_PORTAL_CURRENT_COMPANY_ATTRIBUTE = "companyPortalCurrentCompanyId"; // // public static final String COMPANY_PERSONAL_ID_METADATA = "COMPANY_PERSONAL_ID"; // } // Path: src/java/is/idega/idegaweb/egov/company/presentation/handler/CompanyApplicationTypeSelector.java import is.idega.idegaweb.egov.company.EgovCompanyConstants; import java.util.List; import com.idega.core.builder.presentation.ICPropertyHandler; import com.idega.idegaweb.IWResourceBundle; import com.idega.presentation.IWContext; import com.idega.presentation.PresentationObject; import com.idega.presentation.ui.DropdownMenu; import com.idega.presentation.ui.SelectOption; import com.idega.util.StringUtil; package is.idega.idegaweb.egov.company.presentation.handler; public class CompanyApplicationTypeSelector implements ICPropertyHandler { public List<?> getDefaultHandlerTypes() { return null; } public PresentationObject getHandlerObject(String name, String stringValue, IWContext iwc, boolean oldGenerationHandler, String instanceId, String method) {
IWResourceBundle iwrb = iwc.getIWMainApplication().getBundle(EgovCompanyConstants.IW_BUNDLE_IDENTIFIER).getResourceBundle(iwc);
idega/is.idega.idegaweb.egov.company
src/java/is/idega/idegaweb/egov/company/IWBundleStarter.java
// Path: src/java/is/idega/idegaweb/egov/company/business/CompanyPortalBusiness.java // public interface CompanyPortalBusiness { // // public String SPRING_BEAN_IDENTIFIER = "companyPortalBusiness"; // // public Group getCompanyPortalRootGroup(IWApplicationContext iwac) throws RemoteException; // // public Group getAllCompaniesAdminsGroup(IWApplicationContext iwac); // // public Group getCompanyAdminsGroup(IWApplicationContext iwac, String companyName, String personalID); // public Group getCompanyStaffGroup(IWApplicationContext iwac, String companyName, String personalID); // // public Group getCompanySuperAdminsGroup(IWApplicationContext iwac); // // public Group getGroupByName(Group parentGroup, String name, String personalID); // public Group getChildGroupByType(Group group, String type); // public List<Group> getAllChildGroupsByType(Group group, String type); // // public Group createCompanyGroup(IWApplicationContext iwac, String companyName, String personalID); // public Group createCompanyGroup(IWApplicationContext iwac, Group companyPortal, String companyName, String personalID); // // public Group getCompanyGroup(IWApplicationContext iwac, String companyName, String personalID); // // public List<Group> getAllUserCompanies(User user); // public Company getCompanyForUser(User user); // // public Group getCompanyGroupByUser(User user); // public Group getCompanyStaffGroupByUser(User user); // public Group getCompanyAdminsGroupByUser(User user); // // public void setHomePage(IWApplicationContext iwac, Group group, String homePageKey); // public void setHomePageToGroups(IWApplicationContext iwac); // // public List<User> getAllCompanyUsers(Group company); // public List<User> getAllCompanyUsers(CompanyApplication application); // // public List<Group> getAllCompanyGroups(Group company); // // public boolean isMemberOfCompany(IWApplicationContext iwac, Group group, User user); // // public Company getCompanyByPersonalIdOrUserId(String personalId); // }
import is.idega.idegaweb.egov.EGOVConstants; import is.idega.idegaweb.egov.company.business.CompanyPortalBusiness; import java.rmi.RemoteException; import java.util.Collection; import javax.ejb.CreateException; import javax.ejb.FinderException; import com.idega.builder.business.BuilderLogic; import com.idega.business.IBOLookup; import com.idega.business.IBOLookupException; import com.idega.core.accesscontrol.business.AccessController; import com.idega.core.accesscontrol.business.StandardRoles; import com.idega.idegaweb.IWApplicationContext; import com.idega.idegaweb.IWBundle; import com.idega.idegaweb.IWBundleStartable; import com.idega.servlet.filter.IWBundleResourceFilter; import com.idega.user.business.GroupBusiness; import com.idega.user.data.Group; import com.idega.user.data.GroupType; import com.idega.util.ListUtil; import com.idega.util.expression.ELUtil;
Group companyPortal = null; try { companyPortal = createRootGroup(iwac, groupBusiness); } catch(RemoteException e) { e.printStackTrace(); } if (companyPortal == null) { return; } try { createAdminsGroup(iwac, groupBusiness, companyPortal); } catch (RemoteException e) { e.printStackTrace(); } try { createSuperAdminsGroup(iwac, groupBusiness, companyPortal); } catch (RemoteException e) { e.printStackTrace(); } setRoleToCommuneAcceptedCitizensGroup(iwac, groupBusiness); setHomePageToGroups(iwac); IWBundleResourceFilter.copyAllFilesFromJarDirectory(starterBundle.getApplication(), starterBundle, "/resources/"); } private void setHomePageToGroups(IWApplicationContext iwac) {
// Path: src/java/is/idega/idegaweb/egov/company/business/CompanyPortalBusiness.java // public interface CompanyPortalBusiness { // // public String SPRING_BEAN_IDENTIFIER = "companyPortalBusiness"; // // public Group getCompanyPortalRootGroup(IWApplicationContext iwac) throws RemoteException; // // public Group getAllCompaniesAdminsGroup(IWApplicationContext iwac); // // public Group getCompanyAdminsGroup(IWApplicationContext iwac, String companyName, String personalID); // public Group getCompanyStaffGroup(IWApplicationContext iwac, String companyName, String personalID); // // public Group getCompanySuperAdminsGroup(IWApplicationContext iwac); // // public Group getGroupByName(Group parentGroup, String name, String personalID); // public Group getChildGroupByType(Group group, String type); // public List<Group> getAllChildGroupsByType(Group group, String type); // // public Group createCompanyGroup(IWApplicationContext iwac, String companyName, String personalID); // public Group createCompanyGroup(IWApplicationContext iwac, Group companyPortal, String companyName, String personalID); // // public Group getCompanyGroup(IWApplicationContext iwac, String companyName, String personalID); // // public List<Group> getAllUserCompanies(User user); // public Company getCompanyForUser(User user); // // public Group getCompanyGroupByUser(User user); // public Group getCompanyStaffGroupByUser(User user); // public Group getCompanyAdminsGroupByUser(User user); // // public void setHomePage(IWApplicationContext iwac, Group group, String homePageKey); // public void setHomePageToGroups(IWApplicationContext iwac); // // public List<User> getAllCompanyUsers(Group company); // public List<User> getAllCompanyUsers(CompanyApplication application); // // public List<Group> getAllCompanyGroups(Group company); // // public boolean isMemberOfCompany(IWApplicationContext iwac, Group group, User user); // // public Company getCompanyByPersonalIdOrUserId(String personalId); // } // Path: src/java/is/idega/idegaweb/egov/company/IWBundleStarter.java import is.idega.idegaweb.egov.EGOVConstants; import is.idega.idegaweb.egov.company.business.CompanyPortalBusiness; import java.rmi.RemoteException; import java.util.Collection; import javax.ejb.CreateException; import javax.ejb.FinderException; import com.idega.builder.business.BuilderLogic; import com.idega.business.IBOLookup; import com.idega.business.IBOLookupException; import com.idega.core.accesscontrol.business.AccessController; import com.idega.core.accesscontrol.business.StandardRoles; import com.idega.idegaweb.IWApplicationContext; import com.idega.idegaweb.IWBundle; import com.idega.idegaweb.IWBundleStartable; import com.idega.servlet.filter.IWBundleResourceFilter; import com.idega.user.business.GroupBusiness; import com.idega.user.data.Group; import com.idega.user.data.GroupType; import com.idega.util.ListUtil; import com.idega.util.expression.ELUtil; Group companyPortal = null; try { companyPortal = createRootGroup(iwac, groupBusiness); } catch(RemoteException e) { e.printStackTrace(); } if (companyPortal == null) { return; } try { createAdminsGroup(iwac, groupBusiness, companyPortal); } catch (RemoteException e) { e.printStackTrace(); } try { createSuperAdminsGroup(iwac, groupBusiness, companyPortal); } catch (RemoteException e) { e.printStackTrace(); } setRoleToCommuneAcceptedCitizensGroup(iwac, groupBusiness); setHomePageToGroups(iwac); IWBundleResourceFilter.copyAllFilesFromJarDirectory(starterBundle.getApplication(), starterBundle, "/resources/"); } private void setHomePageToGroups(IWApplicationContext iwac) {
CompanyPortalBusiness companyPortalBusiness = ELUtil.getInstance().getBean(CompanyPortalBusiness.SPRING_BEAN_IDENTIFIER);
idega/is.idega.idegaweb.egov.company
src/java/is/idega/idegaweb/egov/company/business/UserCompanyBusinessBean.java
// Path: src/java/is/idega/idegaweb/egov/company/EgovCompanyConstants.java // public class EgovCompanyConstants { // // private EgovCompanyConstants() {} // // public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.company"; // // public static final String COMPANY_SUPER_ADMIN_ROLE = "company_super_admin"; // public static final String COMPANY_ADMIN_ROLE = "company_admin"; // public static final String COMPANY_EMPLOYEE_ROLE = "company_staff"; // // public static final List<String> ALL_COMPANY_ROLES = Collections.unmodifiableList(Arrays.asList( // StandardRoles.ROLE_KEY_COMPANY, // COMPANY_SUPER_ADMIN_ROLE, // COMPANY_ADMIN_ROLE, // COMPANY_EMPLOYEE_ROLE // )); // // public static final String GROUP_TYPE_COMPANY_ADMINS = "iw_company_admins_group"; // public static final String GROUP_TYPE_COMPANY_STAFF = "iw_company_staff_group"; // public static final List<String> ALL_COMPANY_TYPES = Collections.unmodifiableList(Arrays.asList( // CompanyConstants.GROUP_TYPE_COMPANY, // GROUP_TYPE_COMPANY_ADMINS, // GROUP_TYPE_COMPANY_STAFF // )); // // public static final String CASE_CODE_KEY = "COMPORT"; // // public static final String CONTENT_CODE_REQUEST_INFORMATION = "prm_company_code_request_information"; // // public static final Integer APPLICATION_TYPE_APPROVED = 0; // public static final Integer APPLICATION_TYPE_REJECTED = 1; // public static final Integer APPLICATION_TYPE_UNHANDLED = 2; // // public static final String USER_LOGIN_METADATA = "userLoginEnabledMetaDataForCompanyPortal"; // // public static final String COMPANY_PORTAL_ROOT_GROUP = "Company Portal"; // public static final String COMPANY_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Admins"; // public static final String COMPANY_SUPER_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Super Admins"; // // public static final String COMPANY_PORTAL_HOME_PAGE_APPLICATION_PROPERTY = "companyPortalHomePage"; // public static final String COMPANY_STAFF_HOME_PAGE_APPLICATION_PROPERTY = "companyStaffHomePage"; // // public static final String COMPANY_PORTAL_CURRENT_COMPANY_ATTRIBUTE = "companyPortalCurrentCompanyId"; // // public static final String COMPANY_PERSONAL_ID_METADATA = "COMPANY_PERSONAL_ID"; // }
import is.idega.idegaweb.egov.company.EgovCompanyConstants; import java.rmi.RemoteException; import java.util.Collection; import java.util.List; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import com.idega.business.IBOLookup; import com.idega.business.IBOLookupException; import com.idega.core.builder.data.ICPage; import com.idega.presentation.IWContext; import com.idega.user.business.UserBusiness; import com.idega.user.business.UserCompanyBusiness; import com.idega.user.data.Group; import com.idega.user.data.User; import com.idega.util.ListUtil; import com.idega.util.expression.ELUtil;
package is.idega.idegaweb.egov.company.business; @Scope("singleton") @Service(UserCompanyBusiness.SPRING_BEAN_IDENTIFIER) public class UserCompanyBusinessBean implements UserCompanyBusiness { public void setPreferedCompanyForCurrentUser(String companyId) throws RemoteException { IWContext iwc = IWContext.getCurrentInstance(); getUserBusiness(iwc).setPreferedCompany(companyId, iwc.getCurrentUser()); } public Group getPreferedCompanyForUser(IWContext iwc, User user) throws RemoteException { return getUserBusiness(iwc).getPreferedCompany(user); } protected CompanyApplicationBusiness getCompanyApplicationBusiness(IWContext iwc) throws IBOLookupException { return (CompanyApplicationBusiness) IBOLookup.getServiceInstance(iwc, CompanyApplicationBusiness.class); } protected UserBusiness getUserBusiness(IWContext iwc) throws IBOLookupException { return (UserBusiness) IBOLookup.getServiceInstance(iwc, UserBusiness.class); } public Collection<Group> getUsersCompanies(IWContext iwc, User user) throws RemoteException { CompanyPortalBusiness companyPortalBusiness = ELUtil.getInstance().getBean(CompanyPortalBusiness.SPRING_BEAN_IDENTIFIER); return companyPortalBusiness.getAllUserCompanies(user); } public String getCurrentCompanyAttributeId() {
// Path: src/java/is/idega/idegaweb/egov/company/EgovCompanyConstants.java // public class EgovCompanyConstants { // // private EgovCompanyConstants() {} // // public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.company"; // // public static final String COMPANY_SUPER_ADMIN_ROLE = "company_super_admin"; // public static final String COMPANY_ADMIN_ROLE = "company_admin"; // public static final String COMPANY_EMPLOYEE_ROLE = "company_staff"; // // public static final List<String> ALL_COMPANY_ROLES = Collections.unmodifiableList(Arrays.asList( // StandardRoles.ROLE_KEY_COMPANY, // COMPANY_SUPER_ADMIN_ROLE, // COMPANY_ADMIN_ROLE, // COMPANY_EMPLOYEE_ROLE // )); // // public static final String GROUP_TYPE_COMPANY_ADMINS = "iw_company_admins_group"; // public static final String GROUP_TYPE_COMPANY_STAFF = "iw_company_staff_group"; // public static final List<String> ALL_COMPANY_TYPES = Collections.unmodifiableList(Arrays.asList( // CompanyConstants.GROUP_TYPE_COMPANY, // GROUP_TYPE_COMPANY_ADMINS, // GROUP_TYPE_COMPANY_STAFF // )); // // public static final String CASE_CODE_KEY = "COMPORT"; // // public static final String CONTENT_CODE_REQUEST_INFORMATION = "prm_company_code_request_information"; // // public static final Integer APPLICATION_TYPE_APPROVED = 0; // public static final Integer APPLICATION_TYPE_REJECTED = 1; // public static final Integer APPLICATION_TYPE_UNHANDLED = 2; // // public static final String USER_LOGIN_METADATA = "userLoginEnabledMetaDataForCompanyPortal"; // // public static final String COMPANY_PORTAL_ROOT_GROUP = "Company Portal"; // public static final String COMPANY_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Admins"; // public static final String COMPANY_SUPER_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Super Admins"; // // public static final String COMPANY_PORTAL_HOME_PAGE_APPLICATION_PROPERTY = "companyPortalHomePage"; // public static final String COMPANY_STAFF_HOME_PAGE_APPLICATION_PROPERTY = "companyStaffHomePage"; // // public static final String COMPANY_PORTAL_CURRENT_COMPANY_ATTRIBUTE = "companyPortalCurrentCompanyId"; // // public static final String COMPANY_PERSONAL_ID_METADATA = "COMPANY_PERSONAL_ID"; // } // Path: src/java/is/idega/idegaweb/egov/company/business/UserCompanyBusinessBean.java import is.idega.idegaweb.egov.company.EgovCompanyConstants; import java.rmi.RemoteException; import java.util.Collection; import java.util.List; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import com.idega.business.IBOLookup; import com.idega.business.IBOLookupException; import com.idega.core.builder.data.ICPage; import com.idega.presentation.IWContext; import com.idega.user.business.UserBusiness; import com.idega.user.business.UserCompanyBusiness; import com.idega.user.data.Group; import com.idega.user.data.User; import com.idega.util.ListUtil; import com.idega.util.expression.ELUtil; package is.idega.idegaweb.egov.company.business; @Scope("singleton") @Service(UserCompanyBusiness.SPRING_BEAN_IDENTIFIER) public class UserCompanyBusinessBean implements UserCompanyBusiness { public void setPreferedCompanyForCurrentUser(String companyId) throws RemoteException { IWContext iwc = IWContext.getCurrentInstance(); getUserBusiness(iwc).setPreferedCompany(companyId, iwc.getCurrentUser()); } public Group getPreferedCompanyForUser(IWContext iwc, User user) throws RemoteException { return getUserBusiness(iwc).getPreferedCompany(user); } protected CompanyApplicationBusiness getCompanyApplicationBusiness(IWContext iwc) throws IBOLookupException { return (CompanyApplicationBusiness) IBOLookup.getServiceInstance(iwc, CompanyApplicationBusiness.class); } protected UserBusiness getUserBusiness(IWContext iwc) throws IBOLookupException { return (UserBusiness) IBOLookup.getServiceInstance(iwc, UserBusiness.class); } public Collection<Group> getUsersCompanies(IWContext iwc, User user) throws RemoteException { CompanyPortalBusiness companyPortalBusiness = ELUtil.getInstance().getBean(CompanyPortalBusiness.SPRING_BEAN_IDENTIFIER); return companyPortalBusiness.getAllUserCompanies(user); } public String getCurrentCompanyAttributeId() {
return EgovCompanyConstants.COMPANY_PORTAL_CURRENT_COMPANY_ATTRIBUTE;
idega/is.idega.idegaweb.egov.company
src/java/is/idega/idegaweb/egov/company/data/CompanyApplicationBMPBean.java
// Path: src/java/is/idega/idegaweb/egov/company/EgovCompanyConstants.java // public class EgovCompanyConstants { // // private EgovCompanyConstants() {} // // public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.company"; // // public static final String COMPANY_SUPER_ADMIN_ROLE = "company_super_admin"; // public static final String COMPANY_ADMIN_ROLE = "company_admin"; // public static final String COMPANY_EMPLOYEE_ROLE = "company_staff"; // // public static final List<String> ALL_COMPANY_ROLES = Collections.unmodifiableList(Arrays.asList( // StandardRoles.ROLE_KEY_COMPANY, // COMPANY_SUPER_ADMIN_ROLE, // COMPANY_ADMIN_ROLE, // COMPANY_EMPLOYEE_ROLE // )); // // public static final String GROUP_TYPE_COMPANY_ADMINS = "iw_company_admins_group"; // public static final String GROUP_TYPE_COMPANY_STAFF = "iw_company_staff_group"; // public static final List<String> ALL_COMPANY_TYPES = Collections.unmodifiableList(Arrays.asList( // CompanyConstants.GROUP_TYPE_COMPANY, // GROUP_TYPE_COMPANY_ADMINS, // GROUP_TYPE_COMPANY_STAFF // )); // // public static final String CASE_CODE_KEY = "COMPORT"; // // public static final String CONTENT_CODE_REQUEST_INFORMATION = "prm_company_code_request_information"; // // public static final Integer APPLICATION_TYPE_APPROVED = 0; // public static final Integer APPLICATION_TYPE_REJECTED = 1; // public static final Integer APPLICATION_TYPE_UNHANDLED = 2; // // public static final String USER_LOGIN_METADATA = "userLoginEnabledMetaDataForCompanyPortal"; // // public static final String COMPANY_PORTAL_ROOT_GROUP = "Company Portal"; // public static final String COMPANY_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Admins"; // public static final String COMPANY_SUPER_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Super Admins"; // // public static final String COMPANY_PORTAL_HOME_PAGE_APPLICATION_PROPERTY = "companyPortalHomePage"; // public static final String COMPANY_STAFF_HOME_PAGE_APPLICATION_PROPERTY = "companyStaffHomePage"; // // public static final String COMPANY_PORTAL_CURRENT_COMPANY_ATTRIBUTE = "companyPortalCurrentCompanyId"; // // public static final String COMPANY_PERSONAL_ID_METADATA = "COMPANY_PERSONAL_ID"; // }
import is.idega.idegaweb.egov.application.data.ApplicationCategory; import is.idega.idegaweb.egov.company.EgovCompanyConstants; import java.sql.Timestamp; import java.util.Collection; import java.util.Locale; import java.util.Map; import javax.ejb.FinderException; import com.idega.block.process.data.AbstractCaseBMPBean; import com.idega.block.process.data.CaseCode; import com.idega.block.text.data.LocalizedText; import com.idega.company.data.Company; import com.idega.company.data.CompanyType; import com.idega.core.file.data.ICFile; import com.idega.data.IDOAddRelationshipException; import com.idega.data.IDORelationshipException; import com.idega.data.IDORemoveRelationshipException; import com.idega.data.query.InCriteria; import com.idega.data.query.MatchCriteria; import com.idega.data.query.SelectQuery; import com.idega.data.query.Table; import com.idega.user.data.Group; import com.idega.user.data.User;
package is.idega.idegaweb.egov.company.data; /** * * * @author <a href="anton@idega.com">Anton Makarov</a> * @version Revision: 1.1 * * Last modified: Seo 23, 2008 by Author: Anton * */ public class CompanyApplicationBMPBean extends AbstractCaseBMPBean implements CompanyApplication { private static final long serialVersionUID = -7638155652762635917L; private static final String ENTITY_NAME = "COMPANY_APPLICATION"; private static final String COLUMN_TYPE = "company_type"; private static final String COLUMN_COMPANY = "company_id"; private static final String COLUMN_ADMIN_USER = "admin_user"; private static final String COLUMN_APPLICANT_USER = "applicant_user"; private static final String CATEGORY = "application_category_id"; private static final String CASE_CODE = "case_code"; private static final String CONTRACT_FILE = "contract_file"; private static final String EGOV_APPLICATION_GROUP = "EGOV_APPLICATION_GROUP"; @Override public String getCaseCodeDescription() { return "Application for company portal"; } @Override public String getCaseCodeKey() {
// Path: src/java/is/idega/idegaweb/egov/company/EgovCompanyConstants.java // public class EgovCompanyConstants { // // private EgovCompanyConstants() {} // // public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.company"; // // public static final String COMPANY_SUPER_ADMIN_ROLE = "company_super_admin"; // public static final String COMPANY_ADMIN_ROLE = "company_admin"; // public static final String COMPANY_EMPLOYEE_ROLE = "company_staff"; // // public static final List<String> ALL_COMPANY_ROLES = Collections.unmodifiableList(Arrays.asList( // StandardRoles.ROLE_KEY_COMPANY, // COMPANY_SUPER_ADMIN_ROLE, // COMPANY_ADMIN_ROLE, // COMPANY_EMPLOYEE_ROLE // )); // // public static final String GROUP_TYPE_COMPANY_ADMINS = "iw_company_admins_group"; // public static final String GROUP_TYPE_COMPANY_STAFF = "iw_company_staff_group"; // public static final List<String> ALL_COMPANY_TYPES = Collections.unmodifiableList(Arrays.asList( // CompanyConstants.GROUP_TYPE_COMPANY, // GROUP_TYPE_COMPANY_ADMINS, // GROUP_TYPE_COMPANY_STAFF // )); // // public static final String CASE_CODE_KEY = "COMPORT"; // // public static final String CONTENT_CODE_REQUEST_INFORMATION = "prm_company_code_request_information"; // // public static final Integer APPLICATION_TYPE_APPROVED = 0; // public static final Integer APPLICATION_TYPE_REJECTED = 1; // public static final Integer APPLICATION_TYPE_UNHANDLED = 2; // // public static final String USER_LOGIN_METADATA = "userLoginEnabledMetaDataForCompanyPortal"; // // public static final String COMPANY_PORTAL_ROOT_GROUP = "Company Portal"; // public static final String COMPANY_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Admins"; // public static final String COMPANY_SUPER_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Super Admins"; // // public static final String COMPANY_PORTAL_HOME_PAGE_APPLICATION_PROPERTY = "companyPortalHomePage"; // public static final String COMPANY_STAFF_HOME_PAGE_APPLICATION_PROPERTY = "companyStaffHomePage"; // // public static final String COMPANY_PORTAL_CURRENT_COMPANY_ATTRIBUTE = "companyPortalCurrentCompanyId"; // // public static final String COMPANY_PERSONAL_ID_METADATA = "COMPANY_PERSONAL_ID"; // } // Path: src/java/is/idega/idegaweb/egov/company/data/CompanyApplicationBMPBean.java import is.idega.idegaweb.egov.application.data.ApplicationCategory; import is.idega.idegaweb.egov.company.EgovCompanyConstants; import java.sql.Timestamp; import java.util.Collection; import java.util.Locale; import java.util.Map; import javax.ejb.FinderException; import com.idega.block.process.data.AbstractCaseBMPBean; import com.idega.block.process.data.CaseCode; import com.idega.block.text.data.LocalizedText; import com.idega.company.data.Company; import com.idega.company.data.CompanyType; import com.idega.core.file.data.ICFile; import com.idega.data.IDOAddRelationshipException; import com.idega.data.IDORelationshipException; import com.idega.data.IDORemoveRelationshipException; import com.idega.data.query.InCriteria; import com.idega.data.query.MatchCriteria; import com.idega.data.query.SelectQuery; import com.idega.data.query.Table; import com.idega.user.data.Group; import com.idega.user.data.User; package is.idega.idegaweb.egov.company.data; /** * * * @author <a href="anton@idega.com">Anton Makarov</a> * @version Revision: 1.1 * * Last modified: Seo 23, 2008 by Author: Anton * */ public class CompanyApplicationBMPBean extends AbstractCaseBMPBean implements CompanyApplication { private static final long serialVersionUID = -7638155652762635917L; private static final String ENTITY_NAME = "COMPANY_APPLICATION"; private static final String COLUMN_TYPE = "company_type"; private static final String COLUMN_COMPANY = "company_id"; private static final String COLUMN_ADMIN_USER = "admin_user"; private static final String COLUMN_APPLICANT_USER = "applicant_user"; private static final String CATEGORY = "application_category_id"; private static final String CASE_CODE = "case_code"; private static final String CONTRACT_FILE = "contract_file"; private static final String EGOV_APPLICATION_GROUP = "EGOV_APPLICATION_GROUP"; @Override public String getCaseCodeDescription() { return "Application for company portal"; } @Override public String getCaseCodeKey() {
return EgovCompanyConstants.CASE_CODE_KEY;
idega/is.idega.idegaweb.egov.company
src/java/is/idega/idegaweb/egov/company/business/CompanyPortalBusiness.java
// Path: src/java/is/idega/idegaweb/egov/company/data/CompanyApplication.java // public interface CompanyApplication extends Case, Application { // // public Company getCompany(); // // public void setCompany(Company company); // // public User getAdminUser(); // // public User getApplicantUser(); // // public void setAdminUser(User user); // // public void setApplicantUser(User user); // // public CompanyType getType(); // // public void setType(CompanyType type); // // public String getCaseCodeKey(); // // public ICFile getContract(); // // public void setContract(ICFile contract); // // }
import is.idega.idegaweb.egov.company.data.CompanyApplication; import java.rmi.RemoteException; import java.util.List; import com.idega.company.data.Company; import com.idega.idegaweb.IWApplicationContext; import com.idega.user.data.Group; import com.idega.user.data.User;
package is.idega.idegaweb.egov.company.business; public interface CompanyPortalBusiness { public String SPRING_BEAN_IDENTIFIER = "companyPortalBusiness"; public Group getCompanyPortalRootGroup(IWApplicationContext iwac) throws RemoteException; public Group getAllCompaniesAdminsGroup(IWApplicationContext iwac); public Group getCompanyAdminsGroup(IWApplicationContext iwac, String companyName, String personalID); public Group getCompanyStaffGroup(IWApplicationContext iwac, String companyName, String personalID); public Group getCompanySuperAdminsGroup(IWApplicationContext iwac); public Group getGroupByName(Group parentGroup, String name, String personalID); public Group getChildGroupByType(Group group, String type); public List<Group> getAllChildGroupsByType(Group group, String type); public Group createCompanyGroup(IWApplicationContext iwac, String companyName, String personalID); public Group createCompanyGroup(IWApplicationContext iwac, Group companyPortal, String companyName, String personalID); public Group getCompanyGroup(IWApplicationContext iwac, String companyName, String personalID); public List<Group> getAllUserCompanies(User user); public Company getCompanyForUser(User user); public Group getCompanyGroupByUser(User user); public Group getCompanyStaffGroupByUser(User user); public Group getCompanyAdminsGroupByUser(User user); public void setHomePage(IWApplicationContext iwac, Group group, String homePageKey); public void setHomePageToGroups(IWApplicationContext iwac); public List<User> getAllCompanyUsers(Group company);
// Path: src/java/is/idega/idegaweb/egov/company/data/CompanyApplication.java // public interface CompanyApplication extends Case, Application { // // public Company getCompany(); // // public void setCompany(Company company); // // public User getAdminUser(); // // public User getApplicantUser(); // // public void setAdminUser(User user); // // public void setApplicantUser(User user); // // public CompanyType getType(); // // public void setType(CompanyType type); // // public String getCaseCodeKey(); // // public ICFile getContract(); // // public void setContract(ICFile contract); // // } // Path: src/java/is/idega/idegaweb/egov/company/business/CompanyPortalBusiness.java import is.idega.idegaweb.egov.company.data.CompanyApplication; import java.rmi.RemoteException; import java.util.List; import com.idega.company.data.Company; import com.idega.idegaweb.IWApplicationContext; import com.idega.user.data.Group; import com.idega.user.data.User; package is.idega.idegaweb.egov.company.business; public interface CompanyPortalBusiness { public String SPRING_BEAN_IDENTIFIER = "companyPortalBusiness"; public Group getCompanyPortalRootGroup(IWApplicationContext iwac) throws RemoteException; public Group getAllCompaniesAdminsGroup(IWApplicationContext iwac); public Group getCompanyAdminsGroup(IWApplicationContext iwac, String companyName, String personalID); public Group getCompanyStaffGroup(IWApplicationContext iwac, String companyName, String personalID); public Group getCompanySuperAdminsGroup(IWApplicationContext iwac); public Group getGroupByName(Group parentGroup, String name, String personalID); public Group getChildGroupByType(Group group, String type); public List<Group> getAllChildGroupsByType(Group group, String type); public Group createCompanyGroup(IWApplicationContext iwac, String companyName, String personalID); public Group createCompanyGroup(IWApplicationContext iwac, Group companyPortal, String companyName, String personalID); public Group getCompanyGroup(IWApplicationContext iwac, String companyName, String personalID); public List<Group> getAllUserCompanies(User user); public Company getCompanyForUser(User user); public Group getCompanyGroupByUser(User user); public Group getCompanyStaffGroupByUser(User user); public Group getCompanyAdminsGroupByUser(User user); public void setHomePage(IWApplicationContext iwac, Group group, String homePageKey); public void setHomePageToGroups(IWApplicationContext iwac); public List<User> getAllCompanyUsers(Group company);
public List<User> getAllCompanyUsers(CompanyApplication application);
idega/is.idega.idegaweb.egov.company
src/java/is/idega/idegaweb/egov/company/business/CompanyContractPrintingContext.java
// Path: src/java/is/idega/idegaweb/egov/company/EgovCompanyConstants.java // public class EgovCompanyConstants { // // private EgovCompanyConstants() {} // // public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.company"; // // public static final String COMPANY_SUPER_ADMIN_ROLE = "company_super_admin"; // public static final String COMPANY_ADMIN_ROLE = "company_admin"; // public static final String COMPANY_EMPLOYEE_ROLE = "company_staff"; // // public static final List<String> ALL_COMPANY_ROLES = Collections.unmodifiableList(Arrays.asList( // StandardRoles.ROLE_KEY_COMPANY, // COMPANY_SUPER_ADMIN_ROLE, // COMPANY_ADMIN_ROLE, // COMPANY_EMPLOYEE_ROLE // )); // // public static final String GROUP_TYPE_COMPANY_ADMINS = "iw_company_admins_group"; // public static final String GROUP_TYPE_COMPANY_STAFF = "iw_company_staff_group"; // public static final List<String> ALL_COMPANY_TYPES = Collections.unmodifiableList(Arrays.asList( // CompanyConstants.GROUP_TYPE_COMPANY, // GROUP_TYPE_COMPANY_ADMINS, // GROUP_TYPE_COMPANY_STAFF // )); // // public static final String CASE_CODE_KEY = "COMPORT"; // // public static final String CONTENT_CODE_REQUEST_INFORMATION = "prm_company_code_request_information"; // // public static final Integer APPLICATION_TYPE_APPROVED = 0; // public static final Integer APPLICATION_TYPE_REJECTED = 1; // public static final Integer APPLICATION_TYPE_UNHANDLED = 2; // // public static final String USER_LOGIN_METADATA = "userLoginEnabledMetaDataForCompanyPortal"; // // public static final String COMPANY_PORTAL_ROOT_GROUP = "Company Portal"; // public static final String COMPANY_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Admins"; // public static final String COMPANY_SUPER_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Super Admins"; // // public static final String COMPANY_PORTAL_HOME_PAGE_APPLICATION_PROPERTY = "companyPortalHomePage"; // public static final String COMPANY_STAFF_HOME_PAGE_APPLICATION_PROPERTY = "companyStaffHomePage"; // // public static final String COMPANY_PORTAL_CURRENT_COMPANY_ATTRIBUTE = "companyPortalCurrentCompanyId"; // // public static final String COMPANY_PERSONAL_ID_METADATA = "COMPANY_PERSONAL_ID"; // } // // Path: src/java/is/idega/idegaweb/egov/company/data/CompanyApplication.java // public interface CompanyApplication extends Case, Application { // // public Company getCompany(); // // public void setCompany(Company company); // // public User getAdminUser(); // // public User getApplicantUser(); // // public void setAdminUser(User user); // // public void setApplicantUser(User user); // // public CompanyType getType(); // // public void setType(CompanyType type); // // public String getCaseCodeKey(); // // public ICFile getContract(); // // public void setContract(ICFile contract); // // }
import is.idega.idegaweb.egov.application.data.Application; import is.idega.idegaweb.egov.company.EgovCompanyConstants; import is.idega.idegaweb.egov.company.data.CompanyApplication; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.rmi.RemoteException; import java.util.HashMap; import java.util.Locale; import java.util.Map; import com.idega.block.pdf.business.PrintingContext; import com.idega.block.pdf.business.PrintingContextImpl; import com.idega.business.IBOLookup; import com.idega.business.IBOLookupException; import com.idega.business.IBORuntimeException; import com.idega.company.data.Company; import com.idega.core.location.business.CommuneBusiness; import com.idega.core.location.data.Commune; import com.idega.idegaweb.IWApplicationContext; import com.idega.idegaweb.IWBundle; import com.idega.idegaweb.IWResourceBundle; import com.idega.util.FileUtil;
/* * $Id: CompanyContractPrintingContext.java,v 1.7 2008/10/23 12:29:52 valdas Exp $ * Created on Jun 14, 2007 * * Copyright (C) 2007 Idega Software hf. All Rights Reserved. * * This software is the proprietary information of Idega hf. * Use is subject to license terms. */ package is.idega.idegaweb.egov.company.business; public class CompanyContractPrintingContext extends PrintingContextImpl { protected IWBundle iwb; protected IWResourceBundle iwrb; public CompanyContractPrintingContext(IWApplicationContext iwac, Application application, Locale locale) { try { init(iwac, application, locale); } catch (RemoteException re) { throw new IBORuntimeException(re); } } private void init(IWApplicationContext iwac, Application application, Locale locale) throws RemoteException { Map<String, Object> props = new HashMap<String, Object>();
// Path: src/java/is/idega/idegaweb/egov/company/EgovCompanyConstants.java // public class EgovCompanyConstants { // // private EgovCompanyConstants() {} // // public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.company"; // // public static final String COMPANY_SUPER_ADMIN_ROLE = "company_super_admin"; // public static final String COMPANY_ADMIN_ROLE = "company_admin"; // public static final String COMPANY_EMPLOYEE_ROLE = "company_staff"; // // public static final List<String> ALL_COMPANY_ROLES = Collections.unmodifiableList(Arrays.asList( // StandardRoles.ROLE_KEY_COMPANY, // COMPANY_SUPER_ADMIN_ROLE, // COMPANY_ADMIN_ROLE, // COMPANY_EMPLOYEE_ROLE // )); // // public static final String GROUP_TYPE_COMPANY_ADMINS = "iw_company_admins_group"; // public static final String GROUP_TYPE_COMPANY_STAFF = "iw_company_staff_group"; // public static final List<String> ALL_COMPANY_TYPES = Collections.unmodifiableList(Arrays.asList( // CompanyConstants.GROUP_TYPE_COMPANY, // GROUP_TYPE_COMPANY_ADMINS, // GROUP_TYPE_COMPANY_STAFF // )); // // public static final String CASE_CODE_KEY = "COMPORT"; // // public static final String CONTENT_CODE_REQUEST_INFORMATION = "prm_company_code_request_information"; // // public static final Integer APPLICATION_TYPE_APPROVED = 0; // public static final Integer APPLICATION_TYPE_REJECTED = 1; // public static final Integer APPLICATION_TYPE_UNHANDLED = 2; // // public static final String USER_LOGIN_METADATA = "userLoginEnabledMetaDataForCompanyPortal"; // // public static final String COMPANY_PORTAL_ROOT_GROUP = "Company Portal"; // public static final String COMPANY_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Admins"; // public static final String COMPANY_SUPER_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Super Admins"; // // public static final String COMPANY_PORTAL_HOME_PAGE_APPLICATION_PROPERTY = "companyPortalHomePage"; // public static final String COMPANY_STAFF_HOME_PAGE_APPLICATION_PROPERTY = "companyStaffHomePage"; // // public static final String COMPANY_PORTAL_CURRENT_COMPANY_ATTRIBUTE = "companyPortalCurrentCompanyId"; // // public static final String COMPANY_PERSONAL_ID_METADATA = "COMPANY_PERSONAL_ID"; // } // // Path: src/java/is/idega/idegaweb/egov/company/data/CompanyApplication.java // public interface CompanyApplication extends Case, Application { // // public Company getCompany(); // // public void setCompany(Company company); // // public User getAdminUser(); // // public User getApplicantUser(); // // public void setAdminUser(User user); // // public void setApplicantUser(User user); // // public CompanyType getType(); // // public void setType(CompanyType type); // // public String getCaseCodeKey(); // // public ICFile getContract(); // // public void setContract(ICFile contract); // // } // Path: src/java/is/idega/idegaweb/egov/company/business/CompanyContractPrintingContext.java import is.idega.idegaweb.egov.application.data.Application; import is.idega.idegaweb.egov.company.EgovCompanyConstants; import is.idega.idegaweb.egov.company.data.CompanyApplication; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.rmi.RemoteException; import java.util.HashMap; import java.util.Locale; import java.util.Map; import com.idega.block.pdf.business.PrintingContext; import com.idega.block.pdf.business.PrintingContextImpl; import com.idega.business.IBOLookup; import com.idega.business.IBOLookupException; import com.idega.business.IBORuntimeException; import com.idega.company.data.Company; import com.idega.core.location.business.CommuneBusiness; import com.idega.core.location.data.Commune; import com.idega.idegaweb.IWApplicationContext; import com.idega.idegaweb.IWBundle; import com.idega.idegaweb.IWResourceBundle; import com.idega.util.FileUtil; /* * $Id: CompanyContractPrintingContext.java,v 1.7 2008/10/23 12:29:52 valdas Exp $ * Created on Jun 14, 2007 * * Copyright (C) 2007 Idega Software hf. All Rights Reserved. * * This software is the proprietary information of Idega hf. * Use is subject to license terms. */ package is.idega.idegaweb.egov.company.business; public class CompanyContractPrintingContext extends PrintingContextImpl { protected IWBundle iwb; protected IWResourceBundle iwrb; public CompanyContractPrintingContext(IWApplicationContext iwac, Application application, Locale locale) { try { init(iwac, application, locale); } catch (RemoteException re) { throw new IBORuntimeException(re); } } private void init(IWApplicationContext iwac, Application application, Locale locale) throws RemoteException { Map<String, Object> props = new HashMap<String, Object>();
Company company = ((CompanyApplication)application).getCompany();
idega/is.idega.idegaweb.egov.company
src/java/is/idega/idegaweb/egov/company/business/CompanyContractPrintingContext.java
// Path: src/java/is/idega/idegaweb/egov/company/EgovCompanyConstants.java // public class EgovCompanyConstants { // // private EgovCompanyConstants() {} // // public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.company"; // // public static final String COMPANY_SUPER_ADMIN_ROLE = "company_super_admin"; // public static final String COMPANY_ADMIN_ROLE = "company_admin"; // public static final String COMPANY_EMPLOYEE_ROLE = "company_staff"; // // public static final List<String> ALL_COMPANY_ROLES = Collections.unmodifiableList(Arrays.asList( // StandardRoles.ROLE_KEY_COMPANY, // COMPANY_SUPER_ADMIN_ROLE, // COMPANY_ADMIN_ROLE, // COMPANY_EMPLOYEE_ROLE // )); // // public static final String GROUP_TYPE_COMPANY_ADMINS = "iw_company_admins_group"; // public static final String GROUP_TYPE_COMPANY_STAFF = "iw_company_staff_group"; // public static final List<String> ALL_COMPANY_TYPES = Collections.unmodifiableList(Arrays.asList( // CompanyConstants.GROUP_TYPE_COMPANY, // GROUP_TYPE_COMPANY_ADMINS, // GROUP_TYPE_COMPANY_STAFF // )); // // public static final String CASE_CODE_KEY = "COMPORT"; // // public static final String CONTENT_CODE_REQUEST_INFORMATION = "prm_company_code_request_information"; // // public static final Integer APPLICATION_TYPE_APPROVED = 0; // public static final Integer APPLICATION_TYPE_REJECTED = 1; // public static final Integer APPLICATION_TYPE_UNHANDLED = 2; // // public static final String USER_LOGIN_METADATA = "userLoginEnabledMetaDataForCompanyPortal"; // // public static final String COMPANY_PORTAL_ROOT_GROUP = "Company Portal"; // public static final String COMPANY_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Admins"; // public static final String COMPANY_SUPER_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Super Admins"; // // public static final String COMPANY_PORTAL_HOME_PAGE_APPLICATION_PROPERTY = "companyPortalHomePage"; // public static final String COMPANY_STAFF_HOME_PAGE_APPLICATION_PROPERTY = "companyStaffHomePage"; // // public static final String COMPANY_PORTAL_CURRENT_COMPANY_ATTRIBUTE = "companyPortalCurrentCompanyId"; // // public static final String COMPANY_PERSONAL_ID_METADATA = "COMPANY_PERSONAL_ID"; // } // // Path: src/java/is/idega/idegaweb/egov/company/data/CompanyApplication.java // public interface CompanyApplication extends Case, Application { // // public Company getCompany(); // // public void setCompany(Company company); // // public User getAdminUser(); // // public User getApplicantUser(); // // public void setAdminUser(User user); // // public void setApplicantUser(User user); // // public CompanyType getType(); // // public void setType(CompanyType type); // // public String getCaseCodeKey(); // // public ICFile getContract(); // // public void setContract(ICFile contract); // // }
import is.idega.idegaweb.egov.application.data.Application; import is.idega.idegaweb.egov.company.EgovCompanyConstants; import is.idega.idegaweb.egov.company.data.CompanyApplication; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.rmi.RemoteException; import java.util.HashMap; import java.util.Locale; import java.util.Map; import com.idega.block.pdf.business.PrintingContext; import com.idega.block.pdf.business.PrintingContextImpl; import com.idega.business.IBOLookup; import com.idega.business.IBOLookupException; import com.idega.business.IBORuntimeException; import com.idega.company.data.Company; import com.idega.core.location.business.CommuneBusiness; import com.idega.core.location.data.Commune; import com.idega.idegaweb.IWApplicationContext; import com.idega.idegaweb.IWBundle; import com.idega.idegaweb.IWResourceBundle; import com.idega.util.FileUtil;
setResourceDirectory(FileUtil.getFileAndCreateRecursiveIfNotExists(baseDirectory)); File file = FileUtil.getFileFromWorkspace(baseDirectory + "company_contract_template.xml"); setTemplateStream(new FileInputStream(file)); } catch (IOException e) { e.printStackTrace(); } } protected String getResourceRealPath(IWBundle iwb, Locale locale) { String printFolder = iwb.getApplication().getSettings().getProperty("company_portal.print_contract_folder", "/print/contract/"); if (locale != null) { return iwb.getResourcesRealPath(locale) + printFolder; } else { return iwb.getResourcesRealPath() + printFolder; } } protected FileInputStream getTemplateUrlAsStream(IWBundle iwb, Locale locale, String name, boolean createIfNotExists) throws IOException { File template = new File(getTemplateUrl(iwb, locale, name)); return new FileInputStream(template); } protected String getTemplateUrl(IWBundle iwb, Locale locale, String name) { return getResourceRealPath(iwb, locale) + name; } private String getBundleIdentifier() {
// Path: src/java/is/idega/idegaweb/egov/company/EgovCompanyConstants.java // public class EgovCompanyConstants { // // private EgovCompanyConstants() {} // // public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.company"; // // public static final String COMPANY_SUPER_ADMIN_ROLE = "company_super_admin"; // public static final String COMPANY_ADMIN_ROLE = "company_admin"; // public static final String COMPANY_EMPLOYEE_ROLE = "company_staff"; // // public static final List<String> ALL_COMPANY_ROLES = Collections.unmodifiableList(Arrays.asList( // StandardRoles.ROLE_KEY_COMPANY, // COMPANY_SUPER_ADMIN_ROLE, // COMPANY_ADMIN_ROLE, // COMPANY_EMPLOYEE_ROLE // )); // // public static final String GROUP_TYPE_COMPANY_ADMINS = "iw_company_admins_group"; // public static final String GROUP_TYPE_COMPANY_STAFF = "iw_company_staff_group"; // public static final List<String> ALL_COMPANY_TYPES = Collections.unmodifiableList(Arrays.asList( // CompanyConstants.GROUP_TYPE_COMPANY, // GROUP_TYPE_COMPANY_ADMINS, // GROUP_TYPE_COMPANY_STAFF // )); // // public static final String CASE_CODE_KEY = "COMPORT"; // // public static final String CONTENT_CODE_REQUEST_INFORMATION = "prm_company_code_request_information"; // // public static final Integer APPLICATION_TYPE_APPROVED = 0; // public static final Integer APPLICATION_TYPE_REJECTED = 1; // public static final Integer APPLICATION_TYPE_UNHANDLED = 2; // // public static final String USER_LOGIN_METADATA = "userLoginEnabledMetaDataForCompanyPortal"; // // public static final String COMPANY_PORTAL_ROOT_GROUP = "Company Portal"; // public static final String COMPANY_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Admins"; // public static final String COMPANY_SUPER_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Super Admins"; // // public static final String COMPANY_PORTAL_HOME_PAGE_APPLICATION_PROPERTY = "companyPortalHomePage"; // public static final String COMPANY_STAFF_HOME_PAGE_APPLICATION_PROPERTY = "companyStaffHomePage"; // // public static final String COMPANY_PORTAL_CURRENT_COMPANY_ATTRIBUTE = "companyPortalCurrentCompanyId"; // // public static final String COMPANY_PERSONAL_ID_METADATA = "COMPANY_PERSONAL_ID"; // } // // Path: src/java/is/idega/idegaweb/egov/company/data/CompanyApplication.java // public interface CompanyApplication extends Case, Application { // // public Company getCompany(); // // public void setCompany(Company company); // // public User getAdminUser(); // // public User getApplicantUser(); // // public void setAdminUser(User user); // // public void setApplicantUser(User user); // // public CompanyType getType(); // // public void setType(CompanyType type); // // public String getCaseCodeKey(); // // public ICFile getContract(); // // public void setContract(ICFile contract); // // } // Path: src/java/is/idega/idegaweb/egov/company/business/CompanyContractPrintingContext.java import is.idega.idegaweb.egov.application.data.Application; import is.idega.idegaweb.egov.company.EgovCompanyConstants; import is.idega.idegaweb.egov.company.data.CompanyApplication; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.rmi.RemoteException; import java.util.HashMap; import java.util.Locale; import java.util.Map; import com.idega.block.pdf.business.PrintingContext; import com.idega.block.pdf.business.PrintingContextImpl; import com.idega.business.IBOLookup; import com.idega.business.IBOLookupException; import com.idega.business.IBORuntimeException; import com.idega.company.data.Company; import com.idega.core.location.business.CommuneBusiness; import com.idega.core.location.data.Commune; import com.idega.idegaweb.IWApplicationContext; import com.idega.idegaweb.IWBundle; import com.idega.idegaweb.IWResourceBundle; import com.idega.util.FileUtil; setResourceDirectory(FileUtil.getFileAndCreateRecursiveIfNotExists(baseDirectory)); File file = FileUtil.getFileFromWorkspace(baseDirectory + "company_contract_template.xml"); setTemplateStream(new FileInputStream(file)); } catch (IOException e) { e.printStackTrace(); } } protected String getResourceRealPath(IWBundle iwb, Locale locale) { String printFolder = iwb.getApplication().getSettings().getProperty("company_portal.print_contract_folder", "/print/contract/"); if (locale != null) { return iwb.getResourcesRealPath(locale) + printFolder; } else { return iwb.getResourcesRealPath() + printFolder; } } protected FileInputStream getTemplateUrlAsStream(IWBundle iwb, Locale locale, String name, boolean createIfNotExists) throws IOException { File template = new File(getTemplateUrl(iwb, locale, name)); return new FileInputStream(template); } protected String getTemplateUrl(IWBundle iwb, Locale locale, String name) { return getResourceRealPath(iwb, locale) + name; } private String getBundleIdentifier() {
return EgovCompanyConstants.IW_BUNDLE_IDENTIFIER;
idega/is.idega.idegaweb.egov.company
src/java/is/idega/idegaweb/egov/company/business/CompanyPortalBusinessBean.java
// Path: src/java/is/idega/idegaweb/egov/company/EgovCompanyConstants.java // public class EgovCompanyConstants { // // private EgovCompanyConstants() {} // // public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.company"; // // public static final String COMPANY_SUPER_ADMIN_ROLE = "company_super_admin"; // public static final String COMPANY_ADMIN_ROLE = "company_admin"; // public static final String COMPANY_EMPLOYEE_ROLE = "company_staff"; // // public static final List<String> ALL_COMPANY_ROLES = Collections.unmodifiableList(Arrays.asList( // StandardRoles.ROLE_KEY_COMPANY, // COMPANY_SUPER_ADMIN_ROLE, // COMPANY_ADMIN_ROLE, // COMPANY_EMPLOYEE_ROLE // )); // // public static final String GROUP_TYPE_COMPANY_ADMINS = "iw_company_admins_group"; // public static final String GROUP_TYPE_COMPANY_STAFF = "iw_company_staff_group"; // public static final List<String> ALL_COMPANY_TYPES = Collections.unmodifiableList(Arrays.asList( // CompanyConstants.GROUP_TYPE_COMPANY, // GROUP_TYPE_COMPANY_ADMINS, // GROUP_TYPE_COMPANY_STAFF // )); // // public static final String CASE_CODE_KEY = "COMPORT"; // // public static final String CONTENT_CODE_REQUEST_INFORMATION = "prm_company_code_request_information"; // // public static final Integer APPLICATION_TYPE_APPROVED = 0; // public static final Integer APPLICATION_TYPE_REJECTED = 1; // public static final Integer APPLICATION_TYPE_UNHANDLED = 2; // // public static final String USER_LOGIN_METADATA = "userLoginEnabledMetaDataForCompanyPortal"; // // public static final String COMPANY_PORTAL_ROOT_GROUP = "Company Portal"; // public static final String COMPANY_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Admins"; // public static final String COMPANY_SUPER_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Super Admins"; // // public static final String COMPANY_PORTAL_HOME_PAGE_APPLICATION_PROPERTY = "companyPortalHomePage"; // public static final String COMPANY_STAFF_HOME_PAGE_APPLICATION_PROPERTY = "companyStaffHomePage"; // // public static final String COMPANY_PORTAL_CURRENT_COMPANY_ATTRIBUTE = "companyPortalCurrentCompanyId"; // // public static final String COMPANY_PERSONAL_ID_METADATA = "COMPANY_PERSONAL_ID"; // } // // Path: src/java/is/idega/idegaweb/egov/company/data/CompanyApplication.java // public interface CompanyApplication extends Case, Application { // // public Company getCompany(); // // public void setCompany(Company company); // // public User getAdminUser(); // // public User getApplicantUser(); // // public void setAdminUser(User user); // // public void setApplicantUser(User user); // // public CompanyType getType(); // // public void setType(CompanyType type); // // public String getCaseCodeKey(); // // public ICFile getContract(); // // public void setContract(ICFile contract); // // }
import is.idega.idegaweb.egov.company.EgovCompanyConstants; import is.idega.idegaweb.egov.company.data.CompanyApplication; import java.rmi.RemoteException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.logging.Level; import java.util.logging.Logger; import javax.ejb.EJBException; import javax.ejb.FinderException; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import com.idega.business.IBOLookup; import com.idega.business.IBOLookupException; import com.idega.business.IBORuntimeException; import com.idega.company.CompanyConstants; import com.idega.company.business.CompanyBusiness; import com.idega.company.data.Company; import com.idega.core.builder.data.ICPage; import com.idega.core.business.DefaultSpringBean; import com.idega.core.data.ICTreeNode; import com.idega.idegaweb.IWApplicationContext; import com.idega.idegaweb.IWMainApplication; import com.idega.idegaweb.IWResourceBundle; import com.idega.presentation.IWContext; import com.idega.user.business.GroupBusiness; import com.idega.user.business.UserBusiness; import com.idega.user.data.Group; import com.idega.user.data.User; import com.idega.user.util.UserComparator; import com.idega.util.CoreConstants; import com.idega.util.CoreUtil; import com.idega.util.ListUtil; import com.idega.util.StringUtil; import com.idega.util.expression.ELUtil;
package is.idega.idegaweb.egov.company.business; @Scope(BeanDefinition.SCOPE_SINGLETON) @Service(CompanyPortalBusiness.SPRING_BEAN_IDENTIFIER) public class CompanyPortalBusinessBean extends DefaultSpringBean implements CompanyPortalBusiness { private static final Logger logger = Logger.getLogger(CompanyPortalBusinessBean.class.getName()); @Override public Group getCompanyPortalRootGroup(IWApplicationContext iwac) throws RemoteException {
// Path: src/java/is/idega/idegaweb/egov/company/EgovCompanyConstants.java // public class EgovCompanyConstants { // // private EgovCompanyConstants() {} // // public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.company"; // // public static final String COMPANY_SUPER_ADMIN_ROLE = "company_super_admin"; // public static final String COMPANY_ADMIN_ROLE = "company_admin"; // public static final String COMPANY_EMPLOYEE_ROLE = "company_staff"; // // public static final List<String> ALL_COMPANY_ROLES = Collections.unmodifiableList(Arrays.asList( // StandardRoles.ROLE_KEY_COMPANY, // COMPANY_SUPER_ADMIN_ROLE, // COMPANY_ADMIN_ROLE, // COMPANY_EMPLOYEE_ROLE // )); // // public static final String GROUP_TYPE_COMPANY_ADMINS = "iw_company_admins_group"; // public static final String GROUP_TYPE_COMPANY_STAFF = "iw_company_staff_group"; // public static final List<String> ALL_COMPANY_TYPES = Collections.unmodifiableList(Arrays.asList( // CompanyConstants.GROUP_TYPE_COMPANY, // GROUP_TYPE_COMPANY_ADMINS, // GROUP_TYPE_COMPANY_STAFF // )); // // public static final String CASE_CODE_KEY = "COMPORT"; // // public static final String CONTENT_CODE_REQUEST_INFORMATION = "prm_company_code_request_information"; // // public static final Integer APPLICATION_TYPE_APPROVED = 0; // public static final Integer APPLICATION_TYPE_REJECTED = 1; // public static final Integer APPLICATION_TYPE_UNHANDLED = 2; // // public static final String USER_LOGIN_METADATA = "userLoginEnabledMetaDataForCompanyPortal"; // // public static final String COMPANY_PORTAL_ROOT_GROUP = "Company Portal"; // public static final String COMPANY_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Admins"; // public static final String COMPANY_SUPER_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Super Admins"; // // public static final String COMPANY_PORTAL_HOME_PAGE_APPLICATION_PROPERTY = "companyPortalHomePage"; // public static final String COMPANY_STAFF_HOME_PAGE_APPLICATION_PROPERTY = "companyStaffHomePage"; // // public static final String COMPANY_PORTAL_CURRENT_COMPANY_ATTRIBUTE = "companyPortalCurrentCompanyId"; // // public static final String COMPANY_PERSONAL_ID_METADATA = "COMPANY_PERSONAL_ID"; // } // // Path: src/java/is/idega/idegaweb/egov/company/data/CompanyApplication.java // public interface CompanyApplication extends Case, Application { // // public Company getCompany(); // // public void setCompany(Company company); // // public User getAdminUser(); // // public User getApplicantUser(); // // public void setAdminUser(User user); // // public void setApplicantUser(User user); // // public CompanyType getType(); // // public void setType(CompanyType type); // // public String getCaseCodeKey(); // // public ICFile getContract(); // // public void setContract(ICFile contract); // // } // Path: src/java/is/idega/idegaweb/egov/company/business/CompanyPortalBusinessBean.java import is.idega.idegaweb.egov.company.EgovCompanyConstants; import is.idega.idegaweb.egov.company.data.CompanyApplication; import java.rmi.RemoteException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.logging.Level; import java.util.logging.Logger; import javax.ejb.EJBException; import javax.ejb.FinderException; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import com.idega.business.IBOLookup; import com.idega.business.IBOLookupException; import com.idega.business.IBORuntimeException; import com.idega.company.CompanyConstants; import com.idega.company.business.CompanyBusiness; import com.idega.company.data.Company; import com.idega.core.builder.data.ICPage; import com.idega.core.business.DefaultSpringBean; import com.idega.core.data.ICTreeNode; import com.idega.idegaweb.IWApplicationContext; import com.idega.idegaweb.IWMainApplication; import com.idega.idegaweb.IWResourceBundle; import com.idega.presentation.IWContext; import com.idega.user.business.GroupBusiness; import com.idega.user.business.UserBusiness; import com.idega.user.data.Group; import com.idega.user.data.User; import com.idega.user.util.UserComparator; import com.idega.util.CoreConstants; import com.idega.util.CoreUtil; import com.idega.util.ListUtil; import com.idega.util.StringUtil; import com.idega.util.expression.ELUtil; package is.idega.idegaweb.egov.company.business; @Scope(BeanDefinition.SCOPE_SINGLETON) @Service(CompanyPortalBusiness.SPRING_BEAN_IDENTIFIER) public class CompanyPortalBusinessBean extends DefaultSpringBean implements CompanyPortalBusiness { private static final Logger logger = Logger.getLogger(CompanyPortalBusinessBean.class.getName()); @Override public Group getCompanyPortalRootGroup(IWApplicationContext iwac) throws RemoteException {
Collection<Group> groups = getGroupBusiness(iwac).getGroupsByGroupName(EgovCompanyConstants.COMPANY_PORTAL_ROOT_GROUP);
idega/is.idega.idegaweb.egov.company
src/java/is/idega/idegaweb/egov/company/business/CompanyPortalBusinessBean.java
// Path: src/java/is/idega/idegaweb/egov/company/EgovCompanyConstants.java // public class EgovCompanyConstants { // // private EgovCompanyConstants() {} // // public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.company"; // // public static final String COMPANY_SUPER_ADMIN_ROLE = "company_super_admin"; // public static final String COMPANY_ADMIN_ROLE = "company_admin"; // public static final String COMPANY_EMPLOYEE_ROLE = "company_staff"; // // public static final List<String> ALL_COMPANY_ROLES = Collections.unmodifiableList(Arrays.asList( // StandardRoles.ROLE_KEY_COMPANY, // COMPANY_SUPER_ADMIN_ROLE, // COMPANY_ADMIN_ROLE, // COMPANY_EMPLOYEE_ROLE // )); // // public static final String GROUP_TYPE_COMPANY_ADMINS = "iw_company_admins_group"; // public static final String GROUP_TYPE_COMPANY_STAFF = "iw_company_staff_group"; // public static final List<String> ALL_COMPANY_TYPES = Collections.unmodifiableList(Arrays.asList( // CompanyConstants.GROUP_TYPE_COMPANY, // GROUP_TYPE_COMPANY_ADMINS, // GROUP_TYPE_COMPANY_STAFF // )); // // public static final String CASE_CODE_KEY = "COMPORT"; // // public static final String CONTENT_CODE_REQUEST_INFORMATION = "prm_company_code_request_information"; // // public static final Integer APPLICATION_TYPE_APPROVED = 0; // public static final Integer APPLICATION_TYPE_REJECTED = 1; // public static final Integer APPLICATION_TYPE_UNHANDLED = 2; // // public static final String USER_LOGIN_METADATA = "userLoginEnabledMetaDataForCompanyPortal"; // // public static final String COMPANY_PORTAL_ROOT_GROUP = "Company Portal"; // public static final String COMPANY_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Admins"; // public static final String COMPANY_SUPER_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Super Admins"; // // public static final String COMPANY_PORTAL_HOME_PAGE_APPLICATION_PROPERTY = "companyPortalHomePage"; // public static final String COMPANY_STAFF_HOME_PAGE_APPLICATION_PROPERTY = "companyStaffHomePage"; // // public static final String COMPANY_PORTAL_CURRENT_COMPANY_ATTRIBUTE = "companyPortalCurrentCompanyId"; // // public static final String COMPANY_PERSONAL_ID_METADATA = "COMPANY_PERSONAL_ID"; // } // // Path: src/java/is/idega/idegaweb/egov/company/data/CompanyApplication.java // public interface CompanyApplication extends Case, Application { // // public Company getCompany(); // // public void setCompany(Company company); // // public User getAdminUser(); // // public User getApplicantUser(); // // public void setAdminUser(User user); // // public void setApplicantUser(User user); // // public CompanyType getType(); // // public void setType(CompanyType type); // // public String getCaseCodeKey(); // // public ICFile getContract(); // // public void setContract(ICFile contract); // // }
import is.idega.idegaweb.egov.company.EgovCompanyConstants; import is.idega.idegaweb.egov.company.data.CompanyApplication; import java.rmi.RemoteException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.logging.Level; import java.util.logging.Logger; import javax.ejb.EJBException; import javax.ejb.FinderException; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import com.idega.business.IBOLookup; import com.idega.business.IBOLookupException; import com.idega.business.IBORuntimeException; import com.idega.company.CompanyConstants; import com.idega.company.business.CompanyBusiness; import com.idega.company.data.Company; import com.idega.core.builder.data.ICPage; import com.idega.core.business.DefaultSpringBean; import com.idega.core.data.ICTreeNode; import com.idega.idegaweb.IWApplicationContext; import com.idega.idegaweb.IWMainApplication; import com.idega.idegaweb.IWResourceBundle; import com.idega.presentation.IWContext; import com.idega.user.business.GroupBusiness; import com.idega.user.business.UserBusiness; import com.idega.user.data.Group; import com.idega.user.data.User; import com.idega.user.util.UserComparator; import com.idega.util.CoreConstants; import com.idega.util.CoreUtil; import com.idega.util.ListUtil; import com.idega.util.StringUtil; import com.idega.util.expression.ELUtil;
if (ListUtil.isEmpty(allUsers)) { logger.log(Level.WARNING, "No users found in company: " + company); } if (sortUsers) { return getSortedUsers(allUsers, null); } return allUsers; } private List<User> getSortedUsers(List<User> users, Locale locale) { if (ListUtil.isEmpty(users)) { return null; } if (locale == null) { IWContext iwc = CoreUtil.getIWContext(); if (iwc != null) { locale = iwc.getCurrentLocale(); } } if (locale == null) { locale = Locale.ENGLISH; } Collections.sort(users, new UserComparator(locale)); return users; } @Override
// Path: src/java/is/idega/idegaweb/egov/company/EgovCompanyConstants.java // public class EgovCompanyConstants { // // private EgovCompanyConstants() {} // // public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.company"; // // public static final String COMPANY_SUPER_ADMIN_ROLE = "company_super_admin"; // public static final String COMPANY_ADMIN_ROLE = "company_admin"; // public static final String COMPANY_EMPLOYEE_ROLE = "company_staff"; // // public static final List<String> ALL_COMPANY_ROLES = Collections.unmodifiableList(Arrays.asList( // StandardRoles.ROLE_KEY_COMPANY, // COMPANY_SUPER_ADMIN_ROLE, // COMPANY_ADMIN_ROLE, // COMPANY_EMPLOYEE_ROLE // )); // // public static final String GROUP_TYPE_COMPANY_ADMINS = "iw_company_admins_group"; // public static final String GROUP_TYPE_COMPANY_STAFF = "iw_company_staff_group"; // public static final List<String> ALL_COMPANY_TYPES = Collections.unmodifiableList(Arrays.asList( // CompanyConstants.GROUP_TYPE_COMPANY, // GROUP_TYPE_COMPANY_ADMINS, // GROUP_TYPE_COMPANY_STAFF // )); // // public static final String CASE_CODE_KEY = "COMPORT"; // // public static final String CONTENT_CODE_REQUEST_INFORMATION = "prm_company_code_request_information"; // // public static final Integer APPLICATION_TYPE_APPROVED = 0; // public static final Integer APPLICATION_TYPE_REJECTED = 1; // public static final Integer APPLICATION_TYPE_UNHANDLED = 2; // // public static final String USER_LOGIN_METADATA = "userLoginEnabledMetaDataForCompanyPortal"; // // public static final String COMPANY_PORTAL_ROOT_GROUP = "Company Portal"; // public static final String COMPANY_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Admins"; // public static final String COMPANY_SUPER_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Super Admins"; // // public static final String COMPANY_PORTAL_HOME_PAGE_APPLICATION_PROPERTY = "companyPortalHomePage"; // public static final String COMPANY_STAFF_HOME_PAGE_APPLICATION_PROPERTY = "companyStaffHomePage"; // // public static final String COMPANY_PORTAL_CURRENT_COMPANY_ATTRIBUTE = "companyPortalCurrentCompanyId"; // // public static final String COMPANY_PERSONAL_ID_METADATA = "COMPANY_PERSONAL_ID"; // } // // Path: src/java/is/idega/idegaweb/egov/company/data/CompanyApplication.java // public interface CompanyApplication extends Case, Application { // // public Company getCompany(); // // public void setCompany(Company company); // // public User getAdminUser(); // // public User getApplicantUser(); // // public void setAdminUser(User user); // // public void setApplicantUser(User user); // // public CompanyType getType(); // // public void setType(CompanyType type); // // public String getCaseCodeKey(); // // public ICFile getContract(); // // public void setContract(ICFile contract); // // } // Path: src/java/is/idega/idegaweb/egov/company/business/CompanyPortalBusinessBean.java import is.idega.idegaweb.egov.company.EgovCompanyConstants; import is.idega.idegaweb.egov.company.data.CompanyApplication; import java.rmi.RemoteException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.logging.Level; import java.util.logging.Logger; import javax.ejb.EJBException; import javax.ejb.FinderException; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import com.idega.business.IBOLookup; import com.idega.business.IBOLookupException; import com.idega.business.IBORuntimeException; import com.idega.company.CompanyConstants; import com.idega.company.business.CompanyBusiness; import com.idega.company.data.Company; import com.idega.core.builder.data.ICPage; import com.idega.core.business.DefaultSpringBean; import com.idega.core.data.ICTreeNode; import com.idega.idegaweb.IWApplicationContext; import com.idega.idegaweb.IWMainApplication; import com.idega.idegaweb.IWResourceBundle; import com.idega.presentation.IWContext; import com.idega.user.business.GroupBusiness; import com.idega.user.business.UserBusiness; import com.idega.user.data.Group; import com.idega.user.data.User; import com.idega.user.util.UserComparator; import com.idega.util.CoreConstants; import com.idega.util.CoreUtil; import com.idega.util.ListUtil; import com.idega.util.StringUtil; import com.idega.util.expression.ELUtil; if (ListUtil.isEmpty(allUsers)) { logger.log(Level.WARNING, "No users found in company: " + company); } if (sortUsers) { return getSortedUsers(allUsers, null); } return allUsers; } private List<User> getSortedUsers(List<User> users, Locale locale) { if (ListUtil.isEmpty(users)) { return null; } if (locale == null) { IWContext iwc = CoreUtil.getIWContext(); if (iwc != null) { locale = iwc.getCurrentLocale(); } } if (locale == null) { locale = Locale.ENGLISH; } Collections.sort(users, new UserComparator(locale)); return users; } @Override
public List<User> getAllCompanyUsers(CompanyApplication application) {
IBMStreams/streamsx.hdfs
com.ibm.streamsx.hdfs/impl/java/src/com/ibm/streamsx/hdfs/client/AbstractHdfsClient.java
// Path: com.ibm.streamsx.hdfs/impl/java/src/com/ibm/streamsx/hdfs/client/auth/AuthenticationHelperFactory.java // public class AuthenticationHelperFactory { // // public static IAuthenticationHelper createAuthenticationHelper(String hdfsUri, String hdfsUser, String configPath) // throws Exception { // IAuthenticationHelper authHelper = null; // // // if no URI is defined by the user, default to HDFS // if (hdfsUri == null) { // authHelper = new HDFSAuthenticationHelper(configPath); // } else { // String fsType = HDFSOperatorUtils.getFSType(hdfsUri); // if (fsType.equals(IHdfsConstants.FS_WEBHDFS)) { // authHelper = new WebHdfsAuthenticationHelper(configPath); // } else { // // HDFS and GPFS // authHelper = new HDFSAuthenticationHelper(configPath); // } // } // // return authHelper; // } // }
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.HashMap; import java.util.Map; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.PathFilter; import com.ibm.streamsx.hdfs.client.auth.AuthenticationHelperFactory; import com.ibm.streamsx.hdfs.client.auth.IAuthenticationHelper;
/******************************************************************************* * Copyright (C) 2014-2019, International Business Machines Corporation * All Rights Reserved *******************************************************************************/ package com.ibm.streamsx.hdfs.client; abstract class AbstractHdfsClient implements IHdfsClient { public FileSystem fFileSystem; protected boolean fIsDisconnected; protected IAuthenticationHelper fAuthHelper; private HashMap<String, String> fConnectionProperties = new HashMap<String, String>(); @Override public FileSystem connect(String fileSystemUri, String hdfsUser, String configPath) throws Exception {
// Path: com.ibm.streamsx.hdfs/impl/java/src/com/ibm/streamsx/hdfs/client/auth/AuthenticationHelperFactory.java // public class AuthenticationHelperFactory { // // public static IAuthenticationHelper createAuthenticationHelper(String hdfsUri, String hdfsUser, String configPath) // throws Exception { // IAuthenticationHelper authHelper = null; // // // if no URI is defined by the user, default to HDFS // if (hdfsUri == null) { // authHelper = new HDFSAuthenticationHelper(configPath); // } else { // String fsType = HDFSOperatorUtils.getFSType(hdfsUri); // if (fsType.equals(IHdfsConstants.FS_WEBHDFS)) { // authHelper = new WebHdfsAuthenticationHelper(configPath); // } else { // // HDFS and GPFS // authHelper = new HDFSAuthenticationHelper(configPath); // } // } // // return authHelper; // } // } // Path: com.ibm.streamsx.hdfs/impl/java/src/com/ibm/streamsx/hdfs/client/AbstractHdfsClient.java import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.HashMap; import java.util.Map; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.PathFilter; import com.ibm.streamsx.hdfs.client.auth.AuthenticationHelperFactory; import com.ibm.streamsx.hdfs.client.auth.IAuthenticationHelper; /******************************************************************************* * Copyright (C) 2014-2019, International Business Machines Corporation * All Rights Reserved *******************************************************************************/ package com.ibm.streamsx.hdfs.client; abstract class AbstractHdfsClient implements IHdfsClient { public FileSystem fFileSystem; protected boolean fIsDisconnected; protected IAuthenticationHelper fAuthHelper; private HashMap<String, String> fConnectionProperties = new HashMap<String, String>(); @Override public FileSystem connect(String fileSystemUri, String hdfsUser, String configPath) throws Exception {
fAuthHelper = AuthenticationHelperFactory.createAuthenticationHelper(fileSystemUri, hdfsUser, configPath);
IBMStreams/streamsx.hdfs
com.ibm.streamsx.hdfs/impl/java/src/com/ibm/streamsx/hdfs/AbstractHdfsOperator.java
// Path: com.ibm.streamsx.hdfs/impl/java/src/com/ibm/streamsx/hdfs/client/HdfsJavaClient.java // public class HdfsJavaClient extends AbstractHdfsClient { // // private Logger logger = Logger.getLogger("HdfsJavaClient"); // // public HdfsJavaClient() { // } // } // // Path: com.ibm.streamsx.hdfs/impl/java/src/com/ibm/streamsx/hdfs/client/IHdfsClient.java // public interface IHdfsClient { // // public FileSystem connect(String fileSystemUri, String hdfsUser, String configPath) throws Exception; // // public InputStream getInputStream(String filePath) throws IOException; // // public OutputStream getOutputStream(String filePath, boolean append) throws IOException; // // public FileStatus[] scanDirectory(String dirPath, String filter) throws IOException; // // public boolean exists(String filePath) throws IOException; // // public boolean isDirectory(String filePath) throws IOException; // // public long getFileSize(String filename) throws IOException; // // public boolean rename(String src, String dst) throws IOException; // // public boolean delete(String filePath, boolean recursive) throws IOException; // // public void disconnect() throws Exception; // // public void setConnectionProperty(String name, String value); // // public String getConnectionProperty(String name); // // public Map<String, String> getConnectionProperties(); // }
import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.logging.Logger; import java.util.concurrent.TimeUnit; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import com.ibm.json.java.JSONObject; import com.ibm.streams.operator.AbstractOperator; import com.ibm.streams.operator.OperatorContext; import com.ibm.streams.operator.OperatorContext.ContextCheck; import com.ibm.streams.operator.compile.OperatorContextChecker; import com.ibm.streams.operator.logging.LogLevel; import com.ibm.streams.operator.logging.LoggerNames; import com.ibm.streams.operator.logging.TraceLevel; import com.ibm.streams.operator.model.Parameter; import com.ibm.streams.operator.state.StateHandler; import com.ibm.streamsx.hdfs.client.HdfsJavaClient; import com.ibm.streamsx.hdfs.client.IHdfsClient;
/******************************************************************************* * Copyright (C) 2017-2019, International Business Machines Corporation * All Rights Reserved *******************************************************************************/ package com.ibm.streamsx.hdfs; public abstract class AbstractHdfsOperator extends AbstractOperator implements StateHandler { private static final String CLASS_NAME = "com.ibm.streamsx.hdfs.AbstractHdfsOperator"; /** Create a logger specific to this class */ private static Logger LOGGER = Logger.getLogger(LoggerNames.LOG_FACILITY + "." + CLASS_NAME); private static Logger TRACE = Logger.getLogger(CLASS_NAME); // Common parameters and variables for connection
// Path: com.ibm.streamsx.hdfs/impl/java/src/com/ibm/streamsx/hdfs/client/HdfsJavaClient.java // public class HdfsJavaClient extends AbstractHdfsClient { // // private Logger logger = Logger.getLogger("HdfsJavaClient"); // // public HdfsJavaClient() { // } // } // // Path: com.ibm.streamsx.hdfs/impl/java/src/com/ibm/streamsx/hdfs/client/IHdfsClient.java // public interface IHdfsClient { // // public FileSystem connect(String fileSystemUri, String hdfsUser, String configPath) throws Exception; // // public InputStream getInputStream(String filePath) throws IOException; // // public OutputStream getOutputStream(String filePath, boolean append) throws IOException; // // public FileStatus[] scanDirectory(String dirPath, String filter) throws IOException; // // public boolean exists(String filePath) throws IOException; // // public boolean isDirectory(String filePath) throws IOException; // // public long getFileSize(String filename) throws IOException; // // public boolean rename(String src, String dst) throws IOException; // // public boolean delete(String filePath, boolean recursive) throws IOException; // // public void disconnect() throws Exception; // // public void setConnectionProperty(String name, String value); // // public String getConnectionProperty(String name); // // public Map<String, String> getConnectionProperties(); // } // Path: com.ibm.streamsx.hdfs/impl/java/src/com/ibm/streamsx/hdfs/AbstractHdfsOperator.java import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.logging.Logger; import java.util.concurrent.TimeUnit; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import com.ibm.json.java.JSONObject; import com.ibm.streams.operator.AbstractOperator; import com.ibm.streams.operator.OperatorContext; import com.ibm.streams.operator.OperatorContext.ContextCheck; import com.ibm.streams.operator.compile.OperatorContextChecker; import com.ibm.streams.operator.logging.LogLevel; import com.ibm.streams.operator.logging.LoggerNames; import com.ibm.streams.operator.logging.TraceLevel; import com.ibm.streams.operator.model.Parameter; import com.ibm.streams.operator.state.StateHandler; import com.ibm.streamsx.hdfs.client.HdfsJavaClient; import com.ibm.streamsx.hdfs.client.IHdfsClient; /******************************************************************************* * Copyright (C) 2017-2019, International Business Machines Corporation * All Rights Reserved *******************************************************************************/ package com.ibm.streamsx.hdfs; public abstract class AbstractHdfsOperator extends AbstractOperator implements StateHandler { private static final String CLASS_NAME = "com.ibm.streamsx.hdfs.AbstractHdfsOperator"; /** Create a logger specific to this class */ private static Logger LOGGER = Logger.getLogger(LoggerNames.LOG_FACILITY + "." + CLASS_NAME); private static Logger TRACE = Logger.getLogger(CLASS_NAME); // Common parameters and variables for connection
private IHdfsClient fHdfsClient;
IBMStreams/streamsx.hdfs
com.ibm.streamsx.hdfs/impl/java/src/com/ibm/streamsx/hdfs/AbstractHdfsOperator.java
// Path: com.ibm.streamsx.hdfs/impl/java/src/com/ibm/streamsx/hdfs/client/HdfsJavaClient.java // public class HdfsJavaClient extends AbstractHdfsClient { // // private Logger logger = Logger.getLogger("HdfsJavaClient"); // // public HdfsJavaClient() { // } // } // // Path: com.ibm.streamsx.hdfs/impl/java/src/com/ibm/streamsx/hdfs/client/IHdfsClient.java // public interface IHdfsClient { // // public FileSystem connect(String fileSystemUri, String hdfsUser, String configPath) throws Exception; // // public InputStream getInputStream(String filePath) throws IOException; // // public OutputStream getOutputStream(String filePath, boolean append) throws IOException; // // public FileStatus[] scanDirectory(String dirPath, String filter) throws IOException; // // public boolean exists(String filePath) throws IOException; // // public boolean isDirectory(String filePath) throws IOException; // // public long getFileSize(String filename) throws IOException; // // public boolean rename(String src, String dst) throws IOException; // // public boolean delete(String filePath, boolean recursive) throws IOException; // // public void disconnect() throws Exception; // // public void setConnectionProperty(String name, String value); // // public String getConnectionProperty(String name); // // public Map<String, String> getConnectionProperties(); // }
import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.logging.Logger; import java.util.concurrent.TimeUnit; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import com.ibm.json.java.JSONObject; import com.ibm.streams.operator.AbstractOperator; import com.ibm.streams.operator.OperatorContext; import com.ibm.streams.operator.OperatorContext.ContextCheck; import com.ibm.streams.operator.compile.OperatorContextChecker; import com.ibm.streams.operator.logging.LogLevel; import com.ibm.streams.operator.logging.LoggerNames; import com.ibm.streams.operator.logging.TraceLevel; import com.ibm.streams.operator.model.Parameter; import com.ibm.streams.operator.state.StateHandler; import com.ibm.streamsx.hdfs.client.HdfsJavaClient; import com.ibm.streamsx.hdfs.client.IHdfsClient;
shutdownRequested = true; if (fHdfsClient != null) { fHdfsClient.disconnect(); } super.shutdown(); } protected Thread createProcessThread() { Thread toReturn = getOperatorContext().getThreadFactory().newThread(new Runnable() { @Override public void run() { try { process(); } catch (Exception e) { LOGGER.log(TraceLevel.ERROR, e.getMessage()); // if we get to the point where we got an exception // here we should rethrow the exception to cause the // operator to shut down. throw new RuntimeException(e); } } }); toReturn.setDaemon(false); return toReturn; } protected IHdfsClient createHdfsClient() throws Exception {
// Path: com.ibm.streamsx.hdfs/impl/java/src/com/ibm/streamsx/hdfs/client/HdfsJavaClient.java // public class HdfsJavaClient extends AbstractHdfsClient { // // private Logger logger = Logger.getLogger("HdfsJavaClient"); // // public HdfsJavaClient() { // } // } // // Path: com.ibm.streamsx.hdfs/impl/java/src/com/ibm/streamsx/hdfs/client/IHdfsClient.java // public interface IHdfsClient { // // public FileSystem connect(String fileSystemUri, String hdfsUser, String configPath) throws Exception; // // public InputStream getInputStream(String filePath) throws IOException; // // public OutputStream getOutputStream(String filePath, boolean append) throws IOException; // // public FileStatus[] scanDirectory(String dirPath, String filter) throws IOException; // // public boolean exists(String filePath) throws IOException; // // public boolean isDirectory(String filePath) throws IOException; // // public long getFileSize(String filename) throws IOException; // // public boolean rename(String src, String dst) throws IOException; // // public boolean delete(String filePath, boolean recursive) throws IOException; // // public void disconnect() throws Exception; // // public void setConnectionProperty(String name, String value); // // public String getConnectionProperty(String name); // // public Map<String, String> getConnectionProperties(); // } // Path: com.ibm.streamsx.hdfs/impl/java/src/com/ibm/streamsx/hdfs/AbstractHdfsOperator.java import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.logging.Logger; import java.util.concurrent.TimeUnit; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import com.ibm.json.java.JSONObject; import com.ibm.streams.operator.AbstractOperator; import com.ibm.streams.operator.OperatorContext; import com.ibm.streams.operator.OperatorContext.ContextCheck; import com.ibm.streams.operator.compile.OperatorContextChecker; import com.ibm.streams.operator.logging.LogLevel; import com.ibm.streams.operator.logging.LoggerNames; import com.ibm.streams.operator.logging.TraceLevel; import com.ibm.streams.operator.model.Parameter; import com.ibm.streams.operator.state.StateHandler; import com.ibm.streamsx.hdfs.client.HdfsJavaClient; import com.ibm.streamsx.hdfs.client.IHdfsClient; shutdownRequested = true; if (fHdfsClient != null) { fHdfsClient.disconnect(); } super.shutdown(); } protected Thread createProcessThread() { Thread toReturn = getOperatorContext().getThreadFactory().newThread(new Runnable() { @Override public void run() { try { process(); } catch (Exception e) { LOGGER.log(TraceLevel.ERROR, e.getMessage()); // if we get to the point where we got an exception // here we should rethrow the exception to cause the // operator to shut down. throw new RuntimeException(e); } } }); toReturn.setDaemon(false); return toReturn; } protected IHdfsClient createHdfsClient() throws Exception {
IHdfsClient client = new HdfsJavaClient();
IBMStreams/streamsx.hdfs
com.ibm.streamsx.hdfs/impl/java/src/com/ibm/streamsx/hdfs/HdfsFile.java
// Path: com.ibm.streamsx.hdfs/impl/java/src/com/ibm/streamsx/hdfs/client/IHdfsClient.java // public interface IHdfsClient { // // public FileSystem connect(String fileSystemUri, String hdfsUser, String configPath) throws Exception; // // public InputStream getInputStream(String filePath) throws IOException; // // public OutputStream getOutputStream(String filePath, boolean append) throws IOException; // // public FileStatus[] scanDirectory(String dirPath, String filter) throws IOException; // // public boolean exists(String filePath) throws IOException; // // public boolean isDirectory(String filePath) throws IOException; // // public long getFileSize(String filename) throws IOException; // // public boolean rename(String src, String dst) throws IOException; // // public boolean delete(String filePath, boolean recursive) throws IOException; // // public void disconnect() throws Exception; // // public void setConnectionProperty(String name, String value); // // public String getConnectionProperty(String name); // // public Map<String, String> getConnectionProperties(); // }
import java.io.IOException; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import com.ibm.streams.operator.OperatorContext; import com.ibm.streams.operator.Tuple; import com.ibm.streams.operator.Type.MetaType; import com.ibm.streams.operator.types.RString; import com.ibm.streamsx.hdfs.client.IHdfsClient;
/******************************************************************************* * Copyright (C) 2014-2019, International Business Machines Corporation * All Rights Reserved *******************************************************************************/ package com.ibm.streamsx.hdfs; enum EnumFileExpirationPolicy { NEVER, SIZE, TUPLECNT, PUNC, TIME } public class HdfsFile {
// Path: com.ibm.streamsx.hdfs/impl/java/src/com/ibm/streamsx/hdfs/client/IHdfsClient.java // public interface IHdfsClient { // // public FileSystem connect(String fileSystemUri, String hdfsUser, String configPath) throws Exception; // // public InputStream getInputStream(String filePath) throws IOException; // // public OutputStream getOutputStream(String filePath, boolean append) throws IOException; // // public FileStatus[] scanDirectory(String dirPath, String filter) throws IOException; // // public boolean exists(String filePath) throws IOException; // // public boolean isDirectory(String filePath) throws IOException; // // public long getFileSize(String filename) throws IOException; // // public boolean rename(String src, String dst) throws IOException; // // public boolean delete(String filePath, boolean recursive) throws IOException; // // public void disconnect() throws Exception; // // public void setConnectionProperty(String name, String value); // // public String getConnectionProperty(String name); // // public Map<String, String> getConnectionProperties(); // } // Path: com.ibm.streamsx.hdfs/impl/java/src/com/ibm/streamsx/hdfs/HdfsFile.java import java.io.IOException; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import com.ibm.streams.operator.OperatorContext; import com.ibm.streams.operator.Tuple; import com.ibm.streams.operator.Type.MetaType; import com.ibm.streams.operator.types.RString; import com.ibm.streamsx.hdfs.client.IHdfsClient; /******************************************************************************* * Copyright (C) 2014-2019, International Business Machines Corporation * All Rights Reserved *******************************************************************************/ package com.ibm.streamsx.hdfs; enum EnumFileExpirationPolicy { NEVER, SIZE, TUPLECNT, PUNC, TIME } public class HdfsFile {
private IHdfsClient fHdfsClient;
IBMStreams/streamsx.hdfs
com.ibm.streamsx.hdfs/impl/java/src/com/ibm/streamsx/hdfs/HDFS2FileSource.java
// Path: com.ibm.streamsx.hdfs/impl/java/src/com/ibm/streamsx/hdfs/client/IHdfsClient.java // public interface IHdfsClient { // // public FileSystem connect(String fileSystemUri, String hdfsUser, String configPath) throws Exception; // // public InputStream getInputStream(String filePath) throws IOException; // // public OutputStream getOutputStream(String filePath, boolean append) throws IOException; // // public FileStatus[] scanDirectory(String dirPath, String filter) throws IOException; // // public boolean exists(String filePath) throws IOException; // // public boolean isDirectory(String filePath) throws IOException; // // public long getFileSize(String filename) throws IOException; // // public boolean rename(String src, String dst) throws IOException; // // public boolean delete(String filePath, boolean recursive) throws IOException; // // public void disconnect() throws Exception; // // public void setConnectionProperty(String name, String value); // // public String getConnectionProperty(String name); // // public Map<String, String> getConnectionProperties(); // }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.logging.Logger; import org.apache.hadoop.fs.FSDataInputStream; import com.ibm.streams.operator.OperatorContext; import com.ibm.streams.operator.OperatorContext.ContextCheck; import com.ibm.streams.operator.OutputTuple; import com.ibm.streams.operator.StreamSchema; import com.ibm.streams.operator.StreamingData.Punctuation; import com.ibm.streams.operator.StreamingInput; import com.ibm.streams.operator.StreamingOutput; import com.ibm.streams.operator.Tuple; import com.ibm.streams.operator.Type.MetaType; import com.ibm.streams.operator.compile.OperatorContextChecker; import com.ibm.streams.operator.logging.LogLevel; import com.ibm.streams.operator.logging.LoggerNames; import com.ibm.streams.operator.logging.TraceLevel; import com.ibm.streams.operator.metrics.Metric; import com.ibm.streams.operator.model.Icons; import com.ibm.streams.operator.model.InputPortSet; import com.ibm.streams.operator.model.InputPorts; import com.ibm.streams.operator.model.OutputPortSet; import com.ibm.streams.operator.model.OutputPorts; import com.ibm.streams.operator.model.Parameter; import com.ibm.streams.operator.model.PrimitiveOperator; import com.ibm.streams.operator.model.SharedLoader; import com.ibm.streams.operator.state.Checkpoint; import com.ibm.streams.operator.state.ConsistentRegionContext; import com.ibm.streams.operator.state.StateHandler; import com.ibm.streams.operator.types.ValueFactory; import com.ibm.streams.operator.model.InputPortSet.WindowMode; import com.ibm.streams.operator.model.InputPortSet.WindowPunctuationInputMode; import com.ibm.streams.operator.model.OutputPortSet.WindowPunctuationOutputMode; import com.ibm.streamsx.hdfs.client.IHdfsClient;
if (fileUri.getScheme() != null) { // must have the same scheme if (!hdfsUri.getScheme().equals(fileUri.getScheme())) { checker.setInvalidContext(Messages.getString("HDFS_SOURCE_INVALID_SCHEMA", fileUri.getScheme(), hdfsUri.getScheme()), null); return; } // must have the same authority if ((hdfsUri.getAuthority() == null && fileUri.getAuthority() != null) || (hdfsUri .getAuthority() != null && fileUri.getAuthority() == null) || (hdfsUri.getAuthority() != null && fileUri.getAuthority() != null && !hdfsUri.getAuthority().equals(fileUri .getAuthority()))) { checker.setInvalidContext(Messages.getString("HDFS_SOURCE_INVALID_HOST", fileUri.getAuthority(), hdfsUri.getAuthority()), null); return; } } } } private void initMetrics(OperatorContext context) { nOpenedFiles = context.getMetrics().createCustomMetric(FILES_OPENED_METRIC, "Number of opened files ", Metric.Kind.COUNTER); } private void processFile(String filename) throws Exception { if (LOGGER.isLoggable(LogLevel.INFO)) { LOGGER.log(LogLevel.INFO, Messages.getString("HDFS_SOURCE_PROCESS_FILE", filename)); }
// Path: com.ibm.streamsx.hdfs/impl/java/src/com/ibm/streamsx/hdfs/client/IHdfsClient.java // public interface IHdfsClient { // // public FileSystem connect(String fileSystemUri, String hdfsUser, String configPath) throws Exception; // // public InputStream getInputStream(String filePath) throws IOException; // // public OutputStream getOutputStream(String filePath, boolean append) throws IOException; // // public FileStatus[] scanDirectory(String dirPath, String filter) throws IOException; // // public boolean exists(String filePath) throws IOException; // // public boolean isDirectory(String filePath) throws IOException; // // public long getFileSize(String filename) throws IOException; // // public boolean rename(String src, String dst) throws IOException; // // public boolean delete(String filePath, boolean recursive) throws IOException; // // public void disconnect() throws Exception; // // public void setConnectionProperty(String name, String value); // // public String getConnectionProperty(String name); // // public Map<String, String> getConnectionProperties(); // } // Path: com.ibm.streamsx.hdfs/impl/java/src/com/ibm/streamsx/hdfs/HDFS2FileSource.java import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.logging.Logger; import org.apache.hadoop.fs.FSDataInputStream; import com.ibm.streams.operator.OperatorContext; import com.ibm.streams.operator.OperatorContext.ContextCheck; import com.ibm.streams.operator.OutputTuple; import com.ibm.streams.operator.StreamSchema; import com.ibm.streams.operator.StreamingData.Punctuation; import com.ibm.streams.operator.StreamingInput; import com.ibm.streams.operator.StreamingOutput; import com.ibm.streams.operator.Tuple; import com.ibm.streams.operator.Type.MetaType; import com.ibm.streams.operator.compile.OperatorContextChecker; import com.ibm.streams.operator.logging.LogLevel; import com.ibm.streams.operator.logging.LoggerNames; import com.ibm.streams.operator.logging.TraceLevel; import com.ibm.streams.operator.metrics.Metric; import com.ibm.streams.operator.model.Icons; import com.ibm.streams.operator.model.InputPortSet; import com.ibm.streams.operator.model.InputPorts; import com.ibm.streams.operator.model.OutputPortSet; import com.ibm.streams.operator.model.OutputPorts; import com.ibm.streams.operator.model.Parameter; import com.ibm.streams.operator.model.PrimitiveOperator; import com.ibm.streams.operator.model.SharedLoader; import com.ibm.streams.operator.state.Checkpoint; import com.ibm.streams.operator.state.ConsistentRegionContext; import com.ibm.streams.operator.state.StateHandler; import com.ibm.streams.operator.types.ValueFactory; import com.ibm.streams.operator.model.InputPortSet.WindowMode; import com.ibm.streams.operator.model.InputPortSet.WindowPunctuationInputMode; import com.ibm.streams.operator.model.OutputPortSet.WindowPunctuationOutputMode; import com.ibm.streamsx.hdfs.client.IHdfsClient; if (fileUri.getScheme() != null) { // must have the same scheme if (!hdfsUri.getScheme().equals(fileUri.getScheme())) { checker.setInvalidContext(Messages.getString("HDFS_SOURCE_INVALID_SCHEMA", fileUri.getScheme(), hdfsUri.getScheme()), null); return; } // must have the same authority if ((hdfsUri.getAuthority() == null && fileUri.getAuthority() != null) || (hdfsUri .getAuthority() != null && fileUri.getAuthority() == null) || (hdfsUri.getAuthority() != null && fileUri.getAuthority() != null && !hdfsUri.getAuthority().equals(fileUri .getAuthority()))) { checker.setInvalidContext(Messages.getString("HDFS_SOURCE_INVALID_HOST", fileUri.getAuthority(), hdfsUri.getAuthority()), null); return; } } } } private void initMetrics(OperatorContext context) { nOpenedFiles = context.getMetrics().createCustomMetric(FILES_OPENED_METRIC, "Number of opened files ", Metric.Kind.COUNTER); } private void processFile(String filename) throws Exception { if (LOGGER.isLoggable(LogLevel.INFO)) { LOGGER.log(LogLevel.INFO, Messages.getString("HDFS_SOURCE_PROCESS_FILE", filename)); }
IHdfsClient hdfsClient = getHdfsClient();
rgladwell/m2e-android
me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/resolve/HardCodedLibraryResolver.java
// Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/configuration/ProjectConfigurationException.java // public class ProjectConfigurationException extends AndroidMavenException { // // private static final long serialVersionUID = -4510508504367403748L; // // public ProjectConfigurationException(String message) { // super(message); // } // // public ProjectConfigurationException(Throwable cause) { // super(cause); // } // // public ProjectConfigurationException(String message, Throwable cause) { // super(message, cause); // } // // } // // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/Dependency.java // public interface Dependency { // // public String getName(); // // public String getGroup(); // // public String getVersion(); // // public boolean isLibrary(); // // public String getPath(); // }
import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import me.gladwell.eclipse.m2e.android.configuration.ProjectConfigurationException; import me.gladwell.eclipse.m2e.android.project.Dependency; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.model.Model; import org.apache.maven.project.MavenProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.m2e.core.embedder.IMaven; import com.google.inject.Inject;
/******************************************************************************* * Copyright (c) 2013, 2014 Ricardo Gladwell, * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package me.gladwell.eclipse.m2e.android.resolve; @SuppressWarnings("serial") public class HardCodedLibraryResolver implements LibraryResolver {
// Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/configuration/ProjectConfigurationException.java // public class ProjectConfigurationException extends AndroidMavenException { // // private static final long serialVersionUID = -4510508504367403748L; // // public ProjectConfigurationException(String message) { // super(message); // } // // public ProjectConfigurationException(Throwable cause) { // super(cause); // } // // public ProjectConfigurationException(String message, Throwable cause) { // super(message, cause); // } // // } // // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/Dependency.java // public interface Dependency { // // public String getName(); // // public String getGroup(); // // public String getVersion(); // // public boolean isLibrary(); // // public String getPath(); // } // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/resolve/HardCodedLibraryResolver.java import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import me.gladwell.eclipse.m2e.android.configuration.ProjectConfigurationException; import me.gladwell.eclipse.m2e.android.project.Dependency; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.model.Model; import org.apache.maven.project.MavenProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.m2e.core.embedder.IMaven; import com.google.inject.Inject; /******************************************************************************* * Copyright (c) 2013, 2014 Ricardo Gladwell, * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package me.gladwell.eclipse.m2e.android.resolve; @SuppressWarnings("serial") public class HardCodedLibraryResolver implements LibraryResolver {
private static final List<Dependency> DEPENDENCIES_BELOW_2_1_2 = new ArrayList<Dependency>() {{
rgladwell/m2e-android
me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/resolve/HardCodedLibraryResolver.java
// Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/configuration/ProjectConfigurationException.java // public class ProjectConfigurationException extends AndroidMavenException { // // private static final long serialVersionUID = -4510508504367403748L; // // public ProjectConfigurationException(String message) { // super(message); // } // // public ProjectConfigurationException(Throwable cause) { // super(cause); // } // // public ProjectConfigurationException(String message, Throwable cause) { // super(message, cause); // } // // } // // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/Dependency.java // public interface Dependency { // // public String getName(); // // public String getGroup(); // // public String getVersion(); // // public boolean isLibrary(); // // public String getPath(); // }
import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import me.gladwell.eclipse.m2e.android.configuration.ProjectConfigurationException; import me.gladwell.eclipse.m2e.android.project.Dependency; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.model.Model; import org.apache.maven.project.MavenProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.m2e.core.embedder.IMaven; import com.google.inject.Inject;
}}; private final IMaven maven; @Inject public HardCodedLibraryResolver(IMaven maven) { this.maven = maven; } public List<String> resolveLibraries(Dependency dependency, String type, MavenProject project) { List<Dependency> dependenciesForPlatform = getDependenciesForPlatform(dependency, project.getRemoteArtifactRepositories()); List<String> libraries = new ArrayList<String>(); Artifact androidArtifact = resolve(dependency.getGroup(), dependency.getName(), dependency.getVersion(), type, project.getRemoteArtifactRepositories()); libraries.add(androidArtifact.getFile().getAbsolutePath()); for (Dependency platformDependency : dependenciesForPlatform) { Artifact artifact = resolve(platformDependency.getGroup(), platformDependency.getName(), platformDependency.getVersion(), "jar", project.getRemoteArtifactRepositories()); libraries.add(artifact.getFile().getAbsolutePath()); } return libraries; } private List<Dependency> getDependenciesForPlatform(Dependency dependency,
// Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/configuration/ProjectConfigurationException.java // public class ProjectConfigurationException extends AndroidMavenException { // // private static final long serialVersionUID = -4510508504367403748L; // // public ProjectConfigurationException(String message) { // super(message); // } // // public ProjectConfigurationException(Throwable cause) { // super(cause); // } // // public ProjectConfigurationException(String message, Throwable cause) { // super(message, cause); // } // // } // // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/Dependency.java // public interface Dependency { // // public String getName(); // // public String getGroup(); // // public String getVersion(); // // public boolean isLibrary(); // // public String getPath(); // } // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/resolve/HardCodedLibraryResolver.java import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import me.gladwell.eclipse.m2e.android.configuration.ProjectConfigurationException; import me.gladwell.eclipse.m2e.android.project.Dependency; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.model.Model; import org.apache.maven.project.MavenProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.m2e.core.embedder.IMaven; import com.google.inject.Inject; }}; private final IMaven maven; @Inject public HardCodedLibraryResolver(IMaven maven) { this.maven = maven; } public List<String> resolveLibraries(Dependency dependency, String type, MavenProject project) { List<Dependency> dependenciesForPlatform = getDependenciesForPlatform(dependency, project.getRemoteArtifactRepositories()); List<String> libraries = new ArrayList<String>(); Artifact androidArtifact = resolve(dependency.getGroup(), dependency.getName(), dependency.getVersion(), type, project.getRemoteArtifactRepositories()); libraries.add(androidArtifact.getFile().getAbsolutePath()); for (Dependency platformDependency : dependenciesForPlatform) { Artifact artifact = resolve(platformDependency.getGroup(), platformDependency.getName(), platformDependency.getVersion(), "jar", project.getRemoteArtifactRepositories()); libraries.add(artifact.getFile().getAbsolutePath()); } return libraries; } private List<Dependency> getDependenciesForPlatform(Dependency dependency,
List<ArtifactRepository> artifactRepositories) throws ProjectConfigurationException {
rgladwell/m2e-android
me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/configuration/DependencyNotFoundInWorkspace.java
// Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/Dependency.java // public interface Dependency { // // public String getName(); // // public String getGroup(); // // public String getVersion(); // // public boolean isLibrary(); // // public String getPath(); // }
import me.gladwell.eclipse.m2e.android.AndroidMavenPlugin; import me.gladwell.eclipse.m2e.android.project.Dependency;
/******************************************************************************* * Copyright (c) 2012 Ricardo Gladwell * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package me.gladwell.eclipse.m2e.android.configuration; public class DependencyNotFoundInWorkspace extends ProjectConfigurationError { private static final long serialVersionUID = -3959048624226951719L;
// Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/Dependency.java // public interface Dependency { // // public String getName(); // // public String getGroup(); // // public String getVersion(); // // public boolean isLibrary(); // // public String getPath(); // } // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/configuration/DependencyNotFoundInWorkspace.java import me.gladwell.eclipse.m2e.android.AndroidMavenPlugin; import me.gladwell.eclipse.m2e.android.project.Dependency; /******************************************************************************* * Copyright (c) 2012 Ricardo Gladwell * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package me.gladwell.eclipse.m2e.android.configuration; public class DependencyNotFoundInWorkspace extends ProjectConfigurationError { private static final long serialVersionUID = -3959048624226951719L;
public DependencyNotFoundInWorkspace(Dependency dependency) {
rgladwell/m2e-android
me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/configuration/workspace/FixerWorkspaceConfigurer.java
// Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/IDEAndroidProject.java // public interface IDEAndroidProject { // // public boolean isAndroidProject(); // // public boolean isLibrary(); // // public IProject getProject(); // // public void setAndroidProject(boolean androidProject); // // public void setLibrary(boolean isLibrary); // // public void setLibraryDependencies(List<IDEAndroidProject> dependencies); // // public void fixProject(); // // public boolean isMavenised(); // // public IFile getPom(); // // public void setAssetsDirectory(File file); // // public void setResourceFolder(File resourceDirectory); // // public void setAndroidManifest(File androidManifestFile); // // public Classpath getClasspath(); // // public boolean shouldResolveWorkspaceProjects(); // // public String getPath(); // // public void orderBuilders(); // // } // // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/MavenAndroidProject.java // public interface MavenAndroidProject { // // public String getName(); // // public String getGroup(); // // public String getVersion(); // // public boolean isAndroidProject(); // // public boolean isLibrary(); // // public List<Dependency> getNonRuntimeDependencies(); // // public List<Dependency> getLibraryDependencies(); // // public File getAssetsDirectory(); // // public File getResourceFolder(); // // public File getAndroidManifestFile(); // // public File getDestinationManifestFile(); // // public List<String> getPlatformProvidedDependencies(); // // public List<String> getSourcePaths(); // // public String getOutputDirectory(); // // public boolean isIgnoreOptionalWarningsInGenFolder(); // // public List<String> getTestSourcePaths(); // // public List<String> getResourcePaths(); // // public List<String> getTestResourcePaths(); // // }
import me.gladwell.eclipse.m2e.android.project.IDEAndroidProject; import me.gladwell.eclipse.m2e.android.project.MavenAndroidProject;
/******************************************************************************* * Copyright (c) 2012 Ricardo Gladwell * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package me.gladwell.eclipse.m2e.android.configuration.workspace; public class FixerWorkspaceConfigurer implements WorkspaceConfigurer { public boolean isConfigured(IDEAndroidProject project) { return false; }
// Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/IDEAndroidProject.java // public interface IDEAndroidProject { // // public boolean isAndroidProject(); // // public boolean isLibrary(); // // public IProject getProject(); // // public void setAndroidProject(boolean androidProject); // // public void setLibrary(boolean isLibrary); // // public void setLibraryDependencies(List<IDEAndroidProject> dependencies); // // public void fixProject(); // // public boolean isMavenised(); // // public IFile getPom(); // // public void setAssetsDirectory(File file); // // public void setResourceFolder(File resourceDirectory); // // public void setAndroidManifest(File androidManifestFile); // // public Classpath getClasspath(); // // public boolean shouldResolveWorkspaceProjects(); // // public String getPath(); // // public void orderBuilders(); // // } // // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/MavenAndroidProject.java // public interface MavenAndroidProject { // // public String getName(); // // public String getGroup(); // // public String getVersion(); // // public boolean isAndroidProject(); // // public boolean isLibrary(); // // public List<Dependency> getNonRuntimeDependencies(); // // public List<Dependency> getLibraryDependencies(); // // public File getAssetsDirectory(); // // public File getResourceFolder(); // // public File getAndroidManifestFile(); // // public File getDestinationManifestFile(); // // public List<String> getPlatformProvidedDependencies(); // // public List<String> getSourcePaths(); // // public String getOutputDirectory(); // // public boolean isIgnoreOptionalWarningsInGenFolder(); // // public List<String> getTestSourcePaths(); // // public List<String> getResourcePaths(); // // public List<String> getTestResourcePaths(); // // } // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/configuration/workspace/FixerWorkspaceConfigurer.java import me.gladwell.eclipse.m2e.android.project.IDEAndroidProject; import me.gladwell.eclipse.m2e.android.project.MavenAndroidProject; /******************************************************************************* * Copyright (c) 2012 Ricardo Gladwell * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package me.gladwell.eclipse.m2e.android.configuration.workspace; public class FixerWorkspaceConfigurer implements WorkspaceConfigurer { public boolean isConfigured(IDEAndroidProject project) { return false; }
public boolean isValid(MavenAndroidProject project) {
rgladwell/m2e-android
me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/AndroidMavenLaunchConfigurationListener.java
// Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/Log.java // public static void debug(String message) { // if(DEBUG) { // log.log(status(Status.INFO, "[DEBUG] " + message)); // } // } // // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/IDEAndroidProject.java // public interface IDEAndroidProject { // // public boolean isAndroidProject(); // // public boolean isLibrary(); // // public IProject getProject(); // // public void setAndroidProject(boolean androidProject); // // public void setLibrary(boolean isLibrary); // // public void setLibraryDependencies(List<IDEAndroidProject> dependencies); // // public void fixProject(); // // public boolean isMavenised(); // // public IFile getPom(); // // public void setAssetsDirectory(File file); // // public void setResourceFolder(File resourceDirectory); // // public void setAndroidManifest(File androidManifestFile); // // public Classpath getClasspath(); // // public boolean shouldResolveWorkspaceProjects(); // // public String getPath(); // // public void orderBuilders(); // // } // // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/IDEAndroidProjectFactory.java // public interface IDEAndroidProjectFactory extends AndroidProjectFactory<IDEAndroidProject, IProject> { // // public IDEAndroidProject createAndroidProject(IProject target); // // public IDEAndroidProject createAndroidProject(IProject target, IClasspathDescriptor classpath); // // }
import static org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER; import static org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME; import static org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER; import static me.gladwell.eclipse.m2e.android.Log.debug; import java.util.ArrayList; import java.util.List; import me.gladwell.eclipse.m2e.android.project.IDEAndroidProject; import me.gladwell.eclipse.m2e.android.project.IDEAndroidProjectFactory; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.WorkspaceJob; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationListener; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchManager; import org.eclipse.m2e.core.internal.IMavenConstants; import org.eclipse.m2e.core.project.IMavenProjectChangedListener; import org.eclipse.m2e.core.project.MavenProjectChangedEvent; import com.google.inject.Inject;
/******************************************************************************* * Copyright (c) 2014, 2015 Ricardo Gladwell * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package me.gladwell.eclipse.m2e.android; public class AndroidMavenLaunchConfigurationListener implements ILaunchConfigurationListener, IMavenProjectChangedListener { private static final String ANDROID_TEST_CLASSPATH_PROVIDER = "me.gladwell.m2e.android.classpathProvider"; private static final String ANDROID_TEST_SOURCEPATH_PROVIDER = "me.gladwell.m2e.android.sourcepathProvider";
// Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/Log.java // public static void debug(String message) { // if(DEBUG) { // log.log(status(Status.INFO, "[DEBUG] " + message)); // } // } // // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/IDEAndroidProject.java // public interface IDEAndroidProject { // // public boolean isAndroidProject(); // // public boolean isLibrary(); // // public IProject getProject(); // // public void setAndroidProject(boolean androidProject); // // public void setLibrary(boolean isLibrary); // // public void setLibraryDependencies(List<IDEAndroidProject> dependencies); // // public void fixProject(); // // public boolean isMavenised(); // // public IFile getPom(); // // public void setAssetsDirectory(File file); // // public void setResourceFolder(File resourceDirectory); // // public void setAndroidManifest(File androidManifestFile); // // public Classpath getClasspath(); // // public boolean shouldResolveWorkspaceProjects(); // // public String getPath(); // // public void orderBuilders(); // // } // // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/IDEAndroidProjectFactory.java // public interface IDEAndroidProjectFactory extends AndroidProjectFactory<IDEAndroidProject, IProject> { // // public IDEAndroidProject createAndroidProject(IProject target); // // public IDEAndroidProject createAndroidProject(IProject target, IClasspathDescriptor classpath); // // } // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/AndroidMavenLaunchConfigurationListener.java import static org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER; import static org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME; import static org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER; import static me.gladwell.eclipse.m2e.android.Log.debug; import java.util.ArrayList; import java.util.List; import me.gladwell.eclipse.m2e.android.project.IDEAndroidProject; import me.gladwell.eclipse.m2e.android.project.IDEAndroidProjectFactory; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.WorkspaceJob; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationListener; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchManager; import org.eclipse.m2e.core.internal.IMavenConstants; import org.eclipse.m2e.core.project.IMavenProjectChangedListener; import org.eclipse.m2e.core.project.MavenProjectChangedEvent; import com.google.inject.Inject; /******************************************************************************* * Copyright (c) 2014, 2015 Ricardo Gladwell * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package me.gladwell.eclipse.m2e.android; public class AndroidMavenLaunchConfigurationListener implements ILaunchConfigurationListener, IMavenProjectChangedListener { private static final String ANDROID_TEST_CLASSPATH_PROVIDER = "me.gladwell.m2e.android.classpathProvider"; private static final String ANDROID_TEST_SOURCEPATH_PROVIDER = "me.gladwell.m2e.android.sourcepathProvider";
private final IDEAndroidProjectFactory factory;
rgladwell/m2e-android
me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/AndroidMavenLaunchConfigurationListener.java
// Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/Log.java // public static void debug(String message) { // if(DEBUG) { // log.log(status(Status.INFO, "[DEBUG] " + message)); // } // } // // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/IDEAndroidProject.java // public interface IDEAndroidProject { // // public boolean isAndroidProject(); // // public boolean isLibrary(); // // public IProject getProject(); // // public void setAndroidProject(boolean androidProject); // // public void setLibrary(boolean isLibrary); // // public void setLibraryDependencies(List<IDEAndroidProject> dependencies); // // public void fixProject(); // // public boolean isMavenised(); // // public IFile getPom(); // // public void setAssetsDirectory(File file); // // public void setResourceFolder(File resourceDirectory); // // public void setAndroidManifest(File androidManifestFile); // // public Classpath getClasspath(); // // public boolean shouldResolveWorkspaceProjects(); // // public String getPath(); // // public void orderBuilders(); // // } // // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/IDEAndroidProjectFactory.java // public interface IDEAndroidProjectFactory extends AndroidProjectFactory<IDEAndroidProject, IProject> { // // public IDEAndroidProject createAndroidProject(IProject target); // // public IDEAndroidProject createAndroidProject(IProject target, IClasspathDescriptor classpath); // // }
import static org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER; import static org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME; import static org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER; import static me.gladwell.eclipse.m2e.android.Log.debug; import java.util.ArrayList; import java.util.List; import me.gladwell.eclipse.m2e.android.project.IDEAndroidProject; import me.gladwell.eclipse.m2e.android.project.IDEAndroidProjectFactory; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.WorkspaceJob; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationListener; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchManager; import org.eclipse.m2e.core.internal.IMavenConstants; import org.eclipse.m2e.core.project.IMavenProjectChangedListener; import org.eclipse.m2e.core.project.MavenProjectChangedEvent; import com.google.inject.Inject;
/******************************************************************************* * Copyright (c) 2014, 2015 Ricardo Gladwell * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package me.gladwell.eclipse.m2e.android; public class AndroidMavenLaunchConfigurationListener implements ILaunchConfigurationListener, IMavenProjectChangedListener { private static final String ANDROID_TEST_CLASSPATH_PROVIDER = "me.gladwell.m2e.android.classpathProvider"; private static final String ANDROID_TEST_SOURCEPATH_PROVIDER = "me.gladwell.m2e.android.sourcepathProvider"; private final IDEAndroidProjectFactory factory; @Inject public AndroidMavenLaunchConfigurationListener(IDEAndroidProjectFactory factory) { this.factory = factory; } public void launchConfigurationAdded(ILaunchConfiguration configuration) { updateLaunchConfiguration(configuration); } public void launchConfigurationChanged(ILaunchConfiguration configuration) { updateLaunchConfiguration(configuration); } public void launchConfigurationRemoved(ILaunchConfiguration configuration) { } private void updateLaunchConfiguration(ILaunchConfiguration configuration) { try { String projectName = configuration.getAttribute(ATTR_PROJECT_NAME, (String) null); if (projectName == null) {
// Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/Log.java // public static void debug(String message) { // if(DEBUG) { // log.log(status(Status.INFO, "[DEBUG] " + message)); // } // } // // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/IDEAndroidProject.java // public interface IDEAndroidProject { // // public boolean isAndroidProject(); // // public boolean isLibrary(); // // public IProject getProject(); // // public void setAndroidProject(boolean androidProject); // // public void setLibrary(boolean isLibrary); // // public void setLibraryDependencies(List<IDEAndroidProject> dependencies); // // public void fixProject(); // // public boolean isMavenised(); // // public IFile getPom(); // // public void setAssetsDirectory(File file); // // public void setResourceFolder(File resourceDirectory); // // public void setAndroidManifest(File androidManifestFile); // // public Classpath getClasspath(); // // public boolean shouldResolveWorkspaceProjects(); // // public String getPath(); // // public void orderBuilders(); // // } // // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/IDEAndroidProjectFactory.java // public interface IDEAndroidProjectFactory extends AndroidProjectFactory<IDEAndroidProject, IProject> { // // public IDEAndroidProject createAndroidProject(IProject target); // // public IDEAndroidProject createAndroidProject(IProject target, IClasspathDescriptor classpath); // // } // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/AndroidMavenLaunchConfigurationListener.java import static org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER; import static org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME; import static org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER; import static me.gladwell.eclipse.m2e.android.Log.debug; import java.util.ArrayList; import java.util.List; import me.gladwell.eclipse.m2e.android.project.IDEAndroidProject; import me.gladwell.eclipse.m2e.android.project.IDEAndroidProjectFactory; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.WorkspaceJob; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationListener; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchManager; import org.eclipse.m2e.core.internal.IMavenConstants; import org.eclipse.m2e.core.project.IMavenProjectChangedListener; import org.eclipse.m2e.core.project.MavenProjectChangedEvent; import com.google.inject.Inject; /******************************************************************************* * Copyright (c) 2014, 2015 Ricardo Gladwell * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package me.gladwell.eclipse.m2e.android; public class AndroidMavenLaunchConfigurationListener implements ILaunchConfigurationListener, IMavenProjectChangedListener { private static final String ANDROID_TEST_CLASSPATH_PROVIDER = "me.gladwell.m2e.android.classpathProvider"; private static final String ANDROID_TEST_SOURCEPATH_PROVIDER = "me.gladwell.m2e.android.sourcepathProvider"; private final IDEAndroidProjectFactory factory; @Inject public AndroidMavenLaunchConfigurationListener(IDEAndroidProjectFactory factory) { this.factory = factory; } public void launchConfigurationAdded(ILaunchConfiguration configuration) { updateLaunchConfiguration(configuration); } public void launchConfigurationChanged(ILaunchConfiguration configuration) { updateLaunchConfiguration(configuration); } public void launchConfigurationRemoved(ILaunchConfiguration configuration) { } private void updateLaunchConfiguration(ILaunchConfiguration configuration) { try { String projectName = configuration.getAttribute(ATTR_PROJECT_NAME, (String) null); if (projectName == null) {
debug("Cannot update launch configuration because projectName is null.");
rgladwell/m2e-android
me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/AndroidMavenLaunchConfigurationListener.java
// Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/Log.java // public static void debug(String message) { // if(DEBUG) { // log.log(status(Status.INFO, "[DEBUG] " + message)); // } // } // // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/IDEAndroidProject.java // public interface IDEAndroidProject { // // public boolean isAndroidProject(); // // public boolean isLibrary(); // // public IProject getProject(); // // public void setAndroidProject(boolean androidProject); // // public void setLibrary(boolean isLibrary); // // public void setLibraryDependencies(List<IDEAndroidProject> dependencies); // // public void fixProject(); // // public boolean isMavenised(); // // public IFile getPom(); // // public void setAssetsDirectory(File file); // // public void setResourceFolder(File resourceDirectory); // // public void setAndroidManifest(File androidManifestFile); // // public Classpath getClasspath(); // // public boolean shouldResolveWorkspaceProjects(); // // public String getPath(); // // public void orderBuilders(); // // } // // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/IDEAndroidProjectFactory.java // public interface IDEAndroidProjectFactory extends AndroidProjectFactory<IDEAndroidProject, IProject> { // // public IDEAndroidProject createAndroidProject(IProject target); // // public IDEAndroidProject createAndroidProject(IProject target, IClasspathDescriptor classpath); // // }
import static org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER; import static org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME; import static org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER; import static me.gladwell.eclipse.m2e.android.Log.debug; import java.util.ArrayList; import java.util.List; import me.gladwell.eclipse.m2e.android.project.IDEAndroidProject; import me.gladwell.eclipse.m2e.android.project.IDEAndroidProjectFactory; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.WorkspaceJob; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationListener; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchManager; import org.eclipse.m2e.core.internal.IMavenConstants; import org.eclipse.m2e.core.project.IMavenProjectChangedListener; import org.eclipse.m2e.core.project.MavenProjectChangedEvent; import com.google.inject.Inject;
/******************************************************************************* * Copyright (c) 2014, 2015 Ricardo Gladwell * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package me.gladwell.eclipse.m2e.android; public class AndroidMavenLaunchConfigurationListener implements ILaunchConfigurationListener, IMavenProjectChangedListener { private static final String ANDROID_TEST_CLASSPATH_PROVIDER = "me.gladwell.m2e.android.classpathProvider"; private static final String ANDROID_TEST_SOURCEPATH_PROVIDER = "me.gladwell.m2e.android.sourcepathProvider"; private final IDEAndroidProjectFactory factory; @Inject public AndroidMavenLaunchConfigurationListener(IDEAndroidProjectFactory factory) { this.factory = factory; } public void launchConfigurationAdded(ILaunchConfiguration configuration) { updateLaunchConfiguration(configuration); } public void launchConfigurationChanged(ILaunchConfiguration configuration) { updateLaunchConfiguration(configuration); } public void launchConfigurationRemoved(ILaunchConfiguration configuration) { } private void updateLaunchConfiguration(ILaunchConfiguration configuration) { try { String projectName = configuration.getAttribute(ATTR_PROJECT_NAME, (String) null); if (projectName == null) { debug("Cannot update launch configuration because projectName is null."); return; } IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
// Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/Log.java // public static void debug(String message) { // if(DEBUG) { // log.log(status(Status.INFO, "[DEBUG] " + message)); // } // } // // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/IDEAndroidProject.java // public interface IDEAndroidProject { // // public boolean isAndroidProject(); // // public boolean isLibrary(); // // public IProject getProject(); // // public void setAndroidProject(boolean androidProject); // // public void setLibrary(boolean isLibrary); // // public void setLibraryDependencies(List<IDEAndroidProject> dependencies); // // public void fixProject(); // // public boolean isMavenised(); // // public IFile getPom(); // // public void setAssetsDirectory(File file); // // public void setResourceFolder(File resourceDirectory); // // public void setAndroidManifest(File androidManifestFile); // // public Classpath getClasspath(); // // public boolean shouldResolveWorkspaceProjects(); // // public String getPath(); // // public void orderBuilders(); // // } // // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/IDEAndroidProjectFactory.java // public interface IDEAndroidProjectFactory extends AndroidProjectFactory<IDEAndroidProject, IProject> { // // public IDEAndroidProject createAndroidProject(IProject target); // // public IDEAndroidProject createAndroidProject(IProject target, IClasspathDescriptor classpath); // // } // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/AndroidMavenLaunchConfigurationListener.java import static org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER; import static org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME; import static org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER; import static me.gladwell.eclipse.m2e.android.Log.debug; import java.util.ArrayList; import java.util.List; import me.gladwell.eclipse.m2e.android.project.IDEAndroidProject; import me.gladwell.eclipse.m2e.android.project.IDEAndroidProjectFactory; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.WorkspaceJob; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationListener; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchManager; import org.eclipse.m2e.core.internal.IMavenConstants; import org.eclipse.m2e.core.project.IMavenProjectChangedListener; import org.eclipse.m2e.core.project.MavenProjectChangedEvent; import com.google.inject.Inject; /******************************************************************************* * Copyright (c) 2014, 2015 Ricardo Gladwell * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package me.gladwell.eclipse.m2e.android; public class AndroidMavenLaunchConfigurationListener implements ILaunchConfigurationListener, IMavenProjectChangedListener { private static final String ANDROID_TEST_CLASSPATH_PROVIDER = "me.gladwell.m2e.android.classpathProvider"; private static final String ANDROID_TEST_SOURCEPATH_PROVIDER = "me.gladwell.m2e.android.sourcepathProvider"; private final IDEAndroidProjectFactory factory; @Inject public AndroidMavenLaunchConfigurationListener(IDEAndroidProjectFactory factory) { this.factory = factory; } public void launchConfigurationAdded(ILaunchConfiguration configuration) { updateLaunchConfiguration(configuration); } public void launchConfigurationChanged(ILaunchConfiguration configuration) { updateLaunchConfiguration(configuration); } public void launchConfigurationRemoved(ILaunchConfiguration configuration) { } private void updateLaunchConfiguration(ILaunchConfiguration configuration) { try { String projectName = configuration.getAttribute(ATTR_PROJECT_NAME, (String) null); if (projectName == null) { debug("Cannot update launch configuration because projectName is null."); return; } IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
IDEAndroidProject eclipseProject = factory.createAndroidProject(project);
rgladwell/m2e-android
me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/configuration/workspace/LinkResourceDirectoryConfigurer.java
// Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/IDEAndroidProject.java // public interface IDEAndroidProject { // // public boolean isAndroidProject(); // // public boolean isLibrary(); // // public IProject getProject(); // // public void setAndroidProject(boolean androidProject); // // public void setLibrary(boolean isLibrary); // // public void setLibraryDependencies(List<IDEAndroidProject> dependencies); // // public void fixProject(); // // public boolean isMavenised(); // // public IFile getPom(); // // public void setAssetsDirectory(File file); // // public void setResourceFolder(File resourceDirectory); // // public void setAndroidManifest(File androidManifestFile); // // public Classpath getClasspath(); // // public boolean shouldResolveWorkspaceProjects(); // // public String getPath(); // // public void orderBuilders(); // // } // // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/MavenAndroidProject.java // public interface MavenAndroidProject { // // public String getName(); // // public String getGroup(); // // public String getVersion(); // // public boolean isAndroidProject(); // // public boolean isLibrary(); // // public List<Dependency> getNonRuntimeDependencies(); // // public List<Dependency> getLibraryDependencies(); // // public File getAssetsDirectory(); // // public File getResourceFolder(); // // public File getAndroidManifestFile(); // // public File getDestinationManifestFile(); // // public List<String> getPlatformProvidedDependencies(); // // public List<String> getSourcePaths(); // // public String getOutputDirectory(); // // public boolean isIgnoreOptionalWarningsInGenFolder(); // // public List<String> getTestSourcePaths(); // // public List<String> getResourcePaths(); // // public List<String> getTestResourcePaths(); // // }
import me.gladwell.eclipse.m2e.android.project.IDEAndroidProject; import me.gladwell.eclipse.m2e.android.project.MavenAndroidProject;
package me.gladwell.eclipse.m2e.android.configuration.workspace; public class LinkResourceDirectoryConfigurer implements WorkspaceConfigurer { public boolean isConfigured(IDEAndroidProject project) { return false; }
// Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/IDEAndroidProject.java // public interface IDEAndroidProject { // // public boolean isAndroidProject(); // // public boolean isLibrary(); // // public IProject getProject(); // // public void setAndroidProject(boolean androidProject); // // public void setLibrary(boolean isLibrary); // // public void setLibraryDependencies(List<IDEAndroidProject> dependencies); // // public void fixProject(); // // public boolean isMavenised(); // // public IFile getPom(); // // public void setAssetsDirectory(File file); // // public void setResourceFolder(File resourceDirectory); // // public void setAndroidManifest(File androidManifestFile); // // public Classpath getClasspath(); // // public boolean shouldResolveWorkspaceProjects(); // // public String getPath(); // // public void orderBuilders(); // // } // // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/MavenAndroidProject.java // public interface MavenAndroidProject { // // public String getName(); // // public String getGroup(); // // public String getVersion(); // // public boolean isAndroidProject(); // // public boolean isLibrary(); // // public List<Dependency> getNonRuntimeDependencies(); // // public List<Dependency> getLibraryDependencies(); // // public File getAssetsDirectory(); // // public File getResourceFolder(); // // public File getAndroidManifestFile(); // // public File getDestinationManifestFile(); // // public List<String> getPlatformProvidedDependencies(); // // public List<String> getSourcePaths(); // // public String getOutputDirectory(); // // public boolean isIgnoreOptionalWarningsInGenFolder(); // // public List<String> getTestSourcePaths(); // // public List<String> getResourcePaths(); // // public List<String> getTestResourcePaths(); // // } // Path: me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/configuration/workspace/LinkResourceDirectoryConfigurer.java import me.gladwell.eclipse.m2e.android.project.IDEAndroidProject; import me.gladwell.eclipse.m2e.android.project.MavenAndroidProject; package me.gladwell.eclipse.m2e.android.configuration.workspace; public class LinkResourceDirectoryConfigurer implements WorkspaceConfigurer { public boolean isConfigured(IDEAndroidProject project) { return false; }
public boolean isValid(MavenAndroidProject project) {