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
|
|---|---|---|---|---|---|---|
gejiaheng/Protein
|
app/src/main/java/com/ge/protein/shot/ShotContract.java
|
// Path: app/src/main/java/com/ge/protein/data/model/Shot.java
// @AutoValue
// public abstract class Shot implements Parcelable {
//
// public abstract long id();
//
// public abstract String title();
//
// @Nullable
// public abstract String description();
//
// public abstract int width();
//
// public abstract int height();
//
// public abstract Images images();
//
// public abstract long views_count();
//
// public abstract long likes_count();
//
// public abstract long comments_count();
//
// public abstract long attachments_count();
//
// public abstract long rebounds_count();
//
// public abstract long buckets_count();
//
// public abstract Date created_at();
//
// public abstract Date updated_at();
//
// public abstract String html_url();
//
// public abstract String attachments_url();
//
// public abstract String buckets_url();
//
// public abstract String comments_url();
//
// public abstract String likes_url();
//
// public abstract String projects_url();
//
// public abstract String rebounds_url();
//
// public abstract boolean animated();
//
// public abstract List<String> tags();
//
// @Nullable
// public abstract User user();
//
// @Nullable
// public abstract Team team();
//
// public abstract Shot withUser(User user);
//
// public abstract Shot withLikesCount(long likes_count);
//
// public static TypeAdapter<Shot> typeAdapter(Gson gson) {
// return new AutoValue_Shot.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void start();
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/BaseView.java
// public interface BaseView<T> {
//
// void setPresenter(T presenter);
//
// Context getContext();
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/SnackbarView.java
// public interface SnackbarView {
//
// void showSnackbar(@StringRes int resId);
//
// void showSnackbar(String message);
// }
|
import com.ge.protein.data.model.Shot;
import com.ge.protein.mvp.BasePresenter;
import com.ge.protein.mvp.BaseView;
import com.ge.protein.mvp.SnackbarView;
|
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.shot;
public interface ShotContract {
interface View extends BaseView<Presenter>, SnackbarView {
|
// Path: app/src/main/java/com/ge/protein/data/model/Shot.java
// @AutoValue
// public abstract class Shot implements Parcelable {
//
// public abstract long id();
//
// public abstract String title();
//
// @Nullable
// public abstract String description();
//
// public abstract int width();
//
// public abstract int height();
//
// public abstract Images images();
//
// public abstract long views_count();
//
// public abstract long likes_count();
//
// public abstract long comments_count();
//
// public abstract long attachments_count();
//
// public abstract long rebounds_count();
//
// public abstract long buckets_count();
//
// public abstract Date created_at();
//
// public abstract Date updated_at();
//
// public abstract String html_url();
//
// public abstract String attachments_url();
//
// public abstract String buckets_url();
//
// public abstract String comments_url();
//
// public abstract String likes_url();
//
// public abstract String projects_url();
//
// public abstract String rebounds_url();
//
// public abstract boolean animated();
//
// public abstract List<String> tags();
//
// @Nullable
// public abstract User user();
//
// @Nullable
// public abstract Team team();
//
// public abstract Shot withUser(User user);
//
// public abstract Shot withLikesCount(long likes_count);
//
// public static TypeAdapter<Shot> typeAdapter(Gson gson) {
// return new AutoValue_Shot.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void start();
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/BaseView.java
// public interface BaseView<T> {
//
// void setPresenter(T presenter);
//
// Context getContext();
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/SnackbarView.java
// public interface SnackbarView {
//
// void showSnackbar(@StringRes int resId);
//
// void showSnackbar(String message);
// }
// Path: app/src/main/java/com/ge/protein/shot/ShotContract.java
import com.ge.protein.data.model.Shot;
import com.ge.protein.mvp.BasePresenter;
import com.ge.protein.mvp.BaseView;
import com.ge.protein.mvp.SnackbarView;
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.shot;
public interface ShotContract {
interface View extends BaseView<Presenter>, SnackbarView {
|
void show(Shot shot);
|
gejiaheng/Protein
|
app/src/main/java/com/ge/protein/shot/ShotContract.java
|
// Path: app/src/main/java/com/ge/protein/data/model/Shot.java
// @AutoValue
// public abstract class Shot implements Parcelable {
//
// public abstract long id();
//
// public abstract String title();
//
// @Nullable
// public abstract String description();
//
// public abstract int width();
//
// public abstract int height();
//
// public abstract Images images();
//
// public abstract long views_count();
//
// public abstract long likes_count();
//
// public abstract long comments_count();
//
// public abstract long attachments_count();
//
// public abstract long rebounds_count();
//
// public abstract long buckets_count();
//
// public abstract Date created_at();
//
// public abstract Date updated_at();
//
// public abstract String html_url();
//
// public abstract String attachments_url();
//
// public abstract String buckets_url();
//
// public abstract String comments_url();
//
// public abstract String likes_url();
//
// public abstract String projects_url();
//
// public abstract String rebounds_url();
//
// public abstract boolean animated();
//
// public abstract List<String> tags();
//
// @Nullable
// public abstract User user();
//
// @Nullable
// public abstract Team team();
//
// public abstract Shot withUser(User user);
//
// public abstract Shot withLikesCount(long likes_count);
//
// public static TypeAdapter<Shot> typeAdapter(Gson gson) {
// return new AutoValue_Shot.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void start();
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/BaseView.java
// public interface BaseView<T> {
//
// void setPresenter(T presenter);
//
// Context getContext();
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/SnackbarView.java
// public interface SnackbarView {
//
// void showSnackbar(@StringRes int resId);
//
// void showSnackbar(String message);
// }
|
import com.ge.protein.data.model.Shot;
import com.ge.protein.mvp.BasePresenter;
import com.ge.protein.mvp.BaseView;
import com.ge.protein.mvp.SnackbarView;
|
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.shot;
public interface ShotContract {
interface View extends BaseView<Presenter>, SnackbarView {
void show(Shot shot);
void setLikeFabVisibility(boolean visible);
void setLikeStatus(boolean like);
void updateLikesCount(String likesCountText);
}
|
// Path: app/src/main/java/com/ge/protein/data/model/Shot.java
// @AutoValue
// public abstract class Shot implements Parcelable {
//
// public abstract long id();
//
// public abstract String title();
//
// @Nullable
// public abstract String description();
//
// public abstract int width();
//
// public abstract int height();
//
// public abstract Images images();
//
// public abstract long views_count();
//
// public abstract long likes_count();
//
// public abstract long comments_count();
//
// public abstract long attachments_count();
//
// public abstract long rebounds_count();
//
// public abstract long buckets_count();
//
// public abstract Date created_at();
//
// public abstract Date updated_at();
//
// public abstract String html_url();
//
// public abstract String attachments_url();
//
// public abstract String buckets_url();
//
// public abstract String comments_url();
//
// public abstract String likes_url();
//
// public abstract String projects_url();
//
// public abstract String rebounds_url();
//
// public abstract boolean animated();
//
// public abstract List<String> tags();
//
// @Nullable
// public abstract User user();
//
// @Nullable
// public abstract Team team();
//
// public abstract Shot withUser(User user);
//
// public abstract Shot withLikesCount(long likes_count);
//
// public static TypeAdapter<Shot> typeAdapter(Gson gson) {
// return new AutoValue_Shot.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void start();
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/BaseView.java
// public interface BaseView<T> {
//
// void setPresenter(T presenter);
//
// Context getContext();
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/SnackbarView.java
// public interface SnackbarView {
//
// void showSnackbar(@StringRes int resId);
//
// void showSnackbar(String message);
// }
// Path: app/src/main/java/com/ge/protein/shot/ShotContract.java
import com.ge.protein.data.model.Shot;
import com.ge.protein.mvp.BasePresenter;
import com.ge.protein.mvp.BaseView;
import com.ge.protein.mvp.SnackbarView;
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.shot;
public interface ShotContract {
interface View extends BaseView<Presenter>, SnackbarView {
void show(Shot shot);
void setLikeFabVisibility(boolean visible);
void setLikeStatus(boolean like);
void updateLikesCount(String likesCountText);
}
|
interface Presenter extends BasePresenter {
|
gejiaheng/Protein
|
app/src/main/java/com/ge/protein/auth/AuthContract.java
|
// Path: app/src/main/java/com/ge/protein/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void start();
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/BaseView.java
// public interface BaseView<T> {
//
// void setPresenter(T presenter);
//
// Context getContext();
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/SnackbarView.java
// public interface SnackbarView {
//
// void showSnackbar(@StringRes int resId);
//
// void showSnackbar(String message);
// }
|
import com.ge.protein.mvp.BasePresenter;
import com.ge.protein.mvp.BaseView;
import com.ge.protein.mvp.SnackbarView;
|
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.auth;
interface AuthContract {
interface View extends BaseView<Presenter>, SnackbarView {
void setProgressDialogVisibility(boolean visible);
}
|
// Path: app/src/main/java/com/ge/protein/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void start();
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/BaseView.java
// public interface BaseView<T> {
//
// void setPresenter(T presenter);
//
// Context getContext();
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/SnackbarView.java
// public interface SnackbarView {
//
// void showSnackbar(@StringRes int resId);
//
// void showSnackbar(String message);
// }
// Path: app/src/main/java/com/ge/protein/auth/AuthContract.java
import com.ge.protein.mvp.BasePresenter;
import com.ge.protein.mvp.BaseView;
import com.ge.protein.mvp.SnackbarView;
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.auth;
interface AuthContract {
interface View extends BaseView<Presenter>, SnackbarView {
void setProgressDialogVisibility(boolean visible);
}
|
interface Presenter extends BasePresenter {
|
gejiaheng/Protein
|
app/src/main/java/com/ge/protein/ui/epoxy/models/ShotCommentModel.java
|
// Path: app/src/main/java/com/ge/protein/data/model/Comment.java
// @AutoValue
// public abstract class Comment implements Parcelable {
//
// public abstract long id();
//
// public abstract String body();
//
// public abstract long likes_count();
//
// public abstract String likes_url();
//
// public abstract String created_at();
//
// public abstract String updated_at();
//
// public abstract User user();
//
// public static TypeAdapter<Comment> typeAdapter(Gson gson) {
// return new AutoValue_Comment.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/ui/epoxy/BaseEpoxyHolder.java
// public abstract class BaseEpoxyHolder extends EpoxyHolder {
// @CallSuper
// @Override
// protected void bindView(View itemView) {
// ButterKnife.bind(this, itemView);
// }
// }
//
// Path: app/src/main/java/com/ge/protein/util/StringUtils.java
// public class StringUtils {
//
// public static CharSequence trimTrailingWhitespace(CharSequence source) {
//
// if (source == null) {
// return "";
// }
//
// int i = source.length();
//
// // loop back to the first non-whitespace character
// while (--i >= 0 && Character.isWhitespace(source.charAt(i))) {
// }
//
// return source.subSequence(0, i + 1);
// }
//
// }
|
import android.text.Html;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModelClass;
import com.airbnb.epoxy.EpoxyModelWithHolder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.TransitionOptions;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.ge.protein.R;
import com.ge.protein.data.model.Comment;
import com.ge.protein.ui.epoxy.BaseEpoxyHolder;
import com.ge.protein.util.StringUtils;
import butterknife.BindView;
|
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.ui.epoxy.models;
@EpoxyModelClass(layout = R.layout.epoxy_shot_comment)
public abstract class ShotCommentModel extends EpoxyModelWithHolder<ShotCommentModel.ShotCommentHolder> {
@EpoxyAttribute
|
// Path: app/src/main/java/com/ge/protein/data/model/Comment.java
// @AutoValue
// public abstract class Comment implements Parcelable {
//
// public abstract long id();
//
// public abstract String body();
//
// public abstract long likes_count();
//
// public abstract String likes_url();
//
// public abstract String created_at();
//
// public abstract String updated_at();
//
// public abstract User user();
//
// public static TypeAdapter<Comment> typeAdapter(Gson gson) {
// return new AutoValue_Comment.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/ui/epoxy/BaseEpoxyHolder.java
// public abstract class BaseEpoxyHolder extends EpoxyHolder {
// @CallSuper
// @Override
// protected void bindView(View itemView) {
// ButterKnife.bind(this, itemView);
// }
// }
//
// Path: app/src/main/java/com/ge/protein/util/StringUtils.java
// public class StringUtils {
//
// public static CharSequence trimTrailingWhitespace(CharSequence source) {
//
// if (source == null) {
// return "";
// }
//
// int i = source.length();
//
// // loop back to the first non-whitespace character
// while (--i >= 0 && Character.isWhitespace(source.charAt(i))) {
// }
//
// return source.subSequence(0, i + 1);
// }
//
// }
// Path: app/src/main/java/com/ge/protein/ui/epoxy/models/ShotCommentModel.java
import android.text.Html;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModelClass;
import com.airbnb.epoxy.EpoxyModelWithHolder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.TransitionOptions;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.ge.protein.R;
import com.ge.protein.data.model.Comment;
import com.ge.protein.ui.epoxy.BaseEpoxyHolder;
import com.ge.protein.util.StringUtils;
import butterknife.BindView;
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.ui.epoxy.models;
@EpoxyModelClass(layout = R.layout.epoxy_shot_comment)
public abstract class ShotCommentModel extends EpoxyModelWithHolder<ShotCommentModel.ShotCommentHolder> {
@EpoxyAttribute
|
Comment comment;
|
gejiaheng/Protein
|
app/src/main/java/com/ge/protein/ui/epoxy/models/ShotCommentModel.java
|
// Path: app/src/main/java/com/ge/protein/data/model/Comment.java
// @AutoValue
// public abstract class Comment implements Parcelable {
//
// public abstract long id();
//
// public abstract String body();
//
// public abstract long likes_count();
//
// public abstract String likes_url();
//
// public abstract String created_at();
//
// public abstract String updated_at();
//
// public abstract User user();
//
// public static TypeAdapter<Comment> typeAdapter(Gson gson) {
// return new AutoValue_Comment.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/ui/epoxy/BaseEpoxyHolder.java
// public abstract class BaseEpoxyHolder extends EpoxyHolder {
// @CallSuper
// @Override
// protected void bindView(View itemView) {
// ButterKnife.bind(this, itemView);
// }
// }
//
// Path: app/src/main/java/com/ge/protein/util/StringUtils.java
// public class StringUtils {
//
// public static CharSequence trimTrailingWhitespace(CharSequence source) {
//
// if (source == null) {
// return "";
// }
//
// int i = source.length();
//
// // loop back to the first non-whitespace character
// while (--i >= 0 && Character.isWhitespace(source.charAt(i))) {
// }
//
// return source.subSequence(0, i + 1);
// }
//
// }
|
import android.text.Html;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModelClass;
import com.airbnb.epoxy.EpoxyModelWithHolder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.TransitionOptions;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.ge.protein.R;
import com.ge.protein.data.model.Comment;
import com.ge.protein.ui.epoxy.BaseEpoxyHolder;
import com.ge.protein.util.StringUtils;
import butterknife.BindView;
|
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.ui.epoxy.models;
@EpoxyModelClass(layout = R.layout.epoxy_shot_comment)
public abstract class ShotCommentModel extends EpoxyModelWithHolder<ShotCommentModel.ShotCommentHolder> {
@EpoxyAttribute
Comment comment;
@EpoxyAttribute
View.OnClickListener shotCommentOnClickListener;
private TransitionOptions transitionOptions = DrawableTransitionOptions.withCrossFade();
private RequestOptions requestOptions = RequestOptions.placeholderOf(R.color.avatar_placeholder)
.diskCacheStrategy(DiskCacheStrategy.ALL);
@Override
protected ShotCommentHolder createNewHolder() {
return new ShotCommentHolder();
}
@Override
public void bind(ShotCommentHolder holder) {
super.bind(holder);
Glide.with(holder.avatar.getContext())
.load(comment.user().avatar_url())
.transition(transitionOptions)
.apply(requestOptions)
.into(holder.avatar);
holder.userName.setText(comment.user().name());
holder.commentBody.setText(TextUtils.isEmpty(comment.body()) ?
|
// Path: app/src/main/java/com/ge/protein/data/model/Comment.java
// @AutoValue
// public abstract class Comment implements Parcelable {
//
// public abstract long id();
//
// public abstract String body();
//
// public abstract long likes_count();
//
// public abstract String likes_url();
//
// public abstract String created_at();
//
// public abstract String updated_at();
//
// public abstract User user();
//
// public static TypeAdapter<Comment> typeAdapter(Gson gson) {
// return new AutoValue_Comment.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/ui/epoxy/BaseEpoxyHolder.java
// public abstract class BaseEpoxyHolder extends EpoxyHolder {
// @CallSuper
// @Override
// protected void bindView(View itemView) {
// ButterKnife.bind(this, itemView);
// }
// }
//
// Path: app/src/main/java/com/ge/protein/util/StringUtils.java
// public class StringUtils {
//
// public static CharSequence trimTrailingWhitespace(CharSequence source) {
//
// if (source == null) {
// return "";
// }
//
// int i = source.length();
//
// // loop back to the first non-whitespace character
// while (--i >= 0 && Character.isWhitespace(source.charAt(i))) {
// }
//
// return source.subSequence(0, i + 1);
// }
//
// }
// Path: app/src/main/java/com/ge/protein/ui/epoxy/models/ShotCommentModel.java
import android.text.Html;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModelClass;
import com.airbnb.epoxy.EpoxyModelWithHolder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.TransitionOptions;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.ge.protein.R;
import com.ge.protein.data.model.Comment;
import com.ge.protein.ui.epoxy.BaseEpoxyHolder;
import com.ge.protein.util.StringUtils;
import butterknife.BindView;
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.ui.epoxy.models;
@EpoxyModelClass(layout = R.layout.epoxy_shot_comment)
public abstract class ShotCommentModel extends EpoxyModelWithHolder<ShotCommentModel.ShotCommentHolder> {
@EpoxyAttribute
Comment comment;
@EpoxyAttribute
View.OnClickListener shotCommentOnClickListener;
private TransitionOptions transitionOptions = DrawableTransitionOptions.withCrossFade();
private RequestOptions requestOptions = RequestOptions.placeholderOf(R.color.avatar_placeholder)
.diskCacheStrategy(DiskCacheStrategy.ALL);
@Override
protected ShotCommentHolder createNewHolder() {
return new ShotCommentHolder();
}
@Override
public void bind(ShotCommentHolder holder) {
super.bind(holder);
Glide.with(holder.avatar.getContext())
.load(comment.user().avatar_url())
.transition(transitionOptions)
.apply(requestOptions)
.into(holder.avatar);
holder.userName.setText(comment.user().name());
holder.commentBody.setText(TextUtils.isEmpty(comment.body()) ?
|
"" : StringUtils.trimTrailingWhitespace(Html.fromHtml(comment.body())));
|
gejiaheng/Protein
|
app/src/main/java/com/ge/protein/ui/epoxy/models/ShotCommentModel.java
|
// Path: app/src/main/java/com/ge/protein/data/model/Comment.java
// @AutoValue
// public abstract class Comment implements Parcelable {
//
// public abstract long id();
//
// public abstract String body();
//
// public abstract long likes_count();
//
// public abstract String likes_url();
//
// public abstract String created_at();
//
// public abstract String updated_at();
//
// public abstract User user();
//
// public static TypeAdapter<Comment> typeAdapter(Gson gson) {
// return new AutoValue_Comment.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/ui/epoxy/BaseEpoxyHolder.java
// public abstract class BaseEpoxyHolder extends EpoxyHolder {
// @CallSuper
// @Override
// protected void bindView(View itemView) {
// ButterKnife.bind(this, itemView);
// }
// }
//
// Path: app/src/main/java/com/ge/protein/util/StringUtils.java
// public class StringUtils {
//
// public static CharSequence trimTrailingWhitespace(CharSequence source) {
//
// if (source == null) {
// return "";
// }
//
// int i = source.length();
//
// // loop back to the first non-whitespace character
// while (--i >= 0 && Character.isWhitespace(source.charAt(i))) {
// }
//
// return source.subSequence(0, i + 1);
// }
//
// }
|
import android.text.Html;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModelClass;
import com.airbnb.epoxy.EpoxyModelWithHolder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.TransitionOptions;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.ge.protein.R;
import com.ge.protein.data.model.Comment;
import com.ge.protein.ui.epoxy.BaseEpoxyHolder;
import com.ge.protein.util.StringUtils;
import butterknife.BindView;
|
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.ui.epoxy.models;
@EpoxyModelClass(layout = R.layout.epoxy_shot_comment)
public abstract class ShotCommentModel extends EpoxyModelWithHolder<ShotCommentModel.ShotCommentHolder> {
@EpoxyAttribute
Comment comment;
@EpoxyAttribute
View.OnClickListener shotCommentOnClickListener;
private TransitionOptions transitionOptions = DrawableTransitionOptions.withCrossFade();
private RequestOptions requestOptions = RequestOptions.placeholderOf(R.color.avatar_placeholder)
.diskCacheStrategy(DiskCacheStrategy.ALL);
@Override
protected ShotCommentHolder createNewHolder() {
return new ShotCommentHolder();
}
@Override
public void bind(ShotCommentHolder holder) {
super.bind(holder);
Glide.with(holder.avatar.getContext())
.load(comment.user().avatar_url())
.transition(transitionOptions)
.apply(requestOptions)
.into(holder.avatar);
holder.userName.setText(comment.user().name());
holder.commentBody.setText(TextUtils.isEmpty(comment.body()) ?
"" : StringUtils.trimTrailingWhitespace(Html.fromHtml(comment.body())));
holder.commentBody.setMovementMethod(LinkMovementMethod.getInstance());
holder.avatar.setOnClickListener(shotCommentOnClickListener);
holder.avatar.setTag(R.id.clicked_model, comment.user());
}
|
// Path: app/src/main/java/com/ge/protein/data/model/Comment.java
// @AutoValue
// public abstract class Comment implements Parcelable {
//
// public abstract long id();
//
// public abstract String body();
//
// public abstract long likes_count();
//
// public abstract String likes_url();
//
// public abstract String created_at();
//
// public abstract String updated_at();
//
// public abstract User user();
//
// public static TypeAdapter<Comment> typeAdapter(Gson gson) {
// return new AutoValue_Comment.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/ui/epoxy/BaseEpoxyHolder.java
// public abstract class BaseEpoxyHolder extends EpoxyHolder {
// @CallSuper
// @Override
// protected void bindView(View itemView) {
// ButterKnife.bind(this, itemView);
// }
// }
//
// Path: app/src/main/java/com/ge/protein/util/StringUtils.java
// public class StringUtils {
//
// public static CharSequence trimTrailingWhitespace(CharSequence source) {
//
// if (source == null) {
// return "";
// }
//
// int i = source.length();
//
// // loop back to the first non-whitespace character
// while (--i >= 0 && Character.isWhitespace(source.charAt(i))) {
// }
//
// return source.subSequence(0, i + 1);
// }
//
// }
// Path: app/src/main/java/com/ge/protein/ui/epoxy/models/ShotCommentModel.java
import android.text.Html;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModelClass;
import com.airbnb.epoxy.EpoxyModelWithHolder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.TransitionOptions;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.ge.protein.R;
import com.ge.protein.data.model.Comment;
import com.ge.protein.ui.epoxy.BaseEpoxyHolder;
import com.ge.protein.util.StringUtils;
import butterknife.BindView;
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.ui.epoxy.models;
@EpoxyModelClass(layout = R.layout.epoxy_shot_comment)
public abstract class ShotCommentModel extends EpoxyModelWithHolder<ShotCommentModel.ShotCommentHolder> {
@EpoxyAttribute
Comment comment;
@EpoxyAttribute
View.OnClickListener shotCommentOnClickListener;
private TransitionOptions transitionOptions = DrawableTransitionOptions.withCrossFade();
private RequestOptions requestOptions = RequestOptions.placeholderOf(R.color.avatar_placeholder)
.diskCacheStrategy(DiskCacheStrategy.ALL);
@Override
protected ShotCommentHolder createNewHolder() {
return new ShotCommentHolder();
}
@Override
public void bind(ShotCommentHolder holder) {
super.bind(holder);
Glide.with(holder.avatar.getContext())
.load(comment.user().avatar_url())
.transition(transitionOptions)
.apply(requestOptions)
.into(holder.avatar);
holder.userName.setText(comment.user().name());
holder.commentBody.setText(TextUtils.isEmpty(comment.body()) ?
"" : StringUtils.trimTrailingWhitespace(Html.fromHtml(comment.body())));
holder.commentBody.setMovementMethod(LinkMovementMethod.getInstance());
holder.avatar.setOnClickListener(shotCommentOnClickListener);
holder.avatar.setTag(R.id.clicked_model, comment.user());
}
|
static class ShotCommentHolder extends BaseEpoxyHolder {
|
gejiaheng/Protein
|
app/src/androidTest/java/com/ge/protein/main/MainScreenTest.java
|
// Path: app/src/main/java/com/ge/protein/util/AccountManager.java
// public class AccountManager {
//
// private static AccountManager accountManager = new AccountManager();
// private AccessToken accessToken;
// private User me;
//
// private AccountManager() {
// }
//
// public static AccountManager getInstance() {
// return accountManager;
// }
//
// public AccessToken getAccessToken() {
// return accessToken;
// }
//
// public void setAccessToken(AccessToken accessToken) {
// this.accessToken = accessToken;
// }
//
// public void setAccessToken(String token) {
// accessToken = new GsonBuilder()
// .registerTypeAdapterFactory(ProteinAdapterFactory.create())
// .create()
// .fromJson(token, AccessToken.class);
// }
//
// public boolean isLogin() {
// return accessToken != null;
// }
//
// public User getMe() {
// return me;
// }
//
// public void setMe(User me) {
// this.me = me;
// }
//
// public void clear() {
// accessToken = null;
// me = null;
// }
// }
|
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import android.support.test.filters.LargeTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.ge.protein.R;
import com.ge.protein.util.AccountManager;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.swipeLeft;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isSelected;
|
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.main;
@RunWith(AndroidJUnit4.class)
@LargeTest
public class MainScreenTest {
@Rule
public ActivityTestRule<MainActivity> activityRule = new ActivityTestRule(MainActivity.class);
@Test
public void viewPagerSwipe() {
onView(withId(R.id.view_pager)).perform(swipeLeft());
|
// Path: app/src/main/java/com/ge/protein/util/AccountManager.java
// public class AccountManager {
//
// private static AccountManager accountManager = new AccountManager();
// private AccessToken accessToken;
// private User me;
//
// private AccountManager() {
// }
//
// public static AccountManager getInstance() {
// return accountManager;
// }
//
// public AccessToken getAccessToken() {
// return accessToken;
// }
//
// public void setAccessToken(AccessToken accessToken) {
// this.accessToken = accessToken;
// }
//
// public void setAccessToken(String token) {
// accessToken = new GsonBuilder()
// .registerTypeAdapterFactory(ProteinAdapterFactory.create())
// .create()
// .fromJson(token, AccessToken.class);
// }
//
// public boolean isLogin() {
// return accessToken != null;
// }
//
// public User getMe() {
// return me;
// }
//
// public void setMe(User me) {
// this.me = me;
// }
//
// public void clear() {
// accessToken = null;
// me = null;
// }
// }
// Path: app/src/androidTest/java/com/ge/protein/main/MainScreenTest.java
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import android.support.test.filters.LargeTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.ge.protein.R;
import com.ge.protein.util.AccountManager;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.swipeLeft;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isSelected;
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.main;
@RunWith(AndroidJUnit4.class)
@LargeTest
public class MainScreenTest {
@Rule
public ActivityTestRule<MainActivity> activityRule = new ActivityTestRule(MainActivity.class);
@Test
public void viewPagerSwipe() {
onView(withId(R.id.view_pager)).perform(swipeLeft());
|
if (AccountManager.getInstance().isLogin()) {
|
gejiaheng/Protein
|
app/src/main/java/com/ge/protein/main/MainContract.java
|
// Path: app/src/main/java/com/ge/protein/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void start();
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/BaseView.java
// public interface BaseView<T> {
//
// void setPresenter(T presenter);
//
// Context getContext();
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/User.java
// @AutoValue
// public abstract class User implements Parcelable {
//
// public abstract long id();
//
// public abstract String name();
//
// public abstract String username();
//
// public abstract String html_url();
//
// public abstract String avatar_url();
//
// public abstract String bio();
//
// @Nullable
// public abstract String location();
//
// public abstract Links links();
//
// public abstract long buckets_count();
//
// public abstract long comments_received_count();
//
// public abstract long followers_count();
//
// public abstract long followings_count();
//
// public abstract long likes_count();
//
// public abstract long likes_received_count();
//
// public abstract long projects_count();
//
// public abstract long rebounds_received_count();
//
// public abstract long shots_count();
//
// public abstract long teams_count();
//
// public abstract boolean can_upload_shot();
//
// public abstract String type();
//
// public abstract boolean pro();
//
// public abstract String buckets_url();
//
// public abstract String followers_url();
//
// public abstract String following_url();
//
// public abstract String likes_url();
//
// public abstract String shots_url();
//
// @Nullable
// public abstract String teams_url();
//
// public abstract String created_at();
//
// public abstract String updated_at();
//
// public static TypeAdapter<User> typeAdapter(Gson gson) {
// return new AutoValue_User.GsonTypeAdapter(gson).nullSafe();
// }
// }
|
import com.ge.protein.mvp.BasePresenter;
import com.ge.protein.mvp.BaseView;
import com.ge.protein.data.model.User;
|
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.main;
interface MainContract {
interface View extends BaseView<Presenter> {
void setupView();
void setDefaultUserInfo();
|
// Path: app/src/main/java/com/ge/protein/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void start();
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/BaseView.java
// public interface BaseView<T> {
//
// void setPresenter(T presenter);
//
// Context getContext();
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/User.java
// @AutoValue
// public abstract class User implements Parcelable {
//
// public abstract long id();
//
// public abstract String name();
//
// public abstract String username();
//
// public abstract String html_url();
//
// public abstract String avatar_url();
//
// public abstract String bio();
//
// @Nullable
// public abstract String location();
//
// public abstract Links links();
//
// public abstract long buckets_count();
//
// public abstract long comments_received_count();
//
// public abstract long followers_count();
//
// public abstract long followings_count();
//
// public abstract long likes_count();
//
// public abstract long likes_received_count();
//
// public abstract long projects_count();
//
// public abstract long rebounds_received_count();
//
// public abstract long shots_count();
//
// public abstract long teams_count();
//
// public abstract boolean can_upload_shot();
//
// public abstract String type();
//
// public abstract boolean pro();
//
// public abstract String buckets_url();
//
// public abstract String followers_url();
//
// public abstract String following_url();
//
// public abstract String likes_url();
//
// public abstract String shots_url();
//
// @Nullable
// public abstract String teams_url();
//
// public abstract String created_at();
//
// public abstract String updated_at();
//
// public static TypeAdapter<User> typeAdapter(Gson gson) {
// return new AutoValue_User.GsonTypeAdapter(gson).nullSafe();
// }
// }
// Path: app/src/main/java/com/ge/protein/main/MainContract.java
import com.ge.protein.mvp.BasePresenter;
import com.ge.protein.mvp.BaseView;
import com.ge.protein.data.model.User;
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.main;
interface MainContract {
interface View extends BaseView<Presenter> {
void setupView();
void setDefaultUserInfo();
|
void setUserInfo(User user);
|
gejiaheng/Protein
|
app/src/main/java/com/ge/protein/main/MainContract.java
|
// Path: app/src/main/java/com/ge/protein/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void start();
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/BaseView.java
// public interface BaseView<T> {
//
// void setPresenter(T presenter);
//
// Context getContext();
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/User.java
// @AutoValue
// public abstract class User implements Parcelable {
//
// public abstract long id();
//
// public abstract String name();
//
// public abstract String username();
//
// public abstract String html_url();
//
// public abstract String avatar_url();
//
// public abstract String bio();
//
// @Nullable
// public abstract String location();
//
// public abstract Links links();
//
// public abstract long buckets_count();
//
// public abstract long comments_received_count();
//
// public abstract long followers_count();
//
// public abstract long followings_count();
//
// public abstract long likes_count();
//
// public abstract long likes_received_count();
//
// public abstract long projects_count();
//
// public abstract long rebounds_received_count();
//
// public abstract long shots_count();
//
// public abstract long teams_count();
//
// public abstract boolean can_upload_shot();
//
// public abstract String type();
//
// public abstract boolean pro();
//
// public abstract String buckets_url();
//
// public abstract String followers_url();
//
// public abstract String following_url();
//
// public abstract String likes_url();
//
// public abstract String shots_url();
//
// @Nullable
// public abstract String teams_url();
//
// public abstract String created_at();
//
// public abstract String updated_at();
//
// public static TypeAdapter<User> typeAdapter(Gson gson) {
// return new AutoValue_User.GsonTypeAdapter(gson).nullSafe();
// }
// }
|
import com.ge.protein.mvp.BasePresenter;
import com.ge.protein.mvp.BaseView;
import com.ge.protein.data.model.User;
|
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.main;
interface MainContract {
interface View extends BaseView<Presenter> {
void setupView();
void setDefaultUserInfo();
void setUserInfo(User user);
}
|
// Path: app/src/main/java/com/ge/protein/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void start();
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/BaseView.java
// public interface BaseView<T> {
//
// void setPresenter(T presenter);
//
// Context getContext();
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/User.java
// @AutoValue
// public abstract class User implements Parcelable {
//
// public abstract long id();
//
// public abstract String name();
//
// public abstract String username();
//
// public abstract String html_url();
//
// public abstract String avatar_url();
//
// public abstract String bio();
//
// @Nullable
// public abstract String location();
//
// public abstract Links links();
//
// public abstract long buckets_count();
//
// public abstract long comments_received_count();
//
// public abstract long followers_count();
//
// public abstract long followings_count();
//
// public abstract long likes_count();
//
// public abstract long likes_received_count();
//
// public abstract long projects_count();
//
// public abstract long rebounds_received_count();
//
// public abstract long shots_count();
//
// public abstract long teams_count();
//
// public abstract boolean can_upload_shot();
//
// public abstract String type();
//
// public abstract boolean pro();
//
// public abstract String buckets_url();
//
// public abstract String followers_url();
//
// public abstract String following_url();
//
// public abstract String likes_url();
//
// public abstract String shots_url();
//
// @Nullable
// public abstract String teams_url();
//
// public abstract String created_at();
//
// public abstract String updated_at();
//
// public static TypeAdapter<User> typeAdapter(Gson gson) {
// return new AutoValue_User.GsonTypeAdapter(gson).nullSafe();
// }
// }
// Path: app/src/main/java/com/ge/protein/main/MainContract.java
import com.ge.protein.mvp.BasePresenter;
import com.ge.protein.mvp.BaseView;
import com.ge.protein.data.model.User;
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.main;
interface MainContract {
interface View extends BaseView<Presenter> {
void setupView();
void setDefaultUserInfo();
void setUserInfo(User user);
}
|
interface Presenter extends BasePresenter {
|
gejiaheng/Protein
|
app/src/androidTest/java/com/ge/protein/main/MainIntentTest.java
|
// Path: app/src/main/java/com/ge/protein/user/UserActivity.java
// public class UserActivity extends BaseProteinActivity {
//
// public static final String EXTRA_USER = "extra_user";
//
// private User user;
// private UserPresenter userPresenter;
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// FirebaseCrashUtils.log("UserActivity created");
//
// user = getIntent().getParcelableExtra(EXTRA_USER);
// setContentView(R.layout.activity_user);
//
// userPresenter = new UserPresenter((UserView)findViewById(R.id.user_view), user);
// if (savedInstanceState != null) {
// userPresenter.onRestoreInstanceState(savedInstanceState);
// }
// userPresenter.start();
// }
//
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// userPresenter.onSaveInstanceState(outState);
// }
// }
//
// Path: app/src/main/java/com/ge/protein/util/AccountManager.java
// public class AccountManager {
//
// private static AccountManager accountManager = new AccountManager();
// private AccessToken accessToken;
// private User me;
//
// private AccountManager() {
// }
//
// public static AccountManager getInstance() {
// return accountManager;
// }
//
// public AccessToken getAccessToken() {
// return accessToken;
// }
//
// public void setAccessToken(AccessToken accessToken) {
// this.accessToken = accessToken;
// }
//
// public void setAccessToken(String token) {
// accessToken = new GsonBuilder()
// .registerTypeAdapterFactory(ProteinAdapterFactory.create())
// .create()
// .fromJson(token, AccessToken.class);
// }
//
// public boolean isLogin() {
// return accessToken != null;
// }
//
// public User getMe() {
// return me;
// }
//
// public void setMe(User me) {
// this.me = me;
// }
//
// public void clear() {
// accessToken = null;
// me = null;
// }
// }
|
import android.support.test.espresso.intent.rule.IntentsTestRule;
import android.support.test.filters.LargeTest;
import android.support.test.runner.AndroidJUnit4;
import com.ge.protein.R;
import com.ge.protein.user.UserActivity;
import com.ge.protein.util.AccountManager;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.intent.Intents.intended;
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasComponent;
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasExtraWithKey;
import static android.support.test.espresso.intent.matcher.IntentMatchers.isInternal;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static android.support.test.espresso.matcher.RootMatchers.isDialog;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static org.hamcrest.core.AllOf.allOf;
|
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.main;
@RunWith(AndroidJUnit4.class)
@LargeTest
public class MainIntentTest {
@Rule
public IntentsTestRule<MainActivity> activityRule = new IntentsTestRule<>(MainActivity.class);
@Test
public void clickOnUserLayout() {
onView(withId(R.id.user_layout)).perform(click());
|
// Path: app/src/main/java/com/ge/protein/user/UserActivity.java
// public class UserActivity extends BaseProteinActivity {
//
// public static final String EXTRA_USER = "extra_user";
//
// private User user;
// private UserPresenter userPresenter;
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// FirebaseCrashUtils.log("UserActivity created");
//
// user = getIntent().getParcelableExtra(EXTRA_USER);
// setContentView(R.layout.activity_user);
//
// userPresenter = new UserPresenter((UserView)findViewById(R.id.user_view), user);
// if (savedInstanceState != null) {
// userPresenter.onRestoreInstanceState(savedInstanceState);
// }
// userPresenter.start();
// }
//
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// userPresenter.onSaveInstanceState(outState);
// }
// }
//
// Path: app/src/main/java/com/ge/protein/util/AccountManager.java
// public class AccountManager {
//
// private static AccountManager accountManager = new AccountManager();
// private AccessToken accessToken;
// private User me;
//
// private AccountManager() {
// }
//
// public static AccountManager getInstance() {
// return accountManager;
// }
//
// public AccessToken getAccessToken() {
// return accessToken;
// }
//
// public void setAccessToken(AccessToken accessToken) {
// this.accessToken = accessToken;
// }
//
// public void setAccessToken(String token) {
// accessToken = new GsonBuilder()
// .registerTypeAdapterFactory(ProteinAdapterFactory.create())
// .create()
// .fromJson(token, AccessToken.class);
// }
//
// public boolean isLogin() {
// return accessToken != null;
// }
//
// public User getMe() {
// return me;
// }
//
// public void setMe(User me) {
// this.me = me;
// }
//
// public void clear() {
// accessToken = null;
// me = null;
// }
// }
// Path: app/src/androidTest/java/com/ge/protein/main/MainIntentTest.java
import android.support.test.espresso.intent.rule.IntentsTestRule;
import android.support.test.filters.LargeTest;
import android.support.test.runner.AndroidJUnit4;
import com.ge.protein.R;
import com.ge.protein.user.UserActivity;
import com.ge.protein.util.AccountManager;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.intent.Intents.intended;
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasComponent;
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasExtraWithKey;
import static android.support.test.espresso.intent.matcher.IntentMatchers.isInternal;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static android.support.test.espresso.matcher.RootMatchers.isDialog;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static org.hamcrest.core.AllOf.allOf;
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.main;
@RunWith(AndroidJUnit4.class)
@LargeTest
public class MainIntentTest {
@Rule
public IntentsTestRule<MainActivity> activityRule = new IntentsTestRule<>(MainActivity.class);
@Test
public void clickOnUserLayout() {
onView(withId(R.id.user_layout)).perform(click());
|
if (AccountManager.getInstance().isLogin()) {
|
gejiaheng/Protein
|
app/src/androidTest/java/com/ge/protein/main/MainIntentTest.java
|
// Path: app/src/main/java/com/ge/protein/user/UserActivity.java
// public class UserActivity extends BaseProteinActivity {
//
// public static final String EXTRA_USER = "extra_user";
//
// private User user;
// private UserPresenter userPresenter;
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// FirebaseCrashUtils.log("UserActivity created");
//
// user = getIntent().getParcelableExtra(EXTRA_USER);
// setContentView(R.layout.activity_user);
//
// userPresenter = new UserPresenter((UserView)findViewById(R.id.user_view), user);
// if (savedInstanceState != null) {
// userPresenter.onRestoreInstanceState(savedInstanceState);
// }
// userPresenter.start();
// }
//
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// userPresenter.onSaveInstanceState(outState);
// }
// }
//
// Path: app/src/main/java/com/ge/protein/util/AccountManager.java
// public class AccountManager {
//
// private static AccountManager accountManager = new AccountManager();
// private AccessToken accessToken;
// private User me;
//
// private AccountManager() {
// }
//
// public static AccountManager getInstance() {
// return accountManager;
// }
//
// public AccessToken getAccessToken() {
// return accessToken;
// }
//
// public void setAccessToken(AccessToken accessToken) {
// this.accessToken = accessToken;
// }
//
// public void setAccessToken(String token) {
// accessToken = new GsonBuilder()
// .registerTypeAdapterFactory(ProteinAdapterFactory.create())
// .create()
// .fromJson(token, AccessToken.class);
// }
//
// public boolean isLogin() {
// return accessToken != null;
// }
//
// public User getMe() {
// return me;
// }
//
// public void setMe(User me) {
// this.me = me;
// }
//
// public void clear() {
// accessToken = null;
// me = null;
// }
// }
|
import android.support.test.espresso.intent.rule.IntentsTestRule;
import android.support.test.filters.LargeTest;
import android.support.test.runner.AndroidJUnit4;
import com.ge.protein.R;
import com.ge.protein.user.UserActivity;
import com.ge.protein.util.AccountManager;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.intent.Intents.intended;
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasComponent;
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasExtraWithKey;
import static android.support.test.espresso.intent.matcher.IntentMatchers.isInternal;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static android.support.test.espresso.matcher.RootMatchers.isDialog;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static org.hamcrest.core.AllOf.allOf;
|
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.main;
@RunWith(AndroidJUnit4.class)
@LargeTest
public class MainIntentTest {
@Rule
public IntentsTestRule<MainActivity> activityRule = new IntentsTestRule<>(MainActivity.class);
@Test
public void clickOnUserLayout() {
onView(withId(R.id.user_layout)).perform(click());
if (AccountManager.getInstance().isLogin()) {
intended(allOf(
isInternal(),
|
// Path: app/src/main/java/com/ge/protein/user/UserActivity.java
// public class UserActivity extends BaseProteinActivity {
//
// public static final String EXTRA_USER = "extra_user";
//
// private User user;
// private UserPresenter userPresenter;
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// FirebaseCrashUtils.log("UserActivity created");
//
// user = getIntent().getParcelableExtra(EXTRA_USER);
// setContentView(R.layout.activity_user);
//
// userPresenter = new UserPresenter((UserView)findViewById(R.id.user_view), user);
// if (savedInstanceState != null) {
// userPresenter.onRestoreInstanceState(savedInstanceState);
// }
// userPresenter.start();
// }
//
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// userPresenter.onSaveInstanceState(outState);
// }
// }
//
// Path: app/src/main/java/com/ge/protein/util/AccountManager.java
// public class AccountManager {
//
// private static AccountManager accountManager = new AccountManager();
// private AccessToken accessToken;
// private User me;
//
// private AccountManager() {
// }
//
// public static AccountManager getInstance() {
// return accountManager;
// }
//
// public AccessToken getAccessToken() {
// return accessToken;
// }
//
// public void setAccessToken(AccessToken accessToken) {
// this.accessToken = accessToken;
// }
//
// public void setAccessToken(String token) {
// accessToken = new GsonBuilder()
// .registerTypeAdapterFactory(ProteinAdapterFactory.create())
// .create()
// .fromJson(token, AccessToken.class);
// }
//
// public boolean isLogin() {
// return accessToken != null;
// }
//
// public User getMe() {
// return me;
// }
//
// public void setMe(User me) {
// this.me = me;
// }
//
// public void clear() {
// accessToken = null;
// me = null;
// }
// }
// Path: app/src/androidTest/java/com/ge/protein/main/MainIntentTest.java
import android.support.test.espresso.intent.rule.IntentsTestRule;
import android.support.test.filters.LargeTest;
import android.support.test.runner.AndroidJUnit4;
import com.ge.protein.R;
import com.ge.protein.user.UserActivity;
import com.ge.protein.util.AccountManager;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.intent.Intents.intended;
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasComponent;
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasExtraWithKey;
import static android.support.test.espresso.intent.matcher.IntentMatchers.isInternal;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static android.support.test.espresso.matcher.RootMatchers.isDialog;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static org.hamcrest.core.AllOf.allOf;
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.main;
@RunWith(AndroidJUnit4.class)
@LargeTest
public class MainIntentTest {
@Rule
public IntentsTestRule<MainActivity> activityRule = new IntentsTestRule<>(MainActivity.class);
@Test
public void clickOnUserLayout() {
onView(withId(R.id.user_layout)).perform(click());
if (AccountManager.getInstance().isLogin()) {
intended(allOf(
isInternal(),
|
hasComponent(UserActivity.class.getName()),
|
gejiaheng/Protein
|
app/src/main/java/com/ge/protein/shot/ShotActivity.java
|
// Path: app/src/main/java/com/ge/protein/data/model/Shot.java
// @AutoValue
// public abstract class Shot implements Parcelable {
//
// public abstract long id();
//
// public abstract String title();
//
// @Nullable
// public abstract String description();
//
// public abstract int width();
//
// public abstract int height();
//
// public abstract Images images();
//
// public abstract long views_count();
//
// public abstract long likes_count();
//
// public abstract long comments_count();
//
// public abstract long attachments_count();
//
// public abstract long rebounds_count();
//
// public abstract long buckets_count();
//
// public abstract Date created_at();
//
// public abstract Date updated_at();
//
// public abstract String html_url();
//
// public abstract String attachments_url();
//
// public abstract String buckets_url();
//
// public abstract String comments_url();
//
// public abstract String likes_url();
//
// public abstract String projects_url();
//
// public abstract String rebounds_url();
//
// public abstract boolean animated();
//
// public abstract List<String> tags();
//
// @Nullable
// public abstract User user();
//
// @Nullable
// public abstract Team team();
//
// public abstract Shot withUser(User user);
//
// public abstract Shot withLikesCount(long likes_count);
//
// public static TypeAdapter<Shot> typeAdapter(Gson gson) {
// return new AutoValue_Shot.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/open/java/com/ge/protein/firebase/FirebaseCrashUtils.java
// public class FirebaseCrashUtils {
//
// public static void log(String message) {
// // no-op for product flavor open
// }
// }
//
// Path: app/src/main/java/com/ge/protein/ui/activity/BaseProteinActivity.java
// public abstract class BaseProteinActivity extends RxAppCompatActivity {
//
// protected boolean login;
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// login = AccountManager.getInstance().isLogin();
// }
//
// }
|
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import com.airbnb.deeplinkdispatch.DeepLink;
import com.ge.protein.R;
import com.ge.protein.data.model.Shot;
import com.ge.protein.firebase.FirebaseCrashUtils;
import com.ge.protein.ui.activity.BaseProteinActivity;
|
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.shot;
@DeepLink("https://dribbble.com/shots/{id}")
public class ShotActivity extends BaseProteinActivity {
public static final String EXTRA_SHOT = "extra_shot";
private ShotPresenter shotPresenter;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
|
// Path: app/src/main/java/com/ge/protein/data/model/Shot.java
// @AutoValue
// public abstract class Shot implements Parcelable {
//
// public abstract long id();
//
// public abstract String title();
//
// @Nullable
// public abstract String description();
//
// public abstract int width();
//
// public abstract int height();
//
// public abstract Images images();
//
// public abstract long views_count();
//
// public abstract long likes_count();
//
// public abstract long comments_count();
//
// public abstract long attachments_count();
//
// public abstract long rebounds_count();
//
// public abstract long buckets_count();
//
// public abstract Date created_at();
//
// public abstract Date updated_at();
//
// public abstract String html_url();
//
// public abstract String attachments_url();
//
// public abstract String buckets_url();
//
// public abstract String comments_url();
//
// public abstract String likes_url();
//
// public abstract String projects_url();
//
// public abstract String rebounds_url();
//
// public abstract boolean animated();
//
// public abstract List<String> tags();
//
// @Nullable
// public abstract User user();
//
// @Nullable
// public abstract Team team();
//
// public abstract Shot withUser(User user);
//
// public abstract Shot withLikesCount(long likes_count);
//
// public static TypeAdapter<Shot> typeAdapter(Gson gson) {
// return new AutoValue_Shot.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/open/java/com/ge/protein/firebase/FirebaseCrashUtils.java
// public class FirebaseCrashUtils {
//
// public static void log(String message) {
// // no-op for product flavor open
// }
// }
//
// Path: app/src/main/java/com/ge/protein/ui/activity/BaseProteinActivity.java
// public abstract class BaseProteinActivity extends RxAppCompatActivity {
//
// protected boolean login;
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// login = AccountManager.getInstance().isLogin();
// }
//
// }
// Path: app/src/main/java/com/ge/protein/shot/ShotActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import com.airbnb.deeplinkdispatch.DeepLink;
import com.ge.protein.R;
import com.ge.protein.data.model.Shot;
import com.ge.protein.firebase.FirebaseCrashUtils;
import com.ge.protein.ui.activity.BaseProteinActivity;
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.shot;
@DeepLink("https://dribbble.com/shots/{id}")
public class ShotActivity extends BaseProteinActivity {
public static final String EXTRA_SHOT = "extra_shot";
private ShotPresenter shotPresenter;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
|
FirebaseCrashUtils.log("ShotActivity created");
|
gejiaheng/Protein
|
app/src/main/java/com/ge/protein/shot/ShotActivity.java
|
// Path: app/src/main/java/com/ge/protein/data/model/Shot.java
// @AutoValue
// public abstract class Shot implements Parcelable {
//
// public abstract long id();
//
// public abstract String title();
//
// @Nullable
// public abstract String description();
//
// public abstract int width();
//
// public abstract int height();
//
// public abstract Images images();
//
// public abstract long views_count();
//
// public abstract long likes_count();
//
// public abstract long comments_count();
//
// public abstract long attachments_count();
//
// public abstract long rebounds_count();
//
// public abstract long buckets_count();
//
// public abstract Date created_at();
//
// public abstract Date updated_at();
//
// public abstract String html_url();
//
// public abstract String attachments_url();
//
// public abstract String buckets_url();
//
// public abstract String comments_url();
//
// public abstract String likes_url();
//
// public abstract String projects_url();
//
// public abstract String rebounds_url();
//
// public abstract boolean animated();
//
// public abstract List<String> tags();
//
// @Nullable
// public abstract User user();
//
// @Nullable
// public abstract Team team();
//
// public abstract Shot withUser(User user);
//
// public abstract Shot withLikesCount(long likes_count);
//
// public static TypeAdapter<Shot> typeAdapter(Gson gson) {
// return new AutoValue_Shot.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/open/java/com/ge/protein/firebase/FirebaseCrashUtils.java
// public class FirebaseCrashUtils {
//
// public static void log(String message) {
// // no-op for product flavor open
// }
// }
//
// Path: app/src/main/java/com/ge/protein/ui/activity/BaseProteinActivity.java
// public abstract class BaseProteinActivity extends RxAppCompatActivity {
//
// protected boolean login;
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// login = AccountManager.getInstance().isLogin();
// }
//
// }
|
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import com.airbnb.deeplinkdispatch.DeepLink;
import com.ge.protein.R;
import com.ge.protein.data.model.Shot;
import com.ge.protein.firebase.FirebaseCrashUtils;
import com.ge.protein.ui.activity.BaseProteinActivity;
|
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.shot;
@DeepLink("https://dribbble.com/shots/{id}")
public class ShotActivity extends BaseProteinActivity {
public static final String EXTRA_SHOT = "extra_shot";
private ShotPresenter shotPresenter;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FirebaseCrashUtils.log("ShotActivity created");
setContentView(R.layout.activity_simple_fragment);
Intent intent = getIntent();
boolean isDeepLink = intent.getBooleanExtra(DeepLink.IS_DEEP_LINK, false);
long shotId;
|
// Path: app/src/main/java/com/ge/protein/data/model/Shot.java
// @AutoValue
// public abstract class Shot implements Parcelable {
//
// public abstract long id();
//
// public abstract String title();
//
// @Nullable
// public abstract String description();
//
// public abstract int width();
//
// public abstract int height();
//
// public abstract Images images();
//
// public abstract long views_count();
//
// public abstract long likes_count();
//
// public abstract long comments_count();
//
// public abstract long attachments_count();
//
// public abstract long rebounds_count();
//
// public abstract long buckets_count();
//
// public abstract Date created_at();
//
// public abstract Date updated_at();
//
// public abstract String html_url();
//
// public abstract String attachments_url();
//
// public abstract String buckets_url();
//
// public abstract String comments_url();
//
// public abstract String likes_url();
//
// public abstract String projects_url();
//
// public abstract String rebounds_url();
//
// public abstract boolean animated();
//
// public abstract List<String> tags();
//
// @Nullable
// public abstract User user();
//
// @Nullable
// public abstract Team team();
//
// public abstract Shot withUser(User user);
//
// public abstract Shot withLikesCount(long likes_count);
//
// public static TypeAdapter<Shot> typeAdapter(Gson gson) {
// return new AutoValue_Shot.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/open/java/com/ge/protein/firebase/FirebaseCrashUtils.java
// public class FirebaseCrashUtils {
//
// public static void log(String message) {
// // no-op for product flavor open
// }
// }
//
// Path: app/src/main/java/com/ge/protein/ui/activity/BaseProteinActivity.java
// public abstract class BaseProteinActivity extends RxAppCompatActivity {
//
// protected boolean login;
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// login = AccountManager.getInstance().isLogin();
// }
//
// }
// Path: app/src/main/java/com/ge/protein/shot/ShotActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import com.airbnb.deeplinkdispatch.DeepLink;
import com.ge.protein.R;
import com.ge.protein.data.model.Shot;
import com.ge.protein.firebase.FirebaseCrashUtils;
import com.ge.protein.ui.activity.BaseProteinActivity;
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.shot;
@DeepLink("https://dribbble.com/shots/{id}")
public class ShotActivity extends BaseProteinActivity {
public static final String EXTRA_SHOT = "extra_shot";
private ShotPresenter shotPresenter;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FirebaseCrashUtils.log("ShotActivity created");
setContentView(R.layout.activity_simple_fragment);
Intent intent = getIntent();
boolean isDeepLink = intent.getBooleanExtra(DeepLink.IS_DEEP_LINK, false);
long shotId;
|
Shot shot;
|
gejiaheng/Protein
|
app/src/main/java/com/ge/protein/about/AboutActivity.java
|
// Path: app/src/open/java/com/ge/protein/firebase/FirebaseCrashUtils.java
// public class FirebaseCrashUtils {
//
// public static void log(String message) {
// // no-op for product flavor open
// }
// }
//
// Path: app/src/main/java/com/ge/protein/ui/activity/BaseProteinActivity.java
// public abstract class BaseProteinActivity extends RxAppCompatActivity {
//
// protected boolean login;
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// login = AccountManager.getInstance().isLogin();
// }
//
// }
|
import android.os.Bundle;
import android.support.annotation.Nullable;
import com.ge.protein.R;
import com.ge.protein.firebase.FirebaseCrashUtils;
import com.ge.protein.ui.activity.BaseProteinActivity;
|
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.about;
public class AboutActivity extends BaseProteinActivity {
private AboutPresenter aboutPresenter;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
|
// Path: app/src/open/java/com/ge/protein/firebase/FirebaseCrashUtils.java
// public class FirebaseCrashUtils {
//
// public static void log(String message) {
// // no-op for product flavor open
// }
// }
//
// Path: app/src/main/java/com/ge/protein/ui/activity/BaseProteinActivity.java
// public abstract class BaseProteinActivity extends RxAppCompatActivity {
//
// protected boolean login;
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// login = AccountManager.getInstance().isLogin();
// }
//
// }
// Path: app/src/main/java/com/ge/protein/about/AboutActivity.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import com.ge.protein.R;
import com.ge.protein.firebase.FirebaseCrashUtils;
import com.ge.protein.ui.activity.BaseProteinActivity;
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.about;
public class AboutActivity extends BaseProteinActivity {
private AboutPresenter aboutPresenter;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
|
FirebaseCrashUtils.log("AboutActivity created");
|
gejiaheng/Protein
|
app/src/main/java/com/ge/protein/ui/epoxy/models/FollowerModel.java
|
// Path: app/src/main/java/com/ge/protein/data/model/Follower.java
// @AutoValue
// public abstract class Follower implements Parcelable {
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract User follower();
//
// public static TypeAdapter<Follower> typeAdapter(Gson gson) {
// return new AutoValue_Follower.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/ui/epoxy/BaseEpoxyHolder.java
// public abstract class BaseEpoxyHolder extends EpoxyHolder {
// @CallSuper
// @Override
// protected void bindView(View itemView) {
// ButterKnife.bind(this, itemView);
// }
// }
|
import butterknife.BindView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModelClass;
import com.airbnb.epoxy.EpoxyModelWithHolder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.TransitionOptions;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.ge.protein.R;
import com.ge.protein.data.model.Follower;
import com.ge.protein.ui.epoxy.BaseEpoxyHolder;
|
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.ui.epoxy.models;
@EpoxyModelClass(layout = R.layout.epoxy_follower)
public abstract class FollowerModel extends EpoxyModelWithHolder<FollowerModel.FollowerHolder> {
@EpoxyAttribute
View.OnClickListener itemOnClickListener;
@EpoxyAttribute
|
// Path: app/src/main/java/com/ge/protein/data/model/Follower.java
// @AutoValue
// public abstract class Follower implements Parcelable {
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract User follower();
//
// public static TypeAdapter<Follower> typeAdapter(Gson gson) {
// return new AutoValue_Follower.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/ui/epoxy/BaseEpoxyHolder.java
// public abstract class BaseEpoxyHolder extends EpoxyHolder {
// @CallSuper
// @Override
// protected void bindView(View itemView) {
// ButterKnife.bind(this, itemView);
// }
// }
// Path: app/src/main/java/com/ge/protein/ui/epoxy/models/FollowerModel.java
import butterknife.BindView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModelClass;
import com.airbnb.epoxy.EpoxyModelWithHolder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.TransitionOptions;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.ge.protein.R;
import com.ge.protein.data.model.Follower;
import com.ge.protein.ui.epoxy.BaseEpoxyHolder;
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.ui.epoxy.models;
@EpoxyModelClass(layout = R.layout.epoxy_follower)
public abstract class FollowerModel extends EpoxyModelWithHolder<FollowerModel.FollowerHolder> {
@EpoxyAttribute
View.OnClickListener itemOnClickListener;
@EpoxyAttribute
|
Follower follower;
|
gejiaheng/Protein
|
app/src/main/java/com/ge/protein/ui/epoxy/models/FollowerModel.java
|
// Path: app/src/main/java/com/ge/protein/data/model/Follower.java
// @AutoValue
// public abstract class Follower implements Parcelable {
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract User follower();
//
// public static TypeAdapter<Follower> typeAdapter(Gson gson) {
// return new AutoValue_Follower.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/ui/epoxy/BaseEpoxyHolder.java
// public abstract class BaseEpoxyHolder extends EpoxyHolder {
// @CallSuper
// @Override
// protected void bindView(View itemView) {
// ButterKnife.bind(this, itemView);
// }
// }
|
import butterknife.BindView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModelClass;
import com.airbnb.epoxy.EpoxyModelWithHolder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.TransitionOptions;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.ge.protein.R;
import com.ge.protein.data.model.Follower;
import com.ge.protein.ui.epoxy.BaseEpoxyHolder;
|
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.ui.epoxy.models;
@EpoxyModelClass(layout = R.layout.epoxy_follower)
public abstract class FollowerModel extends EpoxyModelWithHolder<FollowerModel.FollowerHolder> {
@EpoxyAttribute
View.OnClickListener itemOnClickListener;
@EpoxyAttribute
Follower follower;
private TransitionOptions transitionOptions = DrawableTransitionOptions.withCrossFade();
private RequestOptions requestOptions = RequestOptions.placeholderOf(R.color.avatar_placeholder)
.diskCacheStrategy(DiskCacheStrategy.ALL);
@Override
protected FollowerHolder createNewHolder() {
return new FollowerHolder();
}
@Override
public void bind(FollowerHolder holder) {
super.bind(holder);
holder.name.setText(follower.follower().name());
holder.info.setText(holder.itemView.getContext().getString(R.string.user_info, follower.follower().shots_count(),
follower.follower().followers_count()));
Glide.with(holder.itemView.getContext())
.load(follower.follower().avatar_url())
.transition(transitionOptions)
.apply(requestOptions)
.into(holder.avatar);
holder.itemView.setOnClickListener(itemOnClickListener);
holder.itemView.setTag(R.id.clicked_model, follower);
}
|
// Path: app/src/main/java/com/ge/protein/data/model/Follower.java
// @AutoValue
// public abstract class Follower implements Parcelable {
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract User follower();
//
// public static TypeAdapter<Follower> typeAdapter(Gson gson) {
// return new AutoValue_Follower.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/ui/epoxy/BaseEpoxyHolder.java
// public abstract class BaseEpoxyHolder extends EpoxyHolder {
// @CallSuper
// @Override
// protected void bindView(View itemView) {
// ButterKnife.bind(this, itemView);
// }
// }
// Path: app/src/main/java/com/ge/protein/ui/epoxy/models/FollowerModel.java
import butterknife.BindView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModelClass;
import com.airbnb.epoxy.EpoxyModelWithHolder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.TransitionOptions;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.ge.protein.R;
import com.ge.protein.data.model.Follower;
import com.ge.protein.ui.epoxy.BaseEpoxyHolder;
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.ui.epoxy.models;
@EpoxyModelClass(layout = R.layout.epoxy_follower)
public abstract class FollowerModel extends EpoxyModelWithHolder<FollowerModel.FollowerHolder> {
@EpoxyAttribute
View.OnClickListener itemOnClickListener;
@EpoxyAttribute
Follower follower;
private TransitionOptions transitionOptions = DrawableTransitionOptions.withCrossFade();
private RequestOptions requestOptions = RequestOptions.placeholderOf(R.color.avatar_placeholder)
.diskCacheStrategy(DiskCacheStrategy.ALL);
@Override
protected FollowerHolder createNewHolder() {
return new FollowerHolder();
}
@Override
public void bind(FollowerHolder holder) {
super.bind(holder);
holder.name.setText(follower.follower().name());
holder.info.setText(holder.itemView.getContext().getString(R.string.user_info, follower.follower().shots_count(),
follower.follower().followers_count()));
Glide.with(holder.itemView.getContext())
.load(follower.follower().avatar_url())
.transition(transitionOptions)
.apply(requestOptions)
.into(holder.avatar);
holder.itemView.setOnClickListener(itemOnClickListener);
holder.itemView.setTag(R.id.clicked_model, follower);
}
|
static class FollowerHolder extends BaseEpoxyHolder {
|
gejiaheng/Protein
|
app/src/main/java/com/ge/protein/data/api/service/UserService.java
|
// Path: app/src/main/java/com/ge/protein/data/model/Followee.java
// @AutoValue
// public abstract class Followee implements Parcelable {
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract User followee();
//
// public static TypeAdapter<Followee> typeAdapter(Gson gson) {
// return new AutoValue_Followee.GsonTypeAdapter(gson).nullSafe();
// }
//
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/Follower.java
// @AutoValue
// public abstract class Follower implements Parcelable {
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract User follower();
//
// public static TypeAdapter<Follower> typeAdapter(Gson gson) {
// return new AutoValue_Follower.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/Shot.java
// @AutoValue
// public abstract class Shot implements Parcelable {
//
// public abstract long id();
//
// public abstract String title();
//
// @Nullable
// public abstract String description();
//
// public abstract int width();
//
// public abstract int height();
//
// public abstract Images images();
//
// public abstract long views_count();
//
// public abstract long likes_count();
//
// public abstract long comments_count();
//
// public abstract long attachments_count();
//
// public abstract long rebounds_count();
//
// public abstract long buckets_count();
//
// public abstract Date created_at();
//
// public abstract Date updated_at();
//
// public abstract String html_url();
//
// public abstract String attachments_url();
//
// public abstract String buckets_url();
//
// public abstract String comments_url();
//
// public abstract String likes_url();
//
// public abstract String projects_url();
//
// public abstract String rebounds_url();
//
// public abstract boolean animated();
//
// public abstract List<String> tags();
//
// @Nullable
// public abstract User user();
//
// @Nullable
// public abstract Team team();
//
// public abstract Shot withUser(User user);
//
// public abstract Shot withLikesCount(long likes_count);
//
// public static TypeAdapter<Shot> typeAdapter(Gson gson) {
// return new AutoValue_Shot.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/ShotLike.java
// @AutoValue
// public abstract class ShotLike implements Parcelable {
//
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract Shot shot();
//
// public static TypeAdapter<ShotLike> typeAdapter(Gson gson) {
// return new AutoValue_ShotLike.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/User.java
// @AutoValue
// public abstract class User implements Parcelable {
//
// public abstract long id();
//
// public abstract String name();
//
// public abstract String username();
//
// public abstract String html_url();
//
// public abstract String avatar_url();
//
// public abstract String bio();
//
// @Nullable
// public abstract String location();
//
// public abstract Links links();
//
// public abstract long buckets_count();
//
// public abstract long comments_received_count();
//
// public abstract long followers_count();
//
// public abstract long followings_count();
//
// public abstract long likes_count();
//
// public abstract long likes_received_count();
//
// public abstract long projects_count();
//
// public abstract long rebounds_received_count();
//
// public abstract long shots_count();
//
// public abstract long teams_count();
//
// public abstract boolean can_upload_shot();
//
// public abstract String type();
//
// public abstract boolean pro();
//
// public abstract String buckets_url();
//
// public abstract String followers_url();
//
// public abstract String following_url();
//
// public abstract String likes_url();
//
// public abstract String shots_url();
//
// @Nullable
// public abstract String teams_url();
//
// public abstract String created_at();
//
// public abstract String updated_at();
//
// public static TypeAdapter<User> typeAdapter(Gson gson) {
// return new AutoValue_User.GsonTypeAdapter(gson).nullSafe();
// }
// }
|
import retrofit2.http.Query;
import retrofit2.http.Url;
import com.ge.protein.data.model.Followee;
import com.ge.protein.data.model.Follower;
import com.ge.protein.data.model.Shot;
import com.ge.protein.data.model.ShotLike;
import com.ge.protein.data.model.User;
import java.util.List;
import io.reactivex.Observable;
import retrofit2.Response;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.PUT;
import retrofit2.http.Path;
|
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.data.api.service;
public interface UserService {
@GET("/v1/user")
|
// Path: app/src/main/java/com/ge/protein/data/model/Followee.java
// @AutoValue
// public abstract class Followee implements Parcelable {
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract User followee();
//
// public static TypeAdapter<Followee> typeAdapter(Gson gson) {
// return new AutoValue_Followee.GsonTypeAdapter(gson).nullSafe();
// }
//
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/Follower.java
// @AutoValue
// public abstract class Follower implements Parcelable {
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract User follower();
//
// public static TypeAdapter<Follower> typeAdapter(Gson gson) {
// return new AutoValue_Follower.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/Shot.java
// @AutoValue
// public abstract class Shot implements Parcelable {
//
// public abstract long id();
//
// public abstract String title();
//
// @Nullable
// public abstract String description();
//
// public abstract int width();
//
// public abstract int height();
//
// public abstract Images images();
//
// public abstract long views_count();
//
// public abstract long likes_count();
//
// public abstract long comments_count();
//
// public abstract long attachments_count();
//
// public abstract long rebounds_count();
//
// public abstract long buckets_count();
//
// public abstract Date created_at();
//
// public abstract Date updated_at();
//
// public abstract String html_url();
//
// public abstract String attachments_url();
//
// public abstract String buckets_url();
//
// public abstract String comments_url();
//
// public abstract String likes_url();
//
// public abstract String projects_url();
//
// public abstract String rebounds_url();
//
// public abstract boolean animated();
//
// public abstract List<String> tags();
//
// @Nullable
// public abstract User user();
//
// @Nullable
// public abstract Team team();
//
// public abstract Shot withUser(User user);
//
// public abstract Shot withLikesCount(long likes_count);
//
// public static TypeAdapter<Shot> typeAdapter(Gson gson) {
// return new AutoValue_Shot.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/ShotLike.java
// @AutoValue
// public abstract class ShotLike implements Parcelable {
//
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract Shot shot();
//
// public static TypeAdapter<ShotLike> typeAdapter(Gson gson) {
// return new AutoValue_ShotLike.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/User.java
// @AutoValue
// public abstract class User implements Parcelable {
//
// public abstract long id();
//
// public abstract String name();
//
// public abstract String username();
//
// public abstract String html_url();
//
// public abstract String avatar_url();
//
// public abstract String bio();
//
// @Nullable
// public abstract String location();
//
// public abstract Links links();
//
// public abstract long buckets_count();
//
// public abstract long comments_received_count();
//
// public abstract long followers_count();
//
// public abstract long followings_count();
//
// public abstract long likes_count();
//
// public abstract long likes_received_count();
//
// public abstract long projects_count();
//
// public abstract long rebounds_received_count();
//
// public abstract long shots_count();
//
// public abstract long teams_count();
//
// public abstract boolean can_upload_shot();
//
// public abstract String type();
//
// public abstract boolean pro();
//
// public abstract String buckets_url();
//
// public abstract String followers_url();
//
// public abstract String following_url();
//
// public abstract String likes_url();
//
// public abstract String shots_url();
//
// @Nullable
// public abstract String teams_url();
//
// public abstract String created_at();
//
// public abstract String updated_at();
//
// public static TypeAdapter<User> typeAdapter(Gson gson) {
// return new AutoValue_User.GsonTypeAdapter(gson).nullSafe();
// }
// }
// Path: app/src/main/java/com/ge/protein/data/api/service/UserService.java
import retrofit2.http.Query;
import retrofit2.http.Url;
import com.ge.protein.data.model.Followee;
import com.ge.protein.data.model.Follower;
import com.ge.protein.data.model.Shot;
import com.ge.protein.data.model.ShotLike;
import com.ge.protein.data.model.User;
import java.util.List;
import io.reactivex.Observable;
import retrofit2.Response;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.PUT;
import retrofit2.http.Path;
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.data.api.service;
public interface UserService {
@GET("/v1/user")
|
Observable<Response<User>> getMe();
|
gejiaheng/Protein
|
app/src/main/java/com/ge/protein/data/api/service/UserService.java
|
// Path: app/src/main/java/com/ge/protein/data/model/Followee.java
// @AutoValue
// public abstract class Followee implements Parcelable {
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract User followee();
//
// public static TypeAdapter<Followee> typeAdapter(Gson gson) {
// return new AutoValue_Followee.GsonTypeAdapter(gson).nullSafe();
// }
//
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/Follower.java
// @AutoValue
// public abstract class Follower implements Parcelable {
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract User follower();
//
// public static TypeAdapter<Follower> typeAdapter(Gson gson) {
// return new AutoValue_Follower.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/Shot.java
// @AutoValue
// public abstract class Shot implements Parcelable {
//
// public abstract long id();
//
// public abstract String title();
//
// @Nullable
// public abstract String description();
//
// public abstract int width();
//
// public abstract int height();
//
// public abstract Images images();
//
// public abstract long views_count();
//
// public abstract long likes_count();
//
// public abstract long comments_count();
//
// public abstract long attachments_count();
//
// public abstract long rebounds_count();
//
// public abstract long buckets_count();
//
// public abstract Date created_at();
//
// public abstract Date updated_at();
//
// public abstract String html_url();
//
// public abstract String attachments_url();
//
// public abstract String buckets_url();
//
// public abstract String comments_url();
//
// public abstract String likes_url();
//
// public abstract String projects_url();
//
// public abstract String rebounds_url();
//
// public abstract boolean animated();
//
// public abstract List<String> tags();
//
// @Nullable
// public abstract User user();
//
// @Nullable
// public abstract Team team();
//
// public abstract Shot withUser(User user);
//
// public abstract Shot withLikesCount(long likes_count);
//
// public static TypeAdapter<Shot> typeAdapter(Gson gson) {
// return new AutoValue_Shot.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/ShotLike.java
// @AutoValue
// public abstract class ShotLike implements Parcelable {
//
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract Shot shot();
//
// public static TypeAdapter<ShotLike> typeAdapter(Gson gson) {
// return new AutoValue_ShotLike.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/User.java
// @AutoValue
// public abstract class User implements Parcelable {
//
// public abstract long id();
//
// public abstract String name();
//
// public abstract String username();
//
// public abstract String html_url();
//
// public abstract String avatar_url();
//
// public abstract String bio();
//
// @Nullable
// public abstract String location();
//
// public abstract Links links();
//
// public abstract long buckets_count();
//
// public abstract long comments_received_count();
//
// public abstract long followers_count();
//
// public abstract long followings_count();
//
// public abstract long likes_count();
//
// public abstract long likes_received_count();
//
// public abstract long projects_count();
//
// public abstract long rebounds_received_count();
//
// public abstract long shots_count();
//
// public abstract long teams_count();
//
// public abstract boolean can_upload_shot();
//
// public abstract String type();
//
// public abstract boolean pro();
//
// public abstract String buckets_url();
//
// public abstract String followers_url();
//
// public abstract String following_url();
//
// public abstract String likes_url();
//
// public abstract String shots_url();
//
// @Nullable
// public abstract String teams_url();
//
// public abstract String created_at();
//
// public abstract String updated_at();
//
// public static TypeAdapter<User> typeAdapter(Gson gson) {
// return new AutoValue_User.GsonTypeAdapter(gson).nullSafe();
// }
// }
|
import retrofit2.http.Query;
import retrofit2.http.Url;
import com.ge.protein.data.model.Followee;
import com.ge.protein.data.model.Follower;
import com.ge.protein.data.model.Shot;
import com.ge.protein.data.model.ShotLike;
import com.ge.protein.data.model.User;
import java.util.List;
import io.reactivex.Observable;
import retrofit2.Response;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.PUT;
import retrofit2.http.Path;
|
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.data.api.service;
public interface UserService {
@GET("/v1/user")
Observable<Response<User>> getMe();
@GET("/v1/users/{user_id}/shots")
|
// Path: app/src/main/java/com/ge/protein/data/model/Followee.java
// @AutoValue
// public abstract class Followee implements Parcelable {
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract User followee();
//
// public static TypeAdapter<Followee> typeAdapter(Gson gson) {
// return new AutoValue_Followee.GsonTypeAdapter(gson).nullSafe();
// }
//
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/Follower.java
// @AutoValue
// public abstract class Follower implements Parcelable {
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract User follower();
//
// public static TypeAdapter<Follower> typeAdapter(Gson gson) {
// return new AutoValue_Follower.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/Shot.java
// @AutoValue
// public abstract class Shot implements Parcelable {
//
// public abstract long id();
//
// public abstract String title();
//
// @Nullable
// public abstract String description();
//
// public abstract int width();
//
// public abstract int height();
//
// public abstract Images images();
//
// public abstract long views_count();
//
// public abstract long likes_count();
//
// public abstract long comments_count();
//
// public abstract long attachments_count();
//
// public abstract long rebounds_count();
//
// public abstract long buckets_count();
//
// public abstract Date created_at();
//
// public abstract Date updated_at();
//
// public abstract String html_url();
//
// public abstract String attachments_url();
//
// public abstract String buckets_url();
//
// public abstract String comments_url();
//
// public abstract String likes_url();
//
// public abstract String projects_url();
//
// public abstract String rebounds_url();
//
// public abstract boolean animated();
//
// public abstract List<String> tags();
//
// @Nullable
// public abstract User user();
//
// @Nullable
// public abstract Team team();
//
// public abstract Shot withUser(User user);
//
// public abstract Shot withLikesCount(long likes_count);
//
// public static TypeAdapter<Shot> typeAdapter(Gson gson) {
// return new AutoValue_Shot.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/ShotLike.java
// @AutoValue
// public abstract class ShotLike implements Parcelable {
//
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract Shot shot();
//
// public static TypeAdapter<ShotLike> typeAdapter(Gson gson) {
// return new AutoValue_ShotLike.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/User.java
// @AutoValue
// public abstract class User implements Parcelable {
//
// public abstract long id();
//
// public abstract String name();
//
// public abstract String username();
//
// public abstract String html_url();
//
// public abstract String avatar_url();
//
// public abstract String bio();
//
// @Nullable
// public abstract String location();
//
// public abstract Links links();
//
// public abstract long buckets_count();
//
// public abstract long comments_received_count();
//
// public abstract long followers_count();
//
// public abstract long followings_count();
//
// public abstract long likes_count();
//
// public abstract long likes_received_count();
//
// public abstract long projects_count();
//
// public abstract long rebounds_received_count();
//
// public abstract long shots_count();
//
// public abstract long teams_count();
//
// public abstract boolean can_upload_shot();
//
// public abstract String type();
//
// public abstract boolean pro();
//
// public abstract String buckets_url();
//
// public abstract String followers_url();
//
// public abstract String following_url();
//
// public abstract String likes_url();
//
// public abstract String shots_url();
//
// @Nullable
// public abstract String teams_url();
//
// public abstract String created_at();
//
// public abstract String updated_at();
//
// public static TypeAdapter<User> typeAdapter(Gson gson) {
// return new AutoValue_User.GsonTypeAdapter(gson).nullSafe();
// }
// }
// Path: app/src/main/java/com/ge/protein/data/api/service/UserService.java
import retrofit2.http.Query;
import retrofit2.http.Url;
import com.ge.protein.data.model.Followee;
import com.ge.protein.data.model.Follower;
import com.ge.protein.data.model.Shot;
import com.ge.protein.data.model.ShotLike;
import com.ge.protein.data.model.User;
import java.util.List;
import io.reactivex.Observable;
import retrofit2.Response;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.PUT;
import retrofit2.http.Path;
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.data.api.service;
public interface UserService {
@GET("/v1/user")
Observable<Response<User>> getMe();
@GET("/v1/users/{user_id}/shots")
|
Observable<Response<List<Shot>>> listShotsForUser(@Path("user_id") long userId,
|
gejiaheng/Protein
|
app/src/main/java/com/ge/protein/data/api/service/UserService.java
|
// Path: app/src/main/java/com/ge/protein/data/model/Followee.java
// @AutoValue
// public abstract class Followee implements Parcelable {
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract User followee();
//
// public static TypeAdapter<Followee> typeAdapter(Gson gson) {
// return new AutoValue_Followee.GsonTypeAdapter(gson).nullSafe();
// }
//
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/Follower.java
// @AutoValue
// public abstract class Follower implements Parcelable {
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract User follower();
//
// public static TypeAdapter<Follower> typeAdapter(Gson gson) {
// return new AutoValue_Follower.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/Shot.java
// @AutoValue
// public abstract class Shot implements Parcelable {
//
// public abstract long id();
//
// public abstract String title();
//
// @Nullable
// public abstract String description();
//
// public abstract int width();
//
// public abstract int height();
//
// public abstract Images images();
//
// public abstract long views_count();
//
// public abstract long likes_count();
//
// public abstract long comments_count();
//
// public abstract long attachments_count();
//
// public abstract long rebounds_count();
//
// public abstract long buckets_count();
//
// public abstract Date created_at();
//
// public abstract Date updated_at();
//
// public abstract String html_url();
//
// public abstract String attachments_url();
//
// public abstract String buckets_url();
//
// public abstract String comments_url();
//
// public abstract String likes_url();
//
// public abstract String projects_url();
//
// public abstract String rebounds_url();
//
// public abstract boolean animated();
//
// public abstract List<String> tags();
//
// @Nullable
// public abstract User user();
//
// @Nullable
// public abstract Team team();
//
// public abstract Shot withUser(User user);
//
// public abstract Shot withLikesCount(long likes_count);
//
// public static TypeAdapter<Shot> typeAdapter(Gson gson) {
// return new AutoValue_Shot.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/ShotLike.java
// @AutoValue
// public abstract class ShotLike implements Parcelable {
//
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract Shot shot();
//
// public static TypeAdapter<ShotLike> typeAdapter(Gson gson) {
// return new AutoValue_ShotLike.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/User.java
// @AutoValue
// public abstract class User implements Parcelable {
//
// public abstract long id();
//
// public abstract String name();
//
// public abstract String username();
//
// public abstract String html_url();
//
// public abstract String avatar_url();
//
// public abstract String bio();
//
// @Nullable
// public abstract String location();
//
// public abstract Links links();
//
// public abstract long buckets_count();
//
// public abstract long comments_received_count();
//
// public abstract long followers_count();
//
// public abstract long followings_count();
//
// public abstract long likes_count();
//
// public abstract long likes_received_count();
//
// public abstract long projects_count();
//
// public abstract long rebounds_received_count();
//
// public abstract long shots_count();
//
// public abstract long teams_count();
//
// public abstract boolean can_upload_shot();
//
// public abstract String type();
//
// public abstract boolean pro();
//
// public abstract String buckets_url();
//
// public abstract String followers_url();
//
// public abstract String following_url();
//
// public abstract String likes_url();
//
// public abstract String shots_url();
//
// @Nullable
// public abstract String teams_url();
//
// public abstract String created_at();
//
// public abstract String updated_at();
//
// public static TypeAdapter<User> typeAdapter(Gson gson) {
// return new AutoValue_User.GsonTypeAdapter(gson).nullSafe();
// }
// }
|
import retrofit2.http.Query;
import retrofit2.http.Url;
import com.ge.protein.data.model.Followee;
import com.ge.protein.data.model.Follower;
import com.ge.protein.data.model.Shot;
import com.ge.protein.data.model.ShotLike;
import com.ge.protein.data.model.User;
import java.util.List;
import io.reactivex.Observable;
import retrofit2.Response;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.PUT;
import retrofit2.http.Path;
|
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.data.api.service;
public interface UserService {
@GET("/v1/user")
Observable<Response<User>> getMe();
@GET("/v1/users/{user_id}/shots")
Observable<Response<List<Shot>>> listShotsForUser(@Path("user_id") long userId,
@Query("per_page") int perPage);
@GET("/v1/users/{user_id}/likes")
|
// Path: app/src/main/java/com/ge/protein/data/model/Followee.java
// @AutoValue
// public abstract class Followee implements Parcelable {
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract User followee();
//
// public static TypeAdapter<Followee> typeAdapter(Gson gson) {
// return new AutoValue_Followee.GsonTypeAdapter(gson).nullSafe();
// }
//
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/Follower.java
// @AutoValue
// public abstract class Follower implements Parcelable {
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract User follower();
//
// public static TypeAdapter<Follower> typeAdapter(Gson gson) {
// return new AutoValue_Follower.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/Shot.java
// @AutoValue
// public abstract class Shot implements Parcelable {
//
// public abstract long id();
//
// public abstract String title();
//
// @Nullable
// public abstract String description();
//
// public abstract int width();
//
// public abstract int height();
//
// public abstract Images images();
//
// public abstract long views_count();
//
// public abstract long likes_count();
//
// public abstract long comments_count();
//
// public abstract long attachments_count();
//
// public abstract long rebounds_count();
//
// public abstract long buckets_count();
//
// public abstract Date created_at();
//
// public abstract Date updated_at();
//
// public abstract String html_url();
//
// public abstract String attachments_url();
//
// public abstract String buckets_url();
//
// public abstract String comments_url();
//
// public abstract String likes_url();
//
// public abstract String projects_url();
//
// public abstract String rebounds_url();
//
// public abstract boolean animated();
//
// public abstract List<String> tags();
//
// @Nullable
// public abstract User user();
//
// @Nullable
// public abstract Team team();
//
// public abstract Shot withUser(User user);
//
// public abstract Shot withLikesCount(long likes_count);
//
// public static TypeAdapter<Shot> typeAdapter(Gson gson) {
// return new AutoValue_Shot.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/ShotLike.java
// @AutoValue
// public abstract class ShotLike implements Parcelable {
//
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract Shot shot();
//
// public static TypeAdapter<ShotLike> typeAdapter(Gson gson) {
// return new AutoValue_ShotLike.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/User.java
// @AutoValue
// public abstract class User implements Parcelable {
//
// public abstract long id();
//
// public abstract String name();
//
// public abstract String username();
//
// public abstract String html_url();
//
// public abstract String avatar_url();
//
// public abstract String bio();
//
// @Nullable
// public abstract String location();
//
// public abstract Links links();
//
// public abstract long buckets_count();
//
// public abstract long comments_received_count();
//
// public abstract long followers_count();
//
// public abstract long followings_count();
//
// public abstract long likes_count();
//
// public abstract long likes_received_count();
//
// public abstract long projects_count();
//
// public abstract long rebounds_received_count();
//
// public abstract long shots_count();
//
// public abstract long teams_count();
//
// public abstract boolean can_upload_shot();
//
// public abstract String type();
//
// public abstract boolean pro();
//
// public abstract String buckets_url();
//
// public abstract String followers_url();
//
// public abstract String following_url();
//
// public abstract String likes_url();
//
// public abstract String shots_url();
//
// @Nullable
// public abstract String teams_url();
//
// public abstract String created_at();
//
// public abstract String updated_at();
//
// public static TypeAdapter<User> typeAdapter(Gson gson) {
// return new AutoValue_User.GsonTypeAdapter(gson).nullSafe();
// }
// }
// Path: app/src/main/java/com/ge/protein/data/api/service/UserService.java
import retrofit2.http.Query;
import retrofit2.http.Url;
import com.ge.protein.data.model.Followee;
import com.ge.protein.data.model.Follower;
import com.ge.protein.data.model.Shot;
import com.ge.protein.data.model.ShotLike;
import com.ge.protein.data.model.User;
import java.util.List;
import io.reactivex.Observable;
import retrofit2.Response;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.PUT;
import retrofit2.http.Path;
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.data.api.service;
public interface UserService {
@GET("/v1/user")
Observable<Response<User>> getMe();
@GET("/v1/users/{user_id}/shots")
Observable<Response<List<Shot>>> listShotsForUser(@Path("user_id") long userId,
@Query("per_page") int perPage);
@GET("/v1/users/{user_id}/likes")
|
Observable<Response<List<ShotLike>>> listShotLikesForUser(@Path("user_id") long userId,
|
gejiaheng/Protein
|
app/src/main/java/com/ge/protein/data/api/service/UserService.java
|
// Path: app/src/main/java/com/ge/protein/data/model/Followee.java
// @AutoValue
// public abstract class Followee implements Parcelable {
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract User followee();
//
// public static TypeAdapter<Followee> typeAdapter(Gson gson) {
// return new AutoValue_Followee.GsonTypeAdapter(gson).nullSafe();
// }
//
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/Follower.java
// @AutoValue
// public abstract class Follower implements Parcelable {
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract User follower();
//
// public static TypeAdapter<Follower> typeAdapter(Gson gson) {
// return new AutoValue_Follower.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/Shot.java
// @AutoValue
// public abstract class Shot implements Parcelable {
//
// public abstract long id();
//
// public abstract String title();
//
// @Nullable
// public abstract String description();
//
// public abstract int width();
//
// public abstract int height();
//
// public abstract Images images();
//
// public abstract long views_count();
//
// public abstract long likes_count();
//
// public abstract long comments_count();
//
// public abstract long attachments_count();
//
// public abstract long rebounds_count();
//
// public abstract long buckets_count();
//
// public abstract Date created_at();
//
// public abstract Date updated_at();
//
// public abstract String html_url();
//
// public abstract String attachments_url();
//
// public abstract String buckets_url();
//
// public abstract String comments_url();
//
// public abstract String likes_url();
//
// public abstract String projects_url();
//
// public abstract String rebounds_url();
//
// public abstract boolean animated();
//
// public abstract List<String> tags();
//
// @Nullable
// public abstract User user();
//
// @Nullable
// public abstract Team team();
//
// public abstract Shot withUser(User user);
//
// public abstract Shot withLikesCount(long likes_count);
//
// public static TypeAdapter<Shot> typeAdapter(Gson gson) {
// return new AutoValue_Shot.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/ShotLike.java
// @AutoValue
// public abstract class ShotLike implements Parcelable {
//
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract Shot shot();
//
// public static TypeAdapter<ShotLike> typeAdapter(Gson gson) {
// return new AutoValue_ShotLike.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/User.java
// @AutoValue
// public abstract class User implements Parcelable {
//
// public abstract long id();
//
// public abstract String name();
//
// public abstract String username();
//
// public abstract String html_url();
//
// public abstract String avatar_url();
//
// public abstract String bio();
//
// @Nullable
// public abstract String location();
//
// public abstract Links links();
//
// public abstract long buckets_count();
//
// public abstract long comments_received_count();
//
// public abstract long followers_count();
//
// public abstract long followings_count();
//
// public abstract long likes_count();
//
// public abstract long likes_received_count();
//
// public abstract long projects_count();
//
// public abstract long rebounds_received_count();
//
// public abstract long shots_count();
//
// public abstract long teams_count();
//
// public abstract boolean can_upload_shot();
//
// public abstract String type();
//
// public abstract boolean pro();
//
// public abstract String buckets_url();
//
// public abstract String followers_url();
//
// public abstract String following_url();
//
// public abstract String likes_url();
//
// public abstract String shots_url();
//
// @Nullable
// public abstract String teams_url();
//
// public abstract String created_at();
//
// public abstract String updated_at();
//
// public static TypeAdapter<User> typeAdapter(Gson gson) {
// return new AutoValue_User.GsonTypeAdapter(gson).nullSafe();
// }
// }
|
import retrofit2.http.Query;
import retrofit2.http.Url;
import com.ge.protein.data.model.Followee;
import com.ge.protein.data.model.Follower;
import com.ge.protein.data.model.Shot;
import com.ge.protein.data.model.ShotLike;
import com.ge.protein.data.model.User;
import java.util.List;
import io.reactivex.Observable;
import retrofit2.Response;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.PUT;
import retrofit2.http.Path;
|
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.data.api.service;
public interface UserService {
@GET("/v1/user")
Observable<Response<User>> getMe();
@GET("/v1/users/{user_id}/shots")
Observable<Response<List<Shot>>> listShotsForUser(@Path("user_id") long userId,
@Query("per_page") int perPage);
@GET("/v1/users/{user_id}/likes")
Observable<Response<List<ShotLike>>> listShotLikesForUser(@Path("user_id") long userId,
@Query("per_page") int perPage);
@GET
Observable<Response<List<ShotLike>>> listShotLikesForUserOfNextPage(@Url String url);
@GET("/v1/users/{user_id}/following")
|
// Path: app/src/main/java/com/ge/protein/data/model/Followee.java
// @AutoValue
// public abstract class Followee implements Parcelable {
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract User followee();
//
// public static TypeAdapter<Followee> typeAdapter(Gson gson) {
// return new AutoValue_Followee.GsonTypeAdapter(gson).nullSafe();
// }
//
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/Follower.java
// @AutoValue
// public abstract class Follower implements Parcelable {
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract User follower();
//
// public static TypeAdapter<Follower> typeAdapter(Gson gson) {
// return new AutoValue_Follower.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/Shot.java
// @AutoValue
// public abstract class Shot implements Parcelable {
//
// public abstract long id();
//
// public abstract String title();
//
// @Nullable
// public abstract String description();
//
// public abstract int width();
//
// public abstract int height();
//
// public abstract Images images();
//
// public abstract long views_count();
//
// public abstract long likes_count();
//
// public abstract long comments_count();
//
// public abstract long attachments_count();
//
// public abstract long rebounds_count();
//
// public abstract long buckets_count();
//
// public abstract Date created_at();
//
// public abstract Date updated_at();
//
// public abstract String html_url();
//
// public abstract String attachments_url();
//
// public abstract String buckets_url();
//
// public abstract String comments_url();
//
// public abstract String likes_url();
//
// public abstract String projects_url();
//
// public abstract String rebounds_url();
//
// public abstract boolean animated();
//
// public abstract List<String> tags();
//
// @Nullable
// public abstract User user();
//
// @Nullable
// public abstract Team team();
//
// public abstract Shot withUser(User user);
//
// public abstract Shot withLikesCount(long likes_count);
//
// public static TypeAdapter<Shot> typeAdapter(Gson gson) {
// return new AutoValue_Shot.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/ShotLike.java
// @AutoValue
// public abstract class ShotLike implements Parcelable {
//
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract Shot shot();
//
// public static TypeAdapter<ShotLike> typeAdapter(Gson gson) {
// return new AutoValue_ShotLike.GsonTypeAdapter(gson).nullSafe();
// }
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/User.java
// @AutoValue
// public abstract class User implements Parcelable {
//
// public abstract long id();
//
// public abstract String name();
//
// public abstract String username();
//
// public abstract String html_url();
//
// public abstract String avatar_url();
//
// public abstract String bio();
//
// @Nullable
// public abstract String location();
//
// public abstract Links links();
//
// public abstract long buckets_count();
//
// public abstract long comments_received_count();
//
// public abstract long followers_count();
//
// public abstract long followings_count();
//
// public abstract long likes_count();
//
// public abstract long likes_received_count();
//
// public abstract long projects_count();
//
// public abstract long rebounds_received_count();
//
// public abstract long shots_count();
//
// public abstract long teams_count();
//
// public abstract boolean can_upload_shot();
//
// public abstract String type();
//
// public abstract boolean pro();
//
// public abstract String buckets_url();
//
// public abstract String followers_url();
//
// public abstract String following_url();
//
// public abstract String likes_url();
//
// public abstract String shots_url();
//
// @Nullable
// public abstract String teams_url();
//
// public abstract String created_at();
//
// public abstract String updated_at();
//
// public static TypeAdapter<User> typeAdapter(Gson gson) {
// return new AutoValue_User.GsonTypeAdapter(gson).nullSafe();
// }
// }
// Path: app/src/main/java/com/ge/protein/data/api/service/UserService.java
import retrofit2.http.Query;
import retrofit2.http.Url;
import com.ge.protein.data.model.Followee;
import com.ge.protein.data.model.Follower;
import com.ge.protein.data.model.Shot;
import com.ge.protein.data.model.ShotLike;
import com.ge.protein.data.model.User;
import java.util.List;
import io.reactivex.Observable;
import retrofit2.Response;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.PUT;
import retrofit2.http.Path;
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.data.api.service;
public interface UserService {
@GET("/v1/user")
Observable<Response<User>> getMe();
@GET("/v1/users/{user_id}/shots")
Observable<Response<List<Shot>>> listShotsForUser(@Path("user_id") long userId,
@Query("per_page") int perPage);
@GET("/v1/users/{user_id}/likes")
Observable<Response<List<ShotLike>>> listShotLikesForUser(@Path("user_id") long userId,
@Query("per_page") int perPage);
@GET
Observable<Response<List<ShotLike>>> listShotLikesForUserOfNextPage(@Url String url);
@GET("/v1/users/{user_id}/following")
|
Observable<Response<List<Followee>>> listUserFollowing(@Path("user_id") long userId,
|
gejiaheng/Protein
|
app/src/main/java/com/ge/protein/auth/AuthFragment.java
|
// Path: app/src/main/java/com/ge/protein/data/api/ApiConstants.java
// public final class ApiConstants {
//
// private ApiConstants() {
// throw new AssertionError("No construction for constant class");
// }
//
// // general constants of Dribbble API
// public static final String DRIBBBLE_V1_BASE_URL = "https://api.dribbble.com";
// public static final String DRIBBBLE_AUTHORIZE_URL = "https://dribbble.com/oauth/authorize";
// public static final String DRIBBBLE_GET_ACCESS_TOKEN_URL = "https://dribbble.com/oauth/token";
//
// // for both flavor open and play
// public static final String DRIBBBLE_AUTHORIZE_CALLBACK_URI = "x-protein-oauth-dribbble://callback";
// public static final String DRIBBBLE_AUTHORIZE_CALLBACK_URI_SCHEMA = "x-protein-oauth-dribbble";
// public static final String DRIBBBLE_AUTHORIZE_CALLBACK_URI_HOST = "callback";
// public static final String DRIBBBLE_AUTHORIZE_SCOPE = "public write comment upload";
//
// public static final int PER_PAGE = 20;
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/BaseFragment.java
// public class BaseFragment extends RxFragment {
// }
|
import android.app.ProgressDialog;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.CookieManager;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;
import android.widget.Toast;
import com.ge.protein.BuildConfig;
import com.ge.protein.R;
import com.ge.protein.data.api.ApiConstants;
import com.ge.protein.mvp.BaseFragment;
import butterknife.BindView;
import butterknife.ButterKnife;
|
public static AuthFragment newInstance() {
return new AuthFragment();
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle
savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_auth, container, false);
ButterKnife.bind(this, view);
return view;
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
toolbar.setTitle(R.string.label_auth);
swipeRefreshLayout.setOnRefreshListener(this);
progressBar.setProgressTintList(
ResourcesCompat.getColorStateList(getResources(), R.color.colorAccent, getActivity().getTheme()));
cleanWebView();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
webview.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
Uri uri = request.getUrl();
|
// Path: app/src/main/java/com/ge/protein/data/api/ApiConstants.java
// public final class ApiConstants {
//
// private ApiConstants() {
// throw new AssertionError("No construction for constant class");
// }
//
// // general constants of Dribbble API
// public static final String DRIBBBLE_V1_BASE_URL = "https://api.dribbble.com";
// public static final String DRIBBBLE_AUTHORIZE_URL = "https://dribbble.com/oauth/authorize";
// public static final String DRIBBBLE_GET_ACCESS_TOKEN_URL = "https://dribbble.com/oauth/token";
//
// // for both flavor open and play
// public static final String DRIBBBLE_AUTHORIZE_CALLBACK_URI = "x-protein-oauth-dribbble://callback";
// public static final String DRIBBBLE_AUTHORIZE_CALLBACK_URI_SCHEMA = "x-protein-oauth-dribbble";
// public static final String DRIBBBLE_AUTHORIZE_CALLBACK_URI_HOST = "callback";
// public static final String DRIBBBLE_AUTHORIZE_SCOPE = "public write comment upload";
//
// public static final int PER_PAGE = 20;
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/BaseFragment.java
// public class BaseFragment extends RxFragment {
// }
// Path: app/src/main/java/com/ge/protein/auth/AuthFragment.java
import android.app.ProgressDialog;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.CookieManager;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;
import android.widget.Toast;
import com.ge.protein.BuildConfig;
import com.ge.protein.R;
import com.ge.protein.data.api.ApiConstants;
import com.ge.protein.mvp.BaseFragment;
import butterknife.BindView;
import butterknife.ButterKnife;
public static AuthFragment newInstance() {
return new AuthFragment();
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle
savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_auth, container, false);
ButterKnife.bind(this, view);
return view;
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
toolbar.setTitle(R.string.label_auth);
swipeRefreshLayout.setOnRefreshListener(this);
progressBar.setProgressTintList(
ResourcesCompat.getColorStateList(getResources(), R.color.colorAccent, getActivity().getTheme()));
cleanWebView();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
webview.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
Uri uri = request.getUrl();
|
if (ApiConstants.DRIBBBLE_AUTHORIZE_CALLBACK_URI_SCHEMA.equals(uri.getScheme())
|
gejiaheng/Protein
|
app/src/main/java/com/ge/protein/about/AboutPresenter.java
|
// Path: app/src/main/java/com/ge/protein/util/Preconditions.java
// public static <T> T checkNotNull(T reference, @Nullable Object errorMessage) {
// if(reference == null) {
// throw new NullPointerException(String.valueOf(errorMessage));
// } else {
// return reference;
// }
// }
|
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.support.annotation.NonNull;
import com.ge.droid.mdlicense.Library;
import com.ge.droid.mdlicense.MDLicenseIntent;
import java.util.ArrayList;
import static com.ge.protein.util.Preconditions.checkNotNull;
|
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.about;
class AboutPresenter implements AboutContract.Presenter {
private static final String PROTEIN_MARKET_LINK = "market://details?id=com.ge.protein";
private static final String PROTEIN_WEB_LINK = "http://play.google.com/store/apps/details?id=com.ge.protein";
@NonNull
private AboutContract.View view;
AboutPresenter(@NonNull AboutContract.View view) {
|
// Path: app/src/main/java/com/ge/protein/util/Preconditions.java
// public static <T> T checkNotNull(T reference, @Nullable Object errorMessage) {
// if(reference == null) {
// throw new NullPointerException(String.valueOf(errorMessage));
// } else {
// return reference;
// }
// }
// Path: app/src/main/java/com/ge/protein/about/AboutPresenter.java
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.support.annotation.NonNull;
import com.ge.droid.mdlicense.Library;
import com.ge.droid.mdlicense.MDLicenseIntent;
import java.util.ArrayList;
import static com.ge.protein.util.Preconditions.checkNotNull;
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.about;
class AboutPresenter implements AboutContract.Presenter {
private static final String PROTEIN_MARKET_LINK = "market://details?id=com.ge.protein";
private static final String PROTEIN_WEB_LINK = "http://play.google.com/store/apps/details?id=com.ge.protein";
@NonNull
private AboutContract.View view;
AboutPresenter(@NonNull AboutContract.View view) {
|
this.view = checkNotNull(view, "view cannot be null");
|
gejiaheng/Protein
|
app/src/main/java/com/ge/protein/comment/post/CommentPostContract.java
|
// Path: app/src/main/java/com/ge/protein/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void start();
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/BaseView.java
// public interface BaseView<T> {
//
// void setPresenter(T presenter);
//
// Context getContext();
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/SnackbarView.java
// public interface SnackbarView {
//
// void showSnackbar(@StringRes int resId);
//
// void showSnackbar(String message);
// }
|
import com.ge.protein.mvp.BasePresenter;
import com.ge.protein.mvp.BaseView;
import com.ge.protein.mvp.SnackbarView;
|
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.comment.post;
interface CommentPostContract {
interface View extends BaseView<Presenter>, SnackbarView {
void fillInput(CharSequence text);
}
|
// Path: app/src/main/java/com/ge/protein/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void start();
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/BaseView.java
// public interface BaseView<T> {
//
// void setPresenter(T presenter);
//
// Context getContext();
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/SnackbarView.java
// public interface SnackbarView {
//
// void showSnackbar(@StringRes int resId);
//
// void showSnackbar(String message);
// }
// Path: app/src/main/java/com/ge/protein/comment/post/CommentPostContract.java
import com.ge.protein.mvp.BasePresenter;
import com.ge.protein.mvp.BaseView;
import com.ge.protein.mvp.SnackbarView;
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.comment.post;
interface CommentPostContract {
interface View extends BaseView<Presenter>, SnackbarView {
void fillInput(CharSequence text);
}
|
interface Presenter extends BasePresenter {
|
gejiaheng/Protein
|
app/src/main/java/com/ge/protein/ui/epoxy/models/FolloweeModel.java
|
// Path: app/src/main/java/com/ge/protein/data/model/Followee.java
// @AutoValue
// public abstract class Followee implements Parcelable {
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract User followee();
//
// public static TypeAdapter<Followee> typeAdapter(Gson gson) {
// return new AutoValue_Followee.GsonTypeAdapter(gson).nullSafe();
// }
//
// }
//
// Path: app/src/main/java/com/ge/protein/ui/epoxy/BaseEpoxyHolder.java
// public abstract class BaseEpoxyHolder extends EpoxyHolder {
// @CallSuper
// @Override
// protected void bindView(View itemView) {
// ButterKnife.bind(this, itemView);
// }
// }
|
import butterknife.BindView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModelClass;
import com.airbnb.epoxy.EpoxyModelWithHolder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.TransitionOptions;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.ge.protein.R;
import com.ge.protein.data.model.Followee;
import com.ge.protein.ui.epoxy.BaseEpoxyHolder;
|
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.ui.epoxy.models;
@EpoxyModelClass(layout = R.layout.epoxy_followee)
public abstract class FolloweeModel extends EpoxyModelWithHolder<FolloweeModel.FolloweeHolder> {
@EpoxyAttribute
View.OnClickListener itemOnClickListener;
@EpoxyAttribute
|
// Path: app/src/main/java/com/ge/protein/data/model/Followee.java
// @AutoValue
// public abstract class Followee implements Parcelable {
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract User followee();
//
// public static TypeAdapter<Followee> typeAdapter(Gson gson) {
// return new AutoValue_Followee.GsonTypeAdapter(gson).nullSafe();
// }
//
// }
//
// Path: app/src/main/java/com/ge/protein/ui/epoxy/BaseEpoxyHolder.java
// public abstract class BaseEpoxyHolder extends EpoxyHolder {
// @CallSuper
// @Override
// protected void bindView(View itemView) {
// ButterKnife.bind(this, itemView);
// }
// }
// Path: app/src/main/java/com/ge/protein/ui/epoxy/models/FolloweeModel.java
import butterknife.BindView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModelClass;
import com.airbnb.epoxy.EpoxyModelWithHolder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.TransitionOptions;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.ge.protein.R;
import com.ge.protein.data.model.Followee;
import com.ge.protein.ui.epoxy.BaseEpoxyHolder;
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.ui.epoxy.models;
@EpoxyModelClass(layout = R.layout.epoxy_followee)
public abstract class FolloweeModel extends EpoxyModelWithHolder<FolloweeModel.FolloweeHolder> {
@EpoxyAttribute
View.OnClickListener itemOnClickListener;
@EpoxyAttribute
|
Followee followee;
|
gejiaheng/Protein
|
app/src/main/java/com/ge/protein/ui/epoxy/models/FolloweeModel.java
|
// Path: app/src/main/java/com/ge/protein/data/model/Followee.java
// @AutoValue
// public abstract class Followee implements Parcelable {
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract User followee();
//
// public static TypeAdapter<Followee> typeAdapter(Gson gson) {
// return new AutoValue_Followee.GsonTypeAdapter(gson).nullSafe();
// }
//
// }
//
// Path: app/src/main/java/com/ge/protein/ui/epoxy/BaseEpoxyHolder.java
// public abstract class BaseEpoxyHolder extends EpoxyHolder {
// @CallSuper
// @Override
// protected void bindView(View itemView) {
// ButterKnife.bind(this, itemView);
// }
// }
|
import butterknife.BindView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModelClass;
import com.airbnb.epoxy.EpoxyModelWithHolder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.TransitionOptions;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.ge.protein.R;
import com.ge.protein.data.model.Followee;
import com.ge.protein.ui.epoxy.BaseEpoxyHolder;
|
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.ui.epoxy.models;
@EpoxyModelClass(layout = R.layout.epoxy_followee)
public abstract class FolloweeModel extends EpoxyModelWithHolder<FolloweeModel.FolloweeHolder> {
@EpoxyAttribute
View.OnClickListener itemOnClickListener;
@EpoxyAttribute
Followee followee;
private TransitionOptions transitionOptions = DrawableTransitionOptions.withCrossFade();
private RequestOptions requestOptions = RequestOptions.placeholderOf(R.color.avatar_placeholder)
.diskCacheStrategy(DiskCacheStrategy.ALL);
@Override
protected FolloweeHolder createNewHolder() {
return new FolloweeHolder();
}
@Override
public void bind(FolloweeHolder holder) {
super.bind(holder);
holder.name.setText(followee.followee().name());
holder.info.setText(holder.itemView.getContext().getString(R.string.user_info, followee.followee().shots_count(),
followee.followee().followers_count()));
Glide.with(holder.itemView.getContext())
.load(followee.followee().avatar_url())
.transition(transitionOptions)
.apply(requestOptions)
.into(holder.avatar);
holder.itemView.setOnClickListener(itemOnClickListener);
holder.itemView.setTag(R.id.clicked_model, followee);
}
|
// Path: app/src/main/java/com/ge/protein/data/model/Followee.java
// @AutoValue
// public abstract class Followee implements Parcelable {
//
// public abstract long id();
//
// public abstract String created_at();
//
// public abstract User followee();
//
// public static TypeAdapter<Followee> typeAdapter(Gson gson) {
// return new AutoValue_Followee.GsonTypeAdapter(gson).nullSafe();
// }
//
// }
//
// Path: app/src/main/java/com/ge/protein/ui/epoxy/BaseEpoxyHolder.java
// public abstract class BaseEpoxyHolder extends EpoxyHolder {
// @CallSuper
// @Override
// protected void bindView(View itemView) {
// ButterKnife.bind(this, itemView);
// }
// }
// Path: app/src/main/java/com/ge/protein/ui/epoxy/models/FolloweeModel.java
import butterknife.BindView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModelClass;
import com.airbnb.epoxy.EpoxyModelWithHolder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.TransitionOptions;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.ge.protein.R;
import com.ge.protein.data.model.Followee;
import com.ge.protein.ui.epoxy.BaseEpoxyHolder;
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.ui.epoxy.models;
@EpoxyModelClass(layout = R.layout.epoxy_followee)
public abstract class FolloweeModel extends EpoxyModelWithHolder<FolloweeModel.FolloweeHolder> {
@EpoxyAttribute
View.OnClickListener itemOnClickListener;
@EpoxyAttribute
Followee followee;
private TransitionOptions transitionOptions = DrawableTransitionOptions.withCrossFade();
private RequestOptions requestOptions = RequestOptions.placeholderOf(R.color.avatar_placeholder)
.diskCacheStrategy(DiskCacheStrategy.ALL);
@Override
protected FolloweeHolder createNewHolder() {
return new FolloweeHolder();
}
@Override
public void bind(FolloweeHolder holder) {
super.bind(holder);
holder.name.setText(followee.followee().name());
holder.info.setText(holder.itemView.getContext().getString(R.string.user_info, followee.followee().shots_count(),
followee.followee().followers_count()));
Glide.with(holder.itemView.getContext())
.load(followee.followee().avatar_url())
.transition(transitionOptions)
.apply(requestOptions)
.into(holder.avatar);
holder.itemView.setOnClickListener(itemOnClickListener);
holder.itemView.setTag(R.id.clicked_model, followee);
}
|
static class FolloweeHolder extends BaseEpoxyHolder {
|
gejiaheng/Protein
|
app/src/main/java/com/ge/protein/user/UserContract.java
|
// Path: app/src/main/java/com/ge/protein/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void start();
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/BaseView.java
// public interface BaseView<T> {
//
// void setPresenter(T presenter);
//
// Context getContext();
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/User.java
// @AutoValue
// public abstract class User implements Parcelable {
//
// public abstract long id();
//
// public abstract String name();
//
// public abstract String username();
//
// public abstract String html_url();
//
// public abstract String avatar_url();
//
// public abstract String bio();
//
// @Nullable
// public abstract String location();
//
// public abstract Links links();
//
// public abstract long buckets_count();
//
// public abstract long comments_received_count();
//
// public abstract long followers_count();
//
// public abstract long followings_count();
//
// public abstract long likes_count();
//
// public abstract long likes_received_count();
//
// public abstract long projects_count();
//
// public abstract long rebounds_received_count();
//
// public abstract long shots_count();
//
// public abstract long teams_count();
//
// public abstract boolean can_upload_shot();
//
// public abstract String type();
//
// public abstract boolean pro();
//
// public abstract String buckets_url();
//
// public abstract String followers_url();
//
// public abstract String following_url();
//
// public abstract String likes_url();
//
// public abstract String shots_url();
//
// @Nullable
// public abstract String teams_url();
//
// public abstract String created_at();
//
// public abstract String updated_at();
//
// public static TypeAdapter<User> typeAdapter(Gson gson) {
// return new AutoValue_User.GsonTypeAdapter(gson).nullSafe();
// }
// }
|
import com.ge.protein.mvp.BasePresenter;
import com.ge.protein.mvp.BaseView;
import com.ge.protein.data.model.User;
|
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.user;
interface UserContract {
interface View extends BaseView<Presenter> {
|
// Path: app/src/main/java/com/ge/protein/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void start();
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/BaseView.java
// public interface BaseView<T> {
//
// void setPresenter(T presenter);
//
// Context getContext();
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/User.java
// @AutoValue
// public abstract class User implements Parcelable {
//
// public abstract long id();
//
// public abstract String name();
//
// public abstract String username();
//
// public abstract String html_url();
//
// public abstract String avatar_url();
//
// public abstract String bio();
//
// @Nullable
// public abstract String location();
//
// public abstract Links links();
//
// public abstract long buckets_count();
//
// public abstract long comments_received_count();
//
// public abstract long followers_count();
//
// public abstract long followings_count();
//
// public abstract long likes_count();
//
// public abstract long likes_received_count();
//
// public abstract long projects_count();
//
// public abstract long rebounds_received_count();
//
// public abstract long shots_count();
//
// public abstract long teams_count();
//
// public abstract boolean can_upload_shot();
//
// public abstract String type();
//
// public abstract boolean pro();
//
// public abstract String buckets_url();
//
// public abstract String followers_url();
//
// public abstract String following_url();
//
// public abstract String likes_url();
//
// public abstract String shots_url();
//
// @Nullable
// public abstract String teams_url();
//
// public abstract String created_at();
//
// public abstract String updated_at();
//
// public static TypeAdapter<User> typeAdapter(Gson gson) {
// return new AutoValue_User.GsonTypeAdapter(gson).nullSafe();
// }
// }
// Path: app/src/main/java/com/ge/protein/user/UserContract.java
import com.ge.protein.mvp.BasePresenter;
import com.ge.protein.mvp.BaseView;
import com.ge.protein.data.model.User;
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.user;
interface UserContract {
interface View extends BaseView<Presenter> {
|
void setupView(User user);
|
gejiaheng/Protein
|
app/src/main/java/com/ge/protein/user/UserContract.java
|
// Path: app/src/main/java/com/ge/protein/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void start();
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/BaseView.java
// public interface BaseView<T> {
//
// void setPresenter(T presenter);
//
// Context getContext();
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/User.java
// @AutoValue
// public abstract class User implements Parcelable {
//
// public abstract long id();
//
// public abstract String name();
//
// public abstract String username();
//
// public abstract String html_url();
//
// public abstract String avatar_url();
//
// public abstract String bio();
//
// @Nullable
// public abstract String location();
//
// public abstract Links links();
//
// public abstract long buckets_count();
//
// public abstract long comments_received_count();
//
// public abstract long followers_count();
//
// public abstract long followings_count();
//
// public abstract long likes_count();
//
// public abstract long likes_received_count();
//
// public abstract long projects_count();
//
// public abstract long rebounds_received_count();
//
// public abstract long shots_count();
//
// public abstract long teams_count();
//
// public abstract boolean can_upload_shot();
//
// public abstract String type();
//
// public abstract boolean pro();
//
// public abstract String buckets_url();
//
// public abstract String followers_url();
//
// public abstract String following_url();
//
// public abstract String likes_url();
//
// public abstract String shots_url();
//
// @Nullable
// public abstract String teams_url();
//
// public abstract String created_at();
//
// public abstract String updated_at();
//
// public static TypeAdapter<User> typeAdapter(Gson gson) {
// return new AutoValue_User.GsonTypeAdapter(gson).nullSafe();
// }
// }
|
import com.ge.protein.mvp.BasePresenter;
import com.ge.protein.mvp.BaseView;
import com.ge.protein.data.model.User;
|
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.user;
interface UserContract {
interface View extends BaseView<Presenter> {
void setupView(User user);
void showUser(User user);
void setFollowButtonEnabled(boolean enabled);
void setFollowButtonVisibility(boolean visible);
void setFollowing(boolean following);
}
|
// Path: app/src/main/java/com/ge/protein/mvp/BasePresenter.java
// public interface BasePresenter {
//
// void start();
// }
//
// Path: app/src/main/java/com/ge/protein/mvp/BaseView.java
// public interface BaseView<T> {
//
// void setPresenter(T presenter);
//
// Context getContext();
// }
//
// Path: app/src/main/java/com/ge/protein/data/model/User.java
// @AutoValue
// public abstract class User implements Parcelable {
//
// public abstract long id();
//
// public abstract String name();
//
// public abstract String username();
//
// public abstract String html_url();
//
// public abstract String avatar_url();
//
// public abstract String bio();
//
// @Nullable
// public abstract String location();
//
// public abstract Links links();
//
// public abstract long buckets_count();
//
// public abstract long comments_received_count();
//
// public abstract long followers_count();
//
// public abstract long followings_count();
//
// public abstract long likes_count();
//
// public abstract long likes_received_count();
//
// public abstract long projects_count();
//
// public abstract long rebounds_received_count();
//
// public abstract long shots_count();
//
// public abstract long teams_count();
//
// public abstract boolean can_upload_shot();
//
// public abstract String type();
//
// public abstract boolean pro();
//
// public abstract String buckets_url();
//
// public abstract String followers_url();
//
// public abstract String following_url();
//
// public abstract String likes_url();
//
// public abstract String shots_url();
//
// @Nullable
// public abstract String teams_url();
//
// public abstract String created_at();
//
// public abstract String updated_at();
//
// public static TypeAdapter<User> typeAdapter(Gson gson) {
// return new AutoValue_User.GsonTypeAdapter(gson).nullSafe();
// }
// }
// Path: app/src/main/java/com/ge/protein/user/UserContract.java
import com.ge.protein.mvp.BasePresenter;
import com.ge.protein.mvp.BaseView;
import com.ge.protein.data.model.User;
/*
* Copyright 2017 Jiaheng Ge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ge.protein.user;
interface UserContract {
interface View extends BaseView<Presenter> {
void setupView(User user);
void showUser(User user);
void setFollowButtonEnabled(boolean enabled);
void setFollowButtonVisibility(boolean visible);
void setFollowing(boolean following);
}
|
interface Presenter extends BasePresenter {
|
policeman-tools/forbidden-apis
|
src/test/java/de/thetaphi/forbiddenapis/AsmUtilsTest.java
|
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static Pattern glob2Pattern(String... globs) {
// final StringBuilder regex = new StringBuilder();
// boolean needOr = false;
// for (String glob : globs) {
// if (needOr) {
// regex.append('|');
// }
// int i = 0, len = glob.length();
// while (i < len) {
// char c = glob.charAt(i++);
// switch (c) {
// case '*':
// if (i < len && glob.charAt(i) == '*') {
// // crosses package boundaries
// regex.append(".*");
// i++;
// } else {
// // do not cross package boundaries
// regex.append("[^.]*");
// }
// break;
//
// case '?':
// // do not cross package boundaries
// regex.append("[^.]");
// break;
//
// default:
// if (isRegexMeta(c)) {
// regex.append('\\');
// }
// regex.append(c);
// }
// }
// needOr = true;
// }
// return Pattern.compile(regex.toString(), 0);
// }
//
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static boolean isGlob(String s) {
// return s.indexOf('*') >= 0 || s.indexOf('?') >= 0;
// }
//
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static boolean isPortableRuntimeClass(String className) {
// return PORTABLE_RUNTIME_PACKAGE_PATTERN.matcher(className).matches();
// }
//
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static boolean isRuntimeModule(String module) {
// return module != null && RUNTIME_MODULES_PATTERN.matcher(module).matches();
// }
|
import static de.thetaphi.forbiddenapis.AsmUtils.glob2Pattern;
import static de.thetaphi.forbiddenapis.AsmUtils.isGlob;
import static de.thetaphi.forbiddenapis.AsmUtils.isPortableRuntimeClass;
import static de.thetaphi.forbiddenapis.AsmUtils.isRuntimeModule;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.regex.Pattern;
import org.junit.Test;
|
/*
* (C) Copyright Uwe Schindler (Generics Policeman) and others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.thetaphi.forbiddenapis;
public final class AsmUtilsTest {
@Test
public void testIsGlob() {
|
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static Pattern glob2Pattern(String... globs) {
// final StringBuilder regex = new StringBuilder();
// boolean needOr = false;
// for (String glob : globs) {
// if (needOr) {
// regex.append('|');
// }
// int i = 0, len = glob.length();
// while (i < len) {
// char c = glob.charAt(i++);
// switch (c) {
// case '*':
// if (i < len && glob.charAt(i) == '*') {
// // crosses package boundaries
// regex.append(".*");
// i++;
// } else {
// // do not cross package boundaries
// regex.append("[^.]*");
// }
// break;
//
// case '?':
// // do not cross package boundaries
// regex.append("[^.]");
// break;
//
// default:
// if (isRegexMeta(c)) {
// regex.append('\\');
// }
// regex.append(c);
// }
// }
// needOr = true;
// }
// return Pattern.compile(regex.toString(), 0);
// }
//
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static boolean isGlob(String s) {
// return s.indexOf('*') >= 0 || s.indexOf('?') >= 0;
// }
//
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static boolean isPortableRuntimeClass(String className) {
// return PORTABLE_RUNTIME_PACKAGE_PATTERN.matcher(className).matches();
// }
//
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static boolean isRuntimeModule(String module) {
// return module != null && RUNTIME_MODULES_PATTERN.matcher(module).matches();
// }
// Path: src/test/java/de/thetaphi/forbiddenapis/AsmUtilsTest.java
import static de.thetaphi.forbiddenapis.AsmUtils.glob2Pattern;
import static de.thetaphi.forbiddenapis.AsmUtils.isGlob;
import static de.thetaphi.forbiddenapis.AsmUtils.isPortableRuntimeClass;
import static de.thetaphi.forbiddenapis.AsmUtils.isRuntimeModule;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.regex.Pattern;
import org.junit.Test;
/*
* (C) Copyright Uwe Schindler (Generics Policeman) and others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.thetaphi.forbiddenapis;
public final class AsmUtilsTest {
@Test
public void testIsGlob() {
|
assertTrue(isGlob("a.b.c.*"));
|
policeman-tools/forbidden-apis
|
src/test/java/de/thetaphi/forbiddenapis/AsmUtilsTest.java
|
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static Pattern glob2Pattern(String... globs) {
// final StringBuilder regex = new StringBuilder();
// boolean needOr = false;
// for (String glob : globs) {
// if (needOr) {
// regex.append('|');
// }
// int i = 0, len = glob.length();
// while (i < len) {
// char c = glob.charAt(i++);
// switch (c) {
// case '*':
// if (i < len && glob.charAt(i) == '*') {
// // crosses package boundaries
// regex.append(".*");
// i++;
// } else {
// // do not cross package boundaries
// regex.append("[^.]*");
// }
// break;
//
// case '?':
// // do not cross package boundaries
// regex.append("[^.]");
// break;
//
// default:
// if (isRegexMeta(c)) {
// regex.append('\\');
// }
// regex.append(c);
// }
// }
// needOr = true;
// }
// return Pattern.compile(regex.toString(), 0);
// }
//
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static boolean isGlob(String s) {
// return s.indexOf('*') >= 0 || s.indexOf('?') >= 0;
// }
//
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static boolean isPortableRuntimeClass(String className) {
// return PORTABLE_RUNTIME_PACKAGE_PATTERN.matcher(className).matches();
// }
//
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static boolean isRuntimeModule(String module) {
// return module != null && RUNTIME_MODULES_PATTERN.matcher(module).matches();
// }
|
import static de.thetaphi.forbiddenapis.AsmUtils.glob2Pattern;
import static de.thetaphi.forbiddenapis.AsmUtils.isGlob;
import static de.thetaphi.forbiddenapis.AsmUtils.isPortableRuntimeClass;
import static de.thetaphi.forbiddenapis.AsmUtils.isRuntimeModule;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.regex.Pattern;
import org.junit.Test;
|
/*
* (C) Copyright Uwe Schindler (Generics Policeman) and others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.thetaphi.forbiddenapis;
public final class AsmUtilsTest {
@Test
public void testIsGlob() {
assertTrue(isGlob("a.b.c.*"));
assertTrue(isGlob("sun.**"));
assertTrue(isGlob("a?bc.x"));
assertFalse(isGlob(Object.class.getName()));
assertFalse(isGlob(getClass().getName()));
assertFalse(isGlob("sun.misc.Unsafe$1"));
}
@Test
public void testGlob() {
|
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static Pattern glob2Pattern(String... globs) {
// final StringBuilder regex = new StringBuilder();
// boolean needOr = false;
// for (String glob : globs) {
// if (needOr) {
// regex.append('|');
// }
// int i = 0, len = glob.length();
// while (i < len) {
// char c = glob.charAt(i++);
// switch (c) {
// case '*':
// if (i < len && glob.charAt(i) == '*') {
// // crosses package boundaries
// regex.append(".*");
// i++;
// } else {
// // do not cross package boundaries
// regex.append("[^.]*");
// }
// break;
//
// case '?':
// // do not cross package boundaries
// regex.append("[^.]");
// break;
//
// default:
// if (isRegexMeta(c)) {
// regex.append('\\');
// }
// regex.append(c);
// }
// }
// needOr = true;
// }
// return Pattern.compile(regex.toString(), 0);
// }
//
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static boolean isGlob(String s) {
// return s.indexOf('*') >= 0 || s.indexOf('?') >= 0;
// }
//
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static boolean isPortableRuntimeClass(String className) {
// return PORTABLE_RUNTIME_PACKAGE_PATTERN.matcher(className).matches();
// }
//
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static boolean isRuntimeModule(String module) {
// return module != null && RUNTIME_MODULES_PATTERN.matcher(module).matches();
// }
// Path: src/test/java/de/thetaphi/forbiddenapis/AsmUtilsTest.java
import static de.thetaphi.forbiddenapis.AsmUtils.glob2Pattern;
import static de.thetaphi.forbiddenapis.AsmUtils.isGlob;
import static de.thetaphi.forbiddenapis.AsmUtils.isPortableRuntimeClass;
import static de.thetaphi.forbiddenapis.AsmUtils.isRuntimeModule;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.regex.Pattern;
import org.junit.Test;
/*
* (C) Copyright Uwe Schindler (Generics Policeman) and others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.thetaphi.forbiddenapis;
public final class AsmUtilsTest {
@Test
public void testIsGlob() {
assertTrue(isGlob("a.b.c.*"));
assertTrue(isGlob("sun.**"));
assertTrue(isGlob("a?bc.x"));
assertFalse(isGlob(Object.class.getName()));
assertFalse(isGlob(getClass().getName()));
assertFalse(isGlob("sun.misc.Unsafe$1"));
}
@Test
public void testGlob() {
|
Pattern pat = glob2Pattern("a.b.c.*");
|
policeman-tools/forbidden-apis
|
src/test/java/de/thetaphi/forbiddenapis/AsmUtilsTest.java
|
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static Pattern glob2Pattern(String... globs) {
// final StringBuilder regex = new StringBuilder();
// boolean needOr = false;
// for (String glob : globs) {
// if (needOr) {
// regex.append('|');
// }
// int i = 0, len = glob.length();
// while (i < len) {
// char c = glob.charAt(i++);
// switch (c) {
// case '*':
// if (i < len && glob.charAt(i) == '*') {
// // crosses package boundaries
// regex.append(".*");
// i++;
// } else {
// // do not cross package boundaries
// regex.append("[^.]*");
// }
// break;
//
// case '?':
// // do not cross package boundaries
// regex.append("[^.]");
// break;
//
// default:
// if (isRegexMeta(c)) {
// regex.append('\\');
// }
// regex.append(c);
// }
// }
// needOr = true;
// }
// return Pattern.compile(regex.toString(), 0);
// }
//
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static boolean isGlob(String s) {
// return s.indexOf('*') >= 0 || s.indexOf('?') >= 0;
// }
//
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static boolean isPortableRuntimeClass(String className) {
// return PORTABLE_RUNTIME_PACKAGE_PATTERN.matcher(className).matches();
// }
//
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static boolean isRuntimeModule(String module) {
// return module != null && RUNTIME_MODULES_PATTERN.matcher(module).matches();
// }
|
import static de.thetaphi.forbiddenapis.AsmUtils.glob2Pattern;
import static de.thetaphi.forbiddenapis.AsmUtils.isGlob;
import static de.thetaphi.forbiddenapis.AsmUtils.isPortableRuntimeClass;
import static de.thetaphi.forbiddenapis.AsmUtils.isRuntimeModule;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.regex.Pattern;
import org.junit.Test;
|
assertFalse(pat.matcher("a.b.c.d.e").matches());
pat = glob2Pattern("a.b.c.**");
assertTrue(pat.matcher("a.b.c.d").matches());
assertTrue(pat.matcher("a.b.c.def").matches());
assertTrue(pat.matcher("a.b.c.d.e").matches());
assertTrue(pat.matcher("a.b.c.d.e.f").matches());
pat = glob2Pattern("sun.*.*");
assertTrue(pat.matcher("sun.misc.Unsafe").matches());
assertTrue(pat.matcher("sun.misc.Unsafe$1").matches());
assertFalse(pat.matcher("sun.misc.Unsafe.xy").matches());
pat = glob2Pattern("java.**.Array?");
assertTrue(pat.matcher("java.util.Arrays").matches());
assertFalse(pat.matcher("java.util.ArrayList").matches());
assertFalse(pat.matcher("java.util.Array").matches());
assertTrue(pat.matcher("java.lang.reflect.Arrays").matches());
}
@Test
public void testCrazyPatterns() {
// those should not cause havoc:
assertEquals("java\\.\\{.*\\}\\.Array", glob2Pattern("java.{**}.Array").pattern());
assertEquals("java\\./.*<>\\.Array\\$1", glob2Pattern("java./**<>.Array$1").pattern());
assertEquals("\\+\\^\\$", glob2Pattern("+^$").pattern());
}
@Test
public void testPortableRuntime() {
|
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static Pattern glob2Pattern(String... globs) {
// final StringBuilder regex = new StringBuilder();
// boolean needOr = false;
// for (String glob : globs) {
// if (needOr) {
// regex.append('|');
// }
// int i = 0, len = glob.length();
// while (i < len) {
// char c = glob.charAt(i++);
// switch (c) {
// case '*':
// if (i < len && glob.charAt(i) == '*') {
// // crosses package boundaries
// regex.append(".*");
// i++;
// } else {
// // do not cross package boundaries
// regex.append("[^.]*");
// }
// break;
//
// case '?':
// // do not cross package boundaries
// regex.append("[^.]");
// break;
//
// default:
// if (isRegexMeta(c)) {
// regex.append('\\');
// }
// regex.append(c);
// }
// }
// needOr = true;
// }
// return Pattern.compile(regex.toString(), 0);
// }
//
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static boolean isGlob(String s) {
// return s.indexOf('*') >= 0 || s.indexOf('?') >= 0;
// }
//
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static boolean isPortableRuntimeClass(String className) {
// return PORTABLE_RUNTIME_PACKAGE_PATTERN.matcher(className).matches();
// }
//
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static boolean isRuntimeModule(String module) {
// return module != null && RUNTIME_MODULES_PATTERN.matcher(module).matches();
// }
// Path: src/test/java/de/thetaphi/forbiddenapis/AsmUtilsTest.java
import static de.thetaphi.forbiddenapis.AsmUtils.glob2Pattern;
import static de.thetaphi.forbiddenapis.AsmUtils.isGlob;
import static de.thetaphi.forbiddenapis.AsmUtils.isPortableRuntimeClass;
import static de.thetaphi.forbiddenapis.AsmUtils.isRuntimeModule;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.regex.Pattern;
import org.junit.Test;
assertFalse(pat.matcher("a.b.c.d.e").matches());
pat = glob2Pattern("a.b.c.**");
assertTrue(pat.matcher("a.b.c.d").matches());
assertTrue(pat.matcher("a.b.c.def").matches());
assertTrue(pat.matcher("a.b.c.d.e").matches());
assertTrue(pat.matcher("a.b.c.d.e.f").matches());
pat = glob2Pattern("sun.*.*");
assertTrue(pat.matcher("sun.misc.Unsafe").matches());
assertTrue(pat.matcher("sun.misc.Unsafe$1").matches());
assertFalse(pat.matcher("sun.misc.Unsafe.xy").matches());
pat = glob2Pattern("java.**.Array?");
assertTrue(pat.matcher("java.util.Arrays").matches());
assertFalse(pat.matcher("java.util.ArrayList").matches());
assertFalse(pat.matcher("java.util.Array").matches());
assertTrue(pat.matcher("java.lang.reflect.Arrays").matches());
}
@Test
public void testCrazyPatterns() {
// those should not cause havoc:
assertEquals("java\\.\\{.*\\}\\.Array", glob2Pattern("java.{**}.Array").pattern());
assertEquals("java\\./.*<>\\.Array\\$1", glob2Pattern("java./**<>.Array$1").pattern());
assertEquals("\\+\\^\\$", glob2Pattern("+^$").pattern());
}
@Test
public void testPortableRuntime() {
|
assertFalse(isPortableRuntimeClass("sun.misc.Unsafe"));
|
policeman-tools/forbidden-apis
|
src/test/java/de/thetaphi/forbiddenapis/AsmUtilsTest.java
|
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static Pattern glob2Pattern(String... globs) {
// final StringBuilder regex = new StringBuilder();
// boolean needOr = false;
// for (String glob : globs) {
// if (needOr) {
// regex.append('|');
// }
// int i = 0, len = glob.length();
// while (i < len) {
// char c = glob.charAt(i++);
// switch (c) {
// case '*':
// if (i < len && glob.charAt(i) == '*') {
// // crosses package boundaries
// regex.append(".*");
// i++;
// } else {
// // do not cross package boundaries
// regex.append("[^.]*");
// }
// break;
//
// case '?':
// // do not cross package boundaries
// regex.append("[^.]");
// break;
//
// default:
// if (isRegexMeta(c)) {
// regex.append('\\');
// }
// regex.append(c);
// }
// }
// needOr = true;
// }
// return Pattern.compile(regex.toString(), 0);
// }
//
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static boolean isGlob(String s) {
// return s.indexOf('*') >= 0 || s.indexOf('?') >= 0;
// }
//
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static boolean isPortableRuntimeClass(String className) {
// return PORTABLE_RUNTIME_PACKAGE_PATTERN.matcher(className).matches();
// }
//
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static boolean isRuntimeModule(String module) {
// return module != null && RUNTIME_MODULES_PATTERN.matcher(module).matches();
// }
|
import static de.thetaphi.forbiddenapis.AsmUtils.glob2Pattern;
import static de.thetaphi.forbiddenapis.AsmUtils.isGlob;
import static de.thetaphi.forbiddenapis.AsmUtils.isPortableRuntimeClass;
import static de.thetaphi.forbiddenapis.AsmUtils.isRuntimeModule;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.regex.Pattern;
import org.junit.Test;
|
assertFalse(pat.matcher("sun.misc.Unsafe.xy").matches());
pat = glob2Pattern("java.**.Array?");
assertTrue(pat.matcher("java.util.Arrays").matches());
assertFalse(pat.matcher("java.util.ArrayList").matches());
assertFalse(pat.matcher("java.util.Array").matches());
assertTrue(pat.matcher("java.lang.reflect.Arrays").matches());
}
@Test
public void testCrazyPatterns() {
// those should not cause havoc:
assertEquals("java\\.\\{.*\\}\\.Array", glob2Pattern("java.{**}.Array").pattern());
assertEquals("java\\./.*<>\\.Array\\$1", glob2Pattern("java./**<>.Array$1").pattern());
assertEquals("\\+\\^\\$", glob2Pattern("+^$").pattern());
}
@Test
public void testPortableRuntime() {
assertFalse(isPortableRuntimeClass("sun.misc.Unsafe"));
assertFalse(isPortableRuntimeClass("jdk.internal.Asm"));
assertFalse(isPortableRuntimeClass("sun.misc.Unsafe$1"));
assertTrue(isPortableRuntimeClass(Object.class.getName()));
assertTrue(isPortableRuntimeClass(ArrayList.class.getName()));
assertTrue(isPortableRuntimeClass("org.w3c.dom.Document"));
assertFalse(isPortableRuntimeClass(getClass().getName()));
}
@Test
public void testRuntimeModule() {
|
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static Pattern glob2Pattern(String... globs) {
// final StringBuilder regex = new StringBuilder();
// boolean needOr = false;
// for (String glob : globs) {
// if (needOr) {
// regex.append('|');
// }
// int i = 0, len = glob.length();
// while (i < len) {
// char c = glob.charAt(i++);
// switch (c) {
// case '*':
// if (i < len && glob.charAt(i) == '*') {
// // crosses package boundaries
// regex.append(".*");
// i++;
// } else {
// // do not cross package boundaries
// regex.append("[^.]*");
// }
// break;
//
// case '?':
// // do not cross package boundaries
// regex.append("[^.]");
// break;
//
// default:
// if (isRegexMeta(c)) {
// regex.append('\\');
// }
// regex.append(c);
// }
// }
// needOr = true;
// }
// return Pattern.compile(regex.toString(), 0);
// }
//
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static boolean isGlob(String s) {
// return s.indexOf('*') >= 0 || s.indexOf('?') >= 0;
// }
//
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static boolean isPortableRuntimeClass(String className) {
// return PORTABLE_RUNTIME_PACKAGE_PATTERN.matcher(className).matches();
// }
//
// Path: src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
// public static boolean isRuntimeModule(String module) {
// return module != null && RUNTIME_MODULES_PATTERN.matcher(module).matches();
// }
// Path: src/test/java/de/thetaphi/forbiddenapis/AsmUtilsTest.java
import static de.thetaphi.forbiddenapis.AsmUtils.glob2Pattern;
import static de.thetaphi.forbiddenapis.AsmUtils.isGlob;
import static de.thetaphi.forbiddenapis.AsmUtils.isPortableRuntimeClass;
import static de.thetaphi.forbiddenapis.AsmUtils.isRuntimeModule;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.regex.Pattern;
import org.junit.Test;
assertFalse(pat.matcher("sun.misc.Unsafe.xy").matches());
pat = glob2Pattern("java.**.Array?");
assertTrue(pat.matcher("java.util.Arrays").matches());
assertFalse(pat.matcher("java.util.ArrayList").matches());
assertFalse(pat.matcher("java.util.Array").matches());
assertTrue(pat.matcher("java.lang.reflect.Arrays").matches());
}
@Test
public void testCrazyPatterns() {
// those should not cause havoc:
assertEquals("java\\.\\{.*\\}\\.Array", glob2Pattern("java.{**}.Array").pattern());
assertEquals("java\\./.*<>\\.Array\\$1", glob2Pattern("java./**<>.Array$1").pattern());
assertEquals("\\+\\^\\$", glob2Pattern("+^$").pattern());
}
@Test
public void testPortableRuntime() {
assertFalse(isPortableRuntimeClass("sun.misc.Unsafe"));
assertFalse(isPortableRuntimeClass("jdk.internal.Asm"));
assertFalse(isPortableRuntimeClass("sun.misc.Unsafe$1"));
assertTrue(isPortableRuntimeClass(Object.class.getName()));
assertTrue(isPortableRuntimeClass(ArrayList.class.getName()));
assertTrue(isPortableRuntimeClass("org.w3c.dom.Document"));
assertFalse(isPortableRuntimeClass(getClass().getName()));
}
@Test
public void testRuntimeModule() {
|
assertTrue(isRuntimeModule("java.base"));
|
policeman-tools/forbidden-apis
|
src/main/java/de/thetaphi/forbiddenapis/Signatures.java
|
// Path: src/main/java/de/thetaphi/forbiddenapis/Checker.java
// public static enum Option {
// FAIL_ON_MISSING_CLASSES,
// FAIL_ON_VIOLATION,
// FAIL_ON_UNRESOLVABLE_SIGNATURES,
// IGNORE_SIGNATURES_OF_MISSING_CLASSES,
// DISABLE_CLASSLOADING_CACHE
// }
|
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.objectweb.asm.Type;
import org.objectweb.asm.commons.Method;
import de.thetaphi.forbiddenapis.Checker.Option;
|
};
private UnresolvableReporting(boolean reportClassNotFound) {
this.reportClassNotFound = reportClassNotFound;
}
public final boolean reportClassNotFound;
public abstract void parseFailed(Logger logger, String message, String signature) throws ParseException;
}
private final RelatedClassLookup lookup;
private final Logger logger;
private final boolean failOnUnresolvableSignatures, ignoreSignaturesOfMissingClasses;
/** Key is used to lookup forbidden signature in following formats. Keys are generated by the corresponding
* {@link #getKey(String)} (classes), {@link #getKey(String, Method)} (methods),
* {@link #getKey(String, String)} (fields) call.
*/
final Map<String,String> signatures = new HashMap<>();
/** set of patterns of forbidden classes */
final Set<ClassPatternRule> classPatterns = new LinkedHashSet<>();
/** if enabled, the bundled signature to enable heuristics for detection of non-portable runtime calls is used */
private boolean forbidNonPortableRuntime = false;
/** number of files that were interpreted as signatures file. If 0, no (bundled) signatures files were added at all */
private int numberOfFiles = 0;
public Signatures(Checker checker) {
|
// Path: src/main/java/de/thetaphi/forbiddenapis/Checker.java
// public static enum Option {
// FAIL_ON_MISSING_CLASSES,
// FAIL_ON_VIOLATION,
// FAIL_ON_UNRESOLVABLE_SIGNATURES,
// IGNORE_SIGNATURES_OF_MISSING_CLASSES,
// DISABLE_CLASSLOADING_CACHE
// }
// Path: src/main/java/de/thetaphi/forbiddenapis/Signatures.java
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.objectweb.asm.Type;
import org.objectweb.asm.commons.Method;
import de.thetaphi.forbiddenapis.Checker.Option;
};
private UnresolvableReporting(boolean reportClassNotFound) {
this.reportClassNotFound = reportClassNotFound;
}
public final boolean reportClassNotFound;
public abstract void parseFailed(Logger logger, String message, String signature) throws ParseException;
}
private final RelatedClassLookup lookup;
private final Logger logger;
private final boolean failOnUnresolvableSignatures, ignoreSignaturesOfMissingClasses;
/** Key is used to lookup forbidden signature in following formats. Keys are generated by the corresponding
* {@link #getKey(String)} (classes), {@link #getKey(String, Method)} (methods),
* {@link #getKey(String, String)} (fields) call.
*/
final Map<String,String> signatures = new HashMap<>();
/** set of patterns of forbidden classes */
final Set<ClassPatternRule> classPatterns = new LinkedHashSet<>();
/** if enabled, the bundled signature to enable heuristics for detection of non-portable runtime calls is used */
private boolean forbidNonPortableRuntime = false;
/** number of files that were interpreted as signatures file. If 0, no (bundled) signatures files were added at all */
private int numberOfFiles = 0;
public Signatures(Checker checker) {
|
this(checker, checker.logger, checker.options.contains(Option.IGNORE_SIGNATURES_OF_MISSING_CLASSES), checker.options.contains(Option.FAIL_ON_UNRESOLVABLE_SIGNATURES));
|
policeman-tools/forbidden-apis
|
src/test/java/de/thetaphi/forbiddenapis/CheckerSetupTest.java
|
// Path: src/main/java/de/thetaphi/forbiddenapis/Checker.java
// public static enum Option {
// FAIL_ON_MISSING_CLASSES,
// FAIL_ON_VIOLATION,
// FAIL_ON_UNRESOLVABLE_SIGNATURES,
// IGNORE_SIGNATURES_OF_MISSING_CLASSES,
// DISABLE_CLASSLOADING_CACHE
// }
|
import static de.thetaphi.forbiddenapis.Checker.Option.*;
import static org.junit.Assert.*;
import static org.junit.Assume.assumeTrue;
import static org.junit.Assume.assumeNoException;
import java.util.Collections;
import java.util.EnumSet;
import org.junit.Before;
import org.junit.Test;
import org.objectweb.asm.commons.Method;
|
assertTrue(forbiddenSignatures.signatures.containsKey(Signatures.getKey("java/lang/String", new Method("copyValueOf", "([CII)Ljava/lang/String;"))));
assertEquals(Collections.emptySet(), forbiddenSignatures.classPatterns);
assertFalse(checker.hasNoSignatures());
assertFalse(checker.noSignaturesFilesParsed());
}
@Test
public void testWildcardMethodSignatureNoArgs() throws Exception {
checker.parseSignaturesString("java.lang.Object#toString(**) @ Foobar");
assertEquals(Collections.singletonMap(Signatures.getKey("java/lang/Object", new Method("toString", "()Ljava/lang/String;")), "java.lang.Object#toString(**) [Foobar]"),
forbiddenSignatures.signatures);
assertEquals(Collections.emptySet(), forbiddenSignatures.classPatterns);
assertFalse(checker.hasNoSignatures());
assertFalse(checker.noSignaturesFilesParsed());
}
@Test
public void testWildcardMethodSignatureNotExist() throws Exception {
try {
checker.parseSignaturesString("java.lang.Object#foobarNotExist(**) @ Foobar");
fail("Should fail to parse because method does not exist");
} catch (ParseException pe) {
assertEquals("Method not found while parsing signature: java.lang.Object#foobarNotExist(**)", pe.getMessage());
}
}
@Test
public void testEmptyCtor() throws Exception {
Checker chk = new Checker(StdIoLogger.INSTANCE, ClassLoader.getSystemClassLoader());
|
// Path: src/main/java/de/thetaphi/forbiddenapis/Checker.java
// public static enum Option {
// FAIL_ON_MISSING_CLASSES,
// FAIL_ON_VIOLATION,
// FAIL_ON_UNRESOLVABLE_SIGNATURES,
// IGNORE_SIGNATURES_OF_MISSING_CLASSES,
// DISABLE_CLASSLOADING_CACHE
// }
// Path: src/test/java/de/thetaphi/forbiddenapis/CheckerSetupTest.java
import static de.thetaphi.forbiddenapis.Checker.Option.*;
import static org.junit.Assert.*;
import static org.junit.Assume.assumeTrue;
import static org.junit.Assume.assumeNoException;
import java.util.Collections;
import java.util.EnumSet;
import org.junit.Before;
import org.junit.Test;
import org.objectweb.asm.commons.Method;
assertTrue(forbiddenSignatures.signatures.containsKey(Signatures.getKey("java/lang/String", new Method("copyValueOf", "([CII)Ljava/lang/String;"))));
assertEquals(Collections.emptySet(), forbiddenSignatures.classPatterns);
assertFalse(checker.hasNoSignatures());
assertFalse(checker.noSignaturesFilesParsed());
}
@Test
public void testWildcardMethodSignatureNoArgs() throws Exception {
checker.parseSignaturesString("java.lang.Object#toString(**) @ Foobar");
assertEquals(Collections.singletonMap(Signatures.getKey("java/lang/Object", new Method("toString", "()Ljava/lang/String;")), "java.lang.Object#toString(**) [Foobar]"),
forbiddenSignatures.signatures);
assertEquals(Collections.emptySet(), forbiddenSignatures.classPatterns);
assertFalse(checker.hasNoSignatures());
assertFalse(checker.noSignaturesFilesParsed());
}
@Test
public void testWildcardMethodSignatureNotExist() throws Exception {
try {
checker.parseSignaturesString("java.lang.Object#foobarNotExist(**) @ Foobar");
fail("Should fail to parse because method does not exist");
} catch (ParseException pe) {
assertEquals("Method not found while parsing signature: java.lang.Object#foobarNotExist(**)", pe.getMessage());
}
}
@Test
public void testEmptyCtor() throws Exception {
Checker chk = new Checker(StdIoLogger.INSTANCE, ClassLoader.getSystemClassLoader());
|
assertEquals(EnumSet.noneOf(Checker.Option.class), chk.options);
|
stykiaz/we3c_tracker
|
app/controllers/Users.java
|
// Path: app/utils/BasicRequests.java
// public class BasicRequests {
//
// public static class deleteRequest {
// public Long id;
// public deleteRequest() {}
// }
// public static class deleteRequestMongoModel {
// public String id;
// public deleteRequestMongoModel() {}
// }
//
// public static class filterRequest {
// public String term;
// }
//
// public static class listingRequest {
// public Integer p;
// public String list_order_by;
// public String order_dir = "";
// public Byte resultsPerPage;
//
// protected Integer totalResults = 0;
// protected Integer totalPages = 0;
// protected Byte paginationSectionSize = 6;
//
// public listingRequest() {
// p = 1;
// resultsPerPage = 25;
// }
//
// public void setTotalResults(Integer results) {
// totalResults = results;
// this.totalPages = (int)( Math.ceil( (double)totalResults / (double)resultsPerPage ) );
// }
// public Integer getTotalPages() {
// return totalPages;
// }
// public Integer getTotalResults() {
// return totalResults;
// }
// public int getNextSetOfPages() {
// if( this.getTotalPages() - p > paginationSectionSize )
// return p >= paginationSectionSize ? p + paginationSectionSize : ( paginationSectionSize + 3 <= this.getTotalPages() ? paginationSectionSize + 3 : this.getTotalPages() );
// return this.getTotalPages();
//
// }
// public int getFirstSetOfPages() {
// if( p - paginationSectionSize >= 1 ) return p - paginationSectionSize;
// else return 1;
// }
// public int getResultsPerPage() {
// return resultsPerPage;
// }
// public Integer getCurrentPage () {
// return p;
// }
// }
//
//
//
// }
//
// Path: app/models/Administrator.java
// @MongoCollection(name = "administrators")
// public class Administrator {
//
// public static JacksonDBCollection<Administrator.Model, String> coll = MongoDB.getCollection("administrators", Administrator.Model.class, String.class);
// public static class Model {
// @ObjectId
// @Id
// public String _id;
//
// public Date createdAt;
// public Date lastLoginAt;
// public Date lastUpdatedAt;
//
// @Required
// public String username;
// public String password;
// }
//
//
// public static WriteResult<Administrator.Model, String> save(Administrator.Model ob) {
// return coll.save( ob );
// }
// public static WriteResult<Administrator.Model, String> update(String id, Administrator.Model ob) {
// return coll.updateById(id , ob);
// }
// }
//
// Path: app/models/User.java
// @MongoCollection(name = "users")
// public class User {
//
// public static JacksonDBCollection<User.Model, String> coll = MongoDB.getCollection("users", User.Model.class, String.class);
//
// public static class Model {
// @ObjectId
// @Id
// public String _id;
//
// @Required
// public String username;
// public String password;
//
// public Date createdAt;
// public Date lastLoginAt;
// public Date lastUpdatedAt;
//
// public String email;
//
// public String domainsString;
// public List<String> domains;
// }
//
// public static WriteResult<User.Model, String> save(User.Model ob) {
// return coll.save(ob);
// }
// public static WriteResult<User.Model, String> update(String id, User.Model ob) {
// return coll.updateById(id , ob);
// }
//
// public static Boolean isDomainTrackable(String domain, User.Model ob) {
// if( ob.domains.contains(domain) ) return true;
// for(String in : ob.domains) {
// if( in.substring(0, 1).equals(".") ) {
// if( domain.contains(in) || ( "."+domain ).contains( in ) ) return true;
// }
// }
// return false;
// }
//
// public static Integer getSessionsCount(User.Model ob) {
// return TrackSession.coll.find( DBQuery.is("userId", new org.bson.types.ObjectId( ob._id ) ) ).count();
// }
//
// }
|
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import org.bson.types.ObjectId;
import com.mongodb.DBCursor;
import net.vz.mongodb.jackson.DBQuery;
import net.vz.mongodb.jackson.DBQuery.Query;
import ch.qos.logback.core.Context;
import utils.BasicRequests;
import models.Administrator;
import models.User;
import play.data.Form;
import play.libs.Json;
import play.mvc.Controller;
import play.mvc.Http;
import play.mvc.Result;
import play.mvc.With;
import views.html.users.*;
import static play.libs.Json.toJson;
import play.mvc.Security;
|
package controllers;
@Security.Authenticated(AdminSecurity.class)
public class Users extends Controller {
public static String module = "Users";
public static String basePath = controllers.routes.Users.index().toString();
public static class deleteRequest {
public Long id;
public deleteRequest() {}
}
public static Result index() {
Http.Context.current().args.put("admin_module", "Users");
Http.Context.current().args.put("admin_parent_section", "users");
|
// Path: app/utils/BasicRequests.java
// public class BasicRequests {
//
// public static class deleteRequest {
// public Long id;
// public deleteRequest() {}
// }
// public static class deleteRequestMongoModel {
// public String id;
// public deleteRequestMongoModel() {}
// }
//
// public static class filterRequest {
// public String term;
// }
//
// public static class listingRequest {
// public Integer p;
// public String list_order_by;
// public String order_dir = "";
// public Byte resultsPerPage;
//
// protected Integer totalResults = 0;
// protected Integer totalPages = 0;
// protected Byte paginationSectionSize = 6;
//
// public listingRequest() {
// p = 1;
// resultsPerPage = 25;
// }
//
// public void setTotalResults(Integer results) {
// totalResults = results;
// this.totalPages = (int)( Math.ceil( (double)totalResults / (double)resultsPerPage ) );
// }
// public Integer getTotalPages() {
// return totalPages;
// }
// public Integer getTotalResults() {
// return totalResults;
// }
// public int getNextSetOfPages() {
// if( this.getTotalPages() - p > paginationSectionSize )
// return p >= paginationSectionSize ? p + paginationSectionSize : ( paginationSectionSize + 3 <= this.getTotalPages() ? paginationSectionSize + 3 : this.getTotalPages() );
// return this.getTotalPages();
//
// }
// public int getFirstSetOfPages() {
// if( p - paginationSectionSize >= 1 ) return p - paginationSectionSize;
// else return 1;
// }
// public int getResultsPerPage() {
// return resultsPerPage;
// }
// public Integer getCurrentPage () {
// return p;
// }
// }
//
//
//
// }
//
// Path: app/models/Administrator.java
// @MongoCollection(name = "administrators")
// public class Administrator {
//
// public static JacksonDBCollection<Administrator.Model, String> coll = MongoDB.getCollection("administrators", Administrator.Model.class, String.class);
// public static class Model {
// @ObjectId
// @Id
// public String _id;
//
// public Date createdAt;
// public Date lastLoginAt;
// public Date lastUpdatedAt;
//
// @Required
// public String username;
// public String password;
// }
//
//
// public static WriteResult<Administrator.Model, String> save(Administrator.Model ob) {
// return coll.save( ob );
// }
// public static WriteResult<Administrator.Model, String> update(String id, Administrator.Model ob) {
// return coll.updateById(id , ob);
// }
// }
//
// Path: app/models/User.java
// @MongoCollection(name = "users")
// public class User {
//
// public static JacksonDBCollection<User.Model, String> coll = MongoDB.getCollection("users", User.Model.class, String.class);
//
// public static class Model {
// @ObjectId
// @Id
// public String _id;
//
// @Required
// public String username;
// public String password;
//
// public Date createdAt;
// public Date lastLoginAt;
// public Date lastUpdatedAt;
//
// public String email;
//
// public String domainsString;
// public List<String> domains;
// }
//
// public static WriteResult<User.Model, String> save(User.Model ob) {
// return coll.save(ob);
// }
// public static WriteResult<User.Model, String> update(String id, User.Model ob) {
// return coll.updateById(id , ob);
// }
//
// public static Boolean isDomainTrackable(String domain, User.Model ob) {
// if( ob.domains.contains(domain) ) return true;
// for(String in : ob.domains) {
// if( in.substring(0, 1).equals(".") ) {
// if( domain.contains(in) || ( "."+domain ).contains( in ) ) return true;
// }
// }
// return false;
// }
//
// public static Integer getSessionsCount(User.Model ob) {
// return TrackSession.coll.find( DBQuery.is("userId", new org.bson.types.ObjectId( ob._id ) ) ).count();
// }
//
// }
// Path: app/controllers/Users.java
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import org.bson.types.ObjectId;
import com.mongodb.DBCursor;
import net.vz.mongodb.jackson.DBQuery;
import net.vz.mongodb.jackson.DBQuery.Query;
import ch.qos.logback.core.Context;
import utils.BasicRequests;
import models.Administrator;
import models.User;
import play.data.Form;
import play.libs.Json;
import play.mvc.Controller;
import play.mvc.Http;
import play.mvc.Result;
import play.mvc.With;
import views.html.users.*;
import static play.libs.Json.toJson;
import play.mvc.Security;
package controllers;
@Security.Authenticated(AdminSecurity.class)
public class Users extends Controller {
public static String module = "Users";
public static String basePath = controllers.routes.Users.index().toString();
public static class deleteRequest {
public Long id;
public deleteRequest() {}
}
public static Result index() {
Http.Context.current().args.put("admin_module", "Users");
Http.Context.current().args.put("admin_parent_section", "users");
|
utils.BasicRequests.listingRequest params = form( utils.BasicRequests.listingRequest.class ).bindFromRequest().get();
|
stykiaz/we3c_tracker
|
app/controllers/Users.java
|
// Path: app/utils/BasicRequests.java
// public class BasicRequests {
//
// public static class deleteRequest {
// public Long id;
// public deleteRequest() {}
// }
// public static class deleteRequestMongoModel {
// public String id;
// public deleteRequestMongoModel() {}
// }
//
// public static class filterRequest {
// public String term;
// }
//
// public static class listingRequest {
// public Integer p;
// public String list_order_by;
// public String order_dir = "";
// public Byte resultsPerPage;
//
// protected Integer totalResults = 0;
// protected Integer totalPages = 0;
// protected Byte paginationSectionSize = 6;
//
// public listingRequest() {
// p = 1;
// resultsPerPage = 25;
// }
//
// public void setTotalResults(Integer results) {
// totalResults = results;
// this.totalPages = (int)( Math.ceil( (double)totalResults / (double)resultsPerPage ) );
// }
// public Integer getTotalPages() {
// return totalPages;
// }
// public Integer getTotalResults() {
// return totalResults;
// }
// public int getNextSetOfPages() {
// if( this.getTotalPages() - p > paginationSectionSize )
// return p >= paginationSectionSize ? p + paginationSectionSize : ( paginationSectionSize + 3 <= this.getTotalPages() ? paginationSectionSize + 3 : this.getTotalPages() );
// return this.getTotalPages();
//
// }
// public int getFirstSetOfPages() {
// if( p - paginationSectionSize >= 1 ) return p - paginationSectionSize;
// else return 1;
// }
// public int getResultsPerPage() {
// return resultsPerPage;
// }
// public Integer getCurrentPage () {
// return p;
// }
// }
//
//
//
// }
//
// Path: app/models/Administrator.java
// @MongoCollection(name = "administrators")
// public class Administrator {
//
// public static JacksonDBCollection<Administrator.Model, String> coll = MongoDB.getCollection("administrators", Administrator.Model.class, String.class);
// public static class Model {
// @ObjectId
// @Id
// public String _id;
//
// public Date createdAt;
// public Date lastLoginAt;
// public Date lastUpdatedAt;
//
// @Required
// public String username;
// public String password;
// }
//
//
// public static WriteResult<Administrator.Model, String> save(Administrator.Model ob) {
// return coll.save( ob );
// }
// public static WriteResult<Administrator.Model, String> update(String id, Administrator.Model ob) {
// return coll.updateById(id , ob);
// }
// }
//
// Path: app/models/User.java
// @MongoCollection(name = "users")
// public class User {
//
// public static JacksonDBCollection<User.Model, String> coll = MongoDB.getCollection("users", User.Model.class, String.class);
//
// public static class Model {
// @ObjectId
// @Id
// public String _id;
//
// @Required
// public String username;
// public String password;
//
// public Date createdAt;
// public Date lastLoginAt;
// public Date lastUpdatedAt;
//
// public String email;
//
// public String domainsString;
// public List<String> domains;
// }
//
// public static WriteResult<User.Model, String> save(User.Model ob) {
// return coll.save(ob);
// }
// public static WriteResult<User.Model, String> update(String id, User.Model ob) {
// return coll.updateById(id , ob);
// }
//
// public static Boolean isDomainTrackable(String domain, User.Model ob) {
// if( ob.domains.contains(domain) ) return true;
// for(String in : ob.domains) {
// if( in.substring(0, 1).equals(".") ) {
// if( domain.contains(in) || ( "."+domain ).contains( in ) ) return true;
// }
// }
// return false;
// }
//
// public static Integer getSessionsCount(User.Model ob) {
// return TrackSession.coll.find( DBQuery.is("userId", new org.bson.types.ObjectId( ob._id ) ) ).count();
// }
//
// }
|
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import org.bson.types.ObjectId;
import com.mongodb.DBCursor;
import net.vz.mongodb.jackson.DBQuery;
import net.vz.mongodb.jackson.DBQuery.Query;
import ch.qos.logback.core.Context;
import utils.BasicRequests;
import models.Administrator;
import models.User;
import play.data.Form;
import play.libs.Json;
import play.mvc.Controller;
import play.mvc.Http;
import play.mvc.Result;
import play.mvc.With;
import views.html.users.*;
import static play.libs.Json.toJson;
import play.mvc.Security;
|
package controllers;
@Security.Authenticated(AdminSecurity.class)
public class Users extends Controller {
public static String module = "Users";
public static String basePath = controllers.routes.Users.index().toString();
public static class deleteRequest {
public Long id;
public deleteRequest() {}
}
public static Result index() {
Http.Context.current().args.put("admin_module", "Users");
Http.Context.current().args.put("admin_parent_section", "users");
utils.BasicRequests.listingRequest params = form( utils.BasicRequests.listingRequest.class ).bindFromRequest().get();
//Listview init
Query adminQuery = DBQuery.exists("username");
|
// Path: app/utils/BasicRequests.java
// public class BasicRequests {
//
// public static class deleteRequest {
// public Long id;
// public deleteRequest() {}
// }
// public static class deleteRequestMongoModel {
// public String id;
// public deleteRequestMongoModel() {}
// }
//
// public static class filterRequest {
// public String term;
// }
//
// public static class listingRequest {
// public Integer p;
// public String list_order_by;
// public String order_dir = "";
// public Byte resultsPerPage;
//
// protected Integer totalResults = 0;
// protected Integer totalPages = 0;
// protected Byte paginationSectionSize = 6;
//
// public listingRequest() {
// p = 1;
// resultsPerPage = 25;
// }
//
// public void setTotalResults(Integer results) {
// totalResults = results;
// this.totalPages = (int)( Math.ceil( (double)totalResults / (double)resultsPerPage ) );
// }
// public Integer getTotalPages() {
// return totalPages;
// }
// public Integer getTotalResults() {
// return totalResults;
// }
// public int getNextSetOfPages() {
// if( this.getTotalPages() - p > paginationSectionSize )
// return p >= paginationSectionSize ? p + paginationSectionSize : ( paginationSectionSize + 3 <= this.getTotalPages() ? paginationSectionSize + 3 : this.getTotalPages() );
// return this.getTotalPages();
//
// }
// public int getFirstSetOfPages() {
// if( p - paginationSectionSize >= 1 ) return p - paginationSectionSize;
// else return 1;
// }
// public int getResultsPerPage() {
// return resultsPerPage;
// }
// public Integer getCurrentPage () {
// return p;
// }
// }
//
//
//
// }
//
// Path: app/models/Administrator.java
// @MongoCollection(name = "administrators")
// public class Administrator {
//
// public static JacksonDBCollection<Administrator.Model, String> coll = MongoDB.getCollection("administrators", Administrator.Model.class, String.class);
// public static class Model {
// @ObjectId
// @Id
// public String _id;
//
// public Date createdAt;
// public Date lastLoginAt;
// public Date lastUpdatedAt;
//
// @Required
// public String username;
// public String password;
// }
//
//
// public static WriteResult<Administrator.Model, String> save(Administrator.Model ob) {
// return coll.save( ob );
// }
// public static WriteResult<Administrator.Model, String> update(String id, Administrator.Model ob) {
// return coll.updateById(id , ob);
// }
// }
//
// Path: app/models/User.java
// @MongoCollection(name = "users")
// public class User {
//
// public static JacksonDBCollection<User.Model, String> coll = MongoDB.getCollection("users", User.Model.class, String.class);
//
// public static class Model {
// @ObjectId
// @Id
// public String _id;
//
// @Required
// public String username;
// public String password;
//
// public Date createdAt;
// public Date lastLoginAt;
// public Date lastUpdatedAt;
//
// public String email;
//
// public String domainsString;
// public List<String> domains;
// }
//
// public static WriteResult<User.Model, String> save(User.Model ob) {
// return coll.save(ob);
// }
// public static WriteResult<User.Model, String> update(String id, User.Model ob) {
// return coll.updateById(id , ob);
// }
//
// public static Boolean isDomainTrackable(String domain, User.Model ob) {
// if( ob.domains.contains(domain) ) return true;
// for(String in : ob.domains) {
// if( in.substring(0, 1).equals(".") ) {
// if( domain.contains(in) || ( "."+domain ).contains( in ) ) return true;
// }
// }
// return false;
// }
//
// public static Integer getSessionsCount(User.Model ob) {
// return TrackSession.coll.find( DBQuery.is("userId", new org.bson.types.ObjectId( ob._id ) ) ).count();
// }
//
// }
// Path: app/controllers/Users.java
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import org.bson.types.ObjectId;
import com.mongodb.DBCursor;
import net.vz.mongodb.jackson.DBQuery;
import net.vz.mongodb.jackson.DBQuery.Query;
import ch.qos.logback.core.Context;
import utils.BasicRequests;
import models.Administrator;
import models.User;
import play.data.Form;
import play.libs.Json;
import play.mvc.Controller;
import play.mvc.Http;
import play.mvc.Result;
import play.mvc.With;
import views.html.users.*;
import static play.libs.Json.toJson;
import play.mvc.Security;
package controllers;
@Security.Authenticated(AdminSecurity.class)
public class Users extends Controller {
public static String module = "Users";
public static String basePath = controllers.routes.Users.index().toString();
public static class deleteRequest {
public Long id;
public deleteRequest() {}
}
public static Result index() {
Http.Context.current().args.put("admin_module", "Users");
Http.Context.current().args.put("admin_parent_section", "users");
utils.BasicRequests.listingRequest params = form( utils.BasicRequests.listingRequest.class ).bindFromRequest().get();
//Listview init
Query adminQuery = DBQuery.exists("username");
|
net.vz.mongodb.jackson.DBCursor<models.User.Model> users = models.User.coll.find( adminQuery )
|
stykiaz/we3c_tracker
|
app/models/RecordedLocation.java
|
// Path: app/models/TrackSession.java
// public static class Model {
// @ObjectId
// @Id
// public String _id;
// public Date startedAt;
// public Date firstActionAt;
// public Date lastActionAt;
// public String userAgent;
// public String ip;
// public String country;
// public String language;
// public String host;
// //Extracted for possible analytical functions
// public String browser;
// public String os;
// public String mainLanguage;
//
// @ObjectId
// public String userId;
// }
|
import java.util.Date;
import com.mongodb.BasicDBObject;
import models.TrackSession.Model;
import net.vz.mongodb.jackson.Id;
import net.vz.mongodb.jackson.JacksonDBCollection;
import net.vz.mongodb.jackson.MongoCollection;
import net.vz.mongodb.jackson.ObjectId;
import net.vz.mongodb.jackson.WriteResult;
import play.modules.mongodb.jackson.MongoDB;
|
package models;
//TODO: ensureIndex, indexes, query index in Mongo
@MongoCollection(name = "recorded_location")
public class RecordedLocation {
|
// Path: app/models/TrackSession.java
// public static class Model {
// @ObjectId
// @Id
// public String _id;
// public Date startedAt;
// public Date firstActionAt;
// public Date lastActionAt;
// public String userAgent;
// public String ip;
// public String country;
// public String language;
// public String host;
// //Extracted for possible analytical functions
// public String browser;
// public String os;
// public String mainLanguage;
//
// @ObjectId
// public String userId;
// }
// Path: app/models/RecordedLocation.java
import java.util.Date;
import com.mongodb.BasicDBObject;
import models.TrackSession.Model;
import net.vz.mongodb.jackson.Id;
import net.vz.mongodb.jackson.JacksonDBCollection;
import net.vz.mongodb.jackson.MongoCollection;
import net.vz.mongodb.jackson.ObjectId;
import net.vz.mongodb.jackson.WriteResult;
import play.modules.mongodb.jackson.MongoDB;
package models;
//TODO: ensureIndex, indexes, query index in Mongo
@MongoCollection(name = "recorded_location")
public class RecordedLocation {
|
public static JacksonDBCollection<RecordedLocation.Model, String> coll = MongoDB.getCollection("recorded_location", RecordedLocation.Model.class, String.class);
|
stykiaz/we3c_tracker
|
app/Global.java
|
// Path: app/setups/AppConfig.java
// public class AppConfig {
//
// public static String uploadDirectory;
// public static String uploadDirectoryCache;
// public static String temporaryFilesDirectory;
// public static String appRootDirectory;
// public static String domain;
//
//
// public static String mail_smtpPassword;
// public static String mail_smtpUsername;
// public static String mail_smtpHost;
// public static String mail_smtpPort;
//
// public static String mail_fromEmail = "stan@wethreecreatives.com";
// public static String developerEmail = "stan@wethreecreatives.com";
// public static String supportEmail = "stan@wethreecreatives.com";
//
// public static String pathToHtmlToImageGenerator;
//
// public static String googleAnalyticsCode;
//
// public static boolean isProd() {
// return Play.application().configuration().getString("app.envirement").equals("prod");
// }
// public static boolean isTest() {
// return Play.application().configuration().getString("app.envirement").equals("test");
// }
// public static boolean isDev() {
// return Play.application().configuration().getString("app.envirement").equals("dev");
// }
//
// public static void setupDevEnv() {
// appRootDirectory = Play.application().path().getAbsolutePath()+"/";
// uploadDirectory = "/media/ext3/www/htdocs/work/we3c/uploads/";
// uploadDirectoryCache = "/media/ext3/www/htdocs/work/we3c/uploads/cache/";
// temporaryFilesDirectory = "/media/ext3/www/htdocs/work/we3c/tracker_tmp/";
// pathToHtmlToImageGenerator = "/media/ext3/www/htdocs/work/we3c/wkhtmltoimage-i386";
// domain = "localhost:9001";
//
//
//
// googleAnalyticsCode = "";
//
// }
// public static void setupTestEnv() {
// appRootDirectory = Play.application().path().getAbsolutePath()+"/";
// uploadDirectory = "";
// uploadDirectoryCache = "";
// temporaryFilesDirectory = "/www/sites/we3c/tracker_files/";
//
// pathToHtmlToImageGenerator = "/www/sites/we3c/wkhtmltoimage-i386";
// domain = "clickheat.wethreecreatives.com";
//
//
//
// googleAnalyticsCode = "";
//
// }
// public static void setupProdEnv() {
// appRootDirectory = Play.application().path().getAbsolutePath()+"/";
// uploadDirectory = "";
// uploadDirectoryCache = "";
// temporaryFilesDirectory = "/www/sites/we3c/tracker_files/";
// pathToHtmlToImageGenerator = "/www/sites/we3c/wkhtmltoimage-i386";
// domain = "clickheat.wethreecreatives.com";
//
//
//
// googleAnalyticsCode = "";
// }
//
// }
|
import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import akka.util.Duration;
import play.Application;
import play.GlobalSettings;
import play.Play;
import play.mvc.Http.RequestHeader;
import play.mvc.Result;
import setups.AppConfig;
|
public class Global extends GlobalSettings {
@Override
public Result onError(RequestHeader arg1, Throwable arg0) {
|
// Path: app/setups/AppConfig.java
// public class AppConfig {
//
// public static String uploadDirectory;
// public static String uploadDirectoryCache;
// public static String temporaryFilesDirectory;
// public static String appRootDirectory;
// public static String domain;
//
//
// public static String mail_smtpPassword;
// public static String mail_smtpUsername;
// public static String mail_smtpHost;
// public static String mail_smtpPort;
//
// public static String mail_fromEmail = "stan@wethreecreatives.com";
// public static String developerEmail = "stan@wethreecreatives.com";
// public static String supportEmail = "stan@wethreecreatives.com";
//
// public static String pathToHtmlToImageGenerator;
//
// public static String googleAnalyticsCode;
//
// public static boolean isProd() {
// return Play.application().configuration().getString("app.envirement").equals("prod");
// }
// public static boolean isTest() {
// return Play.application().configuration().getString("app.envirement").equals("test");
// }
// public static boolean isDev() {
// return Play.application().configuration().getString("app.envirement").equals("dev");
// }
//
// public static void setupDevEnv() {
// appRootDirectory = Play.application().path().getAbsolutePath()+"/";
// uploadDirectory = "/media/ext3/www/htdocs/work/we3c/uploads/";
// uploadDirectoryCache = "/media/ext3/www/htdocs/work/we3c/uploads/cache/";
// temporaryFilesDirectory = "/media/ext3/www/htdocs/work/we3c/tracker_tmp/";
// pathToHtmlToImageGenerator = "/media/ext3/www/htdocs/work/we3c/wkhtmltoimage-i386";
// domain = "localhost:9001";
//
//
//
// googleAnalyticsCode = "";
//
// }
// public static void setupTestEnv() {
// appRootDirectory = Play.application().path().getAbsolutePath()+"/";
// uploadDirectory = "";
// uploadDirectoryCache = "";
// temporaryFilesDirectory = "/www/sites/we3c/tracker_files/";
//
// pathToHtmlToImageGenerator = "/www/sites/we3c/wkhtmltoimage-i386";
// domain = "clickheat.wethreecreatives.com";
//
//
//
// googleAnalyticsCode = "";
//
// }
// public static void setupProdEnv() {
// appRootDirectory = Play.application().path().getAbsolutePath()+"/";
// uploadDirectory = "";
// uploadDirectoryCache = "";
// temporaryFilesDirectory = "/www/sites/we3c/tracker_files/";
// pathToHtmlToImageGenerator = "/www/sites/we3c/wkhtmltoimage-i386";
// domain = "clickheat.wethreecreatives.com";
//
//
//
// googleAnalyticsCode = "";
// }
//
// }
// Path: app/Global.java
import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import akka.util.Duration;
import play.Application;
import play.GlobalSettings;
import play.Play;
import play.mvc.Http.RequestHeader;
import play.mvc.Result;
import setups.AppConfig;
public class Global extends GlobalSettings {
@Override
public Result onError(RequestHeader arg1, Throwable arg0) {
|
if( !AppConfig.isDev() ) {
|
stykiaz/we3c_tracker
|
app/controllers/RecordedLocations.java
|
// Path: app/models/RecordedLocation.java
// @MongoCollection(name = "recorded_location")
// public class RecordedLocation {
//
// public static JacksonDBCollection<RecordedLocation.Model, String> coll = MongoDB.getCollection("recorded_location", RecordedLocation.Model.class, String.class);
//
// public static class Model {
//
// @ObjectId
// @Id
// public String _id;
//
// @ObjectId
// public String sessionId;
//
// public Date startedAt;
// public Date lastActionAt;
//
// //TODO: separate domain, path
// public String location;
//
// }
// public static WriteResult<RecordedLocation.Model, String> save(Model ob) {
// WriteResult<RecordedLocation.Model, String> tmp = coll.save(ob);
// coll.ensureIndex( new BasicDBObject("sessionId", 1) );
// coll.ensureIndex( new BasicDBObject("location", 1) );
// return tmp;
// }
//
// public static Long getDurationSeconds(Model ob) {
// return ( ( ob.lastActionAt.getTime() - ob.startedAt.getTime() ) / 1000 );
// }
// public static String getDuration(Model ob) {
// Long seconds = getDurationSeconds(ob);
// Long min = seconds / 60;
// Long leftSeconds = seconds % 60 ;
// return min+":"+leftSeconds;
// }
// }
|
import org.bson.types.ObjectId;
import com.mongodb.BasicDBObject;
import net.vz.mongodb.jackson.DBQuery;
import net.vz.mongodb.jackson.DBQuery.Query;
import models.RecordedLocation;
import play.mvc.Controller;
import play.mvc.Http;
import play.mvc.Result;
import views.html.recordedlocations.*;
import play.mvc.Security;
|
package controllers;
@Security.Authenticated(AdminSecurity.class)
public class RecordedLocations extends Controller {
public static class deleteRequest {
public Long id;
public deleteRequest() {}
}
public static class listingRequest extends utils.BasicRequests.listingRequest {
public String sessId;
}
public static Result index() {
Http.Context.current().args.put("admin_module", "Recorded Locations");
Http.Context.current().args.put("admin_parent_section", "recorded_locations");
listingRequest params = form( listingRequest.class ).bindFromRequest().get();
//Listview init
Query adminQuery = DBQuery.exists("sessionId");
if( params.sessId != null && !params.sessId.isEmpty() ) {
adminQuery.is("sessionId", new ObjectId( params.sessId ) );
}
|
// Path: app/models/RecordedLocation.java
// @MongoCollection(name = "recorded_location")
// public class RecordedLocation {
//
// public static JacksonDBCollection<RecordedLocation.Model, String> coll = MongoDB.getCollection("recorded_location", RecordedLocation.Model.class, String.class);
//
// public static class Model {
//
// @ObjectId
// @Id
// public String _id;
//
// @ObjectId
// public String sessionId;
//
// public Date startedAt;
// public Date lastActionAt;
//
// //TODO: separate domain, path
// public String location;
//
// }
// public static WriteResult<RecordedLocation.Model, String> save(Model ob) {
// WriteResult<RecordedLocation.Model, String> tmp = coll.save(ob);
// coll.ensureIndex( new BasicDBObject("sessionId", 1) );
// coll.ensureIndex( new BasicDBObject("location", 1) );
// return tmp;
// }
//
// public static Long getDurationSeconds(Model ob) {
// return ( ( ob.lastActionAt.getTime() - ob.startedAt.getTime() ) / 1000 );
// }
// public static String getDuration(Model ob) {
// Long seconds = getDurationSeconds(ob);
// Long min = seconds / 60;
// Long leftSeconds = seconds % 60 ;
// return min+":"+leftSeconds;
// }
// }
// Path: app/controllers/RecordedLocations.java
import org.bson.types.ObjectId;
import com.mongodb.BasicDBObject;
import net.vz.mongodb.jackson.DBQuery;
import net.vz.mongodb.jackson.DBQuery.Query;
import models.RecordedLocation;
import play.mvc.Controller;
import play.mvc.Http;
import play.mvc.Result;
import views.html.recordedlocations.*;
import play.mvc.Security;
package controllers;
@Security.Authenticated(AdminSecurity.class)
public class RecordedLocations extends Controller {
public static class deleteRequest {
public Long id;
public deleteRequest() {}
}
public static class listingRequest extends utils.BasicRequests.listingRequest {
public String sessId;
}
public static Result index() {
Http.Context.current().args.put("admin_module", "Recorded Locations");
Http.Context.current().args.put("admin_parent_section", "recorded_locations");
listingRequest params = form( listingRequest.class ).bindFromRequest().get();
//Listview init
Query adminQuery = DBQuery.exists("sessionId");
if( params.sessId != null && !params.sessId.isEmpty() ) {
adminQuery.is("sessionId", new ObjectId( params.sessId ) );
}
|
net.vz.mongodb.jackson.DBCursor<RecordedLocation.Model> admins = models.RecordedLocation.coll.find( adminQuery )
|
stykiaz/we3c_tracker
|
app/controllers/Application.java
|
// Path: app/models/Administrator.java
// @MongoCollection(name = "administrators")
// public class Administrator {
//
// public static JacksonDBCollection<Administrator.Model, String> coll = MongoDB.getCollection("administrators", Administrator.Model.class, String.class);
// public static class Model {
// @ObjectId
// @Id
// public String _id;
//
// public Date createdAt;
// public Date lastLoginAt;
// public Date lastUpdatedAt;
//
// @Required
// public String username;
// public String password;
// }
//
//
// public static WriteResult<Administrator.Model, String> save(Administrator.Model ob) {
// return coll.save( ob );
// }
// public static WriteResult<Administrator.Model, String> update(String id, Administrator.Model ob) {
// return coll.updateById(id , ob);
// }
// }
//
// Path: app/utils/Tools.java
// public class Tools {
//
// public static String md5Encode(String input) {
// if( input == null ) return "";
// MessageDigest m;
// try {
// m = MessageDigest.getInstance("MD5");
// byte[] out = m.digest(input.getBytes());
// final String result = new String(Hex.encodeHex(out));
// return result;
// } catch (NoSuchAlgorithmException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// return "";
// } catch(NullPointerException e) {
// return "";
// }
//
// }
// /**
// * generate random password
// * @return
// */
// public static String generateRandomPassword() {
// String uuid = UUID.randomUUID().toString().substring(0, 10);
// return uuid;
// }
//
// public static String base64Encode(String input) {
// return utils.Base64.encode( input.getBytes() );
// }
// /**
// * get the file extension
// * @param file
// * @return
// */
// public static String getFileExtention(File file) {
// String name = file.getName();
// int pos = name.lastIndexOf('.');
// String ext = name.substring(pos+1);
// return ext;
// }
// /**
// * get the file extension
// * @param name
// * @return
// */
// public static String getFileExtention(String name) {
// int pos = name.lastIndexOf('.');
// String ext = name.substring(pos+1);
// return ext;
// }
// public static String join(ArrayList<String> data, String delimiter) {
// StringBuffer buffer = new StringBuffer();
// Iterator<String> iter = data.iterator();
// while (iter.hasNext()) {
// buffer.append(iter.next());
// if (iter.hasNext()) {
// buffer.append(delimiter);
// }
// }
// return buffer.toString();
// }
// }
|
import java.util.NoSuchElementException;
import net.vz.mongodb.jackson.DBQuery;
import models.Administrator;
import play.*;
import play.data.Form;
import play.mvc.*;
import utils.Tools;
import views.html.*;
|
package controllers;
public class Application extends Controller {
public static class AuthenticateReq {
public String username;
public String password;
}
public static Result login() {
return ok( login.render() );
}
public static Result logout() {
session().clear();
return redirect( controllers.routes.Application.login() );
}
public static Result authenticate() {
Form<AuthenticateReq> authRequest = form(AuthenticateReq.class).bindFromRequest();
|
// Path: app/models/Administrator.java
// @MongoCollection(name = "administrators")
// public class Administrator {
//
// public static JacksonDBCollection<Administrator.Model, String> coll = MongoDB.getCollection("administrators", Administrator.Model.class, String.class);
// public static class Model {
// @ObjectId
// @Id
// public String _id;
//
// public Date createdAt;
// public Date lastLoginAt;
// public Date lastUpdatedAt;
//
// @Required
// public String username;
// public String password;
// }
//
//
// public static WriteResult<Administrator.Model, String> save(Administrator.Model ob) {
// return coll.save( ob );
// }
// public static WriteResult<Administrator.Model, String> update(String id, Administrator.Model ob) {
// return coll.updateById(id , ob);
// }
// }
//
// Path: app/utils/Tools.java
// public class Tools {
//
// public static String md5Encode(String input) {
// if( input == null ) return "";
// MessageDigest m;
// try {
// m = MessageDigest.getInstance("MD5");
// byte[] out = m.digest(input.getBytes());
// final String result = new String(Hex.encodeHex(out));
// return result;
// } catch (NoSuchAlgorithmException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// return "";
// } catch(NullPointerException e) {
// return "";
// }
//
// }
// /**
// * generate random password
// * @return
// */
// public static String generateRandomPassword() {
// String uuid = UUID.randomUUID().toString().substring(0, 10);
// return uuid;
// }
//
// public static String base64Encode(String input) {
// return utils.Base64.encode( input.getBytes() );
// }
// /**
// * get the file extension
// * @param file
// * @return
// */
// public static String getFileExtention(File file) {
// String name = file.getName();
// int pos = name.lastIndexOf('.');
// String ext = name.substring(pos+1);
// return ext;
// }
// /**
// * get the file extension
// * @param name
// * @return
// */
// public static String getFileExtention(String name) {
// int pos = name.lastIndexOf('.');
// String ext = name.substring(pos+1);
// return ext;
// }
// public static String join(ArrayList<String> data, String delimiter) {
// StringBuffer buffer = new StringBuffer();
// Iterator<String> iter = data.iterator();
// while (iter.hasNext()) {
// buffer.append(iter.next());
// if (iter.hasNext()) {
// buffer.append(delimiter);
// }
// }
// return buffer.toString();
// }
// }
// Path: app/controllers/Application.java
import java.util.NoSuchElementException;
import net.vz.mongodb.jackson.DBQuery;
import models.Administrator;
import play.*;
import play.data.Form;
import play.mvc.*;
import utils.Tools;
import views.html.*;
package controllers;
public class Application extends Controller {
public static class AuthenticateReq {
public String username;
public String password;
}
public static Result login() {
return ok( login.render() );
}
public static Result logout() {
session().clear();
return redirect( controllers.routes.Application.login() );
}
public static Result authenticate() {
Form<AuthenticateReq> authRequest = form(AuthenticateReq.class).bindFromRequest();
|
models.Administrator.Model administrator = null;
|
stykiaz/we3c_tracker
|
app/controllers/Application.java
|
// Path: app/models/Administrator.java
// @MongoCollection(name = "administrators")
// public class Administrator {
//
// public static JacksonDBCollection<Administrator.Model, String> coll = MongoDB.getCollection("administrators", Administrator.Model.class, String.class);
// public static class Model {
// @ObjectId
// @Id
// public String _id;
//
// public Date createdAt;
// public Date lastLoginAt;
// public Date lastUpdatedAt;
//
// @Required
// public String username;
// public String password;
// }
//
//
// public static WriteResult<Administrator.Model, String> save(Administrator.Model ob) {
// return coll.save( ob );
// }
// public static WriteResult<Administrator.Model, String> update(String id, Administrator.Model ob) {
// return coll.updateById(id , ob);
// }
// }
//
// Path: app/utils/Tools.java
// public class Tools {
//
// public static String md5Encode(String input) {
// if( input == null ) return "";
// MessageDigest m;
// try {
// m = MessageDigest.getInstance("MD5");
// byte[] out = m.digest(input.getBytes());
// final String result = new String(Hex.encodeHex(out));
// return result;
// } catch (NoSuchAlgorithmException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// return "";
// } catch(NullPointerException e) {
// return "";
// }
//
// }
// /**
// * generate random password
// * @return
// */
// public static String generateRandomPassword() {
// String uuid = UUID.randomUUID().toString().substring(0, 10);
// return uuid;
// }
//
// public static String base64Encode(String input) {
// return utils.Base64.encode( input.getBytes() );
// }
// /**
// * get the file extension
// * @param file
// * @return
// */
// public static String getFileExtention(File file) {
// String name = file.getName();
// int pos = name.lastIndexOf('.');
// String ext = name.substring(pos+1);
// return ext;
// }
// /**
// * get the file extension
// * @param name
// * @return
// */
// public static String getFileExtention(String name) {
// int pos = name.lastIndexOf('.');
// String ext = name.substring(pos+1);
// return ext;
// }
// public static String join(ArrayList<String> data, String delimiter) {
// StringBuffer buffer = new StringBuffer();
// Iterator<String> iter = data.iterator();
// while (iter.hasNext()) {
// buffer.append(iter.next());
// if (iter.hasNext()) {
// buffer.append(delimiter);
// }
// }
// return buffer.toString();
// }
// }
|
import java.util.NoSuchElementException;
import net.vz.mongodb.jackson.DBQuery;
import models.Administrator;
import play.*;
import play.data.Form;
import play.mvc.*;
import utils.Tools;
import views.html.*;
|
package controllers;
public class Application extends Controller {
public static class AuthenticateReq {
public String username;
public String password;
}
public static Result login() {
return ok( login.render() );
}
public static Result logout() {
session().clear();
return redirect( controllers.routes.Application.login() );
}
public static Result authenticate() {
Form<AuthenticateReq> authRequest = form(AuthenticateReq.class).bindFromRequest();
models.Administrator.Model administrator = null;
if( authRequest.field("username").valueOr("").isEmpty() || authRequest.field("password").valueOr("").isEmpty() ) {
flash().put("form_error", "Bad username/password !");
return redirect( controllers.routes.Application.login() );
}
try {
|
// Path: app/models/Administrator.java
// @MongoCollection(name = "administrators")
// public class Administrator {
//
// public static JacksonDBCollection<Administrator.Model, String> coll = MongoDB.getCollection("administrators", Administrator.Model.class, String.class);
// public static class Model {
// @ObjectId
// @Id
// public String _id;
//
// public Date createdAt;
// public Date lastLoginAt;
// public Date lastUpdatedAt;
//
// @Required
// public String username;
// public String password;
// }
//
//
// public static WriteResult<Administrator.Model, String> save(Administrator.Model ob) {
// return coll.save( ob );
// }
// public static WriteResult<Administrator.Model, String> update(String id, Administrator.Model ob) {
// return coll.updateById(id , ob);
// }
// }
//
// Path: app/utils/Tools.java
// public class Tools {
//
// public static String md5Encode(String input) {
// if( input == null ) return "";
// MessageDigest m;
// try {
// m = MessageDigest.getInstance("MD5");
// byte[] out = m.digest(input.getBytes());
// final String result = new String(Hex.encodeHex(out));
// return result;
// } catch (NoSuchAlgorithmException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// return "";
// } catch(NullPointerException e) {
// return "";
// }
//
// }
// /**
// * generate random password
// * @return
// */
// public static String generateRandomPassword() {
// String uuid = UUID.randomUUID().toString().substring(0, 10);
// return uuid;
// }
//
// public static String base64Encode(String input) {
// return utils.Base64.encode( input.getBytes() );
// }
// /**
// * get the file extension
// * @param file
// * @return
// */
// public static String getFileExtention(File file) {
// String name = file.getName();
// int pos = name.lastIndexOf('.');
// String ext = name.substring(pos+1);
// return ext;
// }
// /**
// * get the file extension
// * @param name
// * @return
// */
// public static String getFileExtention(String name) {
// int pos = name.lastIndexOf('.');
// String ext = name.substring(pos+1);
// return ext;
// }
// public static String join(ArrayList<String> data, String delimiter) {
// StringBuffer buffer = new StringBuffer();
// Iterator<String> iter = data.iterator();
// while (iter.hasNext()) {
// buffer.append(iter.next());
// if (iter.hasNext()) {
// buffer.append(delimiter);
// }
// }
// return buffer.toString();
// }
// }
// Path: app/controllers/Application.java
import java.util.NoSuchElementException;
import net.vz.mongodb.jackson.DBQuery;
import models.Administrator;
import play.*;
import play.data.Form;
import play.mvc.*;
import utils.Tools;
import views.html.*;
package controllers;
public class Application extends Controller {
public static class AuthenticateReq {
public String username;
public String password;
}
public static Result login() {
return ok( login.render() );
}
public static Result logout() {
session().clear();
return redirect( controllers.routes.Application.login() );
}
public static Result authenticate() {
Form<AuthenticateReq> authRequest = form(AuthenticateReq.class).bindFromRequest();
models.Administrator.Model administrator = null;
if( authRequest.field("username").valueOr("").isEmpty() || authRequest.field("password").valueOr("").isEmpty() ) {
flash().put("form_error", "Bad username/password !");
return redirect( controllers.routes.Application.login() );
}
try {
|
administrator = Administrator.coll.find(DBQuery.is("username", authRequest.get().username).is("password", Tools.md5Encode( authRequest.get().password ))).next();
|
stykiaz/we3c_tracker
|
app/controllers/Administrators.java
|
// Path: app/utils/BasicRequests.java
// public class BasicRequests {
//
// public static class deleteRequest {
// public Long id;
// public deleteRequest() {}
// }
// public static class deleteRequestMongoModel {
// public String id;
// public deleteRequestMongoModel() {}
// }
//
// public static class filterRequest {
// public String term;
// }
//
// public static class listingRequest {
// public Integer p;
// public String list_order_by;
// public String order_dir = "";
// public Byte resultsPerPage;
//
// protected Integer totalResults = 0;
// protected Integer totalPages = 0;
// protected Byte paginationSectionSize = 6;
//
// public listingRequest() {
// p = 1;
// resultsPerPage = 25;
// }
//
// public void setTotalResults(Integer results) {
// totalResults = results;
// this.totalPages = (int)( Math.ceil( (double)totalResults / (double)resultsPerPage ) );
// }
// public Integer getTotalPages() {
// return totalPages;
// }
// public Integer getTotalResults() {
// return totalResults;
// }
// public int getNextSetOfPages() {
// if( this.getTotalPages() - p > paginationSectionSize )
// return p >= paginationSectionSize ? p + paginationSectionSize : ( paginationSectionSize + 3 <= this.getTotalPages() ? paginationSectionSize + 3 : this.getTotalPages() );
// return this.getTotalPages();
//
// }
// public int getFirstSetOfPages() {
// if( p - paginationSectionSize >= 1 ) return p - paginationSectionSize;
// else return 1;
// }
// public int getResultsPerPage() {
// return resultsPerPage;
// }
// public Integer getCurrentPage () {
// return p;
// }
// }
//
//
//
// }
//
// Path: app/models/Administrator.java
// @MongoCollection(name = "administrators")
// public class Administrator {
//
// public static JacksonDBCollection<Administrator.Model, String> coll = MongoDB.getCollection("administrators", Administrator.Model.class, String.class);
// public static class Model {
// @ObjectId
// @Id
// public String _id;
//
// public Date createdAt;
// public Date lastLoginAt;
// public Date lastUpdatedAt;
//
// @Required
// public String username;
// public String password;
// }
//
//
// public static WriteResult<Administrator.Model, String> save(Administrator.Model ob) {
// return coll.save( ob );
// }
// public static WriteResult<Administrator.Model, String> update(String id, Administrator.Model ob) {
// return coll.updateById(id , ob);
// }
// }
|
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import org.bson.types.ObjectId;
import com.mongodb.DBCursor;
import net.vz.mongodb.jackson.DBQuery;
import net.vz.mongodb.jackson.DBQuery.Query;
import ch.qos.logback.core.Context;
import utils.BasicRequests;
import models.Administrator;
import play.data.Form;
import play.libs.Json;
import play.mvc.Controller;
import play.mvc.Http;
import play.mvc.Result;
import play.mvc.With;
import views.html.administrators.*;
import static play.libs.Json.toJson;
import play.mvc.Security;
|
package controllers;
@Security.Authenticated(AdminSecurity.class)
public class Administrators extends Controller {
public static String module = "Administrators";
public static String basePath = controllers.routes.Administrators.index().toString();
public static class deleteRequest {
public Long id;
public deleteRequest() {}
}
public static Result index() {
Http.Context.current().args.put("admin_module", "Administrators");
Http.Context.current().args.put("admin_parent_section", "settings");
|
// Path: app/utils/BasicRequests.java
// public class BasicRequests {
//
// public static class deleteRequest {
// public Long id;
// public deleteRequest() {}
// }
// public static class deleteRequestMongoModel {
// public String id;
// public deleteRequestMongoModel() {}
// }
//
// public static class filterRequest {
// public String term;
// }
//
// public static class listingRequest {
// public Integer p;
// public String list_order_by;
// public String order_dir = "";
// public Byte resultsPerPage;
//
// protected Integer totalResults = 0;
// protected Integer totalPages = 0;
// protected Byte paginationSectionSize = 6;
//
// public listingRequest() {
// p = 1;
// resultsPerPage = 25;
// }
//
// public void setTotalResults(Integer results) {
// totalResults = results;
// this.totalPages = (int)( Math.ceil( (double)totalResults / (double)resultsPerPage ) );
// }
// public Integer getTotalPages() {
// return totalPages;
// }
// public Integer getTotalResults() {
// return totalResults;
// }
// public int getNextSetOfPages() {
// if( this.getTotalPages() - p > paginationSectionSize )
// return p >= paginationSectionSize ? p + paginationSectionSize : ( paginationSectionSize + 3 <= this.getTotalPages() ? paginationSectionSize + 3 : this.getTotalPages() );
// return this.getTotalPages();
//
// }
// public int getFirstSetOfPages() {
// if( p - paginationSectionSize >= 1 ) return p - paginationSectionSize;
// else return 1;
// }
// public int getResultsPerPage() {
// return resultsPerPage;
// }
// public Integer getCurrentPage () {
// return p;
// }
// }
//
//
//
// }
//
// Path: app/models/Administrator.java
// @MongoCollection(name = "administrators")
// public class Administrator {
//
// public static JacksonDBCollection<Administrator.Model, String> coll = MongoDB.getCollection("administrators", Administrator.Model.class, String.class);
// public static class Model {
// @ObjectId
// @Id
// public String _id;
//
// public Date createdAt;
// public Date lastLoginAt;
// public Date lastUpdatedAt;
//
// @Required
// public String username;
// public String password;
// }
//
//
// public static WriteResult<Administrator.Model, String> save(Administrator.Model ob) {
// return coll.save( ob );
// }
// public static WriteResult<Administrator.Model, String> update(String id, Administrator.Model ob) {
// return coll.updateById(id , ob);
// }
// }
// Path: app/controllers/Administrators.java
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import org.bson.types.ObjectId;
import com.mongodb.DBCursor;
import net.vz.mongodb.jackson.DBQuery;
import net.vz.mongodb.jackson.DBQuery.Query;
import ch.qos.logback.core.Context;
import utils.BasicRequests;
import models.Administrator;
import play.data.Form;
import play.libs.Json;
import play.mvc.Controller;
import play.mvc.Http;
import play.mvc.Result;
import play.mvc.With;
import views.html.administrators.*;
import static play.libs.Json.toJson;
import play.mvc.Security;
package controllers;
@Security.Authenticated(AdminSecurity.class)
public class Administrators extends Controller {
public static String module = "Administrators";
public static String basePath = controllers.routes.Administrators.index().toString();
public static class deleteRequest {
public Long id;
public deleteRequest() {}
}
public static Result index() {
Http.Context.current().args.put("admin_module", "Administrators");
Http.Context.current().args.put("admin_parent_section", "settings");
|
utils.BasicRequests.listingRequest params = form( utils.BasicRequests.listingRequest.class ).bindFromRequest().get();
|
stykiaz/we3c_tracker
|
app/controllers/Administrators.java
|
// Path: app/utils/BasicRequests.java
// public class BasicRequests {
//
// public static class deleteRequest {
// public Long id;
// public deleteRequest() {}
// }
// public static class deleteRequestMongoModel {
// public String id;
// public deleteRequestMongoModel() {}
// }
//
// public static class filterRequest {
// public String term;
// }
//
// public static class listingRequest {
// public Integer p;
// public String list_order_by;
// public String order_dir = "";
// public Byte resultsPerPage;
//
// protected Integer totalResults = 0;
// protected Integer totalPages = 0;
// protected Byte paginationSectionSize = 6;
//
// public listingRequest() {
// p = 1;
// resultsPerPage = 25;
// }
//
// public void setTotalResults(Integer results) {
// totalResults = results;
// this.totalPages = (int)( Math.ceil( (double)totalResults / (double)resultsPerPage ) );
// }
// public Integer getTotalPages() {
// return totalPages;
// }
// public Integer getTotalResults() {
// return totalResults;
// }
// public int getNextSetOfPages() {
// if( this.getTotalPages() - p > paginationSectionSize )
// return p >= paginationSectionSize ? p + paginationSectionSize : ( paginationSectionSize + 3 <= this.getTotalPages() ? paginationSectionSize + 3 : this.getTotalPages() );
// return this.getTotalPages();
//
// }
// public int getFirstSetOfPages() {
// if( p - paginationSectionSize >= 1 ) return p - paginationSectionSize;
// else return 1;
// }
// public int getResultsPerPage() {
// return resultsPerPage;
// }
// public Integer getCurrentPage () {
// return p;
// }
// }
//
//
//
// }
//
// Path: app/models/Administrator.java
// @MongoCollection(name = "administrators")
// public class Administrator {
//
// public static JacksonDBCollection<Administrator.Model, String> coll = MongoDB.getCollection("administrators", Administrator.Model.class, String.class);
// public static class Model {
// @ObjectId
// @Id
// public String _id;
//
// public Date createdAt;
// public Date lastLoginAt;
// public Date lastUpdatedAt;
//
// @Required
// public String username;
// public String password;
// }
//
//
// public static WriteResult<Administrator.Model, String> save(Administrator.Model ob) {
// return coll.save( ob );
// }
// public static WriteResult<Administrator.Model, String> update(String id, Administrator.Model ob) {
// return coll.updateById(id , ob);
// }
// }
|
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import org.bson.types.ObjectId;
import com.mongodb.DBCursor;
import net.vz.mongodb.jackson.DBQuery;
import net.vz.mongodb.jackson.DBQuery.Query;
import ch.qos.logback.core.Context;
import utils.BasicRequests;
import models.Administrator;
import play.data.Form;
import play.libs.Json;
import play.mvc.Controller;
import play.mvc.Http;
import play.mvc.Result;
import play.mvc.With;
import views.html.administrators.*;
import static play.libs.Json.toJson;
import play.mvc.Security;
|
package controllers;
@Security.Authenticated(AdminSecurity.class)
public class Administrators extends Controller {
public static String module = "Administrators";
public static String basePath = controllers.routes.Administrators.index().toString();
public static class deleteRequest {
public Long id;
public deleteRequest() {}
}
public static Result index() {
Http.Context.current().args.put("admin_module", "Administrators");
Http.Context.current().args.put("admin_parent_section", "settings");
utils.BasicRequests.listingRequest params = form( utils.BasicRequests.listingRequest.class ).bindFromRequest().get();
//Listview init
Query adminQuery = DBQuery.exists("username");
|
// Path: app/utils/BasicRequests.java
// public class BasicRequests {
//
// public static class deleteRequest {
// public Long id;
// public deleteRequest() {}
// }
// public static class deleteRequestMongoModel {
// public String id;
// public deleteRequestMongoModel() {}
// }
//
// public static class filterRequest {
// public String term;
// }
//
// public static class listingRequest {
// public Integer p;
// public String list_order_by;
// public String order_dir = "";
// public Byte resultsPerPage;
//
// protected Integer totalResults = 0;
// protected Integer totalPages = 0;
// protected Byte paginationSectionSize = 6;
//
// public listingRequest() {
// p = 1;
// resultsPerPage = 25;
// }
//
// public void setTotalResults(Integer results) {
// totalResults = results;
// this.totalPages = (int)( Math.ceil( (double)totalResults / (double)resultsPerPage ) );
// }
// public Integer getTotalPages() {
// return totalPages;
// }
// public Integer getTotalResults() {
// return totalResults;
// }
// public int getNextSetOfPages() {
// if( this.getTotalPages() - p > paginationSectionSize )
// return p >= paginationSectionSize ? p + paginationSectionSize : ( paginationSectionSize + 3 <= this.getTotalPages() ? paginationSectionSize + 3 : this.getTotalPages() );
// return this.getTotalPages();
//
// }
// public int getFirstSetOfPages() {
// if( p - paginationSectionSize >= 1 ) return p - paginationSectionSize;
// else return 1;
// }
// public int getResultsPerPage() {
// return resultsPerPage;
// }
// public Integer getCurrentPage () {
// return p;
// }
// }
//
//
//
// }
//
// Path: app/models/Administrator.java
// @MongoCollection(name = "administrators")
// public class Administrator {
//
// public static JacksonDBCollection<Administrator.Model, String> coll = MongoDB.getCollection("administrators", Administrator.Model.class, String.class);
// public static class Model {
// @ObjectId
// @Id
// public String _id;
//
// public Date createdAt;
// public Date lastLoginAt;
// public Date lastUpdatedAt;
//
// @Required
// public String username;
// public String password;
// }
//
//
// public static WriteResult<Administrator.Model, String> save(Administrator.Model ob) {
// return coll.save( ob );
// }
// public static WriteResult<Administrator.Model, String> update(String id, Administrator.Model ob) {
// return coll.updateById(id , ob);
// }
// }
// Path: app/controllers/Administrators.java
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import org.bson.types.ObjectId;
import com.mongodb.DBCursor;
import net.vz.mongodb.jackson.DBQuery;
import net.vz.mongodb.jackson.DBQuery.Query;
import ch.qos.logback.core.Context;
import utils.BasicRequests;
import models.Administrator;
import play.data.Form;
import play.libs.Json;
import play.mvc.Controller;
import play.mvc.Http;
import play.mvc.Result;
import play.mvc.With;
import views.html.administrators.*;
import static play.libs.Json.toJson;
import play.mvc.Security;
package controllers;
@Security.Authenticated(AdminSecurity.class)
public class Administrators extends Controller {
public static String module = "Administrators";
public static String basePath = controllers.routes.Administrators.index().toString();
public static class deleteRequest {
public Long id;
public deleteRequest() {}
}
public static Result index() {
Http.Context.current().args.put("admin_module", "Administrators");
Http.Context.current().args.put("admin_parent_section", "settings");
utils.BasicRequests.listingRequest params = form( utils.BasicRequests.listingRequest.class ).bindFromRequest().get();
//Listview init
Query adminQuery = DBQuery.exists("username");
|
net.vz.mongodb.jackson.DBCursor<models.Administrator.Model> admins = models.Administrator.coll.find( adminQuery )
|
JackyAndroid/Android-Architecture-Fairy
|
mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/main/activity/presenter/MainPresenter.java
|
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/main/activity/MVP_Main.java
// public interface MVP_Main {
// /**
// * Required View methods available to Presenter.
// * A passive layer, responsible to show data
// * and receive user interactions
// * Presenter to View
// */
// interface RequiredViewOps {
// Context getAppContext();
// Context getActivityContext();
// void showToast(Toast toast);
// void showProgress();
// void hideProgress();
// void showAlert(AlertDialog dialog);
// void notifyItemRemoved(int position);
// void notifyDataSetChanged();
// void notifyItemInserted(int layoutPosition);
// void notifyItemRangeChanged(int positionStart, int itemCount);
// void clearEditText();
// }
//
// /**
// * Operations offered to View to communicate with Presenter.
// * Process user interaction, sends data requests to Model, etc.
// * View to Presenter
// */
// interface ProvidedPresenterOps {
// void onDestroy(boolean isChangingConfiguration);
// void setView(RequiredViewOps view);
// NotesViewHolder createViewHolder(ViewGroup parent, int viewType);
// void bindViewHolder(NotesViewHolder holder, int position);
// int getNotesCount();
// void clickNewNote(EditText editText);
// void clickDeleteNote(Note note, int adapterPos, int layoutPos);
// }
//
// /**
// * Required Presenter methods available to Model.
// * Model to Presenter
// */
// interface RequiredPresenterOps {
// Context getAppContext();
// Context getActivityContext();
// }
//
// /**
// * Operations offered to Model to communicate with Presenter
// * Handles all data business logic.
// * Presenter to Model
// */
// interface ProvidedModelOps {
// void onDestroy(boolean isChangingConfiguration);
// int insertNote(Note note);
// boolean loadData();
// Note getNote(int position);
// boolean deleteNote(Note note, int adapterPos);
// int getNotesCount();
// }
// }
//
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/main/activity/view/recycler/NotesViewHolder.java
// public class NotesViewHolder extends RecyclerView.ViewHolder {
//
// public RelativeLayout container;
// public TextView text, date;
// public ImageButton btnDelete;
//
// public NotesViewHolder(View itemView) {
// super(itemView);
//
// setupViews(itemView);
// }
//
// private void setupViews(View view) {
// container = (RelativeLayout) view.findViewById(R.id.holder_container);
// text = (TextView) view.findViewById(R.id.note_text);
// date = (TextView) view.findViewById(R.id.note_date);
// btnDelete = (ImageButton) view.findViewById(R.id.btn_delete);
// }
//
//
// }
//
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/models/Note.java
// public class Note {
//
// private int id = -1;
// private String mText;
// private String mDate;
//
// public Note() {
// }
//
// public Note(int id, String mText, String mDate) {
// this.id = id;
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public Note(String mText, String mDate) {
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public ContentValues getValues(){
// ContentValues cv = new ContentValues();
// if ( id!=-1) cv.put(DBSchema.TB_NOTES.ID, id);
// cv.put(DBSchema.TB_NOTES.NOTE, mText);
// cv.put(DBSchema.TB_NOTES.DATE, mDate);
// return cv;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public void setDate(String mDate) {
// this.mDate = mDate;
// }
//
// public void setText(String mText) {
// this.mText = mText;
// }
//
// public int getId() {
// return id;
// }
//
// public String getDate() {
// return mDate;
// }
//
// public String getText() {
// return mText;
// }
// }
|
import android.content.Context;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.os.Parcelable;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.Toast;
import com.tinmegali.tutsmvp_sample.R;
import com.tinmegali.tutsmvp_sample.main.activity.MVP_Main;
import com.tinmegali.tutsmvp_sample.main.activity.view.recycler.NotesViewHolder;
import com.tinmegali.tutsmvp_sample.models.Note;
import java.lang.ref.WeakReference;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
|
} catch (NullPointerException e) {
e.printStackTrace();
}
}
/**
* Creat a Toast object with given message
* @param msg Toast message
* @return A Toast object
*/
private Toast makeToast(String msg) {
return Toast.makeText(getView().getAppContext(), msg, Toast.LENGTH_SHORT);
}
/**
* Retrieve total Notes count from Model
* @return Notes size
*/
@Override
public int getNotesCount() {
return mModel.getNotesCount();
}
/**
* Create the RecyclerView holder and setup its view
* @param parent Recycler viewgroup
* @param viewType Holder type
* @return Recycler ViewHolder
*/
@Override
|
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/main/activity/MVP_Main.java
// public interface MVP_Main {
// /**
// * Required View methods available to Presenter.
// * A passive layer, responsible to show data
// * and receive user interactions
// * Presenter to View
// */
// interface RequiredViewOps {
// Context getAppContext();
// Context getActivityContext();
// void showToast(Toast toast);
// void showProgress();
// void hideProgress();
// void showAlert(AlertDialog dialog);
// void notifyItemRemoved(int position);
// void notifyDataSetChanged();
// void notifyItemInserted(int layoutPosition);
// void notifyItemRangeChanged(int positionStart, int itemCount);
// void clearEditText();
// }
//
// /**
// * Operations offered to View to communicate with Presenter.
// * Process user interaction, sends data requests to Model, etc.
// * View to Presenter
// */
// interface ProvidedPresenterOps {
// void onDestroy(boolean isChangingConfiguration);
// void setView(RequiredViewOps view);
// NotesViewHolder createViewHolder(ViewGroup parent, int viewType);
// void bindViewHolder(NotesViewHolder holder, int position);
// int getNotesCount();
// void clickNewNote(EditText editText);
// void clickDeleteNote(Note note, int adapterPos, int layoutPos);
// }
//
// /**
// * Required Presenter methods available to Model.
// * Model to Presenter
// */
// interface RequiredPresenterOps {
// Context getAppContext();
// Context getActivityContext();
// }
//
// /**
// * Operations offered to Model to communicate with Presenter
// * Handles all data business logic.
// * Presenter to Model
// */
// interface ProvidedModelOps {
// void onDestroy(boolean isChangingConfiguration);
// int insertNote(Note note);
// boolean loadData();
// Note getNote(int position);
// boolean deleteNote(Note note, int adapterPos);
// int getNotesCount();
// }
// }
//
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/main/activity/view/recycler/NotesViewHolder.java
// public class NotesViewHolder extends RecyclerView.ViewHolder {
//
// public RelativeLayout container;
// public TextView text, date;
// public ImageButton btnDelete;
//
// public NotesViewHolder(View itemView) {
// super(itemView);
//
// setupViews(itemView);
// }
//
// private void setupViews(View view) {
// container = (RelativeLayout) view.findViewById(R.id.holder_container);
// text = (TextView) view.findViewById(R.id.note_text);
// date = (TextView) view.findViewById(R.id.note_date);
// btnDelete = (ImageButton) view.findViewById(R.id.btn_delete);
// }
//
//
// }
//
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/models/Note.java
// public class Note {
//
// private int id = -1;
// private String mText;
// private String mDate;
//
// public Note() {
// }
//
// public Note(int id, String mText, String mDate) {
// this.id = id;
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public Note(String mText, String mDate) {
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public ContentValues getValues(){
// ContentValues cv = new ContentValues();
// if ( id!=-1) cv.put(DBSchema.TB_NOTES.ID, id);
// cv.put(DBSchema.TB_NOTES.NOTE, mText);
// cv.put(DBSchema.TB_NOTES.DATE, mDate);
// return cv;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public void setDate(String mDate) {
// this.mDate = mDate;
// }
//
// public void setText(String mText) {
// this.mText = mText;
// }
//
// public int getId() {
// return id;
// }
//
// public String getDate() {
// return mDate;
// }
//
// public String getText() {
// return mText;
// }
// }
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/main/activity/presenter/MainPresenter.java
import android.content.Context;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.os.Parcelable;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.Toast;
import com.tinmegali.tutsmvp_sample.R;
import com.tinmegali.tutsmvp_sample.main.activity.MVP_Main;
import com.tinmegali.tutsmvp_sample.main.activity.view.recycler.NotesViewHolder;
import com.tinmegali.tutsmvp_sample.models.Note;
import java.lang.ref.WeakReference;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
} catch (NullPointerException e) {
e.printStackTrace();
}
}
/**
* Creat a Toast object with given message
* @param msg Toast message
* @return A Toast object
*/
private Toast makeToast(String msg) {
return Toast.makeText(getView().getAppContext(), msg, Toast.LENGTH_SHORT);
}
/**
* Retrieve total Notes count from Model
* @return Notes size
*/
@Override
public int getNotesCount() {
return mModel.getNotesCount();
}
/**
* Create the RecyclerView holder and setup its view
* @param parent Recycler viewgroup
* @param viewType Holder type
* @return Recycler ViewHolder
*/
@Override
|
public NotesViewHolder createViewHolder(ViewGroup parent, int viewType) {
|
JackyAndroid/Android-Architecture-Fairy
|
mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/main/activity/presenter/MainPresenter.java
|
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/main/activity/MVP_Main.java
// public interface MVP_Main {
// /**
// * Required View methods available to Presenter.
// * A passive layer, responsible to show data
// * and receive user interactions
// * Presenter to View
// */
// interface RequiredViewOps {
// Context getAppContext();
// Context getActivityContext();
// void showToast(Toast toast);
// void showProgress();
// void hideProgress();
// void showAlert(AlertDialog dialog);
// void notifyItemRemoved(int position);
// void notifyDataSetChanged();
// void notifyItemInserted(int layoutPosition);
// void notifyItemRangeChanged(int positionStart, int itemCount);
// void clearEditText();
// }
//
// /**
// * Operations offered to View to communicate with Presenter.
// * Process user interaction, sends data requests to Model, etc.
// * View to Presenter
// */
// interface ProvidedPresenterOps {
// void onDestroy(boolean isChangingConfiguration);
// void setView(RequiredViewOps view);
// NotesViewHolder createViewHolder(ViewGroup parent, int viewType);
// void bindViewHolder(NotesViewHolder holder, int position);
// int getNotesCount();
// void clickNewNote(EditText editText);
// void clickDeleteNote(Note note, int adapterPos, int layoutPos);
// }
//
// /**
// * Required Presenter methods available to Model.
// * Model to Presenter
// */
// interface RequiredPresenterOps {
// Context getAppContext();
// Context getActivityContext();
// }
//
// /**
// * Operations offered to Model to communicate with Presenter
// * Handles all data business logic.
// * Presenter to Model
// */
// interface ProvidedModelOps {
// void onDestroy(boolean isChangingConfiguration);
// int insertNote(Note note);
// boolean loadData();
// Note getNote(int position);
// boolean deleteNote(Note note, int adapterPos);
// int getNotesCount();
// }
// }
//
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/main/activity/view/recycler/NotesViewHolder.java
// public class NotesViewHolder extends RecyclerView.ViewHolder {
//
// public RelativeLayout container;
// public TextView text, date;
// public ImageButton btnDelete;
//
// public NotesViewHolder(View itemView) {
// super(itemView);
//
// setupViews(itemView);
// }
//
// private void setupViews(View view) {
// container = (RelativeLayout) view.findViewById(R.id.holder_container);
// text = (TextView) view.findViewById(R.id.note_text);
// date = (TextView) view.findViewById(R.id.note_date);
// btnDelete = (ImageButton) view.findViewById(R.id.btn_delete);
// }
//
//
// }
//
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/models/Note.java
// public class Note {
//
// private int id = -1;
// private String mText;
// private String mDate;
//
// public Note() {
// }
//
// public Note(int id, String mText, String mDate) {
// this.id = id;
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public Note(String mText, String mDate) {
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public ContentValues getValues(){
// ContentValues cv = new ContentValues();
// if ( id!=-1) cv.put(DBSchema.TB_NOTES.ID, id);
// cv.put(DBSchema.TB_NOTES.NOTE, mText);
// cv.put(DBSchema.TB_NOTES.DATE, mDate);
// return cv;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public void setDate(String mDate) {
// this.mDate = mDate;
// }
//
// public void setText(String mText) {
// this.mText = mText;
// }
//
// public int getId() {
// return id;
// }
//
// public String getDate() {
// return mDate;
// }
//
// public String getText() {
// return mText;
// }
// }
|
import android.content.Context;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.os.Parcelable;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.Toast;
import com.tinmegali.tutsmvp_sample.R;
import com.tinmegali.tutsmvp_sample.main.activity.MVP_Main;
import com.tinmegali.tutsmvp_sample.main.activity.view.recycler.NotesViewHolder;
import com.tinmegali.tutsmvp_sample.models.Note;
import java.lang.ref.WeakReference;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
|
*/
@Override
public int getNotesCount() {
return mModel.getNotesCount();
}
/**
* Create the RecyclerView holder and setup its view
* @param parent Recycler viewgroup
* @param viewType Holder type
* @return Recycler ViewHolder
*/
@Override
public NotesViewHolder createViewHolder(ViewGroup parent, int viewType) {
NotesViewHolder viewHolder;
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
View viewTaskRow = inflater.inflate(R.layout.holder_notes, parent, false);
viewHolder = new NotesViewHolder(viewTaskRow);
return viewHolder;
}
/**
* Binds ViewHolder with RecyclerView
* @param holder Holder to bind
* @param position Position on Recycler adapter
*/
@Override
public void bindViewHolder(final NotesViewHolder holder, int position) {
|
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/main/activity/MVP_Main.java
// public interface MVP_Main {
// /**
// * Required View methods available to Presenter.
// * A passive layer, responsible to show data
// * and receive user interactions
// * Presenter to View
// */
// interface RequiredViewOps {
// Context getAppContext();
// Context getActivityContext();
// void showToast(Toast toast);
// void showProgress();
// void hideProgress();
// void showAlert(AlertDialog dialog);
// void notifyItemRemoved(int position);
// void notifyDataSetChanged();
// void notifyItemInserted(int layoutPosition);
// void notifyItemRangeChanged(int positionStart, int itemCount);
// void clearEditText();
// }
//
// /**
// * Operations offered to View to communicate with Presenter.
// * Process user interaction, sends data requests to Model, etc.
// * View to Presenter
// */
// interface ProvidedPresenterOps {
// void onDestroy(boolean isChangingConfiguration);
// void setView(RequiredViewOps view);
// NotesViewHolder createViewHolder(ViewGroup parent, int viewType);
// void bindViewHolder(NotesViewHolder holder, int position);
// int getNotesCount();
// void clickNewNote(EditText editText);
// void clickDeleteNote(Note note, int adapterPos, int layoutPos);
// }
//
// /**
// * Required Presenter methods available to Model.
// * Model to Presenter
// */
// interface RequiredPresenterOps {
// Context getAppContext();
// Context getActivityContext();
// }
//
// /**
// * Operations offered to Model to communicate with Presenter
// * Handles all data business logic.
// * Presenter to Model
// */
// interface ProvidedModelOps {
// void onDestroy(boolean isChangingConfiguration);
// int insertNote(Note note);
// boolean loadData();
// Note getNote(int position);
// boolean deleteNote(Note note, int adapterPos);
// int getNotesCount();
// }
// }
//
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/main/activity/view/recycler/NotesViewHolder.java
// public class NotesViewHolder extends RecyclerView.ViewHolder {
//
// public RelativeLayout container;
// public TextView text, date;
// public ImageButton btnDelete;
//
// public NotesViewHolder(View itemView) {
// super(itemView);
//
// setupViews(itemView);
// }
//
// private void setupViews(View view) {
// container = (RelativeLayout) view.findViewById(R.id.holder_container);
// text = (TextView) view.findViewById(R.id.note_text);
// date = (TextView) view.findViewById(R.id.note_date);
// btnDelete = (ImageButton) view.findViewById(R.id.btn_delete);
// }
//
//
// }
//
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/models/Note.java
// public class Note {
//
// private int id = -1;
// private String mText;
// private String mDate;
//
// public Note() {
// }
//
// public Note(int id, String mText, String mDate) {
// this.id = id;
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public Note(String mText, String mDate) {
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public ContentValues getValues(){
// ContentValues cv = new ContentValues();
// if ( id!=-1) cv.put(DBSchema.TB_NOTES.ID, id);
// cv.put(DBSchema.TB_NOTES.NOTE, mText);
// cv.put(DBSchema.TB_NOTES.DATE, mDate);
// return cv;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public void setDate(String mDate) {
// this.mDate = mDate;
// }
//
// public void setText(String mText) {
// this.mText = mText;
// }
//
// public int getId() {
// return id;
// }
//
// public String getDate() {
// return mDate;
// }
//
// public String getText() {
// return mText;
// }
// }
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/main/activity/presenter/MainPresenter.java
import android.content.Context;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.os.Parcelable;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.Toast;
import com.tinmegali.tutsmvp_sample.R;
import com.tinmegali.tutsmvp_sample.main.activity.MVP_Main;
import com.tinmegali.tutsmvp_sample.main.activity.view.recycler.NotesViewHolder;
import com.tinmegali.tutsmvp_sample.models.Note;
import java.lang.ref.WeakReference;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
*/
@Override
public int getNotesCount() {
return mModel.getNotesCount();
}
/**
* Create the RecyclerView holder and setup its view
* @param parent Recycler viewgroup
* @param viewType Holder type
* @return Recycler ViewHolder
*/
@Override
public NotesViewHolder createViewHolder(ViewGroup parent, int viewType) {
NotesViewHolder viewHolder;
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
View viewTaskRow = inflater.inflate(R.layout.holder_notes, parent, false);
viewHolder = new NotesViewHolder(viewTaskRow);
return viewHolder;
}
/**
* Binds ViewHolder with RecyclerView
* @param holder Holder to bind
* @param position Position on Recycler adapter
*/
@Override
public void bindViewHolder(final NotesViewHolder holder, int position) {
|
final Note note = mModel.getNote(position);
|
JackyAndroid/Android-Architecture-Fairy
|
IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Contract.java
|
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/BasePresenter.java
// public interface BasePresenter {
//
// void onCreate();
//
// void onResume();
//
// void onPause();
//
// void onDestroy();
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/BaseView.java
// public interface BaseView<T> {
//
// void setPresenter(T presenter);
// }
|
import tech.jackywang.intermediate.layer.business.BasePresenter;
import tech.jackywang.intermediate.layer.business.BaseView;
|
package tech.jackywang.intermediate.layer.business.business1;
/**
* @author jacky
* @version v1.0
* @description
* @since 2017/10/19
*/
public interface Business1Contract {
interface View extends BaseView<Presenter> {
}
|
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/BasePresenter.java
// public interface BasePresenter {
//
// void onCreate();
//
// void onResume();
//
// void onPause();
//
// void onDestroy();
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/BaseView.java
// public interface BaseView<T> {
//
// void setPresenter(T presenter);
// }
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Contract.java
import tech.jackywang.intermediate.layer.business.BasePresenter;
import tech.jackywang.intermediate.layer.business.BaseView;
package tech.jackywang.intermediate.layer.business.business1;
/**
* @author jacky
* @version v1.0
* @description
* @since 2017/10/19
*/
public interface Business1Contract {
interface View extends BaseView<Presenter> {
}
|
interface Presenter extends BasePresenter {
|
JackyAndroid/Android-Architecture-Fairy
|
mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/data/DAO.java
|
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/models/Note.java
// public class Note {
//
// private int id = -1;
// private String mText;
// private String mDate;
//
// public Note() {
// }
//
// public Note(int id, String mText, String mDate) {
// this.id = id;
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public Note(String mText, String mDate) {
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public ContentValues getValues(){
// ContentValues cv = new ContentValues();
// if ( id!=-1) cv.put(DBSchema.TB_NOTES.ID, id);
// cv.put(DBSchema.TB_NOTES.NOTE, mText);
// cv.put(DBSchema.TB_NOTES.DATE, mDate);
// return cv;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public void setDate(String mDate) {
// this.mDate = mDate;
// }
//
// public void setText(String mText) {
// this.mText = mText;
// }
//
// public int getId() {
// return id;
// }
//
// public String getDate() {
// return mDate;
// }
//
// public String getText() {
// return mText;
// }
// }
|
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.tinmegali.tutsmvp_sample.models.Note;
import java.util.ArrayList;
|
package com.tinmegali.tutsmvp_sample.data;
/**
* ---------------------------------------------------
* Created by Tin Megali on 18/03/16.
* Project: tuts+mvp_sample
* ---------------------------------------------------
* <a href="http://www.tinmegali.com">tinmegali.com</a>
* <a href="http://www.github.com/tinmegali>github</a>
* ---------------------------------------------------
*/
public class DAO {
private DBSchema mHelper;
private Context mContext;
//SELECTIONS
private static final String SELECT_ID_BASED = DBSchema.TB_NOTES.ID + " = ? ";
private static final String PROJECTION_ALL = " * ";
public static final String SORT_ORDER_DEFAULT = DBSchema.TB_NOTES.ID + " DESC";
public DAO(Context context) {
this.mContext = context;
mHelper = new DBSchema(mContext);
}
private SQLiteDatabase getReadDB(){
return mHelper.getReadableDatabase();
}
private SQLiteDatabase getWriteDB(){
return mHelper.getWritableDatabase();
}
|
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/models/Note.java
// public class Note {
//
// private int id = -1;
// private String mText;
// private String mDate;
//
// public Note() {
// }
//
// public Note(int id, String mText, String mDate) {
// this.id = id;
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public Note(String mText, String mDate) {
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public ContentValues getValues(){
// ContentValues cv = new ContentValues();
// if ( id!=-1) cv.put(DBSchema.TB_NOTES.ID, id);
// cv.put(DBSchema.TB_NOTES.NOTE, mText);
// cv.put(DBSchema.TB_NOTES.DATE, mDate);
// return cv;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public void setDate(String mDate) {
// this.mDate = mDate;
// }
//
// public void setText(String mText) {
// this.mText = mText;
// }
//
// public int getId() {
// return id;
// }
//
// public String getDate() {
// return mDate;
// }
//
// public String getText() {
// return mText;
// }
// }
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/data/DAO.java
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.tinmegali.tutsmvp_sample.models.Note;
import java.util.ArrayList;
package com.tinmegali.tutsmvp_sample.data;
/**
* ---------------------------------------------------
* Created by Tin Megali on 18/03/16.
* Project: tuts+mvp_sample
* ---------------------------------------------------
* <a href="http://www.tinmegali.com">tinmegali.com</a>
* <a href="http://www.github.com/tinmegali>github</a>
* ---------------------------------------------------
*/
public class DAO {
private DBSchema mHelper;
private Context mContext;
//SELECTIONS
private static final String SELECT_ID_BASED = DBSchema.TB_NOTES.ID + " = ? ";
private static final String PROJECTION_ALL = " * ";
public static final String SORT_ORDER_DEFAULT = DBSchema.TB_NOTES.ID + " DESC";
public DAO(Context context) {
this.mContext = context;
mHelper = new DBSchema(mContext);
}
private SQLiteDatabase getReadDB(){
return mHelper.getReadableDatabase();
}
private SQLiteDatabase getWriteDB(){
return mHelper.getWritableDatabase();
}
|
public Note insertNote(Note note) {
|
JackyAndroid/Android-Architecture-Fairy
|
IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/BusinessDelegate.java
|
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Contract.java
// public interface Business1Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Model.java
// public class Business1Model implements Business1Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Presenter.java
// public class Business1Presenter implements Business1Contract.Presenter {
//
// public Business1Presenter(Business1Contract.View view, Business1Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1View.java
// public class Business1View extends FrameLayout implements Business1Contract.View {
//
// public Business1View(@NonNull Context context) {
// super(context);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business1Contract.Presenter presenter) {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Contract.java
// public interface Business2Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Model.java
// public class Business2Model implements Business2Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Presenter.java
// public class Business2Presenter implements Business2Contract.Presenter {
//
// public Business2Presenter(Business2Contract.View view, Business2Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2View.java
// public class Business2View extends FrameLayout implements Business2Contract.View {
//
// public Business2View(@NonNull Context context) {
// super(context);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business2Contract.Presenter presenter) {
//
// }
// }
|
import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import java.lang.ref.WeakReference;
import tech.jackywang.intermediate.layer.business.business1.Business1Contract;
import tech.jackywang.intermediate.layer.business.business1.Business1Model;
import tech.jackywang.intermediate.layer.business.business1.Business1Presenter;
import tech.jackywang.intermediate.layer.business.business1.Business1View;
import tech.jackywang.intermediate.layer.business.business2.Business2Contract;
import tech.jackywang.intermediate.layer.business.business2.Business2Model;
import tech.jackywang.intermediate.layer.business.business2.Business2Presenter;
import tech.jackywang.intermediate.layer.business.business2.Business2View;
|
package tech.jackywang.intermediate.layer;
/**
* 委托
*
* @author jacky
* @version v1.0
* @description 委托,隔离各业务间的耦合
* @since 2017/9/14
*/
public class BusinessDelegate extends RelativeLayout implements IBusinessDelegate {
private WeakReference<Context> mContextReference;
|
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Contract.java
// public interface Business1Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Model.java
// public class Business1Model implements Business1Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Presenter.java
// public class Business1Presenter implements Business1Contract.Presenter {
//
// public Business1Presenter(Business1Contract.View view, Business1Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1View.java
// public class Business1View extends FrameLayout implements Business1Contract.View {
//
// public Business1View(@NonNull Context context) {
// super(context);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business1Contract.Presenter presenter) {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Contract.java
// public interface Business2Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Model.java
// public class Business2Model implements Business2Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Presenter.java
// public class Business2Presenter implements Business2Contract.Presenter {
//
// public Business2Presenter(Business2Contract.View view, Business2Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2View.java
// public class Business2View extends FrameLayout implements Business2Contract.View {
//
// public Business2View(@NonNull Context context) {
// super(context);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business2Contract.Presenter presenter) {
//
// }
// }
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/BusinessDelegate.java
import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import java.lang.ref.WeakReference;
import tech.jackywang.intermediate.layer.business.business1.Business1Contract;
import tech.jackywang.intermediate.layer.business.business1.Business1Model;
import tech.jackywang.intermediate.layer.business.business1.Business1Presenter;
import tech.jackywang.intermediate.layer.business.business1.Business1View;
import tech.jackywang.intermediate.layer.business.business2.Business2Contract;
import tech.jackywang.intermediate.layer.business.business2.Business2Model;
import tech.jackywang.intermediate.layer.business.business2.Business2Presenter;
import tech.jackywang.intermediate.layer.business.business2.Business2View;
package tech.jackywang.intermediate.layer;
/**
* 委托
*
* @author jacky
* @version v1.0
* @description 委托,隔离各业务间的耦合
* @since 2017/9/14
*/
public class BusinessDelegate extends RelativeLayout implements IBusinessDelegate {
private WeakReference<Context> mContextReference;
|
private Business1Contract.Presenter mBusiness1Presenter;
|
JackyAndroid/Android-Architecture-Fairy
|
IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/BusinessDelegate.java
|
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Contract.java
// public interface Business1Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Model.java
// public class Business1Model implements Business1Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Presenter.java
// public class Business1Presenter implements Business1Contract.Presenter {
//
// public Business1Presenter(Business1Contract.View view, Business1Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1View.java
// public class Business1View extends FrameLayout implements Business1Contract.View {
//
// public Business1View(@NonNull Context context) {
// super(context);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business1Contract.Presenter presenter) {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Contract.java
// public interface Business2Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Model.java
// public class Business2Model implements Business2Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Presenter.java
// public class Business2Presenter implements Business2Contract.Presenter {
//
// public Business2Presenter(Business2Contract.View view, Business2Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2View.java
// public class Business2View extends FrameLayout implements Business2Contract.View {
//
// public Business2View(@NonNull Context context) {
// super(context);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business2Contract.Presenter presenter) {
//
// }
// }
|
import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import java.lang.ref.WeakReference;
import tech.jackywang.intermediate.layer.business.business1.Business1Contract;
import tech.jackywang.intermediate.layer.business.business1.Business1Model;
import tech.jackywang.intermediate.layer.business.business1.Business1Presenter;
import tech.jackywang.intermediate.layer.business.business1.Business1View;
import tech.jackywang.intermediate.layer.business.business2.Business2Contract;
import tech.jackywang.intermediate.layer.business.business2.Business2Model;
import tech.jackywang.intermediate.layer.business.business2.Business2Presenter;
import tech.jackywang.intermediate.layer.business.business2.Business2View;
|
package tech.jackywang.intermediate.layer;
/**
* 委托
*
* @author jacky
* @version v1.0
* @description 委托,隔离各业务间的耦合
* @since 2017/9/14
*/
public class BusinessDelegate extends RelativeLayout implements IBusinessDelegate {
private WeakReference<Context> mContextReference;
private Business1Contract.Presenter mBusiness1Presenter;
|
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Contract.java
// public interface Business1Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Model.java
// public class Business1Model implements Business1Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Presenter.java
// public class Business1Presenter implements Business1Contract.Presenter {
//
// public Business1Presenter(Business1Contract.View view, Business1Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1View.java
// public class Business1View extends FrameLayout implements Business1Contract.View {
//
// public Business1View(@NonNull Context context) {
// super(context);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business1Contract.Presenter presenter) {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Contract.java
// public interface Business2Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Model.java
// public class Business2Model implements Business2Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Presenter.java
// public class Business2Presenter implements Business2Contract.Presenter {
//
// public Business2Presenter(Business2Contract.View view, Business2Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2View.java
// public class Business2View extends FrameLayout implements Business2Contract.View {
//
// public Business2View(@NonNull Context context) {
// super(context);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business2Contract.Presenter presenter) {
//
// }
// }
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/BusinessDelegate.java
import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import java.lang.ref.WeakReference;
import tech.jackywang.intermediate.layer.business.business1.Business1Contract;
import tech.jackywang.intermediate.layer.business.business1.Business1Model;
import tech.jackywang.intermediate.layer.business.business1.Business1Presenter;
import tech.jackywang.intermediate.layer.business.business1.Business1View;
import tech.jackywang.intermediate.layer.business.business2.Business2Contract;
import tech.jackywang.intermediate.layer.business.business2.Business2Model;
import tech.jackywang.intermediate.layer.business.business2.Business2Presenter;
import tech.jackywang.intermediate.layer.business.business2.Business2View;
package tech.jackywang.intermediate.layer;
/**
* 委托
*
* @author jacky
* @version v1.0
* @description 委托,隔离各业务间的耦合
* @since 2017/9/14
*/
public class BusinessDelegate extends RelativeLayout implements IBusinessDelegate {
private WeakReference<Context> mContextReference;
private Business1Contract.Presenter mBusiness1Presenter;
|
private Business2Contract.Presenter mBusiness2Presenter;
|
JackyAndroid/Android-Architecture-Fairy
|
IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/BusinessDelegate.java
|
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Contract.java
// public interface Business1Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Model.java
// public class Business1Model implements Business1Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Presenter.java
// public class Business1Presenter implements Business1Contract.Presenter {
//
// public Business1Presenter(Business1Contract.View view, Business1Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1View.java
// public class Business1View extends FrameLayout implements Business1Contract.View {
//
// public Business1View(@NonNull Context context) {
// super(context);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business1Contract.Presenter presenter) {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Contract.java
// public interface Business2Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Model.java
// public class Business2Model implements Business2Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Presenter.java
// public class Business2Presenter implements Business2Contract.Presenter {
//
// public Business2Presenter(Business2Contract.View view, Business2Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2View.java
// public class Business2View extends FrameLayout implements Business2Contract.View {
//
// public Business2View(@NonNull Context context) {
// super(context);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business2Contract.Presenter presenter) {
//
// }
// }
|
import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import java.lang.ref.WeakReference;
import tech.jackywang.intermediate.layer.business.business1.Business1Contract;
import tech.jackywang.intermediate.layer.business.business1.Business1Model;
import tech.jackywang.intermediate.layer.business.business1.Business1Presenter;
import tech.jackywang.intermediate.layer.business.business1.Business1View;
import tech.jackywang.intermediate.layer.business.business2.Business2Contract;
import tech.jackywang.intermediate.layer.business.business2.Business2Model;
import tech.jackywang.intermediate.layer.business.business2.Business2Presenter;
import tech.jackywang.intermediate.layer.business.business2.Business2View;
|
package tech.jackywang.intermediate.layer;
/**
* 委托
*
* @author jacky
* @version v1.0
* @description 委托,隔离各业务间的耦合
* @since 2017/9/14
*/
public class BusinessDelegate extends RelativeLayout implements IBusinessDelegate {
private WeakReference<Context> mContextReference;
private Business1Contract.Presenter mBusiness1Presenter;
private Business2Contract.Presenter mBusiness2Presenter;
public BusinessDelegate(Context context) {
super(context);
}
public BusinessDelegate(Context context, AttributeSet attrs) {
super(context, attrs);
}
public BusinessDelegate(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public IBusinessDelegate setup() {
mContextReference = new WeakReference<>(getContext());
removeAllViews();
return this;
}
// ---- 动态加载挂件 Start ----
@Override
public IBusinessDelegate setupBusiness1() {
|
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Contract.java
// public interface Business1Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Model.java
// public class Business1Model implements Business1Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Presenter.java
// public class Business1Presenter implements Business1Contract.Presenter {
//
// public Business1Presenter(Business1Contract.View view, Business1Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1View.java
// public class Business1View extends FrameLayout implements Business1Contract.View {
//
// public Business1View(@NonNull Context context) {
// super(context);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business1Contract.Presenter presenter) {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Contract.java
// public interface Business2Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Model.java
// public class Business2Model implements Business2Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Presenter.java
// public class Business2Presenter implements Business2Contract.Presenter {
//
// public Business2Presenter(Business2Contract.View view, Business2Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2View.java
// public class Business2View extends FrameLayout implements Business2Contract.View {
//
// public Business2View(@NonNull Context context) {
// super(context);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business2Contract.Presenter presenter) {
//
// }
// }
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/BusinessDelegate.java
import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import java.lang.ref.WeakReference;
import tech.jackywang.intermediate.layer.business.business1.Business1Contract;
import tech.jackywang.intermediate.layer.business.business1.Business1Model;
import tech.jackywang.intermediate.layer.business.business1.Business1Presenter;
import tech.jackywang.intermediate.layer.business.business1.Business1View;
import tech.jackywang.intermediate.layer.business.business2.Business2Contract;
import tech.jackywang.intermediate.layer.business.business2.Business2Model;
import tech.jackywang.intermediate.layer.business.business2.Business2Presenter;
import tech.jackywang.intermediate.layer.business.business2.Business2View;
package tech.jackywang.intermediate.layer;
/**
* 委托
*
* @author jacky
* @version v1.0
* @description 委托,隔离各业务间的耦合
* @since 2017/9/14
*/
public class BusinessDelegate extends RelativeLayout implements IBusinessDelegate {
private WeakReference<Context> mContextReference;
private Business1Contract.Presenter mBusiness1Presenter;
private Business2Contract.Presenter mBusiness2Presenter;
public BusinessDelegate(Context context) {
super(context);
}
public BusinessDelegate(Context context, AttributeSet attrs) {
super(context, attrs);
}
public BusinessDelegate(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public IBusinessDelegate setup() {
mContextReference = new WeakReference<>(getContext());
removeAllViews();
return this;
}
// ---- 动态加载挂件 Start ----
@Override
public IBusinessDelegate setupBusiness1() {
|
Business1View view = new Business1View(mContextReference.get());
|
JackyAndroid/Android-Architecture-Fairy
|
IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/BusinessDelegate.java
|
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Contract.java
// public interface Business1Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Model.java
// public class Business1Model implements Business1Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Presenter.java
// public class Business1Presenter implements Business1Contract.Presenter {
//
// public Business1Presenter(Business1Contract.View view, Business1Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1View.java
// public class Business1View extends FrameLayout implements Business1Contract.View {
//
// public Business1View(@NonNull Context context) {
// super(context);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business1Contract.Presenter presenter) {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Contract.java
// public interface Business2Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Model.java
// public class Business2Model implements Business2Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Presenter.java
// public class Business2Presenter implements Business2Contract.Presenter {
//
// public Business2Presenter(Business2Contract.View view, Business2Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2View.java
// public class Business2View extends FrameLayout implements Business2Contract.View {
//
// public Business2View(@NonNull Context context) {
// super(context);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business2Contract.Presenter presenter) {
//
// }
// }
|
import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import java.lang.ref.WeakReference;
import tech.jackywang.intermediate.layer.business.business1.Business1Contract;
import tech.jackywang.intermediate.layer.business.business1.Business1Model;
import tech.jackywang.intermediate.layer.business.business1.Business1Presenter;
import tech.jackywang.intermediate.layer.business.business1.Business1View;
import tech.jackywang.intermediate.layer.business.business2.Business2Contract;
import tech.jackywang.intermediate.layer.business.business2.Business2Model;
import tech.jackywang.intermediate.layer.business.business2.Business2Presenter;
import tech.jackywang.intermediate.layer.business.business2.Business2View;
|
package tech.jackywang.intermediate.layer;
/**
* 委托
*
* @author jacky
* @version v1.0
* @description 委托,隔离各业务间的耦合
* @since 2017/9/14
*/
public class BusinessDelegate extends RelativeLayout implements IBusinessDelegate {
private WeakReference<Context> mContextReference;
private Business1Contract.Presenter mBusiness1Presenter;
private Business2Contract.Presenter mBusiness2Presenter;
public BusinessDelegate(Context context) {
super(context);
}
public BusinessDelegate(Context context, AttributeSet attrs) {
super(context, attrs);
}
public BusinessDelegate(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public IBusinessDelegate setup() {
mContextReference = new WeakReference<>(getContext());
removeAllViews();
return this;
}
// ---- 动态加载挂件 Start ----
@Override
public IBusinessDelegate setupBusiness1() {
Business1View view = new Business1View(mContextReference.get());
|
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Contract.java
// public interface Business1Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Model.java
// public class Business1Model implements Business1Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Presenter.java
// public class Business1Presenter implements Business1Contract.Presenter {
//
// public Business1Presenter(Business1Contract.View view, Business1Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1View.java
// public class Business1View extends FrameLayout implements Business1Contract.View {
//
// public Business1View(@NonNull Context context) {
// super(context);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business1Contract.Presenter presenter) {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Contract.java
// public interface Business2Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Model.java
// public class Business2Model implements Business2Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Presenter.java
// public class Business2Presenter implements Business2Contract.Presenter {
//
// public Business2Presenter(Business2Contract.View view, Business2Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2View.java
// public class Business2View extends FrameLayout implements Business2Contract.View {
//
// public Business2View(@NonNull Context context) {
// super(context);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business2Contract.Presenter presenter) {
//
// }
// }
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/BusinessDelegate.java
import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import java.lang.ref.WeakReference;
import tech.jackywang.intermediate.layer.business.business1.Business1Contract;
import tech.jackywang.intermediate.layer.business.business1.Business1Model;
import tech.jackywang.intermediate.layer.business.business1.Business1Presenter;
import tech.jackywang.intermediate.layer.business.business1.Business1View;
import tech.jackywang.intermediate.layer.business.business2.Business2Contract;
import tech.jackywang.intermediate.layer.business.business2.Business2Model;
import tech.jackywang.intermediate.layer.business.business2.Business2Presenter;
import tech.jackywang.intermediate.layer.business.business2.Business2View;
package tech.jackywang.intermediate.layer;
/**
* 委托
*
* @author jacky
* @version v1.0
* @description 委托,隔离各业务间的耦合
* @since 2017/9/14
*/
public class BusinessDelegate extends RelativeLayout implements IBusinessDelegate {
private WeakReference<Context> mContextReference;
private Business1Contract.Presenter mBusiness1Presenter;
private Business2Contract.Presenter mBusiness2Presenter;
public BusinessDelegate(Context context) {
super(context);
}
public BusinessDelegate(Context context, AttributeSet attrs) {
super(context, attrs);
}
public BusinessDelegate(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public IBusinessDelegate setup() {
mContextReference = new WeakReference<>(getContext());
removeAllViews();
return this;
}
// ---- 动态加载挂件 Start ----
@Override
public IBusinessDelegate setupBusiness1() {
Business1View view = new Business1View(mContextReference.get());
|
mBusiness1Presenter = new Business1Presenter(view, new Business1Model());
|
JackyAndroid/Android-Architecture-Fairy
|
IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/BusinessDelegate.java
|
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Contract.java
// public interface Business1Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Model.java
// public class Business1Model implements Business1Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Presenter.java
// public class Business1Presenter implements Business1Contract.Presenter {
//
// public Business1Presenter(Business1Contract.View view, Business1Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1View.java
// public class Business1View extends FrameLayout implements Business1Contract.View {
//
// public Business1View(@NonNull Context context) {
// super(context);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business1Contract.Presenter presenter) {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Contract.java
// public interface Business2Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Model.java
// public class Business2Model implements Business2Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Presenter.java
// public class Business2Presenter implements Business2Contract.Presenter {
//
// public Business2Presenter(Business2Contract.View view, Business2Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2View.java
// public class Business2View extends FrameLayout implements Business2Contract.View {
//
// public Business2View(@NonNull Context context) {
// super(context);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business2Contract.Presenter presenter) {
//
// }
// }
|
import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import java.lang.ref.WeakReference;
import tech.jackywang.intermediate.layer.business.business1.Business1Contract;
import tech.jackywang.intermediate.layer.business.business1.Business1Model;
import tech.jackywang.intermediate.layer.business.business1.Business1Presenter;
import tech.jackywang.intermediate.layer.business.business1.Business1View;
import tech.jackywang.intermediate.layer.business.business2.Business2Contract;
import tech.jackywang.intermediate.layer.business.business2.Business2Model;
import tech.jackywang.intermediate.layer.business.business2.Business2Presenter;
import tech.jackywang.intermediate.layer.business.business2.Business2View;
|
package tech.jackywang.intermediate.layer;
/**
* 委托
*
* @author jacky
* @version v1.0
* @description 委托,隔离各业务间的耦合
* @since 2017/9/14
*/
public class BusinessDelegate extends RelativeLayout implements IBusinessDelegate {
private WeakReference<Context> mContextReference;
private Business1Contract.Presenter mBusiness1Presenter;
private Business2Contract.Presenter mBusiness2Presenter;
public BusinessDelegate(Context context) {
super(context);
}
public BusinessDelegate(Context context, AttributeSet attrs) {
super(context, attrs);
}
public BusinessDelegate(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public IBusinessDelegate setup() {
mContextReference = new WeakReference<>(getContext());
removeAllViews();
return this;
}
// ---- 动态加载挂件 Start ----
@Override
public IBusinessDelegate setupBusiness1() {
Business1View view = new Business1View(mContextReference.get());
|
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Contract.java
// public interface Business1Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Model.java
// public class Business1Model implements Business1Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Presenter.java
// public class Business1Presenter implements Business1Contract.Presenter {
//
// public Business1Presenter(Business1Contract.View view, Business1Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1View.java
// public class Business1View extends FrameLayout implements Business1Contract.View {
//
// public Business1View(@NonNull Context context) {
// super(context);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business1Contract.Presenter presenter) {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Contract.java
// public interface Business2Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Model.java
// public class Business2Model implements Business2Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Presenter.java
// public class Business2Presenter implements Business2Contract.Presenter {
//
// public Business2Presenter(Business2Contract.View view, Business2Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2View.java
// public class Business2View extends FrameLayout implements Business2Contract.View {
//
// public Business2View(@NonNull Context context) {
// super(context);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business2Contract.Presenter presenter) {
//
// }
// }
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/BusinessDelegate.java
import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import java.lang.ref.WeakReference;
import tech.jackywang.intermediate.layer.business.business1.Business1Contract;
import tech.jackywang.intermediate.layer.business.business1.Business1Model;
import tech.jackywang.intermediate.layer.business.business1.Business1Presenter;
import tech.jackywang.intermediate.layer.business.business1.Business1View;
import tech.jackywang.intermediate.layer.business.business2.Business2Contract;
import tech.jackywang.intermediate.layer.business.business2.Business2Model;
import tech.jackywang.intermediate.layer.business.business2.Business2Presenter;
import tech.jackywang.intermediate.layer.business.business2.Business2View;
package tech.jackywang.intermediate.layer;
/**
* 委托
*
* @author jacky
* @version v1.0
* @description 委托,隔离各业务间的耦合
* @since 2017/9/14
*/
public class BusinessDelegate extends RelativeLayout implements IBusinessDelegate {
private WeakReference<Context> mContextReference;
private Business1Contract.Presenter mBusiness1Presenter;
private Business2Contract.Presenter mBusiness2Presenter;
public BusinessDelegate(Context context) {
super(context);
}
public BusinessDelegate(Context context, AttributeSet attrs) {
super(context, attrs);
}
public BusinessDelegate(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public IBusinessDelegate setup() {
mContextReference = new WeakReference<>(getContext());
removeAllViews();
return this;
}
// ---- 动态加载挂件 Start ----
@Override
public IBusinessDelegate setupBusiness1() {
Business1View view = new Business1View(mContextReference.get());
|
mBusiness1Presenter = new Business1Presenter(view, new Business1Model());
|
JackyAndroid/Android-Architecture-Fairy
|
IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/BusinessDelegate.java
|
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Contract.java
// public interface Business1Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Model.java
// public class Business1Model implements Business1Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Presenter.java
// public class Business1Presenter implements Business1Contract.Presenter {
//
// public Business1Presenter(Business1Contract.View view, Business1Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1View.java
// public class Business1View extends FrameLayout implements Business1Contract.View {
//
// public Business1View(@NonNull Context context) {
// super(context);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business1Contract.Presenter presenter) {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Contract.java
// public interface Business2Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Model.java
// public class Business2Model implements Business2Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Presenter.java
// public class Business2Presenter implements Business2Contract.Presenter {
//
// public Business2Presenter(Business2Contract.View view, Business2Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2View.java
// public class Business2View extends FrameLayout implements Business2Contract.View {
//
// public Business2View(@NonNull Context context) {
// super(context);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business2Contract.Presenter presenter) {
//
// }
// }
|
import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import java.lang.ref.WeakReference;
import tech.jackywang.intermediate.layer.business.business1.Business1Contract;
import tech.jackywang.intermediate.layer.business.business1.Business1Model;
import tech.jackywang.intermediate.layer.business.business1.Business1Presenter;
import tech.jackywang.intermediate.layer.business.business1.Business1View;
import tech.jackywang.intermediate.layer.business.business2.Business2Contract;
import tech.jackywang.intermediate.layer.business.business2.Business2Model;
import tech.jackywang.intermediate.layer.business.business2.Business2Presenter;
import tech.jackywang.intermediate.layer.business.business2.Business2View;
|
public BusinessDelegate(Context context, AttributeSet attrs) {
super(context, attrs);
}
public BusinessDelegate(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public IBusinessDelegate setup() {
mContextReference = new WeakReference<>(getContext());
removeAllViews();
return this;
}
// ---- 动态加载挂件 Start ----
@Override
public IBusinessDelegate setupBusiness1() {
Business1View view = new Business1View(mContextReference.get());
mBusiness1Presenter = new Business1Presenter(view, new Business1Model());
view.setPresenter(mBusiness1Presenter);
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
addView(view, params);
return this;
}
@Override
public IBusinessDelegate setupBusiness2() {
|
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Contract.java
// public interface Business1Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Model.java
// public class Business1Model implements Business1Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Presenter.java
// public class Business1Presenter implements Business1Contract.Presenter {
//
// public Business1Presenter(Business1Contract.View view, Business1Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1View.java
// public class Business1View extends FrameLayout implements Business1Contract.View {
//
// public Business1View(@NonNull Context context) {
// super(context);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business1Contract.Presenter presenter) {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Contract.java
// public interface Business2Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Model.java
// public class Business2Model implements Business2Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Presenter.java
// public class Business2Presenter implements Business2Contract.Presenter {
//
// public Business2Presenter(Business2Contract.View view, Business2Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2View.java
// public class Business2View extends FrameLayout implements Business2Contract.View {
//
// public Business2View(@NonNull Context context) {
// super(context);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business2Contract.Presenter presenter) {
//
// }
// }
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/BusinessDelegate.java
import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import java.lang.ref.WeakReference;
import tech.jackywang.intermediate.layer.business.business1.Business1Contract;
import tech.jackywang.intermediate.layer.business.business1.Business1Model;
import tech.jackywang.intermediate.layer.business.business1.Business1Presenter;
import tech.jackywang.intermediate.layer.business.business1.Business1View;
import tech.jackywang.intermediate.layer.business.business2.Business2Contract;
import tech.jackywang.intermediate.layer.business.business2.Business2Model;
import tech.jackywang.intermediate.layer.business.business2.Business2Presenter;
import tech.jackywang.intermediate.layer.business.business2.Business2View;
public BusinessDelegate(Context context, AttributeSet attrs) {
super(context, attrs);
}
public BusinessDelegate(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public IBusinessDelegate setup() {
mContextReference = new WeakReference<>(getContext());
removeAllViews();
return this;
}
// ---- 动态加载挂件 Start ----
@Override
public IBusinessDelegate setupBusiness1() {
Business1View view = new Business1View(mContextReference.get());
mBusiness1Presenter = new Business1Presenter(view, new Business1Model());
view.setPresenter(mBusiness1Presenter);
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
addView(view, params);
return this;
}
@Override
public IBusinessDelegate setupBusiness2() {
|
Business2View view = new Business2View(mContextReference.get());
|
JackyAndroid/Android-Architecture-Fairy
|
IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/BusinessDelegate.java
|
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Contract.java
// public interface Business1Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Model.java
// public class Business1Model implements Business1Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Presenter.java
// public class Business1Presenter implements Business1Contract.Presenter {
//
// public Business1Presenter(Business1Contract.View view, Business1Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1View.java
// public class Business1View extends FrameLayout implements Business1Contract.View {
//
// public Business1View(@NonNull Context context) {
// super(context);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business1Contract.Presenter presenter) {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Contract.java
// public interface Business2Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Model.java
// public class Business2Model implements Business2Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Presenter.java
// public class Business2Presenter implements Business2Contract.Presenter {
//
// public Business2Presenter(Business2Contract.View view, Business2Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2View.java
// public class Business2View extends FrameLayout implements Business2Contract.View {
//
// public Business2View(@NonNull Context context) {
// super(context);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business2Contract.Presenter presenter) {
//
// }
// }
|
import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import java.lang.ref.WeakReference;
import tech.jackywang.intermediate.layer.business.business1.Business1Contract;
import tech.jackywang.intermediate.layer.business.business1.Business1Model;
import tech.jackywang.intermediate.layer.business.business1.Business1Presenter;
import tech.jackywang.intermediate.layer.business.business1.Business1View;
import tech.jackywang.intermediate.layer.business.business2.Business2Contract;
import tech.jackywang.intermediate.layer.business.business2.Business2Model;
import tech.jackywang.intermediate.layer.business.business2.Business2Presenter;
import tech.jackywang.intermediate.layer.business.business2.Business2View;
|
public BusinessDelegate(Context context, AttributeSet attrs) {
super(context, attrs);
}
public BusinessDelegate(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public IBusinessDelegate setup() {
mContextReference = new WeakReference<>(getContext());
removeAllViews();
return this;
}
// ---- 动态加载挂件 Start ----
@Override
public IBusinessDelegate setupBusiness1() {
Business1View view = new Business1View(mContextReference.get());
mBusiness1Presenter = new Business1Presenter(view, new Business1Model());
view.setPresenter(mBusiness1Presenter);
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
addView(view, params);
return this;
}
@Override
public IBusinessDelegate setupBusiness2() {
Business2View view = new Business2View(mContextReference.get());
|
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Contract.java
// public interface Business1Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Model.java
// public class Business1Model implements Business1Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Presenter.java
// public class Business1Presenter implements Business1Contract.Presenter {
//
// public Business1Presenter(Business1Contract.View view, Business1Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1View.java
// public class Business1View extends FrameLayout implements Business1Contract.View {
//
// public Business1View(@NonNull Context context) {
// super(context);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business1Contract.Presenter presenter) {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Contract.java
// public interface Business2Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Model.java
// public class Business2Model implements Business2Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Presenter.java
// public class Business2Presenter implements Business2Contract.Presenter {
//
// public Business2Presenter(Business2Contract.View view, Business2Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2View.java
// public class Business2View extends FrameLayout implements Business2Contract.View {
//
// public Business2View(@NonNull Context context) {
// super(context);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business2Contract.Presenter presenter) {
//
// }
// }
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/BusinessDelegate.java
import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import java.lang.ref.WeakReference;
import tech.jackywang.intermediate.layer.business.business1.Business1Contract;
import tech.jackywang.intermediate.layer.business.business1.Business1Model;
import tech.jackywang.intermediate.layer.business.business1.Business1Presenter;
import tech.jackywang.intermediate.layer.business.business1.Business1View;
import tech.jackywang.intermediate.layer.business.business2.Business2Contract;
import tech.jackywang.intermediate.layer.business.business2.Business2Model;
import tech.jackywang.intermediate.layer.business.business2.Business2Presenter;
import tech.jackywang.intermediate.layer.business.business2.Business2View;
public BusinessDelegate(Context context, AttributeSet attrs) {
super(context, attrs);
}
public BusinessDelegate(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public IBusinessDelegate setup() {
mContextReference = new WeakReference<>(getContext());
removeAllViews();
return this;
}
// ---- 动态加载挂件 Start ----
@Override
public IBusinessDelegate setupBusiness1() {
Business1View view = new Business1View(mContextReference.get());
mBusiness1Presenter = new Business1Presenter(view, new Business1Model());
view.setPresenter(mBusiness1Presenter);
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
addView(view, params);
return this;
}
@Override
public IBusinessDelegate setupBusiness2() {
Business2View view = new Business2View(mContextReference.get());
|
mBusiness2Presenter = new Business2Presenter(view, new Business2Model());
|
JackyAndroid/Android-Architecture-Fairy
|
IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/BusinessDelegate.java
|
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Contract.java
// public interface Business1Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Model.java
// public class Business1Model implements Business1Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Presenter.java
// public class Business1Presenter implements Business1Contract.Presenter {
//
// public Business1Presenter(Business1Contract.View view, Business1Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1View.java
// public class Business1View extends FrameLayout implements Business1Contract.View {
//
// public Business1View(@NonNull Context context) {
// super(context);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business1Contract.Presenter presenter) {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Contract.java
// public interface Business2Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Model.java
// public class Business2Model implements Business2Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Presenter.java
// public class Business2Presenter implements Business2Contract.Presenter {
//
// public Business2Presenter(Business2Contract.View view, Business2Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2View.java
// public class Business2View extends FrameLayout implements Business2Contract.View {
//
// public Business2View(@NonNull Context context) {
// super(context);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business2Contract.Presenter presenter) {
//
// }
// }
|
import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import java.lang.ref.WeakReference;
import tech.jackywang.intermediate.layer.business.business1.Business1Contract;
import tech.jackywang.intermediate.layer.business.business1.Business1Model;
import tech.jackywang.intermediate.layer.business.business1.Business1Presenter;
import tech.jackywang.intermediate.layer.business.business1.Business1View;
import tech.jackywang.intermediate.layer.business.business2.Business2Contract;
import tech.jackywang.intermediate.layer.business.business2.Business2Model;
import tech.jackywang.intermediate.layer.business.business2.Business2Presenter;
import tech.jackywang.intermediate.layer.business.business2.Business2View;
|
public BusinessDelegate(Context context, AttributeSet attrs) {
super(context, attrs);
}
public BusinessDelegate(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public IBusinessDelegate setup() {
mContextReference = new WeakReference<>(getContext());
removeAllViews();
return this;
}
// ---- 动态加载挂件 Start ----
@Override
public IBusinessDelegate setupBusiness1() {
Business1View view = new Business1View(mContextReference.get());
mBusiness1Presenter = new Business1Presenter(view, new Business1Model());
view.setPresenter(mBusiness1Presenter);
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
addView(view, params);
return this;
}
@Override
public IBusinessDelegate setupBusiness2() {
Business2View view = new Business2View(mContextReference.get());
|
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Contract.java
// public interface Business1Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Model.java
// public class Business1Model implements Business1Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1Presenter.java
// public class Business1Presenter implements Business1Contract.Presenter {
//
// public Business1Presenter(Business1Contract.View view, Business1Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business1/Business1View.java
// public class Business1View extends FrameLayout implements Business1Contract.View {
//
// public Business1View(@NonNull Context context) {
// super(context);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business1View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business1Contract.Presenter presenter) {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Contract.java
// public interface Business2Contract {
//
// interface View extends BaseView<Presenter> {
//
// }
//
// interface Presenter extends BasePresenter {
//
// }
//
// interface Model {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Model.java
// public class Business2Model implements Business2Contract.Model {
//
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Presenter.java
// public class Business2Presenter implements Business2Contract.Presenter {
//
// public Business2Presenter(Business2Contract.View view, Business2Contract.Model model) {
//
// }
//
// @Override
// public void onCreate() {
//
// }
//
// @Override
// public void onResume() {
//
// }
//
// @Override
// public void onPause() {
//
// }
//
// @Override
// public void onDestroy() {
//
// }
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2View.java
// public class Business2View extends FrameLayout implements Business2Contract.View {
//
// public Business2View(@NonNull Context context) {
// super(context);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public Business2View(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// @Override
// public void setPresenter(Business2Contract.Presenter presenter) {
//
// }
// }
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/BusinessDelegate.java
import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import java.lang.ref.WeakReference;
import tech.jackywang.intermediate.layer.business.business1.Business1Contract;
import tech.jackywang.intermediate.layer.business.business1.Business1Model;
import tech.jackywang.intermediate.layer.business.business1.Business1Presenter;
import tech.jackywang.intermediate.layer.business.business1.Business1View;
import tech.jackywang.intermediate.layer.business.business2.Business2Contract;
import tech.jackywang.intermediate.layer.business.business2.Business2Model;
import tech.jackywang.intermediate.layer.business.business2.Business2Presenter;
import tech.jackywang.intermediate.layer.business.business2.Business2View;
public BusinessDelegate(Context context, AttributeSet attrs) {
super(context, attrs);
}
public BusinessDelegate(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public IBusinessDelegate setup() {
mContextReference = new WeakReference<>(getContext());
removeAllViews();
return this;
}
// ---- 动态加载挂件 Start ----
@Override
public IBusinessDelegate setupBusiness1() {
Business1View view = new Business1View(mContextReference.get());
mBusiness1Presenter = new Business1Presenter(view, new Business1Model());
view.setPresenter(mBusiness1Presenter);
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
addView(view, params);
return this;
}
@Override
public IBusinessDelegate setupBusiness2() {
Business2View view = new Business2View(mContextReference.get());
|
mBusiness2Presenter = new Business2Presenter(view, new Business2Model());
|
JackyAndroid/Android-Architecture-Fairy
|
IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Contract.java
|
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/BasePresenter.java
// public interface BasePresenter {
//
// void onCreate();
//
// void onResume();
//
// void onPause();
//
// void onDestroy();
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/BaseView.java
// public interface BaseView<T> {
//
// void setPresenter(T presenter);
// }
|
import tech.jackywang.intermediate.layer.business.BasePresenter;
import tech.jackywang.intermediate.layer.business.BaseView;
|
package tech.jackywang.intermediate.layer.business.business2;
/**
* @author jacky
* @version v1.0
* @description
* @since 2017/10/19
*/
public interface Business2Contract {
interface View extends BaseView<Presenter> {
}
|
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/BasePresenter.java
// public interface BasePresenter {
//
// void onCreate();
//
// void onResume();
//
// void onPause();
//
// void onDestroy();
// }
//
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/BaseView.java
// public interface BaseView<T> {
//
// void setPresenter(T presenter);
// }
// Path: IntermediateLayer/app/src/main/java/tech/jackywang/intermediate/layer/business/business2/Business2Contract.java
import tech.jackywang.intermediate.layer.business.BasePresenter;
import tech.jackywang.intermediate.layer.business.BaseView;
package tech.jackywang.intermediate.layer.business.business2;
/**
* @author jacky
* @version v1.0
* @description
* @since 2017/10/19
*/
public interface Business2Contract {
interface View extends BaseView<Presenter> {
}
|
interface Presenter extends BasePresenter {
|
JackyAndroid/Android-Architecture-Fairy
|
mvp/app/src/test/java/com/tinmegali/tutsmvp_sample/DBTest.java
|
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/data/DAO.java
// public class DAO {
//
// private DBSchema mHelper;
// private Context mContext;
//
// //SELECTIONS
// private static final String SELECT_ID_BASED = DBSchema.TB_NOTES.ID + " = ? ";
// private static final String PROJECTION_ALL = " * ";
// public static final String SORT_ORDER_DEFAULT = DBSchema.TB_NOTES.ID + " DESC";
//
// public DAO(Context context) {
// this.mContext = context;
// mHelper = new DBSchema(mContext);
// }
//
// private SQLiteDatabase getReadDB(){
// return mHelper.getReadableDatabase();
// }
//
// private SQLiteDatabase getWriteDB(){
// return mHelper.getWritableDatabase();
// }
//
// public Note insertNote(Note note) {
// SQLiteDatabase db = getWriteDB();
// long id = db.insert(
// DBSchema.TABLE_NOTES,
// null,
// note.getValues()
// );
// Note insertedNote = getNote((int)id);
// db.close();
// return insertedNote;
// }
//
// public long deleteNote(Note note) {
// SQLiteDatabase db = getWriteDB();
// long res = db.delete(
// DBSchema.TABLE_NOTES,
// SELECT_ID_BASED,
// new String[]{Integer.toString(note.getId())}
//
// );
// db.close();
// return res;
// }
//
// public ArrayList<Note> getAllNotes() {
// SQLiteDatabase db = getReadDB();
// Cursor c = db.query(
// DBSchema.TABLE_NOTES,
// null,
// null,
// null, null, null,
// SORT_ORDER_DEFAULT
// );
// if ( c!= null) {
// c.moveToFirst();
// ArrayList<Note> notes = new ArrayList<>();
// while (!c.isAfterLast()) {
// Note note = new Note();
// note.setId( c.getInt( c.getColumnIndexOrThrow( DBSchema.TB_NOTES.ID )));
// note.setText(c.getString(c.getColumnIndexOrThrow(DBSchema.TB_NOTES.NOTE)));
// note.setDate(c.getString(c.getColumnIndexOrThrow(DBSchema.TB_NOTES.DATE)));
// notes.add(note);
// c.moveToNext();
// }
// c.close();
// db.close();
// return notes;
// } else {
// return null;
// }
// }
//
// public Note getNote(int id){
// SQLiteDatabase db = getReadDB();
// Cursor c = db.query(
// DBSchema.TABLE_NOTES,
// null,
// SELECT_ID_BASED,
// new String[]{Integer.toString(id)},
// null,
// null,
// null
// );
// if (c != null) {
// c.moveToFirst();
// Note note = new Note();
// note.setId(c.getInt(c.getColumnIndexOrThrow(DBSchema.TB_NOTES.ID)));
// note.setText(c.getString(c.getColumnIndexOrThrow(DBSchema.TB_NOTES.NOTE)));
// note.setDate(c.getString(c.getColumnIndexOrThrow(DBSchema.TB_NOTES.DATE)));
// c.close();
// db.close();
// return note;
// } else return null;
// }
//
// }
//
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/models/Note.java
// public class Note {
//
// private int id = -1;
// private String mText;
// private String mDate;
//
// public Note() {
// }
//
// public Note(int id, String mText, String mDate) {
// this.id = id;
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public Note(String mText, String mDate) {
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public ContentValues getValues(){
// ContentValues cv = new ContentValues();
// if ( id!=-1) cv.put(DBSchema.TB_NOTES.ID, id);
// cv.put(DBSchema.TB_NOTES.NOTE, mText);
// cv.put(DBSchema.TB_NOTES.DATE, mDate);
// return cv;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public void setDate(String mDate) {
// this.mDate = mDate;
// }
//
// public void setText(String mText) {
// this.mText = mText;
// }
//
// public int getId() {
// return id;
// }
//
// public String getDate() {
// return mDate;
// }
//
// public String getText() {
// return mText;
// }
// }
|
import android.content.Context;
import com.tinmegali.tutsmvp_sample.data.DAO;
import com.tinmegali.tutsmvp_sample.models.Note;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import java.util.ArrayList;
import static org.junit.Assert.*;
|
package com.tinmegali.tutsmvp_sample;
/**
* ---------------------------------------------------
* Created by Tin Megali on 18/03/16.
* Project: tuts+mvp_sample
* ---------------------------------------------------
* <a href="http://www.tinmegali.com">tinmegali.com</a>
* <a href="http://www.github.com/tinmegali>github</a>
* ---------------------------------------------------
*/
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 21, manifest = "/src/main/AndroidManifest.xml")
public class DBTest {
|
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/data/DAO.java
// public class DAO {
//
// private DBSchema mHelper;
// private Context mContext;
//
// //SELECTIONS
// private static final String SELECT_ID_BASED = DBSchema.TB_NOTES.ID + " = ? ";
// private static final String PROJECTION_ALL = " * ";
// public static final String SORT_ORDER_DEFAULT = DBSchema.TB_NOTES.ID + " DESC";
//
// public DAO(Context context) {
// this.mContext = context;
// mHelper = new DBSchema(mContext);
// }
//
// private SQLiteDatabase getReadDB(){
// return mHelper.getReadableDatabase();
// }
//
// private SQLiteDatabase getWriteDB(){
// return mHelper.getWritableDatabase();
// }
//
// public Note insertNote(Note note) {
// SQLiteDatabase db = getWriteDB();
// long id = db.insert(
// DBSchema.TABLE_NOTES,
// null,
// note.getValues()
// );
// Note insertedNote = getNote((int)id);
// db.close();
// return insertedNote;
// }
//
// public long deleteNote(Note note) {
// SQLiteDatabase db = getWriteDB();
// long res = db.delete(
// DBSchema.TABLE_NOTES,
// SELECT_ID_BASED,
// new String[]{Integer.toString(note.getId())}
//
// );
// db.close();
// return res;
// }
//
// public ArrayList<Note> getAllNotes() {
// SQLiteDatabase db = getReadDB();
// Cursor c = db.query(
// DBSchema.TABLE_NOTES,
// null,
// null,
// null, null, null,
// SORT_ORDER_DEFAULT
// );
// if ( c!= null) {
// c.moveToFirst();
// ArrayList<Note> notes = new ArrayList<>();
// while (!c.isAfterLast()) {
// Note note = new Note();
// note.setId( c.getInt( c.getColumnIndexOrThrow( DBSchema.TB_NOTES.ID )));
// note.setText(c.getString(c.getColumnIndexOrThrow(DBSchema.TB_NOTES.NOTE)));
// note.setDate(c.getString(c.getColumnIndexOrThrow(DBSchema.TB_NOTES.DATE)));
// notes.add(note);
// c.moveToNext();
// }
// c.close();
// db.close();
// return notes;
// } else {
// return null;
// }
// }
//
// public Note getNote(int id){
// SQLiteDatabase db = getReadDB();
// Cursor c = db.query(
// DBSchema.TABLE_NOTES,
// null,
// SELECT_ID_BASED,
// new String[]{Integer.toString(id)},
// null,
// null,
// null
// );
// if (c != null) {
// c.moveToFirst();
// Note note = new Note();
// note.setId(c.getInt(c.getColumnIndexOrThrow(DBSchema.TB_NOTES.ID)));
// note.setText(c.getString(c.getColumnIndexOrThrow(DBSchema.TB_NOTES.NOTE)));
// note.setDate(c.getString(c.getColumnIndexOrThrow(DBSchema.TB_NOTES.DATE)));
// c.close();
// db.close();
// return note;
// } else return null;
// }
//
// }
//
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/models/Note.java
// public class Note {
//
// private int id = -1;
// private String mText;
// private String mDate;
//
// public Note() {
// }
//
// public Note(int id, String mText, String mDate) {
// this.id = id;
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public Note(String mText, String mDate) {
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public ContentValues getValues(){
// ContentValues cv = new ContentValues();
// if ( id!=-1) cv.put(DBSchema.TB_NOTES.ID, id);
// cv.put(DBSchema.TB_NOTES.NOTE, mText);
// cv.put(DBSchema.TB_NOTES.DATE, mDate);
// return cv;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public void setDate(String mDate) {
// this.mDate = mDate;
// }
//
// public void setText(String mText) {
// this.mText = mText;
// }
//
// public int getId() {
// return id;
// }
//
// public String getDate() {
// return mDate;
// }
//
// public String getText() {
// return mText;
// }
// }
// Path: mvp/app/src/test/java/com/tinmegali/tutsmvp_sample/DBTest.java
import android.content.Context;
import com.tinmegali.tutsmvp_sample.data.DAO;
import com.tinmegali.tutsmvp_sample.models.Note;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import java.util.ArrayList;
import static org.junit.Assert.*;
package com.tinmegali.tutsmvp_sample;
/**
* ---------------------------------------------------
* Created by Tin Megali on 18/03/16.
* Project: tuts+mvp_sample
* ---------------------------------------------------
* <a href="http://www.tinmegali.com">tinmegali.com</a>
* <a href="http://www.github.com/tinmegali>github</a>
* ---------------------------------------------------
*/
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 21, manifest = "/src/main/AndroidManifest.xml")
public class DBTest {
|
private DAO dao;
|
JackyAndroid/Android-Architecture-Fairy
|
mvp/app/src/test/java/com/tinmegali/tutsmvp_sample/DBTest.java
|
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/data/DAO.java
// public class DAO {
//
// private DBSchema mHelper;
// private Context mContext;
//
// //SELECTIONS
// private static final String SELECT_ID_BASED = DBSchema.TB_NOTES.ID + " = ? ";
// private static final String PROJECTION_ALL = " * ";
// public static final String SORT_ORDER_DEFAULT = DBSchema.TB_NOTES.ID + " DESC";
//
// public DAO(Context context) {
// this.mContext = context;
// mHelper = new DBSchema(mContext);
// }
//
// private SQLiteDatabase getReadDB(){
// return mHelper.getReadableDatabase();
// }
//
// private SQLiteDatabase getWriteDB(){
// return mHelper.getWritableDatabase();
// }
//
// public Note insertNote(Note note) {
// SQLiteDatabase db = getWriteDB();
// long id = db.insert(
// DBSchema.TABLE_NOTES,
// null,
// note.getValues()
// );
// Note insertedNote = getNote((int)id);
// db.close();
// return insertedNote;
// }
//
// public long deleteNote(Note note) {
// SQLiteDatabase db = getWriteDB();
// long res = db.delete(
// DBSchema.TABLE_NOTES,
// SELECT_ID_BASED,
// new String[]{Integer.toString(note.getId())}
//
// );
// db.close();
// return res;
// }
//
// public ArrayList<Note> getAllNotes() {
// SQLiteDatabase db = getReadDB();
// Cursor c = db.query(
// DBSchema.TABLE_NOTES,
// null,
// null,
// null, null, null,
// SORT_ORDER_DEFAULT
// );
// if ( c!= null) {
// c.moveToFirst();
// ArrayList<Note> notes = new ArrayList<>();
// while (!c.isAfterLast()) {
// Note note = new Note();
// note.setId( c.getInt( c.getColumnIndexOrThrow( DBSchema.TB_NOTES.ID )));
// note.setText(c.getString(c.getColumnIndexOrThrow(DBSchema.TB_NOTES.NOTE)));
// note.setDate(c.getString(c.getColumnIndexOrThrow(DBSchema.TB_NOTES.DATE)));
// notes.add(note);
// c.moveToNext();
// }
// c.close();
// db.close();
// return notes;
// } else {
// return null;
// }
// }
//
// public Note getNote(int id){
// SQLiteDatabase db = getReadDB();
// Cursor c = db.query(
// DBSchema.TABLE_NOTES,
// null,
// SELECT_ID_BASED,
// new String[]{Integer.toString(id)},
// null,
// null,
// null
// );
// if (c != null) {
// c.moveToFirst();
// Note note = new Note();
// note.setId(c.getInt(c.getColumnIndexOrThrow(DBSchema.TB_NOTES.ID)));
// note.setText(c.getString(c.getColumnIndexOrThrow(DBSchema.TB_NOTES.NOTE)));
// note.setDate(c.getString(c.getColumnIndexOrThrow(DBSchema.TB_NOTES.DATE)));
// c.close();
// db.close();
// return note;
// } else return null;
// }
//
// }
//
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/models/Note.java
// public class Note {
//
// private int id = -1;
// private String mText;
// private String mDate;
//
// public Note() {
// }
//
// public Note(int id, String mText, String mDate) {
// this.id = id;
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public Note(String mText, String mDate) {
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public ContentValues getValues(){
// ContentValues cv = new ContentValues();
// if ( id!=-1) cv.put(DBSchema.TB_NOTES.ID, id);
// cv.put(DBSchema.TB_NOTES.NOTE, mText);
// cv.put(DBSchema.TB_NOTES.DATE, mDate);
// return cv;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public void setDate(String mDate) {
// this.mDate = mDate;
// }
//
// public void setText(String mText) {
// this.mText = mText;
// }
//
// public int getId() {
// return id;
// }
//
// public String getDate() {
// return mDate;
// }
//
// public String getText() {
// return mText;
// }
// }
|
import android.content.Context;
import com.tinmegali.tutsmvp_sample.data.DAO;
import com.tinmegali.tutsmvp_sample.models.Note;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import java.util.ArrayList;
import static org.junit.Assert.*;
|
package com.tinmegali.tutsmvp_sample;
/**
* ---------------------------------------------------
* Created by Tin Megali on 18/03/16.
* Project: tuts+mvp_sample
* ---------------------------------------------------
* <a href="http://www.tinmegali.com">tinmegali.com</a>
* <a href="http://www.github.com/tinmegali>github</a>
* ---------------------------------------------------
*/
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 21, manifest = "/src/main/AndroidManifest.xml")
public class DBTest {
private DAO dao;
@Before
public void setup() {
Context context = RuntimeEnvironment.application;
dao = new DAO(context);
}
|
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/data/DAO.java
// public class DAO {
//
// private DBSchema mHelper;
// private Context mContext;
//
// //SELECTIONS
// private static final String SELECT_ID_BASED = DBSchema.TB_NOTES.ID + " = ? ";
// private static final String PROJECTION_ALL = " * ";
// public static final String SORT_ORDER_DEFAULT = DBSchema.TB_NOTES.ID + " DESC";
//
// public DAO(Context context) {
// this.mContext = context;
// mHelper = new DBSchema(mContext);
// }
//
// private SQLiteDatabase getReadDB(){
// return mHelper.getReadableDatabase();
// }
//
// private SQLiteDatabase getWriteDB(){
// return mHelper.getWritableDatabase();
// }
//
// public Note insertNote(Note note) {
// SQLiteDatabase db = getWriteDB();
// long id = db.insert(
// DBSchema.TABLE_NOTES,
// null,
// note.getValues()
// );
// Note insertedNote = getNote((int)id);
// db.close();
// return insertedNote;
// }
//
// public long deleteNote(Note note) {
// SQLiteDatabase db = getWriteDB();
// long res = db.delete(
// DBSchema.TABLE_NOTES,
// SELECT_ID_BASED,
// new String[]{Integer.toString(note.getId())}
//
// );
// db.close();
// return res;
// }
//
// public ArrayList<Note> getAllNotes() {
// SQLiteDatabase db = getReadDB();
// Cursor c = db.query(
// DBSchema.TABLE_NOTES,
// null,
// null,
// null, null, null,
// SORT_ORDER_DEFAULT
// );
// if ( c!= null) {
// c.moveToFirst();
// ArrayList<Note> notes = new ArrayList<>();
// while (!c.isAfterLast()) {
// Note note = new Note();
// note.setId( c.getInt( c.getColumnIndexOrThrow( DBSchema.TB_NOTES.ID )));
// note.setText(c.getString(c.getColumnIndexOrThrow(DBSchema.TB_NOTES.NOTE)));
// note.setDate(c.getString(c.getColumnIndexOrThrow(DBSchema.TB_NOTES.DATE)));
// notes.add(note);
// c.moveToNext();
// }
// c.close();
// db.close();
// return notes;
// } else {
// return null;
// }
// }
//
// public Note getNote(int id){
// SQLiteDatabase db = getReadDB();
// Cursor c = db.query(
// DBSchema.TABLE_NOTES,
// null,
// SELECT_ID_BASED,
// new String[]{Integer.toString(id)},
// null,
// null,
// null
// );
// if (c != null) {
// c.moveToFirst();
// Note note = new Note();
// note.setId(c.getInt(c.getColumnIndexOrThrow(DBSchema.TB_NOTES.ID)));
// note.setText(c.getString(c.getColumnIndexOrThrow(DBSchema.TB_NOTES.NOTE)));
// note.setDate(c.getString(c.getColumnIndexOrThrow(DBSchema.TB_NOTES.DATE)));
// c.close();
// db.close();
// return note;
// } else return null;
// }
//
// }
//
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/models/Note.java
// public class Note {
//
// private int id = -1;
// private String mText;
// private String mDate;
//
// public Note() {
// }
//
// public Note(int id, String mText, String mDate) {
// this.id = id;
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public Note(String mText, String mDate) {
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public ContentValues getValues(){
// ContentValues cv = new ContentValues();
// if ( id!=-1) cv.put(DBSchema.TB_NOTES.ID, id);
// cv.put(DBSchema.TB_NOTES.NOTE, mText);
// cv.put(DBSchema.TB_NOTES.DATE, mDate);
// return cv;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public void setDate(String mDate) {
// this.mDate = mDate;
// }
//
// public void setText(String mText) {
// this.mText = mText;
// }
//
// public int getId() {
// return id;
// }
//
// public String getDate() {
// return mDate;
// }
//
// public String getText() {
// return mText;
// }
// }
// Path: mvp/app/src/test/java/com/tinmegali/tutsmvp_sample/DBTest.java
import android.content.Context;
import com.tinmegali.tutsmvp_sample.data.DAO;
import com.tinmegali.tutsmvp_sample.models.Note;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import java.util.ArrayList;
import static org.junit.Assert.*;
package com.tinmegali.tutsmvp_sample;
/**
* ---------------------------------------------------
* Created by Tin Megali on 18/03/16.
* Project: tuts+mvp_sample
* ---------------------------------------------------
* <a href="http://www.tinmegali.com">tinmegali.com</a>
* <a href="http://www.github.com/tinmegali>github</a>
* ---------------------------------------------------
*/
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 21, manifest = "/src/main/AndroidManifest.xml")
public class DBTest {
private DAO dao;
@Before
public void setup() {
Context context = RuntimeEnvironment.application;
dao = new DAO(context);
}
|
private Note getNote(String text) {
|
JackyAndroid/Android-Architecture-Fairy
|
multi-variants-library/app/src/main/java/com/jacky/myapplication/MainActivity.java
|
// Path: multi-variants-library/common/src/main/java/com/jacky/common/CommonFlavor.java
// public class CommonFlavor {
// public CommonFlavor() {
// Log.d("==Common Flavor= flavor", "" + BuildConfig.FLAVOR);
// Log.d("==Common Flavor==Flag", "" + BuildConfig.flavorFlag);
// }
// }
//
// Path: multi-variants-library/uikit/src/main/java/com/jacky/library/UIKitFlavor.java
// public class UIKitFlavor {
// public UIKitFlavor() {
// Log.d("===UIKit Flavor==flavor", "" + BuildConfig.FLAVOR);
// Log.d("===UIKit Flavor=== Flag", "" + BuildConfig.flavorFlag);
// }
// }
//
// Path: multi-variants-library/sdk/src/main/java/com/jacky/sdk/SdkFlavor.java
// public class SdkFlavor {
// public SdkFlavor() {
// Log.d("===Sdk Flavor=== flavor", "" + BuildConfig.FLAVOR);
// Log.d("===Sdk Flavor=== Flag", "" + BuildConfig.flavorFlag);
// }
// }
|
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import com.jacky.common.CommonFlavor;
import com.jacky.library.UIKitFlavor;
import com.jacky.sdk.SdkFlavor;
|
package com.jacky.myapplication;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d("===App Flavor=== flavor", "" + BuildConfig.FLAVOR);
Log.d("===App Flavor=== Flag", "" + BuildConfig.flavorFlag);
|
// Path: multi-variants-library/common/src/main/java/com/jacky/common/CommonFlavor.java
// public class CommonFlavor {
// public CommonFlavor() {
// Log.d("==Common Flavor= flavor", "" + BuildConfig.FLAVOR);
// Log.d("==Common Flavor==Flag", "" + BuildConfig.flavorFlag);
// }
// }
//
// Path: multi-variants-library/uikit/src/main/java/com/jacky/library/UIKitFlavor.java
// public class UIKitFlavor {
// public UIKitFlavor() {
// Log.d("===UIKit Flavor==flavor", "" + BuildConfig.FLAVOR);
// Log.d("===UIKit Flavor=== Flag", "" + BuildConfig.flavorFlag);
// }
// }
//
// Path: multi-variants-library/sdk/src/main/java/com/jacky/sdk/SdkFlavor.java
// public class SdkFlavor {
// public SdkFlavor() {
// Log.d("===Sdk Flavor=== flavor", "" + BuildConfig.FLAVOR);
// Log.d("===Sdk Flavor=== Flag", "" + BuildConfig.flavorFlag);
// }
// }
// Path: multi-variants-library/app/src/main/java/com/jacky/myapplication/MainActivity.java
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import com.jacky.common.CommonFlavor;
import com.jacky.library.UIKitFlavor;
import com.jacky.sdk.SdkFlavor;
package com.jacky.myapplication;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d("===App Flavor=== flavor", "" + BuildConfig.FLAVOR);
Log.d("===App Flavor=== Flag", "" + BuildConfig.flavorFlag);
|
new UIKitFlavor();
|
JackyAndroid/Android-Architecture-Fairy
|
multi-variants-library/app/src/main/java/com/jacky/myapplication/MainActivity.java
|
// Path: multi-variants-library/common/src/main/java/com/jacky/common/CommonFlavor.java
// public class CommonFlavor {
// public CommonFlavor() {
// Log.d("==Common Flavor= flavor", "" + BuildConfig.FLAVOR);
// Log.d("==Common Flavor==Flag", "" + BuildConfig.flavorFlag);
// }
// }
//
// Path: multi-variants-library/uikit/src/main/java/com/jacky/library/UIKitFlavor.java
// public class UIKitFlavor {
// public UIKitFlavor() {
// Log.d("===UIKit Flavor==flavor", "" + BuildConfig.FLAVOR);
// Log.d("===UIKit Flavor=== Flag", "" + BuildConfig.flavorFlag);
// }
// }
//
// Path: multi-variants-library/sdk/src/main/java/com/jacky/sdk/SdkFlavor.java
// public class SdkFlavor {
// public SdkFlavor() {
// Log.d("===Sdk Flavor=== flavor", "" + BuildConfig.FLAVOR);
// Log.d("===Sdk Flavor=== Flag", "" + BuildConfig.flavorFlag);
// }
// }
|
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import com.jacky.common.CommonFlavor;
import com.jacky.library.UIKitFlavor;
import com.jacky.sdk.SdkFlavor;
|
package com.jacky.myapplication;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d("===App Flavor=== flavor", "" + BuildConfig.FLAVOR);
Log.d("===App Flavor=== Flag", "" + BuildConfig.flavorFlag);
new UIKitFlavor();
|
// Path: multi-variants-library/common/src/main/java/com/jacky/common/CommonFlavor.java
// public class CommonFlavor {
// public CommonFlavor() {
// Log.d("==Common Flavor= flavor", "" + BuildConfig.FLAVOR);
// Log.d("==Common Flavor==Flag", "" + BuildConfig.flavorFlag);
// }
// }
//
// Path: multi-variants-library/uikit/src/main/java/com/jacky/library/UIKitFlavor.java
// public class UIKitFlavor {
// public UIKitFlavor() {
// Log.d("===UIKit Flavor==flavor", "" + BuildConfig.FLAVOR);
// Log.d("===UIKit Flavor=== Flag", "" + BuildConfig.flavorFlag);
// }
// }
//
// Path: multi-variants-library/sdk/src/main/java/com/jacky/sdk/SdkFlavor.java
// public class SdkFlavor {
// public SdkFlavor() {
// Log.d("===Sdk Flavor=== flavor", "" + BuildConfig.FLAVOR);
// Log.d("===Sdk Flavor=== Flag", "" + BuildConfig.flavorFlag);
// }
// }
// Path: multi-variants-library/app/src/main/java/com/jacky/myapplication/MainActivity.java
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import com.jacky.common.CommonFlavor;
import com.jacky.library.UIKitFlavor;
import com.jacky.sdk.SdkFlavor;
package com.jacky.myapplication;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d("===App Flavor=== flavor", "" + BuildConfig.FLAVOR);
Log.d("===App Flavor=== Flag", "" + BuildConfig.flavorFlag);
new UIKitFlavor();
|
new SdkFlavor();
|
JackyAndroid/Android-Architecture-Fairy
|
multi-variants-library/app/src/main/java/com/jacky/myapplication/MainActivity.java
|
// Path: multi-variants-library/common/src/main/java/com/jacky/common/CommonFlavor.java
// public class CommonFlavor {
// public CommonFlavor() {
// Log.d("==Common Flavor= flavor", "" + BuildConfig.FLAVOR);
// Log.d("==Common Flavor==Flag", "" + BuildConfig.flavorFlag);
// }
// }
//
// Path: multi-variants-library/uikit/src/main/java/com/jacky/library/UIKitFlavor.java
// public class UIKitFlavor {
// public UIKitFlavor() {
// Log.d("===UIKit Flavor==flavor", "" + BuildConfig.FLAVOR);
// Log.d("===UIKit Flavor=== Flag", "" + BuildConfig.flavorFlag);
// }
// }
//
// Path: multi-variants-library/sdk/src/main/java/com/jacky/sdk/SdkFlavor.java
// public class SdkFlavor {
// public SdkFlavor() {
// Log.d("===Sdk Flavor=== flavor", "" + BuildConfig.FLAVOR);
// Log.d("===Sdk Flavor=== Flag", "" + BuildConfig.flavorFlag);
// }
// }
|
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import com.jacky.common.CommonFlavor;
import com.jacky.library.UIKitFlavor;
import com.jacky.sdk.SdkFlavor;
|
package com.jacky.myapplication;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d("===App Flavor=== flavor", "" + BuildConfig.FLAVOR);
Log.d("===App Flavor=== Flag", "" + BuildConfig.flavorFlag);
new UIKitFlavor();
new SdkFlavor();
|
// Path: multi-variants-library/common/src/main/java/com/jacky/common/CommonFlavor.java
// public class CommonFlavor {
// public CommonFlavor() {
// Log.d("==Common Flavor= flavor", "" + BuildConfig.FLAVOR);
// Log.d("==Common Flavor==Flag", "" + BuildConfig.flavorFlag);
// }
// }
//
// Path: multi-variants-library/uikit/src/main/java/com/jacky/library/UIKitFlavor.java
// public class UIKitFlavor {
// public UIKitFlavor() {
// Log.d("===UIKit Flavor==flavor", "" + BuildConfig.FLAVOR);
// Log.d("===UIKit Flavor=== Flag", "" + BuildConfig.flavorFlag);
// }
// }
//
// Path: multi-variants-library/sdk/src/main/java/com/jacky/sdk/SdkFlavor.java
// public class SdkFlavor {
// public SdkFlavor() {
// Log.d("===Sdk Flavor=== flavor", "" + BuildConfig.FLAVOR);
// Log.d("===Sdk Flavor=== Flag", "" + BuildConfig.flavorFlag);
// }
// }
// Path: multi-variants-library/app/src/main/java/com/jacky/myapplication/MainActivity.java
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import com.jacky.common.CommonFlavor;
import com.jacky.library.UIKitFlavor;
import com.jacky.sdk.SdkFlavor;
package com.jacky.myapplication;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d("===App Flavor=== flavor", "" + BuildConfig.FLAVOR);
Log.d("===App Flavor=== Flag", "" + BuildConfig.flavorFlag);
new UIKitFlavor();
new SdkFlavor();
|
new CommonFlavor();
|
JackyAndroid/Android-Architecture-Fairy
|
mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/models/Note.java
|
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/data/DBSchema.java
// public class DBSchema extends SQLiteOpenHelper {
//
// private static final int DB_VERSION = 1;
// private static final String DB_NAME = "mvp_sample.db";
//
// public DBSchema(Context context)
// {
// super(context, DB_NAME, null, DB_VERSION);
// }
//
// //Tables
// public static final String TABLE_NOTES = "notes";
//
// private static final String COMMA_SPACE = ", ";
// private static final String CREATE_TABLE = "CREATE TABLE ";
// private static final String PRIMARY_KEY = "PRIMARY KEY ";
// private static final String UNIQUE = "UNIQUE ";
// private static final String TYPE_TEXT = " TEXT ";
// private static final String TYPE_DATE = " DATETIME ";
// private static final String TYPE_INT = " INTEGER ";
// private static final String DEFAULT = "DEFAULT ";
// private static final String AUTOINCREMENT = "AUTOINCREMENT ";
// private static final String NOT_NULL = "NOT NULL ";
// private static final String DROP_TABLE = "DROP TABLE IF EXISTS ";
//
// public static final class TB_NOTES {
// public static final String ID = "_id";
// public static final String NOTE = "note";
// public static final String DATE = "date";
//
//
// }
//
// private static final String CREATE_TABLE_NOTES =
// CREATE_TABLE + TABLE_NOTES + " ( " +
// TB_NOTES.ID + TYPE_INT + NOT_NULL + PRIMARY_KEY + COMMA_SPACE +
// TB_NOTES.NOTE + TYPE_DATE + NOT_NULL + COMMA_SPACE +
// TB_NOTES.DATE + TYPE_TEXT + NOT_NULL +
// ")";
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// db.execSQL(CREATE_TABLE_NOTES);
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// db.execSQL(CREATE_TABLE);
// }
// }
|
import android.content.ContentValues;
import com.tinmegali.tutsmvp_sample.data.DBSchema;
|
package com.tinmegali.tutsmvp_sample.models;
/**
* ---------------------------------------------------
* Created by Tin Megali on 18/03/16.
* Project: tuts+mvp_sample
* ---------------------------------------------------
* <a href="http://www.tinmegali.com">tinmegali.com</a>
* <a href="http://www.github.com/tinmegali>github</a>
* ---------------------------------------------------
*/
public class Note {
private int id = -1;
private String mText;
private String mDate;
public Note() {
}
public Note(int id, String mText, String mDate) {
this.id = id;
this.mText = mText;
this.mDate = mDate;
}
public Note(String mText, String mDate) {
this.mText = mText;
this.mDate = mDate;
}
public ContentValues getValues(){
ContentValues cv = new ContentValues();
|
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/data/DBSchema.java
// public class DBSchema extends SQLiteOpenHelper {
//
// private static final int DB_VERSION = 1;
// private static final String DB_NAME = "mvp_sample.db";
//
// public DBSchema(Context context)
// {
// super(context, DB_NAME, null, DB_VERSION);
// }
//
// //Tables
// public static final String TABLE_NOTES = "notes";
//
// private static final String COMMA_SPACE = ", ";
// private static final String CREATE_TABLE = "CREATE TABLE ";
// private static final String PRIMARY_KEY = "PRIMARY KEY ";
// private static final String UNIQUE = "UNIQUE ";
// private static final String TYPE_TEXT = " TEXT ";
// private static final String TYPE_DATE = " DATETIME ";
// private static final String TYPE_INT = " INTEGER ";
// private static final String DEFAULT = "DEFAULT ";
// private static final String AUTOINCREMENT = "AUTOINCREMENT ";
// private static final String NOT_NULL = "NOT NULL ";
// private static final String DROP_TABLE = "DROP TABLE IF EXISTS ";
//
// public static final class TB_NOTES {
// public static final String ID = "_id";
// public static final String NOTE = "note";
// public static final String DATE = "date";
//
//
// }
//
// private static final String CREATE_TABLE_NOTES =
// CREATE_TABLE + TABLE_NOTES + " ( " +
// TB_NOTES.ID + TYPE_INT + NOT_NULL + PRIMARY_KEY + COMMA_SPACE +
// TB_NOTES.NOTE + TYPE_DATE + NOT_NULL + COMMA_SPACE +
// TB_NOTES.DATE + TYPE_TEXT + NOT_NULL +
// ")";
//
// @Override
// public void onCreate(SQLiteDatabase db) {
// db.execSQL(CREATE_TABLE_NOTES);
// }
//
// @Override
// public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// db.execSQL(CREATE_TABLE);
// }
// }
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/models/Note.java
import android.content.ContentValues;
import com.tinmegali.tutsmvp_sample.data.DBSchema;
package com.tinmegali.tutsmvp_sample.models;
/**
* ---------------------------------------------------
* Created by Tin Megali on 18/03/16.
* Project: tuts+mvp_sample
* ---------------------------------------------------
* <a href="http://www.tinmegali.com">tinmegali.com</a>
* <a href="http://www.github.com/tinmegali>github</a>
* ---------------------------------------------------
*/
public class Note {
private int id = -1;
private String mText;
private String mDate;
public Note() {
}
public Note(int id, String mText, String mDate) {
this.id = id;
this.mText = mText;
this.mDate = mDate;
}
public Note(String mText, String mDate) {
this.mText = mText;
this.mDate = mDate;
}
public ContentValues getValues(){
ContentValues cv = new ContentValues();
|
if ( id!=-1) cv.put(DBSchema.TB_NOTES.ID, id);
|
JackyAndroid/Android-Architecture-Fairy
|
mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/main/activity/MVP_Main.java
|
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/main/activity/view/recycler/NotesViewHolder.java
// public class NotesViewHolder extends RecyclerView.ViewHolder {
//
// public RelativeLayout container;
// public TextView text, date;
// public ImageButton btnDelete;
//
// public NotesViewHolder(View itemView) {
// super(itemView);
//
// setupViews(itemView);
// }
//
// private void setupViews(View view) {
// container = (RelativeLayout) view.findViewById(R.id.holder_container);
// text = (TextView) view.findViewById(R.id.note_text);
// date = (TextView) view.findViewById(R.id.note_date);
// btnDelete = (ImageButton) view.findViewById(R.id.btn_delete);
// }
//
//
// }
//
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/models/Note.java
// public class Note {
//
// private int id = -1;
// private String mText;
// private String mDate;
//
// public Note() {
// }
//
// public Note(int id, String mText, String mDate) {
// this.id = id;
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public Note(String mText, String mDate) {
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public ContentValues getValues(){
// ContentValues cv = new ContentValues();
// if ( id!=-1) cv.put(DBSchema.TB_NOTES.ID, id);
// cv.put(DBSchema.TB_NOTES.NOTE, mText);
// cv.put(DBSchema.TB_NOTES.DATE, mDate);
// return cv;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public void setDate(String mDate) {
// this.mDate = mDate;
// }
//
// public void setText(String mText) {
// this.mText = mText;
// }
//
// public int getId() {
// return id;
// }
//
// public String getDate() {
// return mDate;
// }
//
// public String getText() {
// return mText;
// }
// }
|
import android.content.Context;
import android.support.v7.app.AlertDialog;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.Toast;
import com.tinmegali.tutsmvp_sample.main.activity.view.recycler.NotesViewHolder;
import com.tinmegali.tutsmvp_sample.models.Note;
import java.util.ArrayList;
|
package com.tinmegali.tutsmvp_sample.main.activity;
/**
* Holder interface that contains all interfaces
* responsible to maintain communication between
* Model View Presenter layers.
* Each layer implements its respective interface:
* View implements RequiredViewOps
* Presenter implements ProvidedPresenterOps, RequiredPresenterOps
* Model implements ProvidedModelOps
*
* ---------------------------------------------------
* Created by Tin Megali on 18/03/16.
* Project: tuts+mvp_sample
* ---------------------------------------------------
* <a href="http://www.tinmegali.com">tinmegali.com</a>
* <a href="http://www.github.com/tinmegali>github</a>
* ---------------------------------------------------
*/
public interface MVP_Main {
/**
* Required View methods available to Presenter.
* A passive layer, responsible to show data
* and receive user interactions
* Presenter to View
*/
interface RequiredViewOps {
Context getAppContext();
Context getActivityContext();
void showToast(Toast toast);
void showProgress();
void hideProgress();
void showAlert(AlertDialog dialog);
void notifyItemRemoved(int position);
void notifyDataSetChanged();
void notifyItemInserted(int layoutPosition);
void notifyItemRangeChanged(int positionStart, int itemCount);
void clearEditText();
}
/**
* Operations offered to View to communicate with Presenter.
* Process user interaction, sends data requests to Model, etc.
* View to Presenter
*/
interface ProvidedPresenterOps {
void onDestroy(boolean isChangingConfiguration);
void setView(RequiredViewOps view);
|
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/main/activity/view/recycler/NotesViewHolder.java
// public class NotesViewHolder extends RecyclerView.ViewHolder {
//
// public RelativeLayout container;
// public TextView text, date;
// public ImageButton btnDelete;
//
// public NotesViewHolder(View itemView) {
// super(itemView);
//
// setupViews(itemView);
// }
//
// private void setupViews(View view) {
// container = (RelativeLayout) view.findViewById(R.id.holder_container);
// text = (TextView) view.findViewById(R.id.note_text);
// date = (TextView) view.findViewById(R.id.note_date);
// btnDelete = (ImageButton) view.findViewById(R.id.btn_delete);
// }
//
//
// }
//
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/models/Note.java
// public class Note {
//
// private int id = -1;
// private String mText;
// private String mDate;
//
// public Note() {
// }
//
// public Note(int id, String mText, String mDate) {
// this.id = id;
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public Note(String mText, String mDate) {
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public ContentValues getValues(){
// ContentValues cv = new ContentValues();
// if ( id!=-1) cv.put(DBSchema.TB_NOTES.ID, id);
// cv.put(DBSchema.TB_NOTES.NOTE, mText);
// cv.put(DBSchema.TB_NOTES.DATE, mDate);
// return cv;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public void setDate(String mDate) {
// this.mDate = mDate;
// }
//
// public void setText(String mText) {
// this.mText = mText;
// }
//
// public int getId() {
// return id;
// }
//
// public String getDate() {
// return mDate;
// }
//
// public String getText() {
// return mText;
// }
// }
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/main/activity/MVP_Main.java
import android.content.Context;
import android.support.v7.app.AlertDialog;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.Toast;
import com.tinmegali.tutsmvp_sample.main.activity.view.recycler.NotesViewHolder;
import com.tinmegali.tutsmvp_sample.models.Note;
import java.util.ArrayList;
package com.tinmegali.tutsmvp_sample.main.activity;
/**
* Holder interface that contains all interfaces
* responsible to maintain communication between
* Model View Presenter layers.
* Each layer implements its respective interface:
* View implements RequiredViewOps
* Presenter implements ProvidedPresenterOps, RequiredPresenterOps
* Model implements ProvidedModelOps
*
* ---------------------------------------------------
* Created by Tin Megali on 18/03/16.
* Project: tuts+mvp_sample
* ---------------------------------------------------
* <a href="http://www.tinmegali.com">tinmegali.com</a>
* <a href="http://www.github.com/tinmegali>github</a>
* ---------------------------------------------------
*/
public interface MVP_Main {
/**
* Required View methods available to Presenter.
* A passive layer, responsible to show data
* and receive user interactions
* Presenter to View
*/
interface RequiredViewOps {
Context getAppContext();
Context getActivityContext();
void showToast(Toast toast);
void showProgress();
void hideProgress();
void showAlert(AlertDialog dialog);
void notifyItemRemoved(int position);
void notifyDataSetChanged();
void notifyItemInserted(int layoutPosition);
void notifyItemRangeChanged(int positionStart, int itemCount);
void clearEditText();
}
/**
* Operations offered to View to communicate with Presenter.
* Process user interaction, sends data requests to Model, etc.
* View to Presenter
*/
interface ProvidedPresenterOps {
void onDestroy(boolean isChangingConfiguration);
void setView(RequiredViewOps view);
|
NotesViewHolder createViewHolder(ViewGroup parent, int viewType);
|
JackyAndroid/Android-Architecture-Fairy
|
mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/main/activity/MVP_Main.java
|
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/main/activity/view/recycler/NotesViewHolder.java
// public class NotesViewHolder extends RecyclerView.ViewHolder {
//
// public RelativeLayout container;
// public TextView text, date;
// public ImageButton btnDelete;
//
// public NotesViewHolder(View itemView) {
// super(itemView);
//
// setupViews(itemView);
// }
//
// private void setupViews(View view) {
// container = (RelativeLayout) view.findViewById(R.id.holder_container);
// text = (TextView) view.findViewById(R.id.note_text);
// date = (TextView) view.findViewById(R.id.note_date);
// btnDelete = (ImageButton) view.findViewById(R.id.btn_delete);
// }
//
//
// }
//
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/models/Note.java
// public class Note {
//
// private int id = -1;
// private String mText;
// private String mDate;
//
// public Note() {
// }
//
// public Note(int id, String mText, String mDate) {
// this.id = id;
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public Note(String mText, String mDate) {
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public ContentValues getValues(){
// ContentValues cv = new ContentValues();
// if ( id!=-1) cv.put(DBSchema.TB_NOTES.ID, id);
// cv.put(DBSchema.TB_NOTES.NOTE, mText);
// cv.put(DBSchema.TB_NOTES.DATE, mDate);
// return cv;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public void setDate(String mDate) {
// this.mDate = mDate;
// }
//
// public void setText(String mText) {
// this.mText = mText;
// }
//
// public int getId() {
// return id;
// }
//
// public String getDate() {
// return mDate;
// }
//
// public String getText() {
// return mText;
// }
// }
|
import android.content.Context;
import android.support.v7.app.AlertDialog;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.Toast;
import com.tinmegali.tutsmvp_sample.main.activity.view.recycler.NotesViewHolder;
import com.tinmegali.tutsmvp_sample.models.Note;
import java.util.ArrayList;
|
package com.tinmegali.tutsmvp_sample.main.activity;
/**
* Holder interface that contains all interfaces
* responsible to maintain communication between
* Model View Presenter layers.
* Each layer implements its respective interface:
* View implements RequiredViewOps
* Presenter implements ProvidedPresenterOps, RequiredPresenterOps
* Model implements ProvidedModelOps
*
* ---------------------------------------------------
* Created by Tin Megali on 18/03/16.
* Project: tuts+mvp_sample
* ---------------------------------------------------
* <a href="http://www.tinmegali.com">tinmegali.com</a>
* <a href="http://www.github.com/tinmegali>github</a>
* ---------------------------------------------------
*/
public interface MVP_Main {
/**
* Required View methods available to Presenter.
* A passive layer, responsible to show data
* and receive user interactions
* Presenter to View
*/
interface RequiredViewOps {
Context getAppContext();
Context getActivityContext();
void showToast(Toast toast);
void showProgress();
void hideProgress();
void showAlert(AlertDialog dialog);
void notifyItemRemoved(int position);
void notifyDataSetChanged();
void notifyItemInserted(int layoutPosition);
void notifyItemRangeChanged(int positionStart, int itemCount);
void clearEditText();
}
/**
* Operations offered to View to communicate with Presenter.
* Process user interaction, sends data requests to Model, etc.
* View to Presenter
*/
interface ProvidedPresenterOps {
void onDestroy(boolean isChangingConfiguration);
void setView(RequiredViewOps view);
NotesViewHolder createViewHolder(ViewGroup parent, int viewType);
void bindViewHolder(NotesViewHolder holder, int position);
int getNotesCount();
void clickNewNote(EditText editText);
|
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/main/activity/view/recycler/NotesViewHolder.java
// public class NotesViewHolder extends RecyclerView.ViewHolder {
//
// public RelativeLayout container;
// public TextView text, date;
// public ImageButton btnDelete;
//
// public NotesViewHolder(View itemView) {
// super(itemView);
//
// setupViews(itemView);
// }
//
// private void setupViews(View view) {
// container = (RelativeLayout) view.findViewById(R.id.holder_container);
// text = (TextView) view.findViewById(R.id.note_text);
// date = (TextView) view.findViewById(R.id.note_date);
// btnDelete = (ImageButton) view.findViewById(R.id.btn_delete);
// }
//
//
// }
//
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/models/Note.java
// public class Note {
//
// private int id = -1;
// private String mText;
// private String mDate;
//
// public Note() {
// }
//
// public Note(int id, String mText, String mDate) {
// this.id = id;
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public Note(String mText, String mDate) {
// this.mText = mText;
// this.mDate = mDate;
// }
//
// public ContentValues getValues(){
// ContentValues cv = new ContentValues();
// if ( id!=-1) cv.put(DBSchema.TB_NOTES.ID, id);
// cv.put(DBSchema.TB_NOTES.NOTE, mText);
// cv.put(DBSchema.TB_NOTES.DATE, mDate);
// return cv;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public void setDate(String mDate) {
// this.mDate = mDate;
// }
//
// public void setText(String mText) {
// this.mText = mText;
// }
//
// public int getId() {
// return id;
// }
//
// public String getDate() {
// return mDate;
// }
//
// public String getText() {
// return mText;
// }
// }
// Path: mvp/app/src/main/java/com/tinmegali/tutsmvp_sample/main/activity/MVP_Main.java
import android.content.Context;
import android.support.v7.app.AlertDialog;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.Toast;
import com.tinmegali.tutsmvp_sample.main.activity.view.recycler.NotesViewHolder;
import com.tinmegali.tutsmvp_sample.models.Note;
import java.util.ArrayList;
package com.tinmegali.tutsmvp_sample.main.activity;
/**
* Holder interface that contains all interfaces
* responsible to maintain communication between
* Model View Presenter layers.
* Each layer implements its respective interface:
* View implements RequiredViewOps
* Presenter implements ProvidedPresenterOps, RequiredPresenterOps
* Model implements ProvidedModelOps
*
* ---------------------------------------------------
* Created by Tin Megali on 18/03/16.
* Project: tuts+mvp_sample
* ---------------------------------------------------
* <a href="http://www.tinmegali.com">tinmegali.com</a>
* <a href="http://www.github.com/tinmegali>github</a>
* ---------------------------------------------------
*/
public interface MVP_Main {
/**
* Required View methods available to Presenter.
* A passive layer, responsible to show data
* and receive user interactions
* Presenter to View
*/
interface RequiredViewOps {
Context getAppContext();
Context getActivityContext();
void showToast(Toast toast);
void showProgress();
void hideProgress();
void showAlert(AlertDialog dialog);
void notifyItemRemoved(int position);
void notifyDataSetChanged();
void notifyItemInserted(int layoutPosition);
void notifyItemRangeChanged(int positionStart, int itemCount);
void clearEditText();
}
/**
* Operations offered to View to communicate with Presenter.
* Process user interaction, sends data requests to Model, etc.
* View to Presenter
*/
interface ProvidedPresenterOps {
void onDestroy(boolean isChangingConfiguration);
void setView(RequiredViewOps view);
NotesViewHolder createViewHolder(ViewGroup parent, int viewType);
void bindViewHolder(NotesViewHolder holder, int position);
int getNotesCount();
void clickNewNote(EditText editText);
|
void clickDeleteNote(Note note, int adapterPos, int layoutPos);
|
ACEMerlin/Kratos
|
kratos-compiler/src/main/java/kratos/compiler/BindingClass.java
|
// Path: kratos-compiler/src/main/java/kratos/compiler/binding/KBindingGeneric.java
// public interface KBindingGeneric {
// public void addGenericCode(MethodSpec.Builder result, String key);
//
// public String getMethodName();
//
// public String[] getParameterTypes();
// }
|
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeSpec;
import com.squareup.javapoet.TypeVariableName;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.lang.model.element.Modifier;
import kratos.compiler.binding.KBindingGeneric;
import static javax.lang.model.element.Modifier.FINAL;
import static javax.lang.model.element.Modifier.PUBLIC;
|
result.addMethod(createBindMethod());
return JavaFile.builder(classPackage, result.build())
.addFileComment("Generated code from Kratos. Do not modify!")
.build();
}
private MethodSpec createBindMethod() {
MethodSpec.Builder result = MethodSpec.methodBuilder("bind")
.addAnnotation(Override.class)
.addModifiers(PUBLIC)
.addParameter(TypeVariableName.get("T"), "target", FINAL)
.addParameter(KFINDER, "finder", FINAL);
if (parentViewBinder != null) {
result.addStatement("super.bind(target, finder)");
}
if (layoutId != null) {
if (!isLibrary)
result.addStatement("target.setLayoutId($L)", Integer.parseInt(layoutId));
else
result.addStatement("target.setLayoutId($T.layout.$L)", resClass, layoutId);
result.addStatement("target.init()");
}
//if (!updateKStringBindingMap.isEmpty()) {
// for (Map.Entry<String, UpdateKStringBinding> entry : updateKStringBindingMap.entrySet()) {
// addKStringUpdateBindings(result, entry);
// }
//}
if (!map.isEmpty()) {
|
// Path: kratos-compiler/src/main/java/kratos/compiler/binding/KBindingGeneric.java
// public interface KBindingGeneric {
// public void addGenericCode(MethodSpec.Builder result, String key);
//
// public String getMethodName();
//
// public String[] getParameterTypes();
// }
// Path: kratos-compiler/src/main/java/kratos/compiler/BindingClass.java
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeSpec;
import com.squareup.javapoet.TypeVariableName;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.lang.model.element.Modifier;
import kratos.compiler.binding.KBindingGeneric;
import static javax.lang.model.element.Modifier.FINAL;
import static javax.lang.model.element.Modifier.PUBLIC;
result.addMethod(createBindMethod());
return JavaFile.builder(classPackage, result.build())
.addFileComment("Generated code from Kratos. Do not modify!")
.build();
}
private MethodSpec createBindMethod() {
MethodSpec.Builder result = MethodSpec.methodBuilder("bind")
.addAnnotation(Override.class)
.addModifiers(PUBLIC)
.addParameter(TypeVariableName.get("T"), "target", FINAL)
.addParameter(KFINDER, "finder", FINAL);
if (parentViewBinder != null) {
result.addStatement("super.bind(target, finder)");
}
if (layoutId != null) {
if (!isLibrary)
result.addStatement("target.setLayoutId($L)", Integer.parseInt(layoutId));
else
result.addStatement("target.setLayoutId($T.layout.$L)", resClass, layoutId);
result.addStatement("target.init()");
}
//if (!updateKStringBindingMap.isEmpty()) {
// for (Map.Entry<String, UpdateKStringBinding> entry : updateKStringBindingMap.entrySet()) {
// addKStringUpdateBindings(result, entry);
// }
//}
if (!map.isEmpty()) {
|
for (Map<String, KBindingGeneric> generics : map.values()) {
|
ACEMerlin/Kratos
|
kratos-sample/src/main/java/me/ele/kratos_sample/TextCard.java
|
// Path: kratos-sample/src/main/java/me/ele/kratos_sample/entity/KText.java
// public class KText extends KData {
// public KString text1;
// public KString text2;
// }
|
import android.content.Context;
import android.util.Log;
import android.widget.TextView;
import org.jetbrains.annotations.NotNull;
import kratos.Bind;
import kratos.BindLayout;
import kratos.Binds;
import kratos.OnKStringChanged;
import kratos.card.KCard;
import me.ele.kratos_sample.entity.KText;
|
package me.ele.kratos_sample;
/**
* Created by merlin on 15/12/17.
*/
@BindLayout(R.layout.kcard_text) //@LBindLayout("kcard_text")
@Binds({@Bind(id = R.id.kcard_text_text1, data = "text1"),
@Bind(id = R.id.kcard_text_text2, data = "text2")})
|
// Path: kratos-sample/src/main/java/me/ele/kratos_sample/entity/KText.java
// public class KText extends KData {
// public KString text1;
// public KString text2;
// }
// Path: kratos-sample/src/main/java/me/ele/kratos_sample/TextCard.java
import android.content.Context;
import android.util.Log;
import android.widget.TextView;
import org.jetbrains.annotations.NotNull;
import kratos.Bind;
import kratos.BindLayout;
import kratos.Binds;
import kratos.OnKStringChanged;
import kratos.card.KCard;
import me.ele.kratos_sample.entity.KText;
package me.ele.kratos_sample;
/**
* Created by merlin on 15/12/17.
*/
@BindLayout(R.layout.kcard_text) //@LBindLayout("kcard_text")
@Binds({@Bind(id = R.id.kcard_text_text1, data = "text1"),
@Bind(id = R.id.kcard_text_text2, data = "text2")})
|
public class TextCard extends KCard<KText> {
|
ACEMerlin/Kratos
|
kratos-compiler/src/main/java/kratos/compiler/KratosProcessor.java
|
// Path: kratos-compiler/src/main/java/kratos/compiler/binding/KBooleanBinding.java
// public class KBooleanBinding implements KBindingGeneric {
//
// private String methodName;
// private String[] parameterTypes;
// private static final ClassName ONUPDATELISTENER_KBOOLEAN = ClassName.get("kratos.internal.KBoolean", "OnUpdateListener");
// private static final ClassName VIEW = ClassName.get("android.view", "View");
//
// public KBooleanBinding(String methodName, String[] parameterTypes) {
// this.methodName = methodName;
// this.parameterTypes = parameterTypes;
// }
//
// @Override
// public String getMethodName() {
// return methodName;
// }
//
// @Override
// public String[] getParameterTypes() {
// return parameterTypes;
// }
//
// @Override
// public void addGenericCode(MethodSpec.Builder result, String key) {
// TypeSpec update = TypeSpec.anonymousClassBuilder("")
// .addSuperinterface(ONUPDATELISTENER_KBOOLEAN)
// .addMethod(MethodSpec.methodBuilder("update")
// .addAnnotation(Override.class)
// .addModifiers(Modifier.PUBLIC)
// .addParameter(VIEW, "v")
// .addParameter(boolean.class, "s")
// .returns(void.class)
// .addStatement("target.$L(($L)$N, $N)", getMethodName(), getParameterTypes()[0], "v", "s")
// .build())
// .build();
// result.addStatement("target.getData().$L.setOnUpdateListener($L)", key, update);
// }
// }
//
// Path: kratos-compiler/src/main/java/kratos/compiler/binding/KStringBinding.java
// public class KStringBinding implements KBindingGeneric {
//
// private String methodName;
// private String[] parameterTypes;
// private static final ClassName ONUPDATELISTENER_KSTRING = ClassName.get("kratos.internal.KString", "OnUpdateListener");
// private static final ClassName VIEW = ClassName.get("android.view", "View");
//
// public KStringBinding(String methodName, String[] parameterTypes) {
// this.methodName = methodName;
// this.parameterTypes = parameterTypes;
// }
//
// @Override
// public void addGenericCode(MethodSpec.Builder result, String key) {
// TypeSpec update = TypeSpec.anonymousClassBuilder("")
// .addSuperinterface(ONUPDATELISTENER_KSTRING)
// .addMethod(MethodSpec.methodBuilder("update")
// .addAnnotation(Override.class)
// .addModifiers(Modifier.PUBLIC)
// .addParameter(VIEW, "v")
// .addParameter(String.class, "s")
// .returns(void.class)
// .addStatement("target.$L(($L)$N, $N)", getMethodName(), getParameterTypes()[0], "v", "s")
// .build())
// .build();
// result.addStatement("target.getData().$L.setOnUpdateListener($L)", key, update);
//
// }
//
// @Override
// public String getMethodName() {
// return methodName;
// }
//
// @Override
// public String[] getParameterTypes() {
// return parameterTypes;
// }
//
// }
|
import com.google.auto.common.SuperficialValidation;
import com.google.auto.service.AutoService;
import com.squareup.javapoet.TypeName;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.annotation.Annotation;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.Filer;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.Processor;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.type.TypeVariable;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import kratos.Bind;
import kratos.BindLayout;
import kratos.BindText;
import kratos.Binds;
import kratos.LBindLayout;
import kratos.LBindText;
import kratos.OnKBooleanChanged;
import kratos.OnKStringChanged;
import kratos.PackageName;
import kratos.compiler.binding.KBooleanBinding;
import kratos.compiler.binding.KStringBinding;
import static javax.lang.model.SourceVersion.latestSupported;
import static javax.tools.Diagnostic.Kind.ERROR;
|
return targetClassMap;
}
private void parseOnChangedTarget(RoundEnvironment env, Map<TypeElement, BindingClass> targetClassMap, Set<String> erasedTargetNames, Class... annotationClasses) {
for (Class clazz : annotationClasses) {
for (Element element : env.getElementsAnnotatedWith(clazz)) {
if (!SuperficialValidation.validateElement(element)) continue;
try {
parseOnChanged(element, targetClassMap, erasedTargetNames, clazz);
} catch (Exception e) {
logParsingError(element, clazz, e);
}
}
}
}
private void parseOnChanged(Element element, Map<TypeElement, BindingClass> targetClassMap,
Set<String> erasedTargetNames, Class annotationClass) {
TypeElement enclosingElement = (TypeElement) element.getEnclosingElement();
BindingClass bindingClass = getOrCreateTargetClass(targetClassMap, enclosingElement, false, false);
TypeMirror mirror = element.asType();
if (!(mirror.getKind() == TypeKind.EXECUTABLE))
return;
String method = element.toString().trim();
String methodName = method.substring(0, method.indexOf("("));
Matcher m = Pattern.compile("\\(([^)]+)\\)").matcher(method);
if (m.find()) {
String[] methodTypes = m.group(1).split(",");
String key = null;
if (annotationClass.equals(OnKStringChanged.class)) {
|
// Path: kratos-compiler/src/main/java/kratos/compiler/binding/KBooleanBinding.java
// public class KBooleanBinding implements KBindingGeneric {
//
// private String methodName;
// private String[] parameterTypes;
// private static final ClassName ONUPDATELISTENER_KBOOLEAN = ClassName.get("kratos.internal.KBoolean", "OnUpdateListener");
// private static final ClassName VIEW = ClassName.get("android.view", "View");
//
// public KBooleanBinding(String methodName, String[] parameterTypes) {
// this.methodName = methodName;
// this.parameterTypes = parameterTypes;
// }
//
// @Override
// public String getMethodName() {
// return methodName;
// }
//
// @Override
// public String[] getParameterTypes() {
// return parameterTypes;
// }
//
// @Override
// public void addGenericCode(MethodSpec.Builder result, String key) {
// TypeSpec update = TypeSpec.anonymousClassBuilder("")
// .addSuperinterface(ONUPDATELISTENER_KBOOLEAN)
// .addMethod(MethodSpec.methodBuilder("update")
// .addAnnotation(Override.class)
// .addModifiers(Modifier.PUBLIC)
// .addParameter(VIEW, "v")
// .addParameter(boolean.class, "s")
// .returns(void.class)
// .addStatement("target.$L(($L)$N, $N)", getMethodName(), getParameterTypes()[0], "v", "s")
// .build())
// .build();
// result.addStatement("target.getData().$L.setOnUpdateListener($L)", key, update);
// }
// }
//
// Path: kratos-compiler/src/main/java/kratos/compiler/binding/KStringBinding.java
// public class KStringBinding implements KBindingGeneric {
//
// private String methodName;
// private String[] parameterTypes;
// private static final ClassName ONUPDATELISTENER_KSTRING = ClassName.get("kratos.internal.KString", "OnUpdateListener");
// private static final ClassName VIEW = ClassName.get("android.view", "View");
//
// public KStringBinding(String methodName, String[] parameterTypes) {
// this.methodName = methodName;
// this.parameterTypes = parameterTypes;
// }
//
// @Override
// public void addGenericCode(MethodSpec.Builder result, String key) {
// TypeSpec update = TypeSpec.anonymousClassBuilder("")
// .addSuperinterface(ONUPDATELISTENER_KSTRING)
// .addMethod(MethodSpec.methodBuilder("update")
// .addAnnotation(Override.class)
// .addModifiers(Modifier.PUBLIC)
// .addParameter(VIEW, "v")
// .addParameter(String.class, "s")
// .returns(void.class)
// .addStatement("target.$L(($L)$N, $N)", getMethodName(), getParameterTypes()[0], "v", "s")
// .build())
// .build();
// result.addStatement("target.getData().$L.setOnUpdateListener($L)", key, update);
//
// }
//
// @Override
// public String getMethodName() {
// return methodName;
// }
//
// @Override
// public String[] getParameterTypes() {
// return parameterTypes;
// }
//
// }
// Path: kratos-compiler/src/main/java/kratos/compiler/KratosProcessor.java
import com.google.auto.common.SuperficialValidation;
import com.google.auto.service.AutoService;
import com.squareup.javapoet.TypeName;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.annotation.Annotation;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.Filer;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.Processor;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.type.TypeVariable;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import kratos.Bind;
import kratos.BindLayout;
import kratos.BindText;
import kratos.Binds;
import kratos.LBindLayout;
import kratos.LBindText;
import kratos.OnKBooleanChanged;
import kratos.OnKStringChanged;
import kratos.PackageName;
import kratos.compiler.binding.KBooleanBinding;
import kratos.compiler.binding.KStringBinding;
import static javax.lang.model.SourceVersion.latestSupported;
import static javax.tools.Diagnostic.Kind.ERROR;
return targetClassMap;
}
private void parseOnChangedTarget(RoundEnvironment env, Map<TypeElement, BindingClass> targetClassMap, Set<String> erasedTargetNames, Class... annotationClasses) {
for (Class clazz : annotationClasses) {
for (Element element : env.getElementsAnnotatedWith(clazz)) {
if (!SuperficialValidation.validateElement(element)) continue;
try {
parseOnChanged(element, targetClassMap, erasedTargetNames, clazz);
} catch (Exception e) {
logParsingError(element, clazz, e);
}
}
}
}
private void parseOnChanged(Element element, Map<TypeElement, BindingClass> targetClassMap,
Set<String> erasedTargetNames, Class annotationClass) {
TypeElement enclosingElement = (TypeElement) element.getEnclosingElement();
BindingClass bindingClass = getOrCreateTargetClass(targetClassMap, enclosingElement, false, false);
TypeMirror mirror = element.asType();
if (!(mirror.getKind() == TypeKind.EXECUTABLE))
return;
String method = element.toString().trim();
String methodName = method.substring(0, method.indexOf("("));
Matcher m = Pattern.compile("\\(([^)]+)\\)").matcher(method);
if (m.find()) {
String[] methodTypes = m.group(1).split(",");
String key = null;
if (annotationClass.equals(OnKStringChanged.class)) {
|
KStringBinding binding = new KStringBinding(methodName, methodTypes);
|
ACEMerlin/Kratos
|
kratos-sample/src/main/java/me/ele/kratos_sample/CardSampleActivity.java
|
// Path: kratos/src/main/java/kratos/card/event/KOnClickEvent.java
// public class KOnClickEvent<T extends KData> {
//
// public T data;
// public String id;
// public String url;
// public int position;
//
// public KOnClickEvent(String id, T data, String url) {
// this.id = id;
// this.data = data;
// this.url = url;
// }
//
// public KOnClickEvent(String id, T data, String url, int position) {
// this.id = id;
// this.data = data;
// this.url = url;
// this.position = position;
// }
//
// }
//
// Path: kratos-sample/src/main/java/me/ele/kratos_sample/entity/Customer.java
// public class Customer implements Parcelable {
//
// public KString name = new KString();
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeParcelable(this.name, flags);
// }
//
// public Customer() {
// }
//
// protected Customer(Parcel in) {
// this.name = in.readParcelable(KString.class.getClassLoader());
// }
//
// public static final Creator<Customer> CREATOR = new Creator<Customer>() {
// public Customer createFromParcel(Parcel source) {
// return new Customer(source);
// }
//
// public Customer[] newArray(int size) {
// return new Customer[size];
// }
// };
// }
|
import android.widget.Toast;
import org.jetbrains.annotations.NotNull;
import kratos.card.KCardActivity;
import kratos.card.entity.KData;
import kratos.card.event.KOnClickEvent;
import me.ele.kratos_sample.entity.Customer;
|
package me.ele.kratos_sample;
/**
* Created by merlin on 15/12/14.
*/
public class CardSampleActivity extends KCardActivity {
Customer customer = new Customer();
private void showToast(String text) {
Toast.makeText(CardSampleActivity.this, text, Toast.LENGTH_SHORT).show();
}
@Override
|
// Path: kratos/src/main/java/kratos/card/event/KOnClickEvent.java
// public class KOnClickEvent<T extends KData> {
//
// public T data;
// public String id;
// public String url;
// public int position;
//
// public KOnClickEvent(String id, T data, String url) {
// this.id = id;
// this.data = data;
// this.url = url;
// }
//
// public KOnClickEvent(String id, T data, String url, int position) {
// this.id = id;
// this.data = data;
// this.url = url;
// this.position = position;
// }
//
// }
//
// Path: kratos-sample/src/main/java/me/ele/kratos_sample/entity/Customer.java
// public class Customer implements Parcelable {
//
// public KString name = new KString();
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeParcelable(this.name, flags);
// }
//
// public Customer() {
// }
//
// protected Customer(Parcel in) {
// this.name = in.readParcelable(KString.class.getClassLoader());
// }
//
// public static final Creator<Customer> CREATOR = new Creator<Customer>() {
// public Customer createFromParcel(Parcel source) {
// return new Customer(source);
// }
//
// public Customer[] newArray(int size) {
// return new Customer[size];
// }
// };
// }
// Path: kratos-sample/src/main/java/me/ele/kratos_sample/CardSampleActivity.java
import android.widget.Toast;
import org.jetbrains.annotations.NotNull;
import kratos.card.KCardActivity;
import kratos.card.entity.KData;
import kratos.card.event.KOnClickEvent;
import me.ele.kratos_sample.entity.Customer;
package me.ele.kratos_sample;
/**
* Created by merlin on 15/12/14.
*/
public class CardSampleActivity extends KCardActivity {
Customer customer = new Customer();
private void showToast(String text) {
Toast.makeText(CardSampleActivity.this, text, Toast.LENGTH_SHORT).show();
}
@Override
|
public void onEventMainThread(@NotNull KOnClickEvent<KData> event) {
|
ACEMerlin/Kratos
|
kratos/src/main/java/kratos/Kratos.java
|
// Path: kratos/src/main/java/kratos/internal/KBinder.java
// public interface KBinder<T> {
// void bind(T target, KFinder finder);
// }
//
// Path: kratos/src/main/java/kratos/internal/KFinder.java
// public enum KFinder {
// ACTIVITY {
// @Override
// protected View findView(Object source, int id) {
// return ((Activity) source).findViewById(id);
// }
//
// @Override
// public Context getContext(Object source) {
// return (Activity) source;
// }
// },
// KCARD {
// @Override
// protected View findView(Object source, int id) {
// KCard card = (KCard) source;
// return (card.getRootView()).findViewById(id);
// }
//
// @Override
// public Context getContext(Object source) {
// return ((KCard) source).getContext();
// }
// };
//
// @SuppressWarnings("unchecked") // That's the point.
// public <T> T castView(View view) {
// try {
// return (T) view;
// } catch (ClassCastException e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public <T> T findRequiredView(Object source, int id) {
// T view = findOptionalView(source, id);
// if (view == null) {
// throw new IllegalStateException("Required view"
// + "with ID "
// + id);
// }
// return view;
// }
//
// public <T> T findOptionalView(Object source, int id) {
// View view = findView(source, id);
// return castView(view);
// }
//
// protected abstract View findView(Object source, int id);
//
// public abstract Context getContext(Object source);
// }
|
import android.app.Activity;
import android.support.annotation.NonNull;
import android.util.Log;
import java.util.LinkedHashMap;
import java.util.Map;
import kratos.card.KCard;
import kratos.internal.KBinder;
import kratos.internal.KFinder;
|
package kratos;
/**
* Created by merlin on 15/12/7.
*/
public final class Kratos {
private Kratos() {
}
private static final String TAG = "Kratos";
|
// Path: kratos/src/main/java/kratos/internal/KBinder.java
// public interface KBinder<T> {
// void bind(T target, KFinder finder);
// }
//
// Path: kratos/src/main/java/kratos/internal/KFinder.java
// public enum KFinder {
// ACTIVITY {
// @Override
// protected View findView(Object source, int id) {
// return ((Activity) source).findViewById(id);
// }
//
// @Override
// public Context getContext(Object source) {
// return (Activity) source;
// }
// },
// KCARD {
// @Override
// protected View findView(Object source, int id) {
// KCard card = (KCard) source;
// return (card.getRootView()).findViewById(id);
// }
//
// @Override
// public Context getContext(Object source) {
// return ((KCard) source).getContext();
// }
// };
//
// @SuppressWarnings("unchecked") // That's the point.
// public <T> T castView(View view) {
// try {
// return (T) view;
// } catch (ClassCastException e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public <T> T findRequiredView(Object source, int id) {
// T view = findOptionalView(source, id);
// if (view == null) {
// throw new IllegalStateException("Required view"
// + "with ID "
// + id);
// }
// return view;
// }
//
// public <T> T findOptionalView(Object source, int id) {
// View view = findView(source, id);
// return castView(view);
// }
//
// protected abstract View findView(Object source, int id);
//
// public abstract Context getContext(Object source);
// }
// Path: kratos/src/main/java/kratos/Kratos.java
import android.app.Activity;
import android.support.annotation.NonNull;
import android.util.Log;
import java.util.LinkedHashMap;
import java.util.Map;
import kratos.card.KCard;
import kratos.internal.KBinder;
import kratos.internal.KFinder;
package kratos;
/**
* Created by merlin on 15/12/7.
*/
public final class Kratos {
private Kratos() {
}
private static final String TAG = "Kratos";
|
static final Map<Class<?>, KBinder<Object>> BINDERS = new LinkedHashMap<>();
|
ACEMerlin/Kratos
|
kratos/src/main/java/kratos/Kratos.java
|
// Path: kratos/src/main/java/kratos/internal/KBinder.java
// public interface KBinder<T> {
// void bind(T target, KFinder finder);
// }
//
// Path: kratos/src/main/java/kratos/internal/KFinder.java
// public enum KFinder {
// ACTIVITY {
// @Override
// protected View findView(Object source, int id) {
// return ((Activity) source).findViewById(id);
// }
//
// @Override
// public Context getContext(Object source) {
// return (Activity) source;
// }
// },
// KCARD {
// @Override
// protected View findView(Object source, int id) {
// KCard card = (KCard) source;
// return (card.getRootView()).findViewById(id);
// }
//
// @Override
// public Context getContext(Object source) {
// return ((KCard) source).getContext();
// }
// };
//
// @SuppressWarnings("unchecked") // That's the point.
// public <T> T castView(View view) {
// try {
// return (T) view;
// } catch (ClassCastException e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public <T> T findRequiredView(Object source, int id) {
// T view = findOptionalView(source, id);
// if (view == null) {
// throw new IllegalStateException("Required view"
// + "with ID "
// + id);
// }
// return view;
// }
//
// public <T> T findOptionalView(Object source, int id) {
// View view = findView(source, id);
// return castView(view);
// }
//
// protected abstract View findView(Object source, int id);
//
// public abstract Context getContext(Object source);
// }
|
import android.app.Activity;
import android.support.annotation.NonNull;
import android.util.Log;
import java.util.LinkedHashMap;
import java.util.Map;
import kratos.card.KCard;
import kratos.internal.KBinder;
import kratos.internal.KFinder;
|
package kratos;
/**
* Created by merlin on 15/12/7.
*/
public final class Kratos {
private Kratos() {
}
private static final String TAG = "Kratos";
static final Map<Class<?>, KBinder<Object>> BINDERS = new LinkedHashMap<>();
static final KBinder<Object> NOP_VIEW_BINDER = new KBinder<Object>() {
@Override
|
// Path: kratos/src/main/java/kratos/internal/KBinder.java
// public interface KBinder<T> {
// void bind(T target, KFinder finder);
// }
//
// Path: kratos/src/main/java/kratos/internal/KFinder.java
// public enum KFinder {
// ACTIVITY {
// @Override
// protected View findView(Object source, int id) {
// return ((Activity) source).findViewById(id);
// }
//
// @Override
// public Context getContext(Object source) {
// return (Activity) source;
// }
// },
// KCARD {
// @Override
// protected View findView(Object source, int id) {
// KCard card = (KCard) source;
// return (card.getRootView()).findViewById(id);
// }
//
// @Override
// public Context getContext(Object source) {
// return ((KCard) source).getContext();
// }
// };
//
// @SuppressWarnings("unchecked") // That's the point.
// public <T> T castView(View view) {
// try {
// return (T) view;
// } catch (ClassCastException e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public <T> T findRequiredView(Object source, int id) {
// T view = findOptionalView(source, id);
// if (view == null) {
// throw new IllegalStateException("Required view"
// + "with ID "
// + id);
// }
// return view;
// }
//
// public <T> T findOptionalView(Object source, int id) {
// View view = findView(source, id);
// return castView(view);
// }
//
// protected abstract View findView(Object source, int id);
//
// public abstract Context getContext(Object source);
// }
// Path: kratos/src/main/java/kratos/Kratos.java
import android.app.Activity;
import android.support.annotation.NonNull;
import android.util.Log;
import java.util.LinkedHashMap;
import java.util.Map;
import kratos.card.KCard;
import kratos.internal.KBinder;
import kratos.internal.KFinder;
package kratos;
/**
* Created by merlin on 15/12/7.
*/
public final class Kratos {
private Kratos() {
}
private static final String TAG = "Kratos";
static final Map<Class<?>, KBinder<Object>> BINDERS = new LinkedHashMap<>();
static final KBinder<Object> NOP_VIEW_BINDER = new KBinder<Object>() {
@Override
|
public void bind(Object target, KFinder finder) {
|
ACEMerlin/Kratos
|
kratos/src/main/java/kratos/card/utils/GsonUtils.java
|
// Path: kratos/src/main/java/kratos/internal/KStringDeserializer.java
// public class KStringDeserializer implements JsonDeserializer<KString> {
//
// private Class<?> mTargetClass;
//
// @Override
// public KString deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
// KString field = new KString();
// field.setInitData(json.getAsString());
// return field;
// }
// }
|
import android.content.Context;
import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import kratos.internal.KString;
import kratos.internal.KStringDeserializer;
|
}
public static Gson getGson(Context context, Class clazz) {
GsonBuilder gsonBuilder = new GsonBuilder().addSerializationExclusionStrategy(new ExclusionStrategy() {
@Override
public boolean shouldSkipField(FieldAttributes fieldAttributes) {
return fieldAttributes.getName().endsWith("$delegate")
|| fieldAttributes.getAnnotation(Skip.class) != null;
}
@Override
public boolean shouldSkipClass(Class<?> aClass) {
return false;
}
}).addDeserializationExclusionStrategy(new ExclusionStrategy() {
@Override
public boolean shouldSkipField(FieldAttributes fieldAttributes) {
return fieldAttributes.getName().endsWith("$delegate")
|| fieldAttributes.getAnnotation(Skip.class) != null;
}
@Override
public boolean shouldSkipClass(Class<?> aClass) {
return false;
}
});
if (clazz != null && context != null) {
gsonBuilder.registerTypeAdapter(clazz, new GsonUtilsCreator(context));
}
|
// Path: kratos/src/main/java/kratos/internal/KStringDeserializer.java
// public class KStringDeserializer implements JsonDeserializer<KString> {
//
// private Class<?> mTargetClass;
//
// @Override
// public KString deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
// KString field = new KString();
// field.setInitData(json.getAsString());
// return field;
// }
// }
// Path: kratos/src/main/java/kratos/card/utils/GsonUtils.java
import android.content.Context;
import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import kratos.internal.KString;
import kratos.internal.KStringDeserializer;
}
public static Gson getGson(Context context, Class clazz) {
GsonBuilder gsonBuilder = new GsonBuilder().addSerializationExclusionStrategy(new ExclusionStrategy() {
@Override
public boolean shouldSkipField(FieldAttributes fieldAttributes) {
return fieldAttributes.getName().endsWith("$delegate")
|| fieldAttributes.getAnnotation(Skip.class) != null;
}
@Override
public boolean shouldSkipClass(Class<?> aClass) {
return false;
}
}).addDeserializationExclusionStrategy(new ExclusionStrategy() {
@Override
public boolean shouldSkipField(FieldAttributes fieldAttributes) {
return fieldAttributes.getName().endsWith("$delegate")
|| fieldAttributes.getAnnotation(Skip.class) != null;
}
@Override
public boolean shouldSkipClass(Class<?> aClass) {
return false;
}
});
if (clazz != null && context != null) {
gsonBuilder.registerTypeAdapter(clazz, new GsonUtilsCreator(context));
}
|
gsonBuilder.registerTypeAdapter(KString.class, new KStringDeserializer());
|
ACEMerlin/Kratos
|
kratos-compiler/src/main/java/kratos/compiler/FieldViewBinding.java
|
// Path: kratos-compiler/src/main/java/kratos/compiler/KratosProcessor.java
// static final String VIEW_TYPE = "android.view.View";
|
import com.squareup.javapoet.TypeName;
import static kratos.compiler.KratosProcessor.VIEW_TYPE;
|
package kratos.compiler;
/**
* Created by merlin on 15/12/7.
*/
public final class FieldViewBinding implements KBinding {
private final String name;
private final TypeName type;
private final boolean required;
FieldViewBinding(String name, TypeName type, boolean required) {
this.name = name;
this.type = type;
this.required = required;
}
public String getName() {
return name;
}
public TypeName getType() {
return type;
}
public boolean isRequired() {
return required;
}
public boolean requiresCast() {
|
// Path: kratos-compiler/src/main/java/kratos/compiler/KratosProcessor.java
// static final String VIEW_TYPE = "android.view.View";
// Path: kratos-compiler/src/main/java/kratos/compiler/FieldViewBinding.java
import com.squareup.javapoet.TypeName;
import static kratos.compiler.KratosProcessor.VIEW_TYPE;
package kratos.compiler;
/**
* Created by merlin on 15/12/7.
*/
public final class FieldViewBinding implements KBinding {
private final String name;
private final TypeName type;
private final boolean required;
FieldViewBinding(String name, TypeName type, boolean required) {
this.name = name;
this.type = type;
this.required = required;
}
public String getName() {
return name;
}
public TypeName getType() {
return type;
}
public boolean isRequired() {
return required;
}
public boolean requiresCast() {
|
return !VIEW_TYPE.equals(type.toString());
|
gillius/jalleg
|
jalleg-binding/src/main/java/org/gillius/jalleg/binding/ALLEGRO_JOYSTICK_EVENT.java
|
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static class ALLEGRO_JOYSTICK extends PointerType {
// public ALLEGRO_JOYSTICK(Pointer address) {
// super(address);
// }
// public ALLEGRO_JOYSTICK() {
// super();
// }
// }
|
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.ptr.PointerByReference;
import org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_JOYSTICK;
import java.util.Arrays;
import java.util.List;
|
/*
* Copyright 2016 Jason Winnebeck
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gillius.jalleg.binding;
/**
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br>
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br>
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>.
*/
public class ALLEGRO_JOYSTICK_EVENT extends Structure {
public int type;
public PointerByReference source;
public double timestamp;
|
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static class ALLEGRO_JOYSTICK extends PointerType {
// public ALLEGRO_JOYSTICK(Pointer address) {
// super(address);
// }
// public ALLEGRO_JOYSTICK() {
// super();
// }
// }
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/ALLEGRO_JOYSTICK_EVENT.java
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.ptr.PointerByReference;
import org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_JOYSTICK;
import java.util.Arrays;
import java.util.List;
/*
* Copyright 2016 Jason Winnebeck
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gillius.jalleg.binding;
/**
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br>
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br>
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>.
*/
public class ALLEGRO_JOYSTICK_EVENT extends Structure {
public int type;
public PointerByReference source;
public double timestamp;
|
public ALLEGRO_JOYSTICK id;
|
gillius/jalleg
|
jalleg-framework/src/main/java/org/gillius/jalleg/framework/audio/LoopingSingleInstanceSample.java
|
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/ALLEGRO_SAMPLE_ID.java
// public class ALLEGRO_SAMPLE_ID extends Structure {
// public int _index;
// public int _id;
// public ALLEGRO_SAMPLE_ID() {
// super();
// setAutoSynch(false);
// }
// protected List<? > getFieldOrder() {
// return Arrays.asList("_index", "_id");
// }
// public ALLEGRO_SAMPLE_ID(int _index, int _id) {
// super();
// this._index = _index;
// this._id = _id;
// }
// public ALLEGRO_SAMPLE_ID(Pointer peer) {
// super(peer);
// }
// public static class ByReference extends ALLEGRO_SAMPLE_ID implements Structure.ByReference {
//
// };
// public static class ByValue extends ALLEGRO_SAMPLE_ID implements Structure.ByValue {
//
// };
// }
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static final float ALLEGRO_AUDIO_PAN_NONE = (float)(-1000.0f);
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static native boolean al_play_sample(ALLEGRO_SAMPLE data, float gain, float pan, float speed, int loop, ALLEGRO_SAMPLE_ID ret_id);
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static native void al_stop_sample(ALLEGRO_SAMPLE_ID spl_id);
|
import org.gillius.jalleg.binding.ALLEGRO_SAMPLE_ID;
import java.io.Closeable;
import java.io.IOException;
import static org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_AUDIO_PAN_NONE;
import static org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_PLAYMODE.ALLEGRO_PLAYMODE_LOOP;
import static org.gillius.jalleg.binding.AllegroLibrary.al_play_sample;
import static org.gillius.jalleg.binding.AllegroLibrary.al_stop_sample;
|
package org.gillius.jalleg.framework.audio;
/**
* Plays looping sample data with al_play_sample until a specified time.
*/
public class LoopingSingleInstanceSample implements AutoCloseable {
private final SampleData sampleData;
|
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/ALLEGRO_SAMPLE_ID.java
// public class ALLEGRO_SAMPLE_ID extends Structure {
// public int _index;
// public int _id;
// public ALLEGRO_SAMPLE_ID() {
// super();
// setAutoSynch(false);
// }
// protected List<? > getFieldOrder() {
// return Arrays.asList("_index", "_id");
// }
// public ALLEGRO_SAMPLE_ID(int _index, int _id) {
// super();
// this._index = _index;
// this._id = _id;
// }
// public ALLEGRO_SAMPLE_ID(Pointer peer) {
// super(peer);
// }
// public static class ByReference extends ALLEGRO_SAMPLE_ID implements Structure.ByReference {
//
// };
// public static class ByValue extends ALLEGRO_SAMPLE_ID implements Structure.ByValue {
//
// };
// }
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static final float ALLEGRO_AUDIO_PAN_NONE = (float)(-1000.0f);
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static native boolean al_play_sample(ALLEGRO_SAMPLE data, float gain, float pan, float speed, int loop, ALLEGRO_SAMPLE_ID ret_id);
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static native void al_stop_sample(ALLEGRO_SAMPLE_ID spl_id);
// Path: jalleg-framework/src/main/java/org/gillius/jalleg/framework/audio/LoopingSingleInstanceSample.java
import org.gillius.jalleg.binding.ALLEGRO_SAMPLE_ID;
import java.io.Closeable;
import java.io.IOException;
import static org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_AUDIO_PAN_NONE;
import static org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_PLAYMODE.ALLEGRO_PLAYMODE_LOOP;
import static org.gillius.jalleg.binding.AllegroLibrary.al_play_sample;
import static org.gillius.jalleg.binding.AllegroLibrary.al_stop_sample;
package org.gillius.jalleg.framework.audio;
/**
* Plays looping sample data with al_play_sample until a specified time.
*/
public class LoopingSingleInstanceSample implements AutoCloseable {
private final SampleData sampleData;
|
private final ALLEGRO_SAMPLE_ID id;
|
gillius/jalleg
|
jalleg-framework/src/main/java/org/gillius/jalleg/framework/audio/LoopingSingleInstanceSample.java
|
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/ALLEGRO_SAMPLE_ID.java
// public class ALLEGRO_SAMPLE_ID extends Structure {
// public int _index;
// public int _id;
// public ALLEGRO_SAMPLE_ID() {
// super();
// setAutoSynch(false);
// }
// protected List<? > getFieldOrder() {
// return Arrays.asList("_index", "_id");
// }
// public ALLEGRO_SAMPLE_ID(int _index, int _id) {
// super();
// this._index = _index;
// this._id = _id;
// }
// public ALLEGRO_SAMPLE_ID(Pointer peer) {
// super(peer);
// }
// public static class ByReference extends ALLEGRO_SAMPLE_ID implements Structure.ByReference {
//
// };
// public static class ByValue extends ALLEGRO_SAMPLE_ID implements Structure.ByValue {
//
// };
// }
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static final float ALLEGRO_AUDIO_PAN_NONE = (float)(-1000.0f);
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static native boolean al_play_sample(ALLEGRO_SAMPLE data, float gain, float pan, float speed, int loop, ALLEGRO_SAMPLE_ID ret_id);
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static native void al_stop_sample(ALLEGRO_SAMPLE_ID spl_id);
|
import org.gillius.jalleg.binding.ALLEGRO_SAMPLE_ID;
import java.io.Closeable;
import java.io.IOException;
import static org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_AUDIO_PAN_NONE;
import static org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_PLAYMODE.ALLEGRO_PLAYMODE_LOOP;
import static org.gillius.jalleg.binding.AllegroLibrary.al_play_sample;
import static org.gillius.jalleg.binding.AllegroLibrary.al_stop_sample;
|
package org.gillius.jalleg.framework.audio;
/**
* Plays looping sample data with al_play_sample until a specified time.
*/
public class LoopingSingleInstanceSample implements AutoCloseable {
private final SampleData sampleData;
private final ALLEGRO_SAMPLE_ID id;
private boolean playing;
private double endTime;
private float gain = 1f;
|
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/ALLEGRO_SAMPLE_ID.java
// public class ALLEGRO_SAMPLE_ID extends Structure {
// public int _index;
// public int _id;
// public ALLEGRO_SAMPLE_ID() {
// super();
// setAutoSynch(false);
// }
// protected List<? > getFieldOrder() {
// return Arrays.asList("_index", "_id");
// }
// public ALLEGRO_SAMPLE_ID(int _index, int _id) {
// super();
// this._index = _index;
// this._id = _id;
// }
// public ALLEGRO_SAMPLE_ID(Pointer peer) {
// super(peer);
// }
// public static class ByReference extends ALLEGRO_SAMPLE_ID implements Structure.ByReference {
//
// };
// public static class ByValue extends ALLEGRO_SAMPLE_ID implements Structure.ByValue {
//
// };
// }
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static final float ALLEGRO_AUDIO_PAN_NONE = (float)(-1000.0f);
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static native boolean al_play_sample(ALLEGRO_SAMPLE data, float gain, float pan, float speed, int loop, ALLEGRO_SAMPLE_ID ret_id);
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static native void al_stop_sample(ALLEGRO_SAMPLE_ID spl_id);
// Path: jalleg-framework/src/main/java/org/gillius/jalleg/framework/audio/LoopingSingleInstanceSample.java
import org.gillius.jalleg.binding.ALLEGRO_SAMPLE_ID;
import java.io.Closeable;
import java.io.IOException;
import static org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_AUDIO_PAN_NONE;
import static org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_PLAYMODE.ALLEGRO_PLAYMODE_LOOP;
import static org.gillius.jalleg.binding.AllegroLibrary.al_play_sample;
import static org.gillius.jalleg.binding.AllegroLibrary.al_stop_sample;
package org.gillius.jalleg.framework.audio;
/**
* Plays looping sample data with al_play_sample until a specified time.
*/
public class LoopingSingleInstanceSample implements AutoCloseable {
private final SampleData sampleData;
private final ALLEGRO_SAMPLE_ID id;
private boolean playing;
private double endTime;
private float gain = 1f;
|
private float pan = ALLEGRO_AUDIO_PAN_NONE;
|
gillius/jalleg
|
jalleg-framework/src/main/java/org/gillius/jalleg/framework/audio/LoopingSingleInstanceSample.java
|
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/ALLEGRO_SAMPLE_ID.java
// public class ALLEGRO_SAMPLE_ID extends Structure {
// public int _index;
// public int _id;
// public ALLEGRO_SAMPLE_ID() {
// super();
// setAutoSynch(false);
// }
// protected List<? > getFieldOrder() {
// return Arrays.asList("_index", "_id");
// }
// public ALLEGRO_SAMPLE_ID(int _index, int _id) {
// super();
// this._index = _index;
// this._id = _id;
// }
// public ALLEGRO_SAMPLE_ID(Pointer peer) {
// super(peer);
// }
// public static class ByReference extends ALLEGRO_SAMPLE_ID implements Structure.ByReference {
//
// };
// public static class ByValue extends ALLEGRO_SAMPLE_ID implements Structure.ByValue {
//
// };
// }
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static final float ALLEGRO_AUDIO_PAN_NONE = (float)(-1000.0f);
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static native boolean al_play_sample(ALLEGRO_SAMPLE data, float gain, float pan, float speed, int loop, ALLEGRO_SAMPLE_ID ret_id);
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static native void al_stop_sample(ALLEGRO_SAMPLE_ID spl_id);
|
import org.gillius.jalleg.binding.ALLEGRO_SAMPLE_ID;
import java.io.Closeable;
import java.io.IOException;
import static org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_AUDIO_PAN_NONE;
import static org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_PLAYMODE.ALLEGRO_PLAYMODE_LOOP;
import static org.gillius.jalleg.binding.AllegroLibrary.al_play_sample;
import static org.gillius.jalleg.binding.AllegroLibrary.al_stop_sample;
|
}
public SampleData getSampleData() {
return sampleData;
}
public boolean isPlaying() {
return playing;
}
public double getEndTime() {
return endTime;
}
/**
* Updates this sample. If t is greater than or equal to the endTime, stop playing the sample.
*/
public void update(double t) {
if (playing && t >= endTime) {
stop();
}
}
public void play(double endTime) {
play(gain, pan, speed, endTime);
}
private void play(float gain, float pan, float speed, double endTime) {
stop();
|
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/ALLEGRO_SAMPLE_ID.java
// public class ALLEGRO_SAMPLE_ID extends Structure {
// public int _index;
// public int _id;
// public ALLEGRO_SAMPLE_ID() {
// super();
// setAutoSynch(false);
// }
// protected List<? > getFieldOrder() {
// return Arrays.asList("_index", "_id");
// }
// public ALLEGRO_SAMPLE_ID(int _index, int _id) {
// super();
// this._index = _index;
// this._id = _id;
// }
// public ALLEGRO_SAMPLE_ID(Pointer peer) {
// super(peer);
// }
// public static class ByReference extends ALLEGRO_SAMPLE_ID implements Structure.ByReference {
//
// };
// public static class ByValue extends ALLEGRO_SAMPLE_ID implements Structure.ByValue {
//
// };
// }
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static final float ALLEGRO_AUDIO_PAN_NONE = (float)(-1000.0f);
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static native boolean al_play_sample(ALLEGRO_SAMPLE data, float gain, float pan, float speed, int loop, ALLEGRO_SAMPLE_ID ret_id);
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static native void al_stop_sample(ALLEGRO_SAMPLE_ID spl_id);
// Path: jalleg-framework/src/main/java/org/gillius/jalleg/framework/audio/LoopingSingleInstanceSample.java
import org.gillius.jalleg.binding.ALLEGRO_SAMPLE_ID;
import java.io.Closeable;
import java.io.IOException;
import static org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_AUDIO_PAN_NONE;
import static org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_PLAYMODE.ALLEGRO_PLAYMODE_LOOP;
import static org.gillius.jalleg.binding.AllegroLibrary.al_play_sample;
import static org.gillius.jalleg.binding.AllegroLibrary.al_stop_sample;
}
public SampleData getSampleData() {
return sampleData;
}
public boolean isPlaying() {
return playing;
}
public double getEndTime() {
return endTime;
}
/**
* Updates this sample. If t is greater than or equal to the endTime, stop playing the sample.
*/
public void update(double t) {
if (playing && t >= endTime) {
stop();
}
}
public void play(double endTime) {
play(gain, pan, speed, endTime);
}
private void play(float gain, float pan, float speed, double endTime) {
stop();
|
playing = al_play_sample(sampleData.getSample(), gain, pan, speed, ALLEGRO_PLAYMODE_LOOP, id);
|
gillius/jalleg
|
jalleg-framework/src/main/java/org/gillius/jalleg/framework/audio/LoopingSingleInstanceSample.java
|
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/ALLEGRO_SAMPLE_ID.java
// public class ALLEGRO_SAMPLE_ID extends Structure {
// public int _index;
// public int _id;
// public ALLEGRO_SAMPLE_ID() {
// super();
// setAutoSynch(false);
// }
// protected List<? > getFieldOrder() {
// return Arrays.asList("_index", "_id");
// }
// public ALLEGRO_SAMPLE_ID(int _index, int _id) {
// super();
// this._index = _index;
// this._id = _id;
// }
// public ALLEGRO_SAMPLE_ID(Pointer peer) {
// super(peer);
// }
// public static class ByReference extends ALLEGRO_SAMPLE_ID implements Structure.ByReference {
//
// };
// public static class ByValue extends ALLEGRO_SAMPLE_ID implements Structure.ByValue {
//
// };
// }
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static final float ALLEGRO_AUDIO_PAN_NONE = (float)(-1000.0f);
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static native boolean al_play_sample(ALLEGRO_SAMPLE data, float gain, float pan, float speed, int loop, ALLEGRO_SAMPLE_ID ret_id);
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static native void al_stop_sample(ALLEGRO_SAMPLE_ID spl_id);
|
import org.gillius.jalleg.binding.ALLEGRO_SAMPLE_ID;
import java.io.Closeable;
import java.io.IOException;
import static org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_AUDIO_PAN_NONE;
import static org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_PLAYMODE.ALLEGRO_PLAYMODE_LOOP;
import static org.gillius.jalleg.binding.AllegroLibrary.al_play_sample;
import static org.gillius.jalleg.binding.AllegroLibrary.al_stop_sample;
|
public boolean isPlaying() {
return playing;
}
public double getEndTime() {
return endTime;
}
/**
* Updates this sample. If t is greater than or equal to the endTime, stop playing the sample.
*/
public void update(double t) {
if (playing && t >= endTime) {
stop();
}
}
public void play(double endTime) {
play(gain, pan, speed, endTime);
}
private void play(float gain, float pan, float speed, double endTime) {
stop();
playing = al_play_sample(sampleData.getSample(), gain, pan, speed, ALLEGRO_PLAYMODE_LOOP, id);
this.endTime = endTime;
}
public void stop() {
if (playing) {
|
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/ALLEGRO_SAMPLE_ID.java
// public class ALLEGRO_SAMPLE_ID extends Structure {
// public int _index;
// public int _id;
// public ALLEGRO_SAMPLE_ID() {
// super();
// setAutoSynch(false);
// }
// protected List<? > getFieldOrder() {
// return Arrays.asList("_index", "_id");
// }
// public ALLEGRO_SAMPLE_ID(int _index, int _id) {
// super();
// this._index = _index;
// this._id = _id;
// }
// public ALLEGRO_SAMPLE_ID(Pointer peer) {
// super(peer);
// }
// public static class ByReference extends ALLEGRO_SAMPLE_ID implements Structure.ByReference {
//
// };
// public static class ByValue extends ALLEGRO_SAMPLE_ID implements Structure.ByValue {
//
// };
// }
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static final float ALLEGRO_AUDIO_PAN_NONE = (float)(-1000.0f);
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static native boolean al_play_sample(ALLEGRO_SAMPLE data, float gain, float pan, float speed, int loop, ALLEGRO_SAMPLE_ID ret_id);
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static native void al_stop_sample(ALLEGRO_SAMPLE_ID spl_id);
// Path: jalleg-framework/src/main/java/org/gillius/jalleg/framework/audio/LoopingSingleInstanceSample.java
import org.gillius.jalleg.binding.ALLEGRO_SAMPLE_ID;
import java.io.Closeable;
import java.io.IOException;
import static org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_AUDIO_PAN_NONE;
import static org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_PLAYMODE.ALLEGRO_PLAYMODE_LOOP;
import static org.gillius.jalleg.binding.AllegroLibrary.al_play_sample;
import static org.gillius.jalleg.binding.AllegroLibrary.al_stop_sample;
public boolean isPlaying() {
return playing;
}
public double getEndTime() {
return endTime;
}
/**
* Updates this sample. If t is greater than or equal to the endTime, stop playing the sample.
*/
public void update(double t) {
if (playing && t >= endTime) {
stop();
}
}
public void play(double endTime) {
play(gain, pan, speed, endTime);
}
private void play(float gain, float pan, float speed, double endTime) {
stop();
playing = al_play_sample(sampleData.getSample(), gain, pan, speed, ALLEGRO_PLAYMODE_LOOP, id);
this.endTime = endTime;
}
public void stop() {
if (playing) {
|
al_stop_sample(id);
|
gillius/jalleg
|
jalleg-binding/src/main/java/org/gillius/jalleg/binding/ALLEGRO_FS_INTERFACE.java
|
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static class ALLEGRO_FS_ENTRY extends PointerType {
// public ALLEGRO_FS_ENTRY(Pointer address) { super(address); }
// public ALLEGRO_FS_ENTRY() { super(); }
// }
|
import com.sun.jna.Callback;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.ptr.PointerByReference;
import org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_FS_ENTRY;
import java.util.Arrays;
import java.util.List;
|
/*
* Copyright 2016 Jason Winnebeck
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gillius.jalleg.binding;
/**
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br>
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br>
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>.
*/
public class ALLEGRO_FS_INTERFACE extends Structure {
public ALLEGRO_FS_INTERFACE.fs_create_entry_callback fs_create_entry;
public ALLEGRO_FS_INTERFACE.fs_destroy_entry_callback fs_destroy_entry;
public ALLEGRO_FS_INTERFACE.fs_entry_name_callback fs_entry_name;
public ALLEGRO_FS_INTERFACE.fs_update_entry_callback fs_update_entry;
public ALLEGRO_FS_INTERFACE.fs_entry_mode_callback fs_entry_mode;
public ALLEGRO_FS_INTERFACE.fs_entry_atime_callback fs_entry_atime;
public ALLEGRO_FS_INTERFACE.fs_entry_mtime_callback fs_entry_mtime;
public ALLEGRO_FS_INTERFACE.fs_entry_ctime_callback fs_entry_ctime;
public ALLEGRO_FS_INTERFACE.fs_entry_exists_callback fs_entry_exists;
public ALLEGRO_FS_INTERFACE.fs_remove_entry_callback fs_remove_entry;
public ALLEGRO_FS_INTERFACE.fs_open_directory_callback fs_open_directory;
public ALLEGRO_FS_INTERFACE.fs_read_directory_callback fs_read_directory;
public ALLEGRO_FS_INTERFACE.fs_close_directory_callback fs_close_directory;
public ALLEGRO_FS_INTERFACE.fs_filename_exists_callback fs_filename_exists;
public ALLEGRO_FS_INTERFACE.fs_remove_filename_callback fs_remove_filename;
public ALLEGRO_FS_INTERFACE.fs_get_current_directory_callback fs_get_current_directory;
public ALLEGRO_FS_INTERFACE.fs_change_directory_callback fs_change_directory;
public ALLEGRO_FS_INTERFACE.fs_make_directory_callback fs_make_directory;
public ALLEGRO_FS_INTERFACE.fs_open_file_callback fs_open_file;
public interface fs_create_entry_callback extends Callback {
|
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static class ALLEGRO_FS_ENTRY extends PointerType {
// public ALLEGRO_FS_ENTRY(Pointer address) { super(address); }
// public ALLEGRO_FS_ENTRY() { super(); }
// }
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/ALLEGRO_FS_INTERFACE.java
import com.sun.jna.Callback;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.ptr.PointerByReference;
import org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_FS_ENTRY;
import java.util.Arrays;
import java.util.List;
/*
* Copyright 2016 Jason Winnebeck
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gillius.jalleg.binding;
/**
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br>
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br>
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>.
*/
public class ALLEGRO_FS_INTERFACE extends Structure {
public ALLEGRO_FS_INTERFACE.fs_create_entry_callback fs_create_entry;
public ALLEGRO_FS_INTERFACE.fs_destroy_entry_callback fs_destroy_entry;
public ALLEGRO_FS_INTERFACE.fs_entry_name_callback fs_entry_name;
public ALLEGRO_FS_INTERFACE.fs_update_entry_callback fs_update_entry;
public ALLEGRO_FS_INTERFACE.fs_entry_mode_callback fs_entry_mode;
public ALLEGRO_FS_INTERFACE.fs_entry_atime_callback fs_entry_atime;
public ALLEGRO_FS_INTERFACE.fs_entry_mtime_callback fs_entry_mtime;
public ALLEGRO_FS_INTERFACE.fs_entry_ctime_callback fs_entry_ctime;
public ALLEGRO_FS_INTERFACE.fs_entry_exists_callback fs_entry_exists;
public ALLEGRO_FS_INTERFACE.fs_remove_entry_callback fs_remove_entry;
public ALLEGRO_FS_INTERFACE.fs_open_directory_callback fs_open_directory;
public ALLEGRO_FS_INTERFACE.fs_read_directory_callback fs_read_directory;
public ALLEGRO_FS_INTERFACE.fs_close_directory_callback fs_close_directory;
public ALLEGRO_FS_INTERFACE.fs_filename_exists_callback fs_filename_exists;
public ALLEGRO_FS_INTERFACE.fs_remove_filename_callback fs_remove_filename;
public ALLEGRO_FS_INTERFACE.fs_get_current_directory_callback fs_get_current_directory;
public ALLEGRO_FS_INTERFACE.fs_change_directory_callback fs_change_directory;
public ALLEGRO_FS_INTERFACE.fs_make_directory_callback fs_make_directory;
public ALLEGRO_FS_INTERFACE.fs_open_file_callback fs_open_file;
public interface fs_create_entry_callback extends Callback {
|
ALLEGRO_FS_ENTRY apply(Pointer path);
|
gillius/jalleg
|
jalleg-binding/src/main/java/org/gillius/jalleg/binding/ALLEGRO_MOUSE_STATE.java
|
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static class ALLEGRO_DISPLAY extends PointerType {
// public ALLEGRO_DISPLAY(Pointer address) {
// super(address);
// }
// public ALLEGRO_DISPLAY() {
// super();
// }
// }
|
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.ptr.PointerByReference;
import org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_DISPLAY;
import java.util.Arrays;
import java.util.List;
|
/*
* Copyright 2016 Jason Winnebeck
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gillius.jalleg.binding;
/**
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br>
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br>
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>.
*/
public class ALLEGRO_MOUSE_STATE extends Structure {
public int x;
public int y;
public int z;
public int w;
public int[] more_axes = new int[4];
public int buttons;
public float pressure;
|
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static class ALLEGRO_DISPLAY extends PointerType {
// public ALLEGRO_DISPLAY(Pointer address) {
// super(address);
// }
// public ALLEGRO_DISPLAY() {
// super();
// }
// }
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/ALLEGRO_MOUSE_STATE.java
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.ptr.PointerByReference;
import org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_DISPLAY;
import java.util.Arrays;
import java.util.List;
/*
* Copyright 2016 Jason Winnebeck
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gillius.jalleg.binding;
/**
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br>
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br>
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>.
*/
public class ALLEGRO_MOUSE_STATE extends Structure {
public int x;
public int y;
public int z;
public int w;
public int[] more_axes = new int[4];
public int buttons;
public float pressure;
|
public ALLEGRO_DISPLAY display;
|
gillius/jalleg
|
jalleg-binding/src/main/java/org/gillius/jalleg/binding/ALLEGRO_KEYBOARD_STATE.java
|
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static class ALLEGRO_DISPLAY extends PointerType {
// public ALLEGRO_DISPLAY(Pointer address) {
// super(address);
// }
// public ALLEGRO_DISPLAY() {
// super();
// }
// }
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static final int ALLEGRO_KEY_MAX = 227;
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static native boolean al_key_down(ALLEGRO_KEYBOARD_STATE state, int keycode);
|
import com.sun.jna.Structure;
import org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_DISPLAY;
import java.util.Arrays;
import java.util.List;
import static org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_KEY_MAX;
import static org.gillius.jalleg.binding.AllegroLibrary.al_key_down;
|
/*
* Copyright 2016 Jason Winnebeck
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gillius.jalleg.binding;
/**
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br>
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br>
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>.
*/
public class ALLEGRO_KEYBOARD_STATE extends Structure {
/** public */
public ALLEGRO_DISPLAY display;
public int[] __key_down__internal__ = new int[(ALLEGRO_KEY_MAX + 31) / 32];
/**
* The default constructor builds an ALLEGRO_KEYBOARD_STATE with "autoSynch" turned off. This means that you cannot
* observe the fields from the Java side (it can only be passed into Allegro methods). This is good for performance,
* since normally the fields do not need to be observed.
*/
public ALLEGRO_KEYBOARD_STATE() {
super();
ensureAllocated();
setAutoSynch(false);
}
public ALLEGRO_DISPLAY getDisplay() {
return (ALLEGRO_DISPLAY) readField("display");
}
public boolean isKeyDown(int keyCode) {
|
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static class ALLEGRO_DISPLAY extends PointerType {
// public ALLEGRO_DISPLAY(Pointer address) {
// super(address);
// }
// public ALLEGRO_DISPLAY() {
// super();
// }
// }
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static final int ALLEGRO_KEY_MAX = 227;
//
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static native boolean al_key_down(ALLEGRO_KEYBOARD_STATE state, int keycode);
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/ALLEGRO_KEYBOARD_STATE.java
import com.sun.jna.Structure;
import org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_DISPLAY;
import java.util.Arrays;
import java.util.List;
import static org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_KEY_MAX;
import static org.gillius.jalleg.binding.AllegroLibrary.al_key_down;
/*
* Copyright 2016 Jason Winnebeck
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gillius.jalleg.binding;
/**
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br>
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br>
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>.
*/
public class ALLEGRO_KEYBOARD_STATE extends Structure {
/** public */
public ALLEGRO_DISPLAY display;
public int[] __key_down__internal__ = new int[(ALLEGRO_KEY_MAX + 31) / 32];
/**
* The default constructor builds an ALLEGRO_KEYBOARD_STATE with "autoSynch" turned off. This means that you cannot
* observe the fields from the Java side (it can only be passed into Allegro methods). This is good for performance,
* since normally the fields do not need to be observed.
*/
public ALLEGRO_KEYBOARD_STATE() {
super();
ensureAllocated();
setAutoSynch(false);
}
public ALLEGRO_DISPLAY getDisplay() {
return (ALLEGRO_DISPLAY) readField("display");
}
public boolean isKeyDown(int keyCode) {
|
return al_key_down(this, keyCode);
|
gillius/jalleg
|
jalleg-framework/src/main/java/org/gillius/jalleg/framework/audio/ChipTuneRunner.java
|
// Path: jalleg-framework/src/main/java/org/gillius/jalleg/framework/Timeline.java
// public class Timeline<T> {
// private final PriorityQueue<TimelineEvent<T>> queue = new PriorityQueue<>();
// private double start;
//
// public void add(T item, double time) {
// queue.add(new TimelineEvent<>(item, time));
// }
//
// public double getStart() {
// return start;
// }
//
// public void setStart(double start) {
// this.start = start;
// }
//
// public boolean hasEvent(double currentTime) {
// TimelineEvent<T> event = queue.peek();
// return event != null && event.getTime() <= (currentTime - start);
// }
//
// public double getTimeToNextEvent(double currentTime) {
// TimelineEvent<T> event = queue.peek();
// if (event != null)
// return event.getTime() - (currentTime - start);
// else
// return Double.POSITIVE_INFINITY;
// }
//
// public T getEvent() {
// return queue.poll().getData();
// }
//
// public T poll(double currentTime) {
// if (hasEvent(currentTime))
// return getEvent();
// else
// return null;
// }
// }
|
import org.gillius.jalleg.framework.Timeline;
import java.util.concurrent.*;
|
package org.gillius.jalleg.framework.audio;
public class ChipTuneRunner implements Runnable, AutoCloseable {
private static double nanosPerSecond = TimeUnit.SECONDS.toNanos(1);
private final ChipTuneSystem chipTuneSystem;
|
// Path: jalleg-framework/src/main/java/org/gillius/jalleg/framework/Timeline.java
// public class Timeline<T> {
// private final PriorityQueue<TimelineEvent<T>> queue = new PriorityQueue<>();
// private double start;
//
// public void add(T item, double time) {
// queue.add(new TimelineEvent<>(item, time));
// }
//
// public double getStart() {
// return start;
// }
//
// public void setStart(double start) {
// this.start = start;
// }
//
// public boolean hasEvent(double currentTime) {
// TimelineEvent<T> event = queue.peek();
// return event != null && event.getTime() <= (currentTime - start);
// }
//
// public double getTimeToNextEvent(double currentTime) {
// TimelineEvent<T> event = queue.peek();
// if (event != null)
// return event.getTime() - (currentTime - start);
// else
// return Double.POSITIVE_INFINITY;
// }
//
// public T getEvent() {
// return queue.poll().getData();
// }
//
// public T poll(double currentTime) {
// if (hasEvent(currentTime))
// return getEvent();
// else
// return null;
// }
// }
// Path: jalleg-framework/src/main/java/org/gillius/jalleg/framework/audio/ChipTuneRunner.java
import org.gillius.jalleg.framework.Timeline;
import java.util.concurrent.*;
package org.gillius.jalleg.framework.audio;
public class ChipTuneRunner implements Runnable, AutoCloseable {
private static double nanosPerSecond = TimeUnit.SECONDS.toNanos(1);
private final ChipTuneSystem chipTuneSystem;
|
private final Timeline<ChipTuneNoteInstance> timeline = new Timeline<>();
|
gillius/jalleg
|
jalleg-binding/src/main/java/org/gillius/jalleg/binding/ALLEGRO_USER_EVENT.java
|
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static class ALLEGRO_USER_EVENT_DESCRIPTOR extends PointerType {
// public ALLEGRO_USER_EVENT_DESCRIPTOR(Pointer address) {
// super(address);
// }
// public ALLEGRO_USER_EVENT_DESCRIPTOR() {
// super();
// }
// }
|
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.ptr.IntByReference;
import java.util.Arrays;
import java.util.List;
import org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_USER_EVENT_DESCRIPTOR;
|
/*
* Copyright 2016 Jason Winnebeck
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gillius.jalleg.binding;
/**
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br>
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br>
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>.
*/
public class ALLEGRO_USER_EVENT extends Structure {
public int type;
public AllegroLibrary.ALLEGRO_EVENT_SOURCE source;
public double timestamp;
|
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/AllegroLibrary.java
// public static class ALLEGRO_USER_EVENT_DESCRIPTOR extends PointerType {
// public ALLEGRO_USER_EVENT_DESCRIPTOR(Pointer address) {
// super(address);
// }
// public ALLEGRO_USER_EVENT_DESCRIPTOR() {
// super();
// }
// }
// Path: jalleg-binding/src/main/java/org/gillius/jalleg/binding/ALLEGRO_USER_EVENT.java
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.ptr.IntByReference;
import java.util.Arrays;
import java.util.List;
import org.gillius.jalleg.binding.AllegroLibrary.ALLEGRO_USER_EVENT_DESCRIPTOR;
/*
* Copyright 2016 Jason Winnebeck
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gillius.jalleg.binding;
/**
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br>
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br>
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>.
*/
public class ALLEGRO_USER_EVENT extends Structure {
public int type;
public AllegroLibrary.ALLEGRO_EVENT_SOURCE source;
public double timestamp;
|
public ALLEGRO_USER_EVENT_DESCRIPTOR __internal__descr;
|
cdapio/coopr
|
coopr-server/src/main/java/co/cask/coopr/codec/json/current/PartialTemplateCodec.java
|
// Path: coopr-server/src/main/java/co/cask/coopr/spec/BaseEntity.java
// public class BaseEntity extends NamedEntity {
// protected final String label;
// protected final String description;
// protected final String icon;
// protected int version;
//
// private BaseEntity(String name, String label, String description, String icon, int version) {
// super(name);
// this.label = label;
// this.description = description;
// this.icon = icon;
// this.version = version;
// }
//
// protected BaseEntity(Builder builder) {
// super(builder.name);
// this.label = builder.label;
// this.description = builder.description;
// this.icon = builder.icon;
// this.version = builder.version;
// }
//
// /**
// * Get the label of the entity, or null if none exists.
// *
// * @return label of the entity, or null if none exists.
// */
// public String getLabel() {
// return label;
// }
//
// /**
// * Get the description of the entity, or null if none exists.
// *
// * @return description of the entity, or null if none exists.
// */
// public String getDescription() {
// return description;
// }
//
// /**
// * Get the link to the icon for the entity.
// *
// * @return Link to the icon for the entity.
// */
// public String getIcon() {
// return icon;
// }
//
// /**
// * Retrieves the version of the entity.
// *
// * @return the version of the entity.
// */
// public int getVersion() {
// return version;
// }
//
// /**
// * Sets the version of the entity.
// *
// * @param version the version
// */
// public void setVersion(int version) {
// this.version = version;
// }
//
// /**
// * Create an admin entity from another admin entity.
// *
// * @param other entity to create from
// * @return admin entity created from the given entity
// */
// public static BaseEntity from(BaseEntity other) {
// return new BaseEntity(other.name, other.label, other.description, other.icon, other.version);
// }
//
// /**
// * Base builder for creating admin entities.
// */
// public abstract static class Builder<T extends BaseEntity> {
// protected String name;
// protected String label;
// protected String description;
// protected String icon;
// protected int version = Constants.DEFAULT_VERSION;
//
// public Builder<T> setName(String name) {
// this.name = name;
// return this;
// }
//
// public Builder<T> setLabel(String label) {
// this.label = label;
// return this;
// }
//
// public Builder<T> setDescription(String description) {
// this.description = description;
// return this;
// }
//
// public Builder<T> setIcon(String icon) {
// this.icon = icon;
// return this;
// }
//
// public Builder<T> setVersion(int version) {
// this.version = version;
// return this;
// }
//
// public Builder<T> setBaseFields(String name, String label, String description, String icon, int version) {
// this.name = name;
// this.label = label;
// this.description = description;
// this.icon = icon;
// this.version = version;
// return this;
// }
//
// public abstract T build();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (!(o instanceof BaseEntity)) {
// return false;
// }
//
// BaseEntity that = (BaseEntity) o;
//
// return super.equals(that) &&
// Objects.equal(label, that.label) &&
// Objects.equal(description, that.description) &&
// Objects.equal(icon, that.icon) &&
// Objects.equal(version, that.version);
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(super.hashCode(), label, description, icon, version);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("label", label)
// .add("description", description)
// .add("icon", icon)
// .add("version", version)
// .toString();
// }
// }
|
import co.cask.coopr.spec.BaseEntity;
import co.cask.coopr.spec.template.AbstractTemplate;
import co.cask.coopr.spec.template.PartialTemplate;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
|
/*
* Copyright © 2012-2014 Cask Data, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package co.cask.coopr.codec.json.current;
/**
* Codec for serializing/deserializing a {@link PartialTemplate}.
*/
public class PartialTemplateCodec extends AbstractTemplateCodec<PartialTemplate> {
private static final String IMMUTABLE_KEY = "immutable";
@Override
protected void addChildFields(PartialTemplate template, JsonObject jsonObj, JsonSerializationContext context) {
super.addChildFields(template, jsonObj, context);
jsonObj.add(IMMUTABLE_KEY, context.serialize(template.isImmutable()));
}
@Override
|
// Path: coopr-server/src/main/java/co/cask/coopr/spec/BaseEntity.java
// public class BaseEntity extends NamedEntity {
// protected final String label;
// protected final String description;
// protected final String icon;
// protected int version;
//
// private BaseEntity(String name, String label, String description, String icon, int version) {
// super(name);
// this.label = label;
// this.description = description;
// this.icon = icon;
// this.version = version;
// }
//
// protected BaseEntity(Builder builder) {
// super(builder.name);
// this.label = builder.label;
// this.description = builder.description;
// this.icon = builder.icon;
// this.version = builder.version;
// }
//
// /**
// * Get the label of the entity, or null if none exists.
// *
// * @return label of the entity, or null if none exists.
// */
// public String getLabel() {
// return label;
// }
//
// /**
// * Get the description of the entity, or null if none exists.
// *
// * @return description of the entity, or null if none exists.
// */
// public String getDescription() {
// return description;
// }
//
// /**
// * Get the link to the icon for the entity.
// *
// * @return Link to the icon for the entity.
// */
// public String getIcon() {
// return icon;
// }
//
// /**
// * Retrieves the version of the entity.
// *
// * @return the version of the entity.
// */
// public int getVersion() {
// return version;
// }
//
// /**
// * Sets the version of the entity.
// *
// * @param version the version
// */
// public void setVersion(int version) {
// this.version = version;
// }
//
// /**
// * Create an admin entity from another admin entity.
// *
// * @param other entity to create from
// * @return admin entity created from the given entity
// */
// public static BaseEntity from(BaseEntity other) {
// return new BaseEntity(other.name, other.label, other.description, other.icon, other.version);
// }
//
// /**
// * Base builder for creating admin entities.
// */
// public abstract static class Builder<T extends BaseEntity> {
// protected String name;
// protected String label;
// protected String description;
// protected String icon;
// protected int version = Constants.DEFAULT_VERSION;
//
// public Builder<T> setName(String name) {
// this.name = name;
// return this;
// }
//
// public Builder<T> setLabel(String label) {
// this.label = label;
// return this;
// }
//
// public Builder<T> setDescription(String description) {
// this.description = description;
// return this;
// }
//
// public Builder<T> setIcon(String icon) {
// this.icon = icon;
// return this;
// }
//
// public Builder<T> setVersion(int version) {
// this.version = version;
// return this;
// }
//
// public Builder<T> setBaseFields(String name, String label, String description, String icon, int version) {
// this.name = name;
// this.label = label;
// this.description = description;
// this.icon = icon;
// this.version = version;
// return this;
// }
//
// public abstract T build();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (!(o instanceof BaseEntity)) {
// return false;
// }
//
// BaseEntity that = (BaseEntity) o;
//
// return super.equals(that) &&
// Objects.equal(label, that.label) &&
// Objects.equal(description, that.description) &&
// Objects.equal(icon, that.icon) &&
// Objects.equal(version, that.version);
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(super.hashCode(), label, description, icon, version);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("label", label)
// .add("description", description)
// .add("icon", icon)
// .add("version", version)
// .toString();
// }
// }
// Path: coopr-server/src/main/java/co/cask/coopr/codec/json/current/PartialTemplateCodec.java
import co.cask.coopr.spec.BaseEntity;
import co.cask.coopr.spec.template.AbstractTemplate;
import co.cask.coopr.spec.template.PartialTemplate;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
/*
* Copyright © 2012-2014 Cask Data, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package co.cask.coopr.codec.json.current;
/**
* Codec for serializing/deserializing a {@link PartialTemplate}.
*/
public class PartialTemplateCodec extends AbstractTemplateCodec<PartialTemplate> {
private static final String IMMUTABLE_KEY = "immutable";
@Override
protected void addChildFields(PartialTemplate template, JsonObject jsonObj, JsonSerializationContext context) {
super.addChildFields(template, jsonObj, context);
jsonObj.add(IMMUTABLE_KEY, context.serialize(template.isImmutable()));
}
@Override
|
protected BaseEntity.Builder<PartialTemplate> getBuilder(JsonObject jsonObj, JsonDeserializationContext context) {
|
cdapio/coopr
|
coopr-rest-client/src/test/java/co/cask/coopr/client/rest/PluginRestTest.java
|
// Path: coopr-server/src/main/java/co/cask/coopr/spec/plugin/AutomatorType.java
// public class AutomatorType extends AbstractPluginSpecification {
//
// private AutomatorType(BaseEntity.Builder baseBuilder,
// Map<ParameterType, ParametersSpecification> parameters,
// Map<String, ResourceTypeSpecification> resourceTypes) {
// super(baseBuilder, parameters, resourceTypes);
// }
//
// /**
// * Get a builder for creating automator types.
// *
// * @return builder for creating automator types
// */
// public static Builder builder() {
// return new Builder();
// }
//
// /**
// * Builder for creating automator types.
// */
// public static class Builder extends AbstractPluginSpecification.Builder<AutomatorType> {
// @Override
// public AutomatorType build() {
// return new AutomatorType(this, parameters, resourceTypes);
// }
// }
// }
|
import co.cask.common.http.exception.HttpFailureException;
import co.cask.coopr.client.ClientManager;
import co.cask.coopr.client.PluginClient;
import co.cask.coopr.client.rest.handler.PluginTestConstants;
import co.cask.coopr.client.rest.handler.PluginTestHandler;
import co.cask.coopr.provisioner.plugin.ResourceMeta;
import co.cask.coopr.provisioner.plugin.ResourceStatus;
import co.cask.coopr.spec.plugin.AutomatorType;
import co.cask.coopr.spec.plugin.ProviderType;
import co.cask.http.NettyHttpService;
import com.google.common.collect.ImmutableSet;
import org.apache.http.HttpStatus;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;
|
PluginTestHandler handler = new PluginTestHandler();
NettyHttpService.Builder builder = NettyHttpService.builder();
builder.addHttpHandlers(ImmutableSet.of(handler));
builder.setHost("localhost");
builder.setPort(0);
builder.setConnectionBacklog(200);
builder.setExecThreadPoolSize(10);
builder.setBossThreadPoolSize(1);
builder.setWorkerThreadPoolSize(1);
httpService = builder.build();
httpService.startAndWait();
int testServerPort = httpService.getBindAddress().getPort();
String testServerHost = httpService.getBindAddress().getHostName();
clientManager = new RestClientManager(RestClientConnectionConfig.builder(testServerHost, testServerPort)
.userId(PluginTestConstants.TEST_USER_ID)
.tenantId(PluginTestConstants.TEST_TENANT_ID).build());
pluginRestClient = clientManager.getPluginClient();
}
@AfterClass
public static void cleanupTestClass() {
httpService.stopAndWait();
}
@Test
public void getAllAutomatorTypesSuccessTest() throws IOException {
|
// Path: coopr-server/src/main/java/co/cask/coopr/spec/plugin/AutomatorType.java
// public class AutomatorType extends AbstractPluginSpecification {
//
// private AutomatorType(BaseEntity.Builder baseBuilder,
// Map<ParameterType, ParametersSpecification> parameters,
// Map<String, ResourceTypeSpecification> resourceTypes) {
// super(baseBuilder, parameters, resourceTypes);
// }
//
// /**
// * Get a builder for creating automator types.
// *
// * @return builder for creating automator types
// */
// public static Builder builder() {
// return new Builder();
// }
//
// /**
// * Builder for creating automator types.
// */
// public static class Builder extends AbstractPluginSpecification.Builder<AutomatorType> {
// @Override
// public AutomatorType build() {
// return new AutomatorType(this, parameters, resourceTypes);
// }
// }
// }
// Path: coopr-rest-client/src/test/java/co/cask/coopr/client/rest/PluginRestTest.java
import co.cask.common.http.exception.HttpFailureException;
import co.cask.coopr.client.ClientManager;
import co.cask.coopr.client.PluginClient;
import co.cask.coopr.client.rest.handler.PluginTestConstants;
import co.cask.coopr.client.rest.handler.PluginTestHandler;
import co.cask.coopr.provisioner.plugin.ResourceMeta;
import co.cask.coopr.provisioner.plugin.ResourceStatus;
import co.cask.coopr.spec.plugin.AutomatorType;
import co.cask.coopr.spec.plugin.ProviderType;
import co.cask.http.NettyHttpService;
import com.google.common.collect.ImmutableSet;
import org.apache.http.HttpStatus;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;
PluginTestHandler handler = new PluginTestHandler();
NettyHttpService.Builder builder = NettyHttpService.builder();
builder.addHttpHandlers(ImmutableSet.of(handler));
builder.setHost("localhost");
builder.setPort(0);
builder.setConnectionBacklog(200);
builder.setExecThreadPoolSize(10);
builder.setBossThreadPoolSize(1);
builder.setWorkerThreadPoolSize(1);
httpService = builder.build();
httpService.startAndWait();
int testServerPort = httpService.getBindAddress().getPort();
String testServerHost = httpService.getBindAddress().getHostName();
clientManager = new RestClientManager(RestClientConnectionConfig.builder(testServerHost, testServerPort)
.userId(PluginTestConstants.TEST_USER_ID)
.tenantId(PluginTestConstants.TEST_TENANT_ID).build());
pluginRestClient = clientManager.getPluginClient();
}
@AfterClass
public static void cleanupTestClass() {
httpService.stopAndWait();
}
@Test
public void getAllAutomatorTypesSuccessTest() throws IOException {
|
List<AutomatorType> allAutomatorTypes = pluginRestClient.getAllAutomatorTypes();
|
cdapio/coopr
|
coopr-server/src/test/java/co/cask/coopr/scheduler/task/TaskServiceTest.java
|
// Path: coopr-server/src/main/java/co/cask/coopr/account/Account.java
// public final class Account {
// public static final Account SUPERADMIN = new Account(Constants.ADMIN_USER, Constants.SUPERADMIN_TENANT);
// private final String userId;
// private final String tenantId;
//
// public Account(String userId, String tenantId) {
// Preconditions.checkArgument(userId != null && !userId.isEmpty(), "Account must have a user id.");
// Preconditions.checkArgument(tenantId != null && !tenantId.isEmpty(), "Account must have a tenant id.");
// this.userId = userId;
// this.tenantId = tenantId;
// }
//
// public String getUserId() {
// return userId;
// }
//
// public String getTenantId() {
// return tenantId;
// }
//
// public boolean isAdmin() {
// return Constants.ADMIN_USER.equals(userId);
// }
//
// public boolean isSuperadmin() {
// return Constants.ADMIN_USER.equals(userId) && Constants.SUPERADMIN_TENANT.equals(tenantId);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (!(o instanceof Account)) {
// return false;
// }
//
// Account other = (Account) o;
// return Objects.equal(userId, other.userId) &&
// Objects.equal(tenantId, other.tenantId);
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(userId, tenantId);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("userId", userId)
// .add("tenantId", tenantId)
// .toString();
// }
// }
//
// Path: coopr-server/src/main/java/co/cask/coopr/scheduler/ClusterAction.java
// public enum ClusterAction {
// SOLVE_LAYOUT(Cluster.Status.TERMINATED),
// CLUSTER_CREATE(Cluster.Status.INCOMPLETE),
// CLUSTER_DELETE(Cluster.Status.INCOMPLETE),
// CLUSTER_CONFIGURE(Cluster.Status.INCONSISTENT),
// CLUSTER_CONFIGURE_WITH_RESTART(Cluster.Status.INCONSISTENT),
// STOP_SERVICES(Cluster.Status.INCONSISTENT),
// START_SERVICES(Cluster.Status.INCONSISTENT),
// RESTART_SERVICES(Cluster.Status.INCONSISTENT),
// ADD_SERVICES(Cluster.Status.INCONSISTENT);
//
// // these are runtime actions for services that don't change cluster state
// public static final Set<ClusterAction> SERVICE_RUNTIME_ACTIONS = ImmutableSet.of(
// STOP_SERVICES, START_SERVICES, RESTART_SERVICES);
// private final Cluster.Status failureStatus;
//
// ClusterAction(Cluster.Status status) {
// failureStatus = status;
// }
//
// public Cluster.Status getFailureStatus() {
// return failureStatus;
// }
// }
|
import co.cask.coopr.BaseTest;
import co.cask.coopr.Entities;
import co.cask.coopr.account.Account;
import co.cask.coopr.cluster.Cluster;
import co.cask.coopr.scheduler.ClusterAction;
import com.google.common.collect.Maps;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import java.util.Map;
|
package co.cask.coopr.scheduler.task;
/**
*
*/
public class TaskServiceTest extends BaseTest {
private static TaskService taskService;
@BeforeClass
public static void setupTaskServiceTest() {
taskService = injector.getInstance(TaskService.class);
}
@Test
public void testOnlyDeleteFinishWipesCredentials() throws Exception {
|
// Path: coopr-server/src/main/java/co/cask/coopr/account/Account.java
// public final class Account {
// public static final Account SUPERADMIN = new Account(Constants.ADMIN_USER, Constants.SUPERADMIN_TENANT);
// private final String userId;
// private final String tenantId;
//
// public Account(String userId, String tenantId) {
// Preconditions.checkArgument(userId != null && !userId.isEmpty(), "Account must have a user id.");
// Preconditions.checkArgument(tenantId != null && !tenantId.isEmpty(), "Account must have a tenant id.");
// this.userId = userId;
// this.tenantId = tenantId;
// }
//
// public String getUserId() {
// return userId;
// }
//
// public String getTenantId() {
// return tenantId;
// }
//
// public boolean isAdmin() {
// return Constants.ADMIN_USER.equals(userId);
// }
//
// public boolean isSuperadmin() {
// return Constants.ADMIN_USER.equals(userId) && Constants.SUPERADMIN_TENANT.equals(tenantId);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (!(o instanceof Account)) {
// return false;
// }
//
// Account other = (Account) o;
// return Objects.equal(userId, other.userId) &&
// Objects.equal(tenantId, other.tenantId);
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(userId, tenantId);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("userId", userId)
// .add("tenantId", tenantId)
// .toString();
// }
// }
//
// Path: coopr-server/src/main/java/co/cask/coopr/scheduler/ClusterAction.java
// public enum ClusterAction {
// SOLVE_LAYOUT(Cluster.Status.TERMINATED),
// CLUSTER_CREATE(Cluster.Status.INCOMPLETE),
// CLUSTER_DELETE(Cluster.Status.INCOMPLETE),
// CLUSTER_CONFIGURE(Cluster.Status.INCONSISTENT),
// CLUSTER_CONFIGURE_WITH_RESTART(Cluster.Status.INCONSISTENT),
// STOP_SERVICES(Cluster.Status.INCONSISTENT),
// START_SERVICES(Cluster.Status.INCONSISTENT),
// RESTART_SERVICES(Cluster.Status.INCONSISTENT),
// ADD_SERVICES(Cluster.Status.INCONSISTENT);
//
// // these are runtime actions for services that don't change cluster state
// public static final Set<ClusterAction> SERVICE_RUNTIME_ACTIONS = ImmutableSet.of(
// STOP_SERVICES, START_SERVICES, RESTART_SERVICES);
// private final Cluster.Status failureStatus;
//
// ClusterAction(Cluster.Status status) {
// failureStatus = status;
// }
//
// public Cluster.Status getFailureStatus() {
// return failureStatus;
// }
// }
// Path: coopr-server/src/test/java/co/cask/coopr/scheduler/task/TaskServiceTest.java
import co.cask.coopr.BaseTest;
import co.cask.coopr.Entities;
import co.cask.coopr.account.Account;
import co.cask.coopr.cluster.Cluster;
import co.cask.coopr.scheduler.ClusterAction;
import com.google.common.collect.Maps;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import java.util.Map;
package co.cask.coopr.scheduler.task;
/**
*
*/
public class TaskServiceTest extends BaseTest {
private static TaskService taskService;
@BeforeClass
public static void setupTaskServiceTest() {
taskService = injector.getInstance(TaskService.class);
}
@Test
public void testOnlyDeleteFinishWipesCredentials() throws Exception {
|
Account account = new Account("user", "tenant");
|
cdapio/coopr
|
coopr-server/src/test/java/co/cask/coopr/scheduler/task/TaskServiceTest.java
|
// Path: coopr-server/src/main/java/co/cask/coopr/account/Account.java
// public final class Account {
// public static final Account SUPERADMIN = new Account(Constants.ADMIN_USER, Constants.SUPERADMIN_TENANT);
// private final String userId;
// private final String tenantId;
//
// public Account(String userId, String tenantId) {
// Preconditions.checkArgument(userId != null && !userId.isEmpty(), "Account must have a user id.");
// Preconditions.checkArgument(tenantId != null && !tenantId.isEmpty(), "Account must have a tenant id.");
// this.userId = userId;
// this.tenantId = tenantId;
// }
//
// public String getUserId() {
// return userId;
// }
//
// public String getTenantId() {
// return tenantId;
// }
//
// public boolean isAdmin() {
// return Constants.ADMIN_USER.equals(userId);
// }
//
// public boolean isSuperadmin() {
// return Constants.ADMIN_USER.equals(userId) && Constants.SUPERADMIN_TENANT.equals(tenantId);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (!(o instanceof Account)) {
// return false;
// }
//
// Account other = (Account) o;
// return Objects.equal(userId, other.userId) &&
// Objects.equal(tenantId, other.tenantId);
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(userId, tenantId);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("userId", userId)
// .add("tenantId", tenantId)
// .toString();
// }
// }
//
// Path: coopr-server/src/main/java/co/cask/coopr/scheduler/ClusterAction.java
// public enum ClusterAction {
// SOLVE_LAYOUT(Cluster.Status.TERMINATED),
// CLUSTER_CREATE(Cluster.Status.INCOMPLETE),
// CLUSTER_DELETE(Cluster.Status.INCOMPLETE),
// CLUSTER_CONFIGURE(Cluster.Status.INCONSISTENT),
// CLUSTER_CONFIGURE_WITH_RESTART(Cluster.Status.INCONSISTENT),
// STOP_SERVICES(Cluster.Status.INCONSISTENT),
// START_SERVICES(Cluster.Status.INCONSISTENT),
// RESTART_SERVICES(Cluster.Status.INCONSISTENT),
// ADD_SERVICES(Cluster.Status.INCONSISTENT);
//
// // these are runtime actions for services that don't change cluster state
// public static final Set<ClusterAction> SERVICE_RUNTIME_ACTIONS = ImmutableSet.of(
// STOP_SERVICES, START_SERVICES, RESTART_SERVICES);
// private final Cluster.Status failureStatus;
//
// ClusterAction(Cluster.Status status) {
// failureStatus = status;
// }
//
// public Cluster.Status getFailureStatus() {
// return failureStatus;
// }
// }
|
import co.cask.coopr.BaseTest;
import co.cask.coopr.Entities;
import co.cask.coopr.account.Account;
import co.cask.coopr.cluster.Cluster;
import co.cask.coopr.scheduler.ClusterAction;
import com.google.common.collect.Maps;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import java.util.Map;
|
package co.cask.coopr.scheduler.task;
/**
*
*/
public class TaskServiceTest extends BaseTest {
private static TaskService taskService;
@BeforeClass
public static void setupTaskServiceTest() {
taskService = injector.getInstance(TaskService.class);
}
@Test
public void testOnlyDeleteFinishWipesCredentials() throws Exception {
Account account = new Account("user", "tenant");
String clusterId = "123";
Cluster cluster = Cluster.builder()
.setName("cluster1")
.setID(clusterId)
.setProvider(Entities.ProviderExample.RACKSPACE)
.setClusterTemplate(Entities.ClusterTemplateExample.HDFS)
.setAccount(account)
.setStatus(Cluster.Status.ACTIVE)
.build();
// write credentials
Map<String, Object> sensitiveFields = Maps.newHashMap();
sensitiveFields.put("key", "keycontents");
credentialStore.set(account.getTenantId(), clusterId, sensitiveFields);
long jobNum = 1;
|
// Path: coopr-server/src/main/java/co/cask/coopr/account/Account.java
// public final class Account {
// public static final Account SUPERADMIN = new Account(Constants.ADMIN_USER, Constants.SUPERADMIN_TENANT);
// private final String userId;
// private final String tenantId;
//
// public Account(String userId, String tenantId) {
// Preconditions.checkArgument(userId != null && !userId.isEmpty(), "Account must have a user id.");
// Preconditions.checkArgument(tenantId != null && !tenantId.isEmpty(), "Account must have a tenant id.");
// this.userId = userId;
// this.tenantId = tenantId;
// }
//
// public String getUserId() {
// return userId;
// }
//
// public String getTenantId() {
// return tenantId;
// }
//
// public boolean isAdmin() {
// return Constants.ADMIN_USER.equals(userId);
// }
//
// public boolean isSuperadmin() {
// return Constants.ADMIN_USER.equals(userId) && Constants.SUPERADMIN_TENANT.equals(tenantId);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (!(o instanceof Account)) {
// return false;
// }
//
// Account other = (Account) o;
// return Objects.equal(userId, other.userId) &&
// Objects.equal(tenantId, other.tenantId);
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(userId, tenantId);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("userId", userId)
// .add("tenantId", tenantId)
// .toString();
// }
// }
//
// Path: coopr-server/src/main/java/co/cask/coopr/scheduler/ClusterAction.java
// public enum ClusterAction {
// SOLVE_LAYOUT(Cluster.Status.TERMINATED),
// CLUSTER_CREATE(Cluster.Status.INCOMPLETE),
// CLUSTER_DELETE(Cluster.Status.INCOMPLETE),
// CLUSTER_CONFIGURE(Cluster.Status.INCONSISTENT),
// CLUSTER_CONFIGURE_WITH_RESTART(Cluster.Status.INCONSISTENT),
// STOP_SERVICES(Cluster.Status.INCONSISTENT),
// START_SERVICES(Cluster.Status.INCONSISTENT),
// RESTART_SERVICES(Cluster.Status.INCONSISTENT),
// ADD_SERVICES(Cluster.Status.INCONSISTENT);
//
// // these are runtime actions for services that don't change cluster state
// public static final Set<ClusterAction> SERVICE_RUNTIME_ACTIONS = ImmutableSet.of(
// STOP_SERVICES, START_SERVICES, RESTART_SERVICES);
// private final Cluster.Status failureStatus;
//
// ClusterAction(Cluster.Status status) {
// failureStatus = status;
// }
//
// public Cluster.Status getFailureStatus() {
// return failureStatus;
// }
// }
// Path: coopr-server/src/test/java/co/cask/coopr/scheduler/task/TaskServiceTest.java
import co.cask.coopr.BaseTest;
import co.cask.coopr.Entities;
import co.cask.coopr.account.Account;
import co.cask.coopr.cluster.Cluster;
import co.cask.coopr.scheduler.ClusterAction;
import com.google.common.collect.Maps;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import java.util.Map;
package co.cask.coopr.scheduler.task;
/**
*
*/
public class TaskServiceTest extends BaseTest {
private static TaskService taskService;
@BeforeClass
public static void setupTaskServiceTest() {
taskService = injector.getInstance(TaskService.class);
}
@Test
public void testOnlyDeleteFinishWipesCredentials() throws Exception {
Account account = new Account("user", "tenant");
String clusterId = "123";
Cluster cluster = Cluster.builder()
.setName("cluster1")
.setID(clusterId)
.setProvider(Entities.ProviderExample.RACKSPACE)
.setClusterTemplate(Entities.ClusterTemplateExample.HDFS)
.setAccount(account)
.setStatus(Cluster.Status.ACTIVE)
.build();
// write credentials
Map<String, Object> sensitiveFields = Maps.newHashMap();
sensitiveFields.put("key", "keycontents");
credentialStore.set(account.getTenantId(), clusterId, sensitiveFields);
long jobNum = 1;
|
for (ClusterAction action : ClusterAction.values()) {
|
cdapio/coopr
|
coopr-server/src/main/java/co/cask/coopr/macro/Expression.java
|
// Path: coopr-server/src/main/java/co/cask/coopr/macro/eval/Evaluator.java
// public interface Evaluator {
//
// /**
// * Evaluate the macro expression on the given node of the given cluster, with the given cluster nodes.
// * Returns null if the macro does not expand to anything.
// *
// * @param cluster Cluster the macro is being expanded for.
// * @param clusterNodes Nodes in the cluster the macro is being expanded for.
// * @param node The cluster node that the macro is being expanded for.
// * @return Evaluated macro expression.
// * @throws IncompleteClusterException if the cluster does not contain the information required to evaluate the macro.
// */
// List<String> evaluate(Cluster cluster, Set<Node> clusterNodes, Node node) throws IncompleteClusterException;
// }
|
import co.cask.coopr.cluster.Cluster;
import co.cask.coopr.cluster.Node;
import co.cask.coopr.macro.eval.Evaluator;
import com.google.common.base.Objects;
import java.util.List;
import java.util.Set;
import javax.annotation.Nullable;
|
/*
* Copyright © 2012-2014 Cask Data, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package co.cask.coopr.macro;
/**
* An expression represents a single macro. It has a type and a name that are used to lookup the substitute for the
* macro. Currently, the substitute is either the list of ip addresses or the list of host names of the nodes that the
* named service runs on. By default, the substitute is returned as a comma-separated list. The list separator can be
* overridden by passing a different one to the constructor. Also, optionally each element in the substitute can be
* formatted according to a format string. The actual element is inserted by replacing the $ in the format string. The
* $ sign can be escaped by preceding it with another $.
*/
public class Expression {
private static final String DEFAULT_SEPARATOR = ",";
private static final char PLACEHOLDER = '$';
|
// Path: coopr-server/src/main/java/co/cask/coopr/macro/eval/Evaluator.java
// public interface Evaluator {
//
// /**
// * Evaluate the macro expression on the given node of the given cluster, with the given cluster nodes.
// * Returns null if the macro does not expand to anything.
// *
// * @param cluster Cluster the macro is being expanded for.
// * @param clusterNodes Nodes in the cluster the macro is being expanded for.
// * @param node The cluster node that the macro is being expanded for.
// * @return Evaluated macro expression.
// * @throws IncompleteClusterException if the cluster does not contain the information required to evaluate the macro.
// */
// List<String> evaluate(Cluster cluster, Set<Node> clusterNodes, Node node) throws IncompleteClusterException;
// }
// Path: coopr-server/src/main/java/co/cask/coopr/macro/Expression.java
import co.cask.coopr.cluster.Cluster;
import co.cask.coopr.cluster.Node;
import co.cask.coopr.macro.eval.Evaluator;
import com.google.common.base.Objects;
import java.util.List;
import java.util.Set;
import javax.annotation.Nullable;
/*
* Copyright © 2012-2014 Cask Data, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package co.cask.coopr.macro;
/**
* An expression represents a single macro. It has a type and a name that are used to lookup the substitute for the
* macro. Currently, the substitute is either the list of ip addresses or the list of host names of the nodes that the
* named service runs on. By default, the substitute is returned as a comma-separated list. The list separator can be
* overridden by passing a different one to the constructor. Also, optionally each element in the substitute can be
* formatted according to a format string. The actual element is inserted by replacing the $ in the format string. The
* $ sign can be escaped by preceding it with another $.
*/
public class Expression {
private static final String DEFAULT_SEPARATOR = ",";
private static final char PLACEHOLDER = '$';
|
private final Evaluator evaluator;
|
cdapio/coopr
|
coopr-server/src/main/java/co/cask/coopr/store/user/SQLUserStore.java
|
// Path: coopr-server/src/main/java/co/cask/coopr/account/Account.java
// public final class Account {
// public static final Account SUPERADMIN = new Account(Constants.ADMIN_USER, Constants.SUPERADMIN_TENANT);
// private final String userId;
// private final String tenantId;
//
// public Account(String userId, String tenantId) {
// Preconditions.checkArgument(userId != null && !userId.isEmpty(), "Account must have a user id.");
// Preconditions.checkArgument(tenantId != null && !tenantId.isEmpty(), "Account must have a tenant id.");
// this.userId = userId;
// this.tenantId = tenantId;
// }
//
// public String getUserId() {
// return userId;
// }
//
// public String getTenantId() {
// return tenantId;
// }
//
// public boolean isAdmin() {
// return Constants.ADMIN_USER.equals(userId);
// }
//
// public boolean isSuperadmin() {
// return Constants.ADMIN_USER.equals(userId) && Constants.SUPERADMIN_TENANT.equals(tenantId);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (!(o instanceof Account)) {
// return false;
// }
//
// Account other = (Account) o;
// return Objects.equal(userId, other.userId) &&
// Objects.equal(tenantId, other.tenantId);
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(userId, tenantId);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("userId", userId)
// .add("tenantId", tenantId)
// .toString();
// }
// }
//
// Path: coopr-server/src/main/java/co/cask/coopr/store/DBPut.java
// public abstract class DBPut {
//
// /**
// * Execute the put using the given connection.
// *
// * @param conn Connection to use to execute the put
// * @throws SQLException
// */
// public void executePut(Connection conn) throws SQLException {
// PreparedStatement updateStatement = createUpdateStatement(conn);
// try {
// int rowsUpdated = updateStatement.executeUpdate();
// // if no rows are updated, perform the insert
// if (rowsUpdated == 0) {
// PreparedStatement insertStatement = createInsertStatement(conn);
// try {
// insertStatement.executeUpdate();
// } finally {
// insertStatement.close();
// }
// }
// } finally {
// updateStatement.close();
// }
// }
//
// protected abstract PreparedStatement createUpdateStatement(Connection conn) throws SQLException;
//
// protected abstract PreparedStatement createInsertStatement(Connection conn) throws SQLException;
// }
|
import java.util.Map;
import co.cask.coopr.account.Account;
import co.cask.coopr.store.DBConnectionPool;
import co.cask.coopr.store.DBHelper;
import co.cask.coopr.store.DBPut;
import co.cask.coopr.store.DBQueryExecutor;
import com.google.common.util.concurrent.AbstractIdleService;
import com.google.gson.reflect.TypeToken;
import com.google.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
|
Connection conn = dbConnectionPool.getConnection();
try {
PreparedStatement stmt = conn.prepareStatement("DELETE FROM users");
try {
stmt.executeUpdate();
} finally {
stmt.close();
}
} finally {
conn.close();
}
}
@Override
protected void startUp() throws Exception {
if (dbConnectionPool.isEmbeddedDerbyDB()) {
DBHelper.createDerbyTableIfNotExists(
"CREATE TABLE users ( " +
"user_id VARCHAR(256), " +
"tenant_id VARCHAR(64), " +
"profile BLOB )", dbConnectionPool);
}
}
@Override
protected void shutDown() throws Exception {
// No-op
}
@Override
|
// Path: coopr-server/src/main/java/co/cask/coopr/account/Account.java
// public final class Account {
// public static final Account SUPERADMIN = new Account(Constants.ADMIN_USER, Constants.SUPERADMIN_TENANT);
// private final String userId;
// private final String tenantId;
//
// public Account(String userId, String tenantId) {
// Preconditions.checkArgument(userId != null && !userId.isEmpty(), "Account must have a user id.");
// Preconditions.checkArgument(tenantId != null && !tenantId.isEmpty(), "Account must have a tenant id.");
// this.userId = userId;
// this.tenantId = tenantId;
// }
//
// public String getUserId() {
// return userId;
// }
//
// public String getTenantId() {
// return tenantId;
// }
//
// public boolean isAdmin() {
// return Constants.ADMIN_USER.equals(userId);
// }
//
// public boolean isSuperadmin() {
// return Constants.ADMIN_USER.equals(userId) && Constants.SUPERADMIN_TENANT.equals(tenantId);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (!(o instanceof Account)) {
// return false;
// }
//
// Account other = (Account) o;
// return Objects.equal(userId, other.userId) &&
// Objects.equal(tenantId, other.tenantId);
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(userId, tenantId);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("userId", userId)
// .add("tenantId", tenantId)
// .toString();
// }
// }
//
// Path: coopr-server/src/main/java/co/cask/coopr/store/DBPut.java
// public abstract class DBPut {
//
// /**
// * Execute the put using the given connection.
// *
// * @param conn Connection to use to execute the put
// * @throws SQLException
// */
// public void executePut(Connection conn) throws SQLException {
// PreparedStatement updateStatement = createUpdateStatement(conn);
// try {
// int rowsUpdated = updateStatement.executeUpdate();
// // if no rows are updated, perform the insert
// if (rowsUpdated == 0) {
// PreparedStatement insertStatement = createInsertStatement(conn);
// try {
// insertStatement.executeUpdate();
// } finally {
// insertStatement.close();
// }
// }
// } finally {
// updateStatement.close();
// }
// }
//
// protected abstract PreparedStatement createUpdateStatement(Connection conn) throws SQLException;
//
// protected abstract PreparedStatement createInsertStatement(Connection conn) throws SQLException;
// }
// Path: coopr-server/src/main/java/co/cask/coopr/store/user/SQLUserStore.java
import java.util.Map;
import co.cask.coopr.account.Account;
import co.cask.coopr.store.DBConnectionPool;
import co.cask.coopr.store.DBHelper;
import co.cask.coopr.store.DBPut;
import co.cask.coopr.store.DBQueryExecutor;
import com.google.common.util.concurrent.AbstractIdleService;
import com.google.gson.reflect.TypeToken;
import com.google.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
Connection conn = dbConnectionPool.getConnection();
try {
PreparedStatement stmt = conn.prepareStatement("DELETE FROM users");
try {
stmt.executeUpdate();
} finally {
stmt.close();
}
} finally {
conn.close();
}
}
@Override
protected void startUp() throws Exception {
if (dbConnectionPool.isEmbeddedDerbyDB()) {
DBHelper.createDerbyTableIfNotExists(
"CREATE TABLE users ( " +
"user_id VARCHAR(256), " +
"tenant_id VARCHAR(64), " +
"profile BLOB )", dbConnectionPool);
}
}
@Override
protected void shutDown() throws Exception {
// No-op
}
@Override
|
public Map<String, Object> getProfile(Account account) throws IOException {
|
cdapio/coopr
|
coopr-server/src/main/java/co/cask/coopr/store/user/SQLUserStore.java
|
// Path: coopr-server/src/main/java/co/cask/coopr/account/Account.java
// public final class Account {
// public static final Account SUPERADMIN = new Account(Constants.ADMIN_USER, Constants.SUPERADMIN_TENANT);
// private final String userId;
// private final String tenantId;
//
// public Account(String userId, String tenantId) {
// Preconditions.checkArgument(userId != null && !userId.isEmpty(), "Account must have a user id.");
// Preconditions.checkArgument(tenantId != null && !tenantId.isEmpty(), "Account must have a tenant id.");
// this.userId = userId;
// this.tenantId = tenantId;
// }
//
// public String getUserId() {
// return userId;
// }
//
// public String getTenantId() {
// return tenantId;
// }
//
// public boolean isAdmin() {
// return Constants.ADMIN_USER.equals(userId);
// }
//
// public boolean isSuperadmin() {
// return Constants.ADMIN_USER.equals(userId) && Constants.SUPERADMIN_TENANT.equals(tenantId);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (!(o instanceof Account)) {
// return false;
// }
//
// Account other = (Account) o;
// return Objects.equal(userId, other.userId) &&
// Objects.equal(tenantId, other.tenantId);
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(userId, tenantId);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("userId", userId)
// .add("tenantId", tenantId)
// .toString();
// }
// }
//
// Path: coopr-server/src/main/java/co/cask/coopr/store/DBPut.java
// public abstract class DBPut {
//
// /**
// * Execute the put using the given connection.
// *
// * @param conn Connection to use to execute the put
// * @throws SQLException
// */
// public void executePut(Connection conn) throws SQLException {
// PreparedStatement updateStatement = createUpdateStatement(conn);
// try {
// int rowsUpdated = updateStatement.executeUpdate();
// // if no rows are updated, perform the insert
// if (rowsUpdated == 0) {
// PreparedStatement insertStatement = createInsertStatement(conn);
// try {
// insertStatement.executeUpdate();
// } finally {
// insertStatement.close();
// }
// }
// } finally {
// updateStatement.close();
// }
// }
//
// protected abstract PreparedStatement createUpdateStatement(Connection conn) throws SQLException;
//
// protected abstract PreparedStatement createInsertStatement(Connection conn) throws SQLException;
// }
|
import java.util.Map;
import co.cask.coopr.account.Account;
import co.cask.coopr.store.DBConnectionPool;
import co.cask.coopr.store.DBHelper;
import co.cask.coopr.store.DBPut;
import co.cask.coopr.store.DBQueryExecutor;
import com.google.common.util.concurrent.AbstractIdleService;
import com.google.gson.reflect.TypeToken;
import com.google.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
|
}
@Override
public Map<String, Object> getProfile(Account account) throws IOException {
try {
Connection conn = dbConnectionPool.getConnection();
try {
PreparedStatement statement =
conn.prepareStatement("SELECT profile FROM users WHERE user_id=? AND tenant_id=?");
try {
statement.setString(1, account.getUserId());
statement.setString(2, account.getTenantId());
return dbQueryExecutor.getQueryItem(statement, Map.class);
} finally {
statement.close();
}
} finally {
conn.close();
}
} catch (SQLException e) {
LOG.error("Exception getting profile for account {}.", account, e);
throw new IOException(e);
}
}
@Override
public void writeProfile(Account account, Map<String, Object> profile) throws IOException {
try {
Connection conn = dbConnectionPool.getConnection();
try {
|
// Path: coopr-server/src/main/java/co/cask/coopr/account/Account.java
// public final class Account {
// public static final Account SUPERADMIN = new Account(Constants.ADMIN_USER, Constants.SUPERADMIN_TENANT);
// private final String userId;
// private final String tenantId;
//
// public Account(String userId, String tenantId) {
// Preconditions.checkArgument(userId != null && !userId.isEmpty(), "Account must have a user id.");
// Preconditions.checkArgument(tenantId != null && !tenantId.isEmpty(), "Account must have a tenant id.");
// this.userId = userId;
// this.tenantId = tenantId;
// }
//
// public String getUserId() {
// return userId;
// }
//
// public String getTenantId() {
// return tenantId;
// }
//
// public boolean isAdmin() {
// return Constants.ADMIN_USER.equals(userId);
// }
//
// public boolean isSuperadmin() {
// return Constants.ADMIN_USER.equals(userId) && Constants.SUPERADMIN_TENANT.equals(tenantId);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (!(o instanceof Account)) {
// return false;
// }
//
// Account other = (Account) o;
// return Objects.equal(userId, other.userId) &&
// Objects.equal(tenantId, other.tenantId);
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(userId, tenantId);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("userId", userId)
// .add("tenantId", tenantId)
// .toString();
// }
// }
//
// Path: coopr-server/src/main/java/co/cask/coopr/store/DBPut.java
// public abstract class DBPut {
//
// /**
// * Execute the put using the given connection.
// *
// * @param conn Connection to use to execute the put
// * @throws SQLException
// */
// public void executePut(Connection conn) throws SQLException {
// PreparedStatement updateStatement = createUpdateStatement(conn);
// try {
// int rowsUpdated = updateStatement.executeUpdate();
// // if no rows are updated, perform the insert
// if (rowsUpdated == 0) {
// PreparedStatement insertStatement = createInsertStatement(conn);
// try {
// insertStatement.executeUpdate();
// } finally {
// insertStatement.close();
// }
// }
// } finally {
// updateStatement.close();
// }
// }
//
// protected abstract PreparedStatement createUpdateStatement(Connection conn) throws SQLException;
//
// protected abstract PreparedStatement createInsertStatement(Connection conn) throws SQLException;
// }
// Path: coopr-server/src/main/java/co/cask/coopr/store/user/SQLUserStore.java
import java.util.Map;
import co.cask.coopr.account.Account;
import co.cask.coopr.store.DBConnectionPool;
import co.cask.coopr.store.DBHelper;
import co.cask.coopr.store.DBPut;
import co.cask.coopr.store.DBQueryExecutor;
import com.google.common.util.concurrent.AbstractIdleService;
import com.google.gson.reflect.TypeToken;
import com.google.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
}
@Override
public Map<String, Object> getProfile(Account account) throws IOException {
try {
Connection conn = dbConnectionPool.getConnection();
try {
PreparedStatement statement =
conn.prepareStatement("SELECT profile FROM users WHERE user_id=? AND tenant_id=?");
try {
statement.setString(1, account.getUserId());
statement.setString(2, account.getTenantId());
return dbQueryExecutor.getQueryItem(statement, Map.class);
} finally {
statement.close();
}
} finally {
conn.close();
}
} catch (SQLException e) {
LOG.error("Exception getting profile for account {}.", account, e);
throw new IOException(e);
}
}
@Override
public void writeProfile(Account account, Map<String, Object> profile) throws IOException {
try {
Connection conn = dbConnectionPool.getConnection();
try {
|
DBPut profilePut = new ProfileDBPut(account, profile);
|
cdapio/coopr
|
coopr-server/src/main/java/co/cask/coopr/store/provisioner/SQLPluginMetaStoreView.java
|
// Path: coopr-server/src/main/java/co/cask/coopr/account/Account.java
// public final class Account {
// public static final Account SUPERADMIN = new Account(Constants.ADMIN_USER, Constants.SUPERADMIN_TENANT);
// private final String userId;
// private final String tenantId;
//
// public Account(String userId, String tenantId) {
// Preconditions.checkArgument(userId != null && !userId.isEmpty(), "Account must have a user id.");
// Preconditions.checkArgument(tenantId != null && !tenantId.isEmpty(), "Account must have a tenant id.");
// this.userId = userId;
// this.tenantId = tenantId;
// }
//
// public String getUserId() {
// return userId;
// }
//
// public String getTenantId() {
// return tenantId;
// }
//
// public boolean isAdmin() {
// return Constants.ADMIN_USER.equals(userId);
// }
//
// public boolean isSuperadmin() {
// return Constants.ADMIN_USER.equals(userId) && Constants.SUPERADMIN_TENANT.equals(tenantId);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (!(o instanceof Account)) {
// return false;
// }
//
// Account other = (Account) o;
// return Objects.equal(userId, other.userId) &&
// Objects.equal(tenantId, other.tenantId);
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(userId, tenantId);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("userId", userId)
// .add("tenantId", tenantId)
// .toString();
// }
// }
|
import java.util.Map;
import co.cask.coopr.account.Account;
import co.cask.coopr.common.utils.ImmutablePair;
import co.cask.coopr.provisioner.plugin.ResourceCollection;
import co.cask.coopr.provisioner.plugin.ResourceMeta;
import co.cask.coopr.provisioner.plugin.ResourceType;
import co.cask.coopr.spec.plugin.ResourceTypeSpecification;
import co.cask.coopr.store.DBConnectionPool;
import co.cask.coopr.store.DBQueryExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
|
/*
* Copyright © 2012-2014 Cask Data, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package co.cask.coopr.store.provisioner;
/**
* View of the plugin metadata persistent store for a given account, backed by a SQL database.
*/
public class SQLPluginMetaStoreView implements PluginMetaStoreView {
private static final Logger LOG = LoggerFactory.getLogger(SQLPluginMetaStoreView.class);
private final DBConnectionPool dbConnectionPool;
private final DBQueryExecutor dbQueryExecutor;
|
// Path: coopr-server/src/main/java/co/cask/coopr/account/Account.java
// public final class Account {
// public static final Account SUPERADMIN = new Account(Constants.ADMIN_USER, Constants.SUPERADMIN_TENANT);
// private final String userId;
// private final String tenantId;
//
// public Account(String userId, String tenantId) {
// Preconditions.checkArgument(userId != null && !userId.isEmpty(), "Account must have a user id.");
// Preconditions.checkArgument(tenantId != null && !tenantId.isEmpty(), "Account must have a tenant id.");
// this.userId = userId;
// this.tenantId = tenantId;
// }
//
// public String getUserId() {
// return userId;
// }
//
// public String getTenantId() {
// return tenantId;
// }
//
// public boolean isAdmin() {
// return Constants.ADMIN_USER.equals(userId);
// }
//
// public boolean isSuperadmin() {
// return Constants.ADMIN_USER.equals(userId) && Constants.SUPERADMIN_TENANT.equals(tenantId);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (!(o instanceof Account)) {
// return false;
// }
//
// Account other = (Account) o;
// return Objects.equal(userId, other.userId) &&
// Objects.equal(tenantId, other.tenantId);
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(userId, tenantId);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("userId", userId)
// .add("tenantId", tenantId)
// .toString();
// }
// }
// Path: coopr-server/src/main/java/co/cask/coopr/store/provisioner/SQLPluginMetaStoreView.java
import java.util.Map;
import co.cask.coopr.account.Account;
import co.cask.coopr.common.utils.ImmutablePair;
import co.cask.coopr.provisioner.plugin.ResourceCollection;
import co.cask.coopr.provisioner.plugin.ResourceMeta;
import co.cask.coopr.provisioner.plugin.ResourceType;
import co.cask.coopr.spec.plugin.ResourceTypeSpecification;
import co.cask.coopr.store.DBConnectionPool;
import co.cask.coopr.store.DBQueryExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
/*
* Copyright © 2012-2014 Cask Data, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package co.cask.coopr.store.provisioner;
/**
* View of the plugin metadata persistent store for a given account, backed by a SQL database.
*/
public class SQLPluginMetaStoreView implements PluginMetaStoreView {
private static final Logger LOG = LoggerFactory.getLogger(SQLPluginMetaStoreView.class);
private final DBConnectionPool dbConnectionPool;
private final DBQueryExecutor dbQueryExecutor;
|
private final Account account;
|
cdapio/coopr
|
coopr-server/src/main/java/co/cask/coopr/store/entity/BaseEntityStoreView.java
|
// Path: coopr-server/src/main/java/co/cask/coopr/spec/plugin/AutomatorType.java
// public class AutomatorType extends AbstractPluginSpecification {
//
// private AutomatorType(BaseEntity.Builder baseBuilder,
// Map<ParameterType, ParametersSpecification> parameters,
// Map<String, ResourceTypeSpecification> resourceTypes) {
// super(baseBuilder, parameters, resourceTypes);
// }
//
// /**
// * Get a builder for creating automator types.
// *
// * @return builder for creating automator types
// */
// public static Builder builder() {
// return new Builder();
// }
//
// /**
// * Builder for creating automator types.
// */
// public static class Builder extends AbstractPluginSpecification.Builder<AutomatorType> {
// @Override
// public AutomatorType build() {
// return new AutomatorType(this, parameters, resourceTypes);
// }
// }
// }
|
import java.util.Collection;
import javax.annotation.Nullable;
import co.cask.coopr.common.conf.Constants;
import co.cask.coopr.spec.HardwareType;
import co.cask.coopr.spec.ImageType;
import co.cask.coopr.spec.Provider;
import co.cask.coopr.spec.plugin.AutomatorType;
import co.cask.coopr.spec.plugin.ProviderType;
import co.cask.coopr.spec.service.Service;
import co.cask.coopr.spec.template.ClusterTemplate;
import co.cask.coopr.spec.template.PartialTemplate;
import com.google.common.base.Charsets;
import com.google.common.base.Function;
import com.google.gson.Gson;
import java.io.IOException;
import java.lang.reflect.Type;
|
@Nullable
@Override
public Service apply(@Nullable byte[] input) {
return deserialize(input, Service.class);
}
};
private final Function<byte[], ClusterTemplate> clusterTemplateTransform =
new Function<byte[], ClusterTemplate>() {
@Nullable
@Override
public ClusterTemplate apply(@Nullable byte[] input) {
return deserialize(input, ClusterTemplate.class);
}
};
private final Function<byte[], PartialTemplate> partialTemplateTransform =
new Function<byte[], PartialTemplate>() {
@Nullable
@Override
public PartialTemplate apply(@Nullable byte[] input) {
return deserialize(input, PartialTemplate.class);
}
};
private final Function<byte[], ProviderType> providerTypeTransform =
new Function<byte[], ProviderType>() {
@Nullable
@Override
public ProviderType apply(@Nullable byte[] input) {
return deserialize(input, ProviderType.class);
}
};
|
// Path: coopr-server/src/main/java/co/cask/coopr/spec/plugin/AutomatorType.java
// public class AutomatorType extends AbstractPluginSpecification {
//
// private AutomatorType(BaseEntity.Builder baseBuilder,
// Map<ParameterType, ParametersSpecification> parameters,
// Map<String, ResourceTypeSpecification> resourceTypes) {
// super(baseBuilder, parameters, resourceTypes);
// }
//
// /**
// * Get a builder for creating automator types.
// *
// * @return builder for creating automator types
// */
// public static Builder builder() {
// return new Builder();
// }
//
// /**
// * Builder for creating automator types.
// */
// public static class Builder extends AbstractPluginSpecification.Builder<AutomatorType> {
// @Override
// public AutomatorType build() {
// return new AutomatorType(this, parameters, resourceTypes);
// }
// }
// }
// Path: coopr-server/src/main/java/co/cask/coopr/store/entity/BaseEntityStoreView.java
import java.util.Collection;
import javax.annotation.Nullable;
import co.cask.coopr.common.conf.Constants;
import co.cask.coopr.spec.HardwareType;
import co.cask.coopr.spec.ImageType;
import co.cask.coopr.spec.Provider;
import co.cask.coopr.spec.plugin.AutomatorType;
import co.cask.coopr.spec.plugin.ProviderType;
import co.cask.coopr.spec.service.Service;
import co.cask.coopr.spec.template.ClusterTemplate;
import co.cask.coopr.spec.template.PartialTemplate;
import com.google.common.base.Charsets;
import com.google.common.base.Function;
import com.google.gson.Gson;
import java.io.IOException;
import java.lang.reflect.Type;
@Nullable
@Override
public Service apply(@Nullable byte[] input) {
return deserialize(input, Service.class);
}
};
private final Function<byte[], ClusterTemplate> clusterTemplateTransform =
new Function<byte[], ClusterTemplate>() {
@Nullable
@Override
public ClusterTemplate apply(@Nullable byte[] input) {
return deserialize(input, ClusterTemplate.class);
}
};
private final Function<byte[], PartialTemplate> partialTemplateTransform =
new Function<byte[], PartialTemplate>() {
@Nullable
@Override
public PartialTemplate apply(@Nullable byte[] input) {
return deserialize(input, PartialTemplate.class);
}
};
private final Function<byte[], ProviderType> providerTypeTransform =
new Function<byte[], ProviderType>() {
@Nullable
@Override
public ProviderType apply(@Nullable byte[] input) {
return deserialize(input, ProviderType.class);
}
};
|
private final Function<byte[], AutomatorType> automatorTypeTransform =
|
cdapio/coopr
|
coopr-server/src/main/java/co/cask/coopr/scheduler/JobPlanner.java
|
// Path: coopr-server/src/main/java/co/cask/coopr/spec/ProvisionerAction.java
// public enum ProvisionerAction {
// CREATE,
// CONFIRM,
// BOOTSTRAP,
// INSTALL,
// REMOVE,
// INITIALIZE,
// CONFIGURE,
// START,
// STOP,
// DELETE;
//
// public boolean isHardwareAction() {
// return this == CREATE || this == CONFIRM || this == BOOTSTRAP || this == DELETE;
// }
//
// public boolean isRuntimeAction() {
// return this == INITIALIZE || this == START || this == STOP;
// }
//
// public boolean isInstallTimeAction() {
// return this == INSTALL || this == REMOVE;
// }
// }
|
import co.cask.coopr.cluster.Node;
import co.cask.coopr.scheduler.dag.TaskDag;
import co.cask.coopr.scheduler.dag.TaskNode;
import co.cask.coopr.scheduler.task.ClusterJob;
import co.cask.coopr.scheduler.task.ClusterTask;
import co.cask.coopr.spec.ProvisionerAction;
import co.cask.coopr.spec.service.Service;
import com.google.common.base.Function;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.Map;
import java.util.Set;
|
public Map<String, Node> getNodeMap() {
return nodeMap;
}
/**
* Create a plan of tasks to be executed in order to perform the cluster operation. Each item in the list represents
* a stage of tasks that can be performed. All tasks in a stage may be run in parallel, but every task in a stage
* must be successfully completed before moving on to the next stage.
*
* @return Plan of tasks to be executed in order to perform a cluster operation.
*/
public List<Set<TaskNode>> linearizeDependentTasks() {
TaskDag taskDag = createTaskDag();
long start = System.currentTimeMillis();
List<Set<TaskNode>> linearizedTasks = taskDag.linearize();
long dur = System.currentTimeMillis() - start;
LOG.debug("took {} ms to linearize action plan.", dur);
return linearizedTasks;
}
/**
* Creates a DAG (directed acyclic graph) of tasks to execute in order to perform the cluster job.
*
* @return Task dag for the cluster operation.
*/
TaskDag createTaskDag() {
long start = System.currentTimeMillis();
TaskDag taskDag = new TaskDag();
|
// Path: coopr-server/src/main/java/co/cask/coopr/spec/ProvisionerAction.java
// public enum ProvisionerAction {
// CREATE,
// CONFIRM,
// BOOTSTRAP,
// INSTALL,
// REMOVE,
// INITIALIZE,
// CONFIGURE,
// START,
// STOP,
// DELETE;
//
// public boolean isHardwareAction() {
// return this == CREATE || this == CONFIRM || this == BOOTSTRAP || this == DELETE;
// }
//
// public boolean isRuntimeAction() {
// return this == INITIALIZE || this == START || this == STOP;
// }
//
// public boolean isInstallTimeAction() {
// return this == INSTALL || this == REMOVE;
// }
// }
// Path: coopr-server/src/main/java/co/cask/coopr/scheduler/JobPlanner.java
import co.cask.coopr.cluster.Node;
import co.cask.coopr.scheduler.dag.TaskDag;
import co.cask.coopr.scheduler.dag.TaskNode;
import co.cask.coopr.scheduler.task.ClusterJob;
import co.cask.coopr.scheduler.task.ClusterTask;
import co.cask.coopr.spec.ProvisionerAction;
import co.cask.coopr.spec.service.Service;
import com.google.common.base.Function;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.Map;
import java.util.Set;
public Map<String, Node> getNodeMap() {
return nodeMap;
}
/**
* Create a plan of tasks to be executed in order to perform the cluster operation. Each item in the list represents
* a stage of tasks that can be performed. All tasks in a stage may be run in parallel, but every task in a stage
* must be successfully completed before moving on to the next stage.
*
* @return Plan of tasks to be executed in order to perform a cluster operation.
*/
public List<Set<TaskNode>> linearizeDependentTasks() {
TaskDag taskDag = createTaskDag();
long start = System.currentTimeMillis();
List<Set<TaskNode>> linearizedTasks = taskDag.linearize();
long dur = System.currentTimeMillis() - start;
LOG.debug("took {} ms to linearize action plan.", dur);
return linearizedTasks;
}
/**
* Creates a DAG (directed acyclic graph) of tasks to execute in order to perform the cluster job.
*
* @return Task dag for the cluster operation.
*/
TaskDag createTaskDag() {
long start = System.currentTimeMillis();
TaskDag taskDag = new TaskDag();
|
List<ProvisionerAction> actionOrder = actions.getActionOrder().get(clusterAction);
|
cdapio/coopr
|
coopr-server/src/main/java/co/cask/coopr/http/handler/PluginHandler.java
|
// Path: coopr-server/src/main/java/co/cask/coopr/account/Account.java
// public final class Account {
// public static final Account SUPERADMIN = new Account(Constants.ADMIN_USER, Constants.SUPERADMIN_TENANT);
// private final String userId;
// private final String tenantId;
//
// public Account(String userId, String tenantId) {
// Preconditions.checkArgument(userId != null && !userId.isEmpty(), "Account must have a user id.");
// Preconditions.checkArgument(tenantId != null && !tenantId.isEmpty(), "Account must have a tenant id.");
// this.userId = userId;
// this.tenantId = tenantId;
// }
//
// public String getUserId() {
// return userId;
// }
//
// public String getTenantId() {
// return tenantId;
// }
//
// public boolean isAdmin() {
// return Constants.ADMIN_USER.equals(userId);
// }
//
// public boolean isSuperadmin() {
// return Constants.ADMIN_USER.equals(userId) && Constants.SUPERADMIN_TENANT.equals(tenantId);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (!(o instanceof Account)) {
// return false;
// }
//
// Account other = (Account) o;
// return Objects.equal(userId, other.userId) &&
// Objects.equal(tenantId, other.tenantId);
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(userId, tenantId);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("userId", userId)
// .add("tenantId", tenantId)
// .toString();
// }
// }
//
// Path: coopr-server/src/main/java/co/cask/coopr/scheduler/task/MissingEntityException.java
// public class MissingEntityException extends Exception {
//
// /**
// * New exception with error message.
// * @param message the error message
// */
// public MissingEntityException(String message) {
// super(message);
// }
//
// public MissingEntityException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public MissingEntityException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: coopr-server/src/main/java/co/cask/coopr/store/entity/EntityStoreService.java
// public interface EntityStoreService extends Service {
//
// /**
// * Get a view of the entity store as seen by the given account.
// *
// * @param account Account that will be viewing the entity store
// * @return view of the entity store as seen by the given account.
// */
// EntityStoreView getView(Account account);
//
// /**
// * Copy all entities from one account to another. Overwrites existing entities in target account if they already
// * exist. This operation is not atomic, and should be used only in specific circumstances, such as when bootstrapping
// * a new, empty account.
// *
// * @param from Account to copy from
// * @param to Account to copy to
// * @throws IOException if there was a problem copying the entities
// */
// void copyEntities(Account from, Account to) throws IOException, IllegalAccessException;
// }
|
import co.cask.coopr.account.Account;
import co.cask.coopr.common.conf.Constants;
import co.cask.coopr.provisioner.TenantProvisionerService;
import co.cask.coopr.provisioner.plugin.PluginType;
import co.cask.coopr.provisioner.plugin.ResourceMeta;
import co.cask.coopr.provisioner.plugin.ResourceService;
import co.cask.coopr.provisioner.plugin.ResourceStatus;
import co.cask.coopr.provisioner.plugin.ResourceType;
import co.cask.coopr.scheduler.task.MissingEntityException;
import co.cask.coopr.spec.plugin.AbstractPluginSpecification;
import co.cask.coopr.store.entity.EntityStoreService;
import co.cask.coopr.store.tenant.TenantStore;
import co.cask.http.BodyConsumer;
import co.cask.http.HttpResponder;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.google.inject.Inject;
import org.jboss.netty.handler.codec.http.HttpRequest;
import org.jboss.netty.handler.codec.http.HttpResponseStatus;
import org.jboss.netty.handler.codec.http.QueryStringDecoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
|
/*
* Copyright © 2012-2014 Cask Data, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package co.cask.coopr.http.handler;
/**
* Handler for plugin resource related operations, such as uploading resources, staging, and recalling resources,
* and syncing resources. Only a tenant admin can access these APIs.
*/
@Path(Constants.API_BASE + "/plugins")
public class PluginHandler extends AbstractAuthHandler {
private static final Logger LOG = LoggerFactory.getLogger(PluginHandler.class);
private final Gson gson;
private final ResourceService resourceService;
|
// Path: coopr-server/src/main/java/co/cask/coopr/account/Account.java
// public final class Account {
// public static final Account SUPERADMIN = new Account(Constants.ADMIN_USER, Constants.SUPERADMIN_TENANT);
// private final String userId;
// private final String tenantId;
//
// public Account(String userId, String tenantId) {
// Preconditions.checkArgument(userId != null && !userId.isEmpty(), "Account must have a user id.");
// Preconditions.checkArgument(tenantId != null && !tenantId.isEmpty(), "Account must have a tenant id.");
// this.userId = userId;
// this.tenantId = tenantId;
// }
//
// public String getUserId() {
// return userId;
// }
//
// public String getTenantId() {
// return tenantId;
// }
//
// public boolean isAdmin() {
// return Constants.ADMIN_USER.equals(userId);
// }
//
// public boolean isSuperadmin() {
// return Constants.ADMIN_USER.equals(userId) && Constants.SUPERADMIN_TENANT.equals(tenantId);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (!(o instanceof Account)) {
// return false;
// }
//
// Account other = (Account) o;
// return Objects.equal(userId, other.userId) &&
// Objects.equal(tenantId, other.tenantId);
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(userId, tenantId);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("userId", userId)
// .add("tenantId", tenantId)
// .toString();
// }
// }
//
// Path: coopr-server/src/main/java/co/cask/coopr/scheduler/task/MissingEntityException.java
// public class MissingEntityException extends Exception {
//
// /**
// * New exception with error message.
// * @param message the error message
// */
// public MissingEntityException(String message) {
// super(message);
// }
//
// public MissingEntityException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public MissingEntityException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: coopr-server/src/main/java/co/cask/coopr/store/entity/EntityStoreService.java
// public interface EntityStoreService extends Service {
//
// /**
// * Get a view of the entity store as seen by the given account.
// *
// * @param account Account that will be viewing the entity store
// * @return view of the entity store as seen by the given account.
// */
// EntityStoreView getView(Account account);
//
// /**
// * Copy all entities from one account to another. Overwrites existing entities in target account if they already
// * exist. This operation is not atomic, and should be used only in specific circumstances, such as when bootstrapping
// * a new, empty account.
// *
// * @param from Account to copy from
// * @param to Account to copy to
// * @throws IOException if there was a problem copying the entities
// */
// void copyEntities(Account from, Account to) throws IOException, IllegalAccessException;
// }
// Path: coopr-server/src/main/java/co/cask/coopr/http/handler/PluginHandler.java
import co.cask.coopr.account.Account;
import co.cask.coopr.common.conf.Constants;
import co.cask.coopr.provisioner.TenantProvisionerService;
import co.cask.coopr.provisioner.plugin.PluginType;
import co.cask.coopr.provisioner.plugin.ResourceMeta;
import co.cask.coopr.provisioner.plugin.ResourceService;
import co.cask.coopr.provisioner.plugin.ResourceStatus;
import co.cask.coopr.provisioner.plugin.ResourceType;
import co.cask.coopr.scheduler.task.MissingEntityException;
import co.cask.coopr.spec.plugin.AbstractPluginSpecification;
import co.cask.coopr.store.entity.EntityStoreService;
import co.cask.coopr.store.tenant.TenantStore;
import co.cask.http.BodyConsumer;
import co.cask.http.HttpResponder;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.google.inject.Inject;
import org.jboss.netty.handler.codec.http.HttpRequest;
import org.jboss.netty.handler.codec.http.HttpResponseStatus;
import org.jboss.netty.handler.codec.http.QueryStringDecoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
/*
* Copyright © 2012-2014 Cask Data, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package co.cask.coopr.http.handler;
/**
* Handler for plugin resource related operations, such as uploading resources, staging, and recalling resources,
* and syncing resources. Only a tenant admin can access these APIs.
*/
@Path(Constants.API_BASE + "/plugins")
public class PluginHandler extends AbstractAuthHandler {
private static final Logger LOG = LoggerFactory.getLogger(PluginHandler.class);
private final Gson gson;
private final ResourceService resourceService;
|
private final EntityStoreService entityStoreService;
|
cdapio/coopr
|
coopr-server/src/main/java/co/cask/coopr/http/handler/PluginHandler.java
|
// Path: coopr-server/src/main/java/co/cask/coopr/account/Account.java
// public final class Account {
// public static final Account SUPERADMIN = new Account(Constants.ADMIN_USER, Constants.SUPERADMIN_TENANT);
// private final String userId;
// private final String tenantId;
//
// public Account(String userId, String tenantId) {
// Preconditions.checkArgument(userId != null && !userId.isEmpty(), "Account must have a user id.");
// Preconditions.checkArgument(tenantId != null && !tenantId.isEmpty(), "Account must have a tenant id.");
// this.userId = userId;
// this.tenantId = tenantId;
// }
//
// public String getUserId() {
// return userId;
// }
//
// public String getTenantId() {
// return tenantId;
// }
//
// public boolean isAdmin() {
// return Constants.ADMIN_USER.equals(userId);
// }
//
// public boolean isSuperadmin() {
// return Constants.ADMIN_USER.equals(userId) && Constants.SUPERADMIN_TENANT.equals(tenantId);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (!(o instanceof Account)) {
// return false;
// }
//
// Account other = (Account) o;
// return Objects.equal(userId, other.userId) &&
// Objects.equal(tenantId, other.tenantId);
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(userId, tenantId);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("userId", userId)
// .add("tenantId", tenantId)
// .toString();
// }
// }
//
// Path: coopr-server/src/main/java/co/cask/coopr/scheduler/task/MissingEntityException.java
// public class MissingEntityException extends Exception {
//
// /**
// * New exception with error message.
// * @param message the error message
// */
// public MissingEntityException(String message) {
// super(message);
// }
//
// public MissingEntityException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public MissingEntityException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: coopr-server/src/main/java/co/cask/coopr/store/entity/EntityStoreService.java
// public interface EntityStoreService extends Service {
//
// /**
// * Get a view of the entity store as seen by the given account.
// *
// * @param account Account that will be viewing the entity store
// * @return view of the entity store as seen by the given account.
// */
// EntityStoreView getView(Account account);
//
// /**
// * Copy all entities from one account to another. Overwrites existing entities in target account if they already
// * exist. This operation is not atomic, and should be used only in specific circumstances, such as when bootstrapping
// * a new, empty account.
// *
// * @param from Account to copy from
// * @param to Account to copy to
// * @throws IOException if there was a problem copying the entities
// */
// void copyEntities(Account from, Account to) throws IOException, IllegalAccessException;
// }
|
import co.cask.coopr.account.Account;
import co.cask.coopr.common.conf.Constants;
import co.cask.coopr.provisioner.TenantProvisionerService;
import co.cask.coopr.provisioner.plugin.PluginType;
import co.cask.coopr.provisioner.plugin.ResourceMeta;
import co.cask.coopr.provisioner.plugin.ResourceService;
import co.cask.coopr.provisioner.plugin.ResourceStatus;
import co.cask.coopr.provisioner.plugin.ResourceType;
import co.cask.coopr.scheduler.task.MissingEntityException;
import co.cask.coopr.spec.plugin.AbstractPluginSpecification;
import co.cask.coopr.store.entity.EntityStoreService;
import co.cask.coopr.store.tenant.TenantStore;
import co.cask.http.BodyConsumer;
import co.cask.http.HttpResponder;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.google.inject.Inject;
import org.jboss.netty.handler.codec.http.HttpRequest;
import org.jboss.netty.handler.codec.http.HttpResponseStatus;
import org.jboss.netty.handler.codec.http.QueryStringDecoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
|
}
/**
* Push staged resources to the provisioners, and remove recalled resources from the provisioners.
*
* @param request Request to sync resources to the provisioners
* @param responder Responder for responding to the request
*/
@POST
@Path("/sync")
public void syncPlugins(HttpRequest request, HttpResponder responder) {
Account account = getAndAuthenticateAccount(request, responder);
if (account == null) {
return;
}
if (!account.isAdmin()) {
responder.sendError(HttpResponseStatus.FORBIDDEN, "user unauthorized, must be admin.");
return;
}
LOG.debug("Plugin sync called for tenant {}.", account.getTenantId());
try {
tenantProvisionerService.syncResources(account);
responder.sendStatus(HttpResponseStatus.OK);
} catch (IOException e) {
responder.sendError(HttpResponseStatus.INTERNAL_SERVER_ERROR, "Error syncing plugin resources");
}
}
private void validateTypeExists(Account account, ResourceType resourceType)
|
// Path: coopr-server/src/main/java/co/cask/coopr/account/Account.java
// public final class Account {
// public static final Account SUPERADMIN = new Account(Constants.ADMIN_USER, Constants.SUPERADMIN_TENANT);
// private final String userId;
// private final String tenantId;
//
// public Account(String userId, String tenantId) {
// Preconditions.checkArgument(userId != null && !userId.isEmpty(), "Account must have a user id.");
// Preconditions.checkArgument(tenantId != null && !tenantId.isEmpty(), "Account must have a tenant id.");
// this.userId = userId;
// this.tenantId = tenantId;
// }
//
// public String getUserId() {
// return userId;
// }
//
// public String getTenantId() {
// return tenantId;
// }
//
// public boolean isAdmin() {
// return Constants.ADMIN_USER.equals(userId);
// }
//
// public boolean isSuperadmin() {
// return Constants.ADMIN_USER.equals(userId) && Constants.SUPERADMIN_TENANT.equals(tenantId);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (!(o instanceof Account)) {
// return false;
// }
//
// Account other = (Account) o;
// return Objects.equal(userId, other.userId) &&
// Objects.equal(tenantId, other.tenantId);
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(userId, tenantId);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("userId", userId)
// .add("tenantId", tenantId)
// .toString();
// }
// }
//
// Path: coopr-server/src/main/java/co/cask/coopr/scheduler/task/MissingEntityException.java
// public class MissingEntityException extends Exception {
//
// /**
// * New exception with error message.
// * @param message the error message
// */
// public MissingEntityException(String message) {
// super(message);
// }
//
// public MissingEntityException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public MissingEntityException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: coopr-server/src/main/java/co/cask/coopr/store/entity/EntityStoreService.java
// public interface EntityStoreService extends Service {
//
// /**
// * Get a view of the entity store as seen by the given account.
// *
// * @param account Account that will be viewing the entity store
// * @return view of the entity store as seen by the given account.
// */
// EntityStoreView getView(Account account);
//
// /**
// * Copy all entities from one account to another. Overwrites existing entities in target account if they already
// * exist. This operation is not atomic, and should be used only in specific circumstances, such as when bootstrapping
// * a new, empty account.
// *
// * @param from Account to copy from
// * @param to Account to copy to
// * @throws IOException if there was a problem copying the entities
// */
// void copyEntities(Account from, Account to) throws IOException, IllegalAccessException;
// }
// Path: coopr-server/src/main/java/co/cask/coopr/http/handler/PluginHandler.java
import co.cask.coopr.account.Account;
import co.cask.coopr.common.conf.Constants;
import co.cask.coopr.provisioner.TenantProvisionerService;
import co.cask.coopr.provisioner.plugin.PluginType;
import co.cask.coopr.provisioner.plugin.ResourceMeta;
import co.cask.coopr.provisioner.plugin.ResourceService;
import co.cask.coopr.provisioner.plugin.ResourceStatus;
import co.cask.coopr.provisioner.plugin.ResourceType;
import co.cask.coopr.scheduler.task.MissingEntityException;
import co.cask.coopr.spec.plugin.AbstractPluginSpecification;
import co.cask.coopr.store.entity.EntityStoreService;
import co.cask.coopr.store.tenant.TenantStore;
import co.cask.http.BodyConsumer;
import co.cask.http.HttpResponder;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.google.inject.Inject;
import org.jboss.netty.handler.codec.http.HttpRequest;
import org.jboss.netty.handler.codec.http.HttpResponseStatus;
import org.jboss.netty.handler.codec.http.QueryStringDecoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
}
/**
* Push staged resources to the provisioners, and remove recalled resources from the provisioners.
*
* @param request Request to sync resources to the provisioners
* @param responder Responder for responding to the request
*/
@POST
@Path("/sync")
public void syncPlugins(HttpRequest request, HttpResponder responder) {
Account account = getAndAuthenticateAccount(request, responder);
if (account == null) {
return;
}
if (!account.isAdmin()) {
responder.sendError(HttpResponseStatus.FORBIDDEN, "user unauthorized, must be admin.");
return;
}
LOG.debug("Plugin sync called for tenant {}.", account.getTenantId());
try {
tenantProvisionerService.syncResources(account);
responder.sendStatus(HttpResponseStatus.OK);
} catch (IOException e) {
responder.sendError(HttpResponseStatus.INTERNAL_SERVER_ERROR, "Error syncing plugin resources");
}
}
private void validateTypeExists(Account account, ResourceType resourceType)
|
throws MissingEntityException, IOException {
|
cdapio/coopr
|
coopr-server/src/test/java/co/cask/coopr/spec/template/PartialTemplateTest.java
|
// Path: coopr-server/src/main/java/co/cask/coopr/account/Account.java
// public final class Account {
// public static final Account SUPERADMIN = new Account(Constants.ADMIN_USER, Constants.SUPERADMIN_TENANT);
// private final String userId;
// private final String tenantId;
//
// public Account(String userId, String tenantId) {
// Preconditions.checkArgument(userId != null && !userId.isEmpty(), "Account must have a user id.");
// Preconditions.checkArgument(tenantId != null && !tenantId.isEmpty(), "Account must have a tenant id.");
// this.userId = userId;
// this.tenantId = tenantId;
// }
//
// public String getUserId() {
// return userId;
// }
//
// public String getTenantId() {
// return tenantId;
// }
//
// public boolean isAdmin() {
// return Constants.ADMIN_USER.equals(userId);
// }
//
// public boolean isSuperadmin() {
// return Constants.ADMIN_USER.equals(userId) && Constants.SUPERADMIN_TENANT.equals(tenantId);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (!(o instanceof Account)) {
// return false;
// }
//
// Account other = (Account) o;
// return Objects.equal(userId, other.userId) &&
// Objects.equal(tenantId, other.tenantId);
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(userId, tenantId);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("userId", userId)
// .add("tenantId", tenantId)
// .toString();
// }
// }
|
import co.cask.coopr.BaseTest;
import co.cask.coopr.account.Account;
import co.cask.coopr.cluster.ClusterService;
import co.cask.coopr.common.conf.Constants;
import co.cask.coopr.provisioner.Provisioner;
import co.cask.coopr.provisioner.TenantProvisionerService;
import co.cask.coopr.spec.Tenant;
import co.cask.coopr.spec.TenantSpecification;
import co.cask.coopr.store.entity.EntityStoreView;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.gson.JsonSyntaxException;
import org.apache.commons.io.IOUtils;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import java.io.InputStream;
import java.util.Map;
import java.util.Set;
|
package co.cask.coopr.spec.template;
/**
*
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class PartialTemplateTest extends BaseTest {
private static ClusterTemplate insecureTemplate;
private static ClusterTemplate secureTemplate;
private static ClusterTemplate distributedTemplate;
private static PartialTemplate sensuPartial;
private static PartialTemplate ldapPartial;
private static PartialTemplate partialWithOverrides;
private static ClusterTemplate templateWithOverridesInBody;
private static ClusterTemplate templateWithOverridesInPartial;
private static EntityStoreView entityStoreView;
private static ClusterService clusterService;
|
// Path: coopr-server/src/main/java/co/cask/coopr/account/Account.java
// public final class Account {
// public static final Account SUPERADMIN = new Account(Constants.ADMIN_USER, Constants.SUPERADMIN_TENANT);
// private final String userId;
// private final String tenantId;
//
// public Account(String userId, String tenantId) {
// Preconditions.checkArgument(userId != null && !userId.isEmpty(), "Account must have a user id.");
// Preconditions.checkArgument(tenantId != null && !tenantId.isEmpty(), "Account must have a tenant id.");
// this.userId = userId;
// this.tenantId = tenantId;
// }
//
// public String getUserId() {
// return userId;
// }
//
// public String getTenantId() {
// return tenantId;
// }
//
// public boolean isAdmin() {
// return Constants.ADMIN_USER.equals(userId);
// }
//
// public boolean isSuperadmin() {
// return Constants.ADMIN_USER.equals(userId) && Constants.SUPERADMIN_TENANT.equals(tenantId);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (!(o instanceof Account)) {
// return false;
// }
//
// Account other = (Account) o;
// return Objects.equal(userId, other.userId) &&
// Objects.equal(tenantId, other.tenantId);
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(userId, tenantId);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("userId", userId)
// .add("tenantId", tenantId)
// .toString();
// }
// }
// Path: coopr-server/src/test/java/co/cask/coopr/spec/template/PartialTemplateTest.java
import co.cask.coopr.BaseTest;
import co.cask.coopr.account.Account;
import co.cask.coopr.cluster.ClusterService;
import co.cask.coopr.common.conf.Constants;
import co.cask.coopr.provisioner.Provisioner;
import co.cask.coopr.provisioner.TenantProvisionerService;
import co.cask.coopr.spec.Tenant;
import co.cask.coopr.spec.TenantSpecification;
import co.cask.coopr.store.entity.EntityStoreView;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.gson.JsonSyntaxException;
import org.apache.commons.io.IOUtils;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import java.io.InputStream;
import java.util.Map;
import java.util.Set;
package co.cask.coopr.spec.template;
/**
*
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class PartialTemplateTest extends BaseTest {
private static ClusterTemplate insecureTemplate;
private static ClusterTemplate secureTemplate;
private static ClusterTemplate distributedTemplate;
private static PartialTemplate sensuPartial;
private static PartialTemplate ldapPartial;
private static PartialTemplate partialWithOverrides;
private static ClusterTemplate templateWithOverridesInBody;
private static ClusterTemplate templateWithOverridesInPartial;
private static EntityStoreView entityStoreView;
private static ClusterService clusterService;
|
private static Account account;
|
cdapio/coopr
|
coopr-rest-client/src/main/java/co/cask/coopr/client/ClusterClient.java
|
// Path: coopr-server/src/main/java/co/cask/coopr/http/request/ClusterStatusResponse.java
// public class ClusterStatusResponse {
// private final String clusterid;
// private final int stepstotal;
// private final int stepscompleted;
// private final Cluster.Status status;
// private final ClusterJob.Status actionstatus;
// private final ClusterAction action;
//
// public ClusterStatusResponse(Cluster cluster, ClusterJob job) {
// this.clusterid = cluster.getId();
// this.status = cluster.getStatus();
// this.actionstatus = job.getJobStatus();
// this.action = job.getClusterAction();
// Map<String, ClusterTask.Status> taskStatus = job.getTaskStatus();
//
// int completedTasks = 0;
// for (Map.Entry<String, ClusterTask.Status> entry : taskStatus.entrySet()) {
// if (entry.getValue().equals(ClusterTask.Status.COMPLETE)) {
// completedTasks++;
// }
// }
// this.stepscompleted = completedTasks;
// this.stepstotal = taskStatus.size();
// }
//
// public String getClusterid() {
// return clusterid;
// }
//
// public int getStepstotal() {
// return stepstotal;
// }
//
// public int getStepscompleted() {
// return stepscompleted;
// }
//
// public Cluster.Status getStatus() {
// return status;
// }
//
// public ClusterJob.Status getActionstatus() {
// return actionstatus;
// }
//
// public ClusterAction getAction() {
// return action;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
//
// ClusterStatusResponse that = (ClusterStatusResponse) o;
//
// return Objects.equal(clusterid, that.clusterid) &&
// stepscompleted == that.stepscompleted &&
// stepstotal == that.stepstotal &&
// status == that.status &&
// action == that.action &&
// actionstatus == that.actionstatus;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(clusterid, stepstotal, stepscompleted, status, actionstatus, action);
// }
// }
|
import co.cask.coopr.cluster.ClusterDetails;
import co.cask.coopr.cluster.ClusterSummary;
import co.cask.coopr.http.request.AddServicesRequest;
import co.cask.coopr.http.request.ClusterConfigureRequest;
import co.cask.coopr.http.request.ClusterCreateRequest;
import co.cask.coopr.http.request.ClusterOperationRequest;
import co.cask.coopr.http.request.ClusterStatusResponse;
import com.google.gson.JsonObject;
import java.io.IOException;
import java.util.List;
|
/*
* Copyright © 2012-2014 Cask Data, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package co.cask.coopr.client;
/**
* The client API for manage clusters.
*/
public interface ClusterClient {
/**
* Provides a summary of details about all clusters visible to a user.
* If there are no visible clusters, returns empty list.
*
* @return list of {@link co.cask.coopr.cluster.ClusterSummary} objects
* @throws IOException in case of a problem or the connection was aborted
*/
List<ClusterSummary> getClusters() throws IOException;
/**
* Provides full details about a cluster by id.
*
* @param clusterId String value of a cluster id
* @return {@link co.cask.coopr.cluster.ClusterDetails} object
* @throws IOException in case of a problem or the connection was aborted
*/
ClusterDetails getCluster(String clusterId) throws IOException;
/**
* Deletes specified cluster by id.
*
* @param clusterId String value of a cluster id
* @throws IOException in case of a problem or the connection was aborted
*/
void deleteCluster(String clusterId) throws IOException;
/**
* Deletes specified cluster by id with optional provider fields.
*
* @param clusterId String value of a cluster id
* @param clusterOperationRequest Request to delete the cluster, containing optional provider fields
* @throws IOException in case of a problem or the connection was aborted
*/
void deleteCluster(String clusterId, ClusterOperationRequest clusterOperationRequest) throws IOException;
/**
* Creates new Cluster according to the specified parameters.
*
* @param clusterCreateRequest {@link co.cask.coopr.http.request.ClusterCreateRequest} object
* @return new Cluster id
* @throws IOException in case of a problem or the connection was aborted
*/
String createCluster(ClusterCreateRequest clusterCreateRequest) throws IOException;
/**
* Retrieves the status of a cluster by id.
*
* @param clusterId String value of a cluster id
* @return {@link co.cask.coopr.http.request.ClusterStatusResponse} object
* @throws IOException in case of a problem or the connection was aborted
*/
|
// Path: coopr-server/src/main/java/co/cask/coopr/http/request/ClusterStatusResponse.java
// public class ClusterStatusResponse {
// private final String clusterid;
// private final int stepstotal;
// private final int stepscompleted;
// private final Cluster.Status status;
// private final ClusterJob.Status actionstatus;
// private final ClusterAction action;
//
// public ClusterStatusResponse(Cluster cluster, ClusterJob job) {
// this.clusterid = cluster.getId();
// this.status = cluster.getStatus();
// this.actionstatus = job.getJobStatus();
// this.action = job.getClusterAction();
// Map<String, ClusterTask.Status> taskStatus = job.getTaskStatus();
//
// int completedTasks = 0;
// for (Map.Entry<String, ClusterTask.Status> entry : taskStatus.entrySet()) {
// if (entry.getValue().equals(ClusterTask.Status.COMPLETE)) {
// completedTasks++;
// }
// }
// this.stepscompleted = completedTasks;
// this.stepstotal = taskStatus.size();
// }
//
// public String getClusterid() {
// return clusterid;
// }
//
// public int getStepstotal() {
// return stepstotal;
// }
//
// public int getStepscompleted() {
// return stepscompleted;
// }
//
// public Cluster.Status getStatus() {
// return status;
// }
//
// public ClusterJob.Status getActionstatus() {
// return actionstatus;
// }
//
// public ClusterAction getAction() {
// return action;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
//
// ClusterStatusResponse that = (ClusterStatusResponse) o;
//
// return Objects.equal(clusterid, that.clusterid) &&
// stepscompleted == that.stepscompleted &&
// stepstotal == that.stepstotal &&
// status == that.status &&
// action == that.action &&
// actionstatus == that.actionstatus;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(clusterid, stepstotal, stepscompleted, status, actionstatus, action);
// }
// }
// Path: coopr-rest-client/src/main/java/co/cask/coopr/client/ClusterClient.java
import co.cask.coopr.cluster.ClusterDetails;
import co.cask.coopr.cluster.ClusterSummary;
import co.cask.coopr.http.request.AddServicesRequest;
import co.cask.coopr.http.request.ClusterConfigureRequest;
import co.cask.coopr.http.request.ClusterCreateRequest;
import co.cask.coopr.http.request.ClusterOperationRequest;
import co.cask.coopr.http.request.ClusterStatusResponse;
import com.google.gson.JsonObject;
import java.io.IOException;
import java.util.List;
/*
* Copyright © 2012-2014 Cask Data, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package co.cask.coopr.client;
/**
* The client API for manage clusters.
*/
public interface ClusterClient {
/**
* Provides a summary of details about all clusters visible to a user.
* If there are no visible clusters, returns empty list.
*
* @return list of {@link co.cask.coopr.cluster.ClusterSummary} objects
* @throws IOException in case of a problem or the connection was aborted
*/
List<ClusterSummary> getClusters() throws IOException;
/**
* Provides full details about a cluster by id.
*
* @param clusterId String value of a cluster id
* @return {@link co.cask.coopr.cluster.ClusterDetails} object
* @throws IOException in case of a problem or the connection was aborted
*/
ClusterDetails getCluster(String clusterId) throws IOException;
/**
* Deletes specified cluster by id.
*
* @param clusterId String value of a cluster id
* @throws IOException in case of a problem or the connection was aborted
*/
void deleteCluster(String clusterId) throws IOException;
/**
* Deletes specified cluster by id with optional provider fields.
*
* @param clusterId String value of a cluster id
* @param clusterOperationRequest Request to delete the cluster, containing optional provider fields
* @throws IOException in case of a problem or the connection was aborted
*/
void deleteCluster(String clusterId, ClusterOperationRequest clusterOperationRequest) throws IOException;
/**
* Creates new Cluster according to the specified parameters.
*
* @param clusterCreateRequest {@link co.cask.coopr.http.request.ClusterCreateRequest} object
* @return new Cluster id
* @throws IOException in case of a problem or the connection was aborted
*/
String createCluster(ClusterCreateRequest clusterCreateRequest) throws IOException;
/**
* Retrieves the status of a cluster by id.
*
* @param clusterId String value of a cluster id
* @return {@link co.cask.coopr.http.request.ClusterStatusResponse} object
* @throws IOException in case of a problem or the connection was aborted
*/
|
ClusterStatusResponse getClusterStatus(String clusterId) throws IOException;
|
cdapio/coopr
|
coopr-server/src/main/java/co/cask/coopr/http/request/ClusterStatusResponse.java
|
// Path: coopr-server/src/main/java/co/cask/coopr/scheduler/ClusterAction.java
// public enum ClusterAction {
// SOLVE_LAYOUT(Cluster.Status.TERMINATED),
// CLUSTER_CREATE(Cluster.Status.INCOMPLETE),
// CLUSTER_DELETE(Cluster.Status.INCOMPLETE),
// CLUSTER_CONFIGURE(Cluster.Status.INCONSISTENT),
// CLUSTER_CONFIGURE_WITH_RESTART(Cluster.Status.INCONSISTENT),
// STOP_SERVICES(Cluster.Status.INCONSISTENT),
// START_SERVICES(Cluster.Status.INCONSISTENT),
// RESTART_SERVICES(Cluster.Status.INCONSISTENT),
// ADD_SERVICES(Cluster.Status.INCONSISTENT);
//
// // these are runtime actions for services that don't change cluster state
// public static final Set<ClusterAction> SERVICE_RUNTIME_ACTIONS = ImmutableSet.of(
// STOP_SERVICES, START_SERVICES, RESTART_SERVICES);
// private final Cluster.Status failureStatus;
//
// ClusterAction(Cluster.Status status) {
// failureStatus = status;
// }
//
// public Cluster.Status getFailureStatus() {
// return failureStatus;
// }
// }
|
import co.cask.coopr.cluster.Cluster;
import co.cask.coopr.scheduler.ClusterAction;
import co.cask.coopr.scheduler.task.ClusterJob;
import co.cask.coopr.scheduler.task.ClusterTask;
import com.google.common.base.Objects;
import java.util.Map;
|
package co.cask.coopr.http.request;
/**
* The response to a cluster status call.
*/
public class ClusterStatusResponse {
private final String clusterid;
private final int stepstotal;
private final int stepscompleted;
private final Cluster.Status status;
private final ClusterJob.Status actionstatus;
|
// Path: coopr-server/src/main/java/co/cask/coopr/scheduler/ClusterAction.java
// public enum ClusterAction {
// SOLVE_LAYOUT(Cluster.Status.TERMINATED),
// CLUSTER_CREATE(Cluster.Status.INCOMPLETE),
// CLUSTER_DELETE(Cluster.Status.INCOMPLETE),
// CLUSTER_CONFIGURE(Cluster.Status.INCONSISTENT),
// CLUSTER_CONFIGURE_WITH_RESTART(Cluster.Status.INCONSISTENT),
// STOP_SERVICES(Cluster.Status.INCONSISTENT),
// START_SERVICES(Cluster.Status.INCONSISTENT),
// RESTART_SERVICES(Cluster.Status.INCONSISTENT),
// ADD_SERVICES(Cluster.Status.INCONSISTENT);
//
// // these are runtime actions for services that don't change cluster state
// public static final Set<ClusterAction> SERVICE_RUNTIME_ACTIONS = ImmutableSet.of(
// STOP_SERVICES, START_SERVICES, RESTART_SERVICES);
// private final Cluster.Status failureStatus;
//
// ClusterAction(Cluster.Status status) {
// failureStatus = status;
// }
//
// public Cluster.Status getFailureStatus() {
// return failureStatus;
// }
// }
// Path: coopr-server/src/main/java/co/cask/coopr/http/request/ClusterStatusResponse.java
import co.cask.coopr.cluster.Cluster;
import co.cask.coopr.scheduler.ClusterAction;
import co.cask.coopr.scheduler.task.ClusterJob;
import co.cask.coopr.scheduler.task.ClusterTask;
import com.google.common.base.Objects;
import java.util.Map;
package co.cask.coopr.http.request;
/**
* The response to a cluster status call.
*/
public class ClusterStatusResponse {
private final String clusterid;
private final int stepstotal;
private final int stepscompleted;
private final Cluster.Status status;
private final ClusterJob.Status actionstatus;
|
private final ClusterAction action;
|
prolificinteractive/material-calendarview
|
library/src/main/java/com/prolificinteractive/materialcalendarview/MaterialCalendarView.java
|
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/ArrayWeekDayFormatter.java
// public class ArrayWeekDayFormatter implements WeekDayFormatter {
//
// private final CharSequence[] weekDayLabels;
//
// /**
// * @param weekDayLabels an array of 7 labels, starting with Sunday
// */
// public ArrayWeekDayFormatter(final CharSequence[] weekDayLabels) {
// if (weekDayLabels == null) {
// throw new IllegalArgumentException("Cannot be null");
// }
// if (weekDayLabels.length != 7) {
// throw new IllegalArgumentException("Array must contain exactly 7 elements");
// }
// this.weekDayLabels = weekDayLabels;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override public CharSequence format(final DayOfWeek dayOfWeek) {
// return weekDayLabels[dayOfWeek.getValue() - 1];
// }
// }
//
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/DayFormatter.java
// public interface DayFormatter {
//
// /**
// * Default format for displaying the day.
// */
// String DEFAULT_FORMAT = "d";
//
// /**
// * Default implementation used by {@linkplain com.prolificinteractive.materialcalendarview.MaterialCalendarView}
// */
// DayFormatter DEFAULT = new DateFormatDayFormatter();
//
// /**
// * Format a given day into a string
// *
// * @param day the day
// * @return a label for the day
// */
// @NonNull String format(@NonNull CalendarDay day);
// }
//
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/MonthArrayTitleFormatter.java
// public class MonthArrayTitleFormatter implements TitleFormatter {
//
// private final CharSequence[] monthLabels;
//
// /**
// * Format using an array of month labels
// *
// * @param monthLabels an array of 12 labels to use for months, starting with January
// */
// public MonthArrayTitleFormatter(CharSequence[] monthLabels) {
// if (monthLabels == null) {
// throw new IllegalArgumentException("Label array cannot be null");
// }
// if (monthLabels.length < 12) {
// throw new IllegalArgumentException("Label array is too short");
// }
// this.monthLabels = monthLabels;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public CharSequence format(CalendarDay day) {
// return new SpannableStringBuilder()
// .append(monthLabels[day.getMonth() - 1])
// .append(" ")
// .append(String.valueOf(day.getYear()));
// }
// }
//
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/TitleFormatter.java
// public interface TitleFormatter {
//
// String DEFAULT_FORMAT = "LLLL yyyy";
//
// TitleFormatter DEFAULT = new DateFormatTitleFormatter();
//
// /**
// * Converts the supplied day to a suitable month/year title
// *
// * @param day the day containing relevant month and year information
// * @return a label to display for the given month/year
// */
// CharSequence format(CalendarDay day);
// }
//
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/WeekDayFormatter.java
// public interface WeekDayFormatter {
// /**
// * Convert a given day of the week into a label.
// *
// * @param dayOfWeek the day of the week as returned by {@linkplain DayOfWeek#getValue()}.
// * @return a label for the day of week.
// */
// CharSequence format(DayOfWeek dayOfWeek);
//
// /**
// * Default implementation used by {@linkplain com.prolificinteractive.materialcalendarview.MaterialCalendarView}
// */
// WeekDayFormatter DEFAULT = new CalendarWeekDayFormatter();
// }
|
import android.annotation.SuppressLint;
import android.app.Service;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.ArrayRes;
import android.support.annotation.DrawableRes;
import android.support.annotation.IntDef;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.util.SparseArray;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.prolificinteractive.materialcalendarview.format.ArrayWeekDayFormatter;
import com.prolificinteractive.materialcalendarview.format.DayFormatter;
import com.prolificinteractive.materialcalendarview.format.MonthArrayTitleFormatter;
import com.prolificinteractive.materialcalendarview.format.TitleFormatter;
import com.prolificinteractive.materialcalendarview.format.WeekDayFormatter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import org.threeten.bp.DayOfWeek;
import org.threeten.bp.LocalDate;
import org.threeten.bp.temporal.WeekFields;
|
*/
public void setContentDescriptionArrowFuture(final CharSequence description) {
buttonFuture.setContentDescription(description);
}
/**
* Set content description for calendar
*
* @param description String to use as content description
*/
public void setContentDescriptionCalendar(final CharSequence description) {
calendarContentDescription = description;
}
/**
* Get content description for calendar
*
* @return calendar's content description
*/
public CharSequence getCalendarContentDescription() {
return calendarContentDescription != null
? calendarContentDescription
: getContext().getString(R.string.calendar);
}
/**
* Set a formatter for day content description.
*
* @param formatter the new formatter, null for default
*/
|
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/ArrayWeekDayFormatter.java
// public class ArrayWeekDayFormatter implements WeekDayFormatter {
//
// private final CharSequence[] weekDayLabels;
//
// /**
// * @param weekDayLabels an array of 7 labels, starting with Sunday
// */
// public ArrayWeekDayFormatter(final CharSequence[] weekDayLabels) {
// if (weekDayLabels == null) {
// throw new IllegalArgumentException("Cannot be null");
// }
// if (weekDayLabels.length != 7) {
// throw new IllegalArgumentException("Array must contain exactly 7 elements");
// }
// this.weekDayLabels = weekDayLabels;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override public CharSequence format(final DayOfWeek dayOfWeek) {
// return weekDayLabels[dayOfWeek.getValue() - 1];
// }
// }
//
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/DayFormatter.java
// public interface DayFormatter {
//
// /**
// * Default format for displaying the day.
// */
// String DEFAULT_FORMAT = "d";
//
// /**
// * Default implementation used by {@linkplain com.prolificinteractive.materialcalendarview.MaterialCalendarView}
// */
// DayFormatter DEFAULT = new DateFormatDayFormatter();
//
// /**
// * Format a given day into a string
// *
// * @param day the day
// * @return a label for the day
// */
// @NonNull String format(@NonNull CalendarDay day);
// }
//
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/MonthArrayTitleFormatter.java
// public class MonthArrayTitleFormatter implements TitleFormatter {
//
// private final CharSequence[] monthLabels;
//
// /**
// * Format using an array of month labels
// *
// * @param monthLabels an array of 12 labels to use for months, starting with January
// */
// public MonthArrayTitleFormatter(CharSequence[] monthLabels) {
// if (monthLabels == null) {
// throw new IllegalArgumentException("Label array cannot be null");
// }
// if (monthLabels.length < 12) {
// throw new IllegalArgumentException("Label array is too short");
// }
// this.monthLabels = monthLabels;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public CharSequence format(CalendarDay day) {
// return new SpannableStringBuilder()
// .append(monthLabels[day.getMonth() - 1])
// .append(" ")
// .append(String.valueOf(day.getYear()));
// }
// }
//
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/TitleFormatter.java
// public interface TitleFormatter {
//
// String DEFAULT_FORMAT = "LLLL yyyy";
//
// TitleFormatter DEFAULT = new DateFormatTitleFormatter();
//
// /**
// * Converts the supplied day to a suitable month/year title
// *
// * @param day the day containing relevant month and year information
// * @return a label to display for the given month/year
// */
// CharSequence format(CalendarDay day);
// }
//
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/WeekDayFormatter.java
// public interface WeekDayFormatter {
// /**
// * Convert a given day of the week into a label.
// *
// * @param dayOfWeek the day of the week as returned by {@linkplain DayOfWeek#getValue()}.
// * @return a label for the day of week.
// */
// CharSequence format(DayOfWeek dayOfWeek);
//
// /**
// * Default implementation used by {@linkplain com.prolificinteractive.materialcalendarview.MaterialCalendarView}
// */
// WeekDayFormatter DEFAULT = new CalendarWeekDayFormatter();
// }
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/MaterialCalendarView.java
import android.annotation.SuppressLint;
import android.app.Service;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.ArrayRes;
import android.support.annotation.DrawableRes;
import android.support.annotation.IntDef;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.util.SparseArray;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.prolificinteractive.materialcalendarview.format.ArrayWeekDayFormatter;
import com.prolificinteractive.materialcalendarview.format.DayFormatter;
import com.prolificinteractive.materialcalendarview.format.MonthArrayTitleFormatter;
import com.prolificinteractive.materialcalendarview.format.TitleFormatter;
import com.prolificinteractive.materialcalendarview.format.WeekDayFormatter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import org.threeten.bp.DayOfWeek;
import org.threeten.bp.LocalDate;
import org.threeten.bp.temporal.WeekFields;
*/
public void setContentDescriptionArrowFuture(final CharSequence description) {
buttonFuture.setContentDescription(description);
}
/**
* Set content description for calendar
*
* @param description String to use as content description
*/
public void setContentDescriptionCalendar(final CharSequence description) {
calendarContentDescription = description;
}
/**
* Get content description for calendar
*
* @return calendar's content description
*/
public CharSequence getCalendarContentDescription() {
return calendarContentDescription != null
? calendarContentDescription
: getContext().getString(R.string.calendar);
}
/**
* Set a formatter for day content description.
*
* @param formatter the new formatter, null for default
*/
|
public void setDayFormatterContentDescription(DayFormatter formatter) {
|
prolificinteractive/material-calendarview
|
library/src/main/java/com/prolificinteractive/materialcalendarview/MaterialCalendarView.java
|
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/ArrayWeekDayFormatter.java
// public class ArrayWeekDayFormatter implements WeekDayFormatter {
//
// private final CharSequence[] weekDayLabels;
//
// /**
// * @param weekDayLabels an array of 7 labels, starting with Sunday
// */
// public ArrayWeekDayFormatter(final CharSequence[] weekDayLabels) {
// if (weekDayLabels == null) {
// throw new IllegalArgumentException("Cannot be null");
// }
// if (weekDayLabels.length != 7) {
// throw new IllegalArgumentException("Array must contain exactly 7 elements");
// }
// this.weekDayLabels = weekDayLabels;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override public CharSequence format(final DayOfWeek dayOfWeek) {
// return weekDayLabels[dayOfWeek.getValue() - 1];
// }
// }
//
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/DayFormatter.java
// public interface DayFormatter {
//
// /**
// * Default format for displaying the day.
// */
// String DEFAULT_FORMAT = "d";
//
// /**
// * Default implementation used by {@linkplain com.prolificinteractive.materialcalendarview.MaterialCalendarView}
// */
// DayFormatter DEFAULT = new DateFormatDayFormatter();
//
// /**
// * Format a given day into a string
// *
// * @param day the day
// * @return a label for the day
// */
// @NonNull String format(@NonNull CalendarDay day);
// }
//
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/MonthArrayTitleFormatter.java
// public class MonthArrayTitleFormatter implements TitleFormatter {
//
// private final CharSequence[] monthLabels;
//
// /**
// * Format using an array of month labels
// *
// * @param monthLabels an array of 12 labels to use for months, starting with January
// */
// public MonthArrayTitleFormatter(CharSequence[] monthLabels) {
// if (monthLabels == null) {
// throw new IllegalArgumentException("Label array cannot be null");
// }
// if (monthLabels.length < 12) {
// throw new IllegalArgumentException("Label array is too short");
// }
// this.monthLabels = monthLabels;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public CharSequence format(CalendarDay day) {
// return new SpannableStringBuilder()
// .append(monthLabels[day.getMonth() - 1])
// .append(" ")
// .append(String.valueOf(day.getYear()));
// }
// }
//
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/TitleFormatter.java
// public interface TitleFormatter {
//
// String DEFAULT_FORMAT = "LLLL yyyy";
//
// TitleFormatter DEFAULT = new DateFormatTitleFormatter();
//
// /**
// * Converts the supplied day to a suitable month/year title
// *
// * @param day the day containing relevant month and year information
// * @return a label to display for the given month/year
// */
// CharSequence format(CalendarDay day);
// }
//
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/WeekDayFormatter.java
// public interface WeekDayFormatter {
// /**
// * Convert a given day of the week into a label.
// *
// * @param dayOfWeek the day of the week as returned by {@linkplain DayOfWeek#getValue()}.
// * @return a label for the day of week.
// */
// CharSequence format(DayOfWeek dayOfWeek);
//
// /**
// * Default implementation used by {@linkplain com.prolificinteractive.materialcalendarview.MaterialCalendarView}
// */
// WeekDayFormatter DEFAULT = new CalendarWeekDayFormatter();
// }
|
import android.annotation.SuppressLint;
import android.app.Service;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.ArrayRes;
import android.support.annotation.DrawableRes;
import android.support.annotation.IntDef;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.util.SparseArray;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.prolificinteractive.materialcalendarview.format.ArrayWeekDayFormatter;
import com.prolificinteractive.materialcalendarview.format.DayFormatter;
import com.prolificinteractive.materialcalendarview.format.MonthArrayTitleFormatter;
import com.prolificinteractive.materialcalendarview.format.TitleFormatter;
import com.prolificinteractive.materialcalendarview.format.WeekDayFormatter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import org.threeten.bp.DayOfWeek;
import org.threeten.bp.LocalDate;
import org.threeten.bp.temporal.WeekFields;
|
* @see #SHOW_NONE
* @see #SHOW_DEFAULTS
* @see #SHOW_OTHER_MONTHS
* @see #SHOW_OUT_OF_RANGE
* @see #SHOW_DECORATED_DISABLED
*/
@ShowOtherDates
public int getShowOtherDates() {
return adapter.getShowOtherDates();
}
/**
* @return true if allow click on days outside current month displayed
*/
public boolean allowClickDaysOutsideCurrentMonth() {
return allowClickDaysOutsideCurrentMonth;
}
/**
* @return true if the week days names are shown
*/
public boolean isShowWeekDays() {
return showWeekDays;
}
/**
* Set a custom formatter for the month/year title
*
* @param titleFormatter new formatter to use, null to use default formatter
*/
|
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/ArrayWeekDayFormatter.java
// public class ArrayWeekDayFormatter implements WeekDayFormatter {
//
// private final CharSequence[] weekDayLabels;
//
// /**
// * @param weekDayLabels an array of 7 labels, starting with Sunday
// */
// public ArrayWeekDayFormatter(final CharSequence[] weekDayLabels) {
// if (weekDayLabels == null) {
// throw new IllegalArgumentException("Cannot be null");
// }
// if (weekDayLabels.length != 7) {
// throw new IllegalArgumentException("Array must contain exactly 7 elements");
// }
// this.weekDayLabels = weekDayLabels;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override public CharSequence format(final DayOfWeek dayOfWeek) {
// return weekDayLabels[dayOfWeek.getValue() - 1];
// }
// }
//
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/DayFormatter.java
// public interface DayFormatter {
//
// /**
// * Default format for displaying the day.
// */
// String DEFAULT_FORMAT = "d";
//
// /**
// * Default implementation used by {@linkplain com.prolificinteractive.materialcalendarview.MaterialCalendarView}
// */
// DayFormatter DEFAULT = new DateFormatDayFormatter();
//
// /**
// * Format a given day into a string
// *
// * @param day the day
// * @return a label for the day
// */
// @NonNull String format(@NonNull CalendarDay day);
// }
//
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/MonthArrayTitleFormatter.java
// public class MonthArrayTitleFormatter implements TitleFormatter {
//
// private final CharSequence[] monthLabels;
//
// /**
// * Format using an array of month labels
// *
// * @param monthLabels an array of 12 labels to use for months, starting with January
// */
// public MonthArrayTitleFormatter(CharSequence[] monthLabels) {
// if (monthLabels == null) {
// throw new IllegalArgumentException("Label array cannot be null");
// }
// if (monthLabels.length < 12) {
// throw new IllegalArgumentException("Label array is too short");
// }
// this.monthLabels = monthLabels;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public CharSequence format(CalendarDay day) {
// return new SpannableStringBuilder()
// .append(monthLabels[day.getMonth() - 1])
// .append(" ")
// .append(String.valueOf(day.getYear()));
// }
// }
//
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/TitleFormatter.java
// public interface TitleFormatter {
//
// String DEFAULT_FORMAT = "LLLL yyyy";
//
// TitleFormatter DEFAULT = new DateFormatTitleFormatter();
//
// /**
// * Converts the supplied day to a suitable month/year title
// *
// * @param day the day containing relevant month and year information
// * @return a label to display for the given month/year
// */
// CharSequence format(CalendarDay day);
// }
//
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/WeekDayFormatter.java
// public interface WeekDayFormatter {
// /**
// * Convert a given day of the week into a label.
// *
// * @param dayOfWeek the day of the week as returned by {@linkplain DayOfWeek#getValue()}.
// * @return a label for the day of week.
// */
// CharSequence format(DayOfWeek dayOfWeek);
//
// /**
// * Default implementation used by {@linkplain com.prolificinteractive.materialcalendarview.MaterialCalendarView}
// */
// WeekDayFormatter DEFAULT = new CalendarWeekDayFormatter();
// }
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/MaterialCalendarView.java
import android.annotation.SuppressLint;
import android.app.Service;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.ArrayRes;
import android.support.annotation.DrawableRes;
import android.support.annotation.IntDef;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.util.SparseArray;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.prolificinteractive.materialcalendarview.format.ArrayWeekDayFormatter;
import com.prolificinteractive.materialcalendarview.format.DayFormatter;
import com.prolificinteractive.materialcalendarview.format.MonthArrayTitleFormatter;
import com.prolificinteractive.materialcalendarview.format.TitleFormatter;
import com.prolificinteractive.materialcalendarview.format.WeekDayFormatter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import org.threeten.bp.DayOfWeek;
import org.threeten.bp.LocalDate;
import org.threeten.bp.temporal.WeekFields;
* @see #SHOW_NONE
* @see #SHOW_DEFAULTS
* @see #SHOW_OTHER_MONTHS
* @see #SHOW_OUT_OF_RANGE
* @see #SHOW_DECORATED_DISABLED
*/
@ShowOtherDates
public int getShowOtherDates() {
return adapter.getShowOtherDates();
}
/**
* @return true if allow click on days outside current month displayed
*/
public boolean allowClickDaysOutsideCurrentMonth() {
return allowClickDaysOutsideCurrentMonth;
}
/**
* @return true if the week days names are shown
*/
public boolean isShowWeekDays() {
return showWeekDays;
}
/**
* Set a custom formatter for the month/year title
*
* @param titleFormatter new formatter to use, null to use default formatter
*/
|
public void setTitleFormatter(@Nullable TitleFormatter titleFormatter) {
|
prolificinteractive/material-calendarview
|
library/src/main/java/com/prolificinteractive/materialcalendarview/CalendarPagerView.java
|
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/DayFormatter.java
// public interface DayFormatter {
//
// /**
// * Default format for displaying the day.
// */
// String DEFAULT_FORMAT = "d";
//
// /**
// * Default implementation used by {@linkplain com.prolificinteractive.materialcalendarview.MaterialCalendarView}
// */
// DayFormatter DEFAULT = new DateFormatDayFormatter();
//
// /**
// * Format a given day into a string
// *
// * @param day the day
// * @return a label for the day
// */
// @NonNull String format(@NonNull CalendarDay day);
// }
//
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/WeekDayFormatter.java
// public interface WeekDayFormatter {
// /**
// * Convert a given day of the week into a label.
// *
// * @param dayOfWeek the day of the week as returned by {@linkplain DayOfWeek#getValue()}.
// * @return a label for the day of week.
// */
// CharSequence format(DayOfWeek dayOfWeek);
//
// /**
// * Default implementation used by {@linkplain com.prolificinteractive.materialcalendarview.MaterialCalendarView}
// */
// WeekDayFormatter DEFAULT = new CalendarWeekDayFormatter();
// }
//
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/MaterialCalendarView.java
// public static boolean showOtherMonths(@ShowOtherDates int showOtherDates) {
// return (showOtherDates & SHOW_OTHER_MONTHS) != 0;
// }
|
import android.os.Build;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import com.prolificinteractive.materialcalendarview.MaterialCalendarView.ShowOtherDates;
import com.prolificinteractive.materialcalendarview.format.DayFormatter;
import com.prolificinteractive.materialcalendarview.format.WeekDayFormatter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.threeten.bp.DayOfWeek;
import org.threeten.bp.LocalDate;
import org.threeten.bp.temporal.TemporalField;
import org.threeten.bp.temporal.WeekFields;
import static com.prolificinteractive.materialcalendarview.MaterialCalendarView.SHOW_DEFAULTS;
import static com.prolificinteractive.materialcalendarview.MaterialCalendarView.showOtherMonths;
|
}
private void buildWeekDays(LocalDate calendar) {
LocalDate local = calendar;
for (int i = 0; i < DEFAULT_DAYS_IN_WEEK; i++) {
WeekDayView weekDayView = new WeekDayView(getContext(), local.getDayOfWeek());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
weekDayView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
}
weekDayViews.add(weekDayView);
addView(weekDayView);
local = local.plusDays(1);
}
}
protected void addDayView(Collection<DayView> dayViews, LocalDate temp) {
CalendarDay day = CalendarDay.from(temp);
DayView dayView = new DayView(getContext(), day);
dayView.setOnClickListener(this);
dayView.setOnLongClickListener(this);
dayViews.add(dayView);
addView(dayView, new LayoutParams());
}
protected LocalDate resetAndGetWorkingCalendar() {
final TemporalField firstDayOfWeek = WeekFields.of(this.firstDayOfWeek, 1).dayOfWeek();
final LocalDate temp = getFirstViewDay().getDate().with(firstDayOfWeek, 1);
int dow = temp.getDayOfWeek().getValue();
int delta = getFirstDayOfWeek().getValue() - dow;
//If the delta is positive, we want to remove a week
|
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/DayFormatter.java
// public interface DayFormatter {
//
// /**
// * Default format for displaying the day.
// */
// String DEFAULT_FORMAT = "d";
//
// /**
// * Default implementation used by {@linkplain com.prolificinteractive.materialcalendarview.MaterialCalendarView}
// */
// DayFormatter DEFAULT = new DateFormatDayFormatter();
//
// /**
// * Format a given day into a string
// *
// * @param day the day
// * @return a label for the day
// */
// @NonNull String format(@NonNull CalendarDay day);
// }
//
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/WeekDayFormatter.java
// public interface WeekDayFormatter {
// /**
// * Convert a given day of the week into a label.
// *
// * @param dayOfWeek the day of the week as returned by {@linkplain DayOfWeek#getValue()}.
// * @return a label for the day of week.
// */
// CharSequence format(DayOfWeek dayOfWeek);
//
// /**
// * Default implementation used by {@linkplain com.prolificinteractive.materialcalendarview.MaterialCalendarView}
// */
// WeekDayFormatter DEFAULT = new CalendarWeekDayFormatter();
// }
//
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/MaterialCalendarView.java
// public static boolean showOtherMonths(@ShowOtherDates int showOtherDates) {
// return (showOtherDates & SHOW_OTHER_MONTHS) != 0;
// }
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/CalendarPagerView.java
import android.os.Build;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import com.prolificinteractive.materialcalendarview.MaterialCalendarView.ShowOtherDates;
import com.prolificinteractive.materialcalendarview.format.DayFormatter;
import com.prolificinteractive.materialcalendarview.format.WeekDayFormatter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.threeten.bp.DayOfWeek;
import org.threeten.bp.LocalDate;
import org.threeten.bp.temporal.TemporalField;
import org.threeten.bp.temporal.WeekFields;
import static com.prolificinteractive.materialcalendarview.MaterialCalendarView.SHOW_DEFAULTS;
import static com.prolificinteractive.materialcalendarview.MaterialCalendarView.showOtherMonths;
}
private void buildWeekDays(LocalDate calendar) {
LocalDate local = calendar;
for (int i = 0; i < DEFAULT_DAYS_IN_WEEK; i++) {
WeekDayView weekDayView = new WeekDayView(getContext(), local.getDayOfWeek());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
weekDayView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
}
weekDayViews.add(weekDayView);
addView(weekDayView);
local = local.plusDays(1);
}
}
protected void addDayView(Collection<DayView> dayViews, LocalDate temp) {
CalendarDay day = CalendarDay.from(temp);
DayView dayView = new DayView(getContext(), day);
dayView.setOnClickListener(this);
dayView.setOnLongClickListener(this);
dayViews.add(dayView);
addView(dayView, new LayoutParams());
}
protected LocalDate resetAndGetWorkingCalendar() {
final TemporalField firstDayOfWeek = WeekFields.of(this.firstDayOfWeek, 1).dayOfWeek();
final LocalDate temp = getFirstViewDay().getDate().with(firstDayOfWeek, 1);
int dow = temp.getDayOfWeek().getValue();
int delta = getFirstDayOfWeek().getValue() - dow;
//If the delta is positive, we want to remove a week
|
boolean removeRow = showOtherMonths(showOtherDates) ? delta >= 0 : delta > 0;
|
prolificinteractive/material-calendarview
|
library/src/main/java/com/prolificinteractive/materialcalendarview/CalendarPagerView.java
|
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/DayFormatter.java
// public interface DayFormatter {
//
// /**
// * Default format for displaying the day.
// */
// String DEFAULT_FORMAT = "d";
//
// /**
// * Default implementation used by {@linkplain com.prolificinteractive.materialcalendarview.MaterialCalendarView}
// */
// DayFormatter DEFAULT = new DateFormatDayFormatter();
//
// /**
// * Format a given day into a string
// *
// * @param day the day
// * @return a label for the day
// */
// @NonNull String format(@NonNull CalendarDay day);
// }
//
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/WeekDayFormatter.java
// public interface WeekDayFormatter {
// /**
// * Convert a given day of the week into a label.
// *
// * @param dayOfWeek the day of the week as returned by {@linkplain DayOfWeek#getValue()}.
// * @return a label for the day of week.
// */
// CharSequence format(DayOfWeek dayOfWeek);
//
// /**
// * Default implementation used by {@linkplain com.prolificinteractive.materialcalendarview.MaterialCalendarView}
// */
// WeekDayFormatter DEFAULT = new CalendarWeekDayFormatter();
// }
//
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/MaterialCalendarView.java
// public static boolean showOtherMonths(@ShowOtherDates int showOtherDates) {
// return (showOtherDates & SHOW_OTHER_MONTHS) != 0;
// }
|
import android.os.Build;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import com.prolificinteractive.materialcalendarview.MaterialCalendarView.ShowOtherDates;
import com.prolificinteractive.materialcalendarview.format.DayFormatter;
import com.prolificinteractive.materialcalendarview.format.WeekDayFormatter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.threeten.bp.DayOfWeek;
import org.threeten.bp.LocalDate;
import org.threeten.bp.temporal.TemporalField;
import org.threeten.bp.temporal.WeekFields;
import static com.prolificinteractive.materialcalendarview.MaterialCalendarView.SHOW_DEFAULTS;
import static com.prolificinteractive.materialcalendarview.MaterialCalendarView.showOtherMonths;
|
public void setWeekDayTextAppearance(int taId) {
for (WeekDayView weekDayView : weekDayViews) {
weekDayView.setTextAppearance(getContext(), taId);
}
}
public void setDateTextAppearance(int taId) {
for (DayView dayView : dayViews) {
dayView.setTextAppearance(getContext(), taId);
}
}
public void setShowOtherDates(@ShowOtherDates int showFlags) {
this.showOtherDates = showFlags;
updateUi();
}
public void setSelectionEnabled(boolean selectionEnabled) {
for (DayView dayView : dayViews) {
dayView.setOnClickListener(selectionEnabled ? this : null);
dayView.setClickable(selectionEnabled);
}
}
public void setSelectionColor(int color) {
for (DayView dayView : dayViews) {
dayView.setSelectionColor(color);
}
}
|
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/DayFormatter.java
// public interface DayFormatter {
//
// /**
// * Default format for displaying the day.
// */
// String DEFAULT_FORMAT = "d";
//
// /**
// * Default implementation used by {@linkplain com.prolificinteractive.materialcalendarview.MaterialCalendarView}
// */
// DayFormatter DEFAULT = new DateFormatDayFormatter();
//
// /**
// * Format a given day into a string
// *
// * @param day the day
// * @return a label for the day
// */
// @NonNull String format(@NonNull CalendarDay day);
// }
//
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/WeekDayFormatter.java
// public interface WeekDayFormatter {
// /**
// * Convert a given day of the week into a label.
// *
// * @param dayOfWeek the day of the week as returned by {@linkplain DayOfWeek#getValue()}.
// * @return a label for the day of week.
// */
// CharSequence format(DayOfWeek dayOfWeek);
//
// /**
// * Default implementation used by {@linkplain com.prolificinteractive.materialcalendarview.MaterialCalendarView}
// */
// WeekDayFormatter DEFAULT = new CalendarWeekDayFormatter();
// }
//
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/MaterialCalendarView.java
// public static boolean showOtherMonths(@ShowOtherDates int showOtherDates) {
// return (showOtherDates & SHOW_OTHER_MONTHS) != 0;
// }
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/CalendarPagerView.java
import android.os.Build;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import com.prolificinteractive.materialcalendarview.MaterialCalendarView.ShowOtherDates;
import com.prolificinteractive.materialcalendarview.format.DayFormatter;
import com.prolificinteractive.materialcalendarview.format.WeekDayFormatter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.threeten.bp.DayOfWeek;
import org.threeten.bp.LocalDate;
import org.threeten.bp.temporal.TemporalField;
import org.threeten.bp.temporal.WeekFields;
import static com.prolificinteractive.materialcalendarview.MaterialCalendarView.SHOW_DEFAULTS;
import static com.prolificinteractive.materialcalendarview.MaterialCalendarView.showOtherMonths;
public void setWeekDayTextAppearance(int taId) {
for (WeekDayView weekDayView : weekDayViews) {
weekDayView.setTextAppearance(getContext(), taId);
}
}
public void setDateTextAppearance(int taId) {
for (DayView dayView : dayViews) {
dayView.setTextAppearance(getContext(), taId);
}
}
public void setShowOtherDates(@ShowOtherDates int showFlags) {
this.showOtherDates = showFlags;
updateUi();
}
public void setSelectionEnabled(boolean selectionEnabled) {
for (DayView dayView : dayViews) {
dayView.setOnClickListener(selectionEnabled ? this : null);
dayView.setClickable(selectionEnabled);
}
}
public void setSelectionColor(int color) {
for (DayView dayView : dayViews) {
dayView.setSelectionColor(color);
}
}
|
public void setWeekDayFormatter(WeekDayFormatter formatter) {
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.