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
EManual/EManual-Android
app/src/main/java/io/github/emanual/app/ui/adapter/InterviewListAdapter.java
// Path: app/src/main/java/io/github/emanual/app/entity/InterviewJSONEntity.java // public class InterviewJSONEntity extends BaseEntity { // // private String title; // private InterviewInfoEntity info; // // public InterviewInfoEntity getInfo() { // return info; // } // // public void setInfo(InterviewInfoEntity info) { // this.info = info; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // @Override public String toString() { // return "InterviewJSONEntity{" + // "info=" + info + // ", title='" + title + '\'' + // '}'; // } // } // // Path: app/src/main/java/io/github/emanual/app/ui/QuestionListActivity.java // public class QuestionListActivity extends SwipeBackActivity { // public static final String EXTRA_INTERVIEW = "EXTRA_INTERVIEW"; // public static final String EXTRA_INDEX_PAGE = "INDEX_PAGE"; // // InterviewJSONEntity interviewJSONEntity; // ProgressDialog mProgressDialog; // @Bind(R.id.recyclerView) RecyclerView recyclerView; // // @Override protected void initData(Bundle savedInstanceState) { // interviewJSONEntity = (InterviewJSONEntity)getIntent().getSerializableExtra(EXTRA_INTERVIEW); // if(interviewJSONEntity == null){ // finish(); // } // } // // @Override protected void initLayout(Bundle savedInstanceState) { // if(isFinishing()){ // return; // } // // setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // getSupportActionBar().setTitle(R.string.acty_question_list); // // mProgressDialog = new ProgressDialog(getContext()); // mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); // // recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); // // EventBus.getDefault().post(new GetQuestionListEvent(interviewJSONEntity.getInfo().getName())); // } // // @Override protected int getContentViewId() { // return R.layout.acty_question_list; // } // // @Subscribe(threadMode = ThreadMode.Async) // public void onGetQuestionsList(GetQuestionListEvent event){ // List<QuestionEntity> data = InterviewResource.getQuestionList(getContext(), event.getInterviewName()); // EventBus.getDefault().post(new FinishLoadQuestionListEvent(data)); // } // // @Subscribe(threadMode = ThreadMode.MainThread) // public void onFinishLoadQuestionList(FinishLoadQuestionListEvent event){ // recyclerView.setAdapter(new QuestionListAdapter(getContext(), event.getQuestionEntityList())); // } // }
import android.content.Context; import android.content.Intent; import android.net.Uri; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.facebook.drawee.view.SimpleDraweeView; import java.util.List; import butterknife.Bind; import butterknife.ButterKnife; import io.github.emanual.app.R; import io.github.emanual.app.entity.InterviewJSONEntity; import io.github.emanual.app.ui.QuestionListActivity;
package io.github.emanual.app.ui.adapter; /** * Author: jayin * Date: 2/25/16 */ public class InterviewListAdapter extends RecyclerView.Adapter<InterviewListAdapter.ViewHolder>{ Context context; List<InterviewJSONEntity> data; public InterviewListAdapter(Context context, List<InterviewJSONEntity> data){ this.context = context; this.data = data; } public Context getContext() { return context; } public List<InterviewJSONEntity> getData() { return data; } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { return new ViewHolder(LayoutInflater.from(context).inflate(R.layout.adapter_interviewlist, parent, false)); } @Override public void onBindViewHolder(ViewHolder holder, int position) { final InterviewJSONEntity item = data.get(position); holder.tv_name.setText(item.getInfo().getName_cn()); holder.iv_icon.setImageURI(Uri.parse(item.getInfo().getIcon_url())); holder.layout_container.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {
// Path: app/src/main/java/io/github/emanual/app/entity/InterviewJSONEntity.java // public class InterviewJSONEntity extends BaseEntity { // // private String title; // private InterviewInfoEntity info; // // public InterviewInfoEntity getInfo() { // return info; // } // // public void setInfo(InterviewInfoEntity info) { // this.info = info; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // @Override public String toString() { // return "InterviewJSONEntity{" + // "info=" + info + // ", title='" + title + '\'' + // '}'; // } // } // // Path: app/src/main/java/io/github/emanual/app/ui/QuestionListActivity.java // public class QuestionListActivity extends SwipeBackActivity { // public static final String EXTRA_INTERVIEW = "EXTRA_INTERVIEW"; // public static final String EXTRA_INDEX_PAGE = "INDEX_PAGE"; // // InterviewJSONEntity interviewJSONEntity; // ProgressDialog mProgressDialog; // @Bind(R.id.recyclerView) RecyclerView recyclerView; // // @Override protected void initData(Bundle savedInstanceState) { // interviewJSONEntity = (InterviewJSONEntity)getIntent().getSerializableExtra(EXTRA_INTERVIEW); // if(interviewJSONEntity == null){ // finish(); // } // } // // @Override protected void initLayout(Bundle savedInstanceState) { // if(isFinishing()){ // return; // } // // setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // getSupportActionBar().setTitle(R.string.acty_question_list); // // mProgressDialog = new ProgressDialog(getContext()); // mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); // // recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); // // EventBus.getDefault().post(new GetQuestionListEvent(interviewJSONEntity.getInfo().getName())); // } // // @Override protected int getContentViewId() { // return R.layout.acty_question_list; // } // // @Subscribe(threadMode = ThreadMode.Async) // public void onGetQuestionsList(GetQuestionListEvent event){ // List<QuestionEntity> data = InterviewResource.getQuestionList(getContext(), event.getInterviewName()); // EventBus.getDefault().post(new FinishLoadQuestionListEvent(data)); // } // // @Subscribe(threadMode = ThreadMode.MainThread) // public void onFinishLoadQuestionList(FinishLoadQuestionListEvent event){ // recyclerView.setAdapter(new QuestionListAdapter(getContext(), event.getQuestionEntityList())); // } // } // Path: app/src/main/java/io/github/emanual/app/ui/adapter/InterviewListAdapter.java import android.content.Context; import android.content.Intent; import android.net.Uri; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.facebook.drawee.view.SimpleDraweeView; import java.util.List; import butterknife.Bind; import butterknife.ButterKnife; import io.github.emanual.app.R; import io.github.emanual.app.entity.InterviewJSONEntity; import io.github.emanual.app.ui.QuestionListActivity; package io.github.emanual.app.ui.adapter; /** * Author: jayin * Date: 2/25/16 */ public class InterviewListAdapter extends RecyclerView.Adapter<InterviewListAdapter.ViewHolder>{ Context context; List<InterviewJSONEntity> data; public InterviewListAdapter(Context context, List<InterviewJSONEntity> data){ this.context = context; this.data = data; } public Context getContext() { return context; } public List<InterviewJSONEntity> getData() { return data; } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { return new ViewHolder(LayoutInflater.from(context).inflate(R.layout.adapter_interviewlist, parent, false)); } @Override public void onBindViewHolder(ViewHolder holder, int position) { final InterviewJSONEntity item = data.get(position); holder.tv_name.setText(item.getInfo().getName_cn()); holder.iv_icon.setImageURI(Uri.parse(item.getInfo().getIcon_url())); holder.layout_container.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {
Intent intent = new Intent(getContext(), QuestionListActivity.class);
EManual/EManual-Android
app/src/main/java/io/github/emanual/app/utils/InterviewResource.java
// Path: app/src/main/java/io/github/emanual/app/entity/InterviewJSONEntity.java // public class InterviewJSONEntity extends BaseEntity { // // private String title; // private InterviewInfoEntity info; // // public InterviewInfoEntity getInfo() { // return info; // } // // public void setInfo(InterviewInfoEntity info) { // this.info = info; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // @Override public String toString() { // return "InterviewJSONEntity{" + // "info=" + info + // ", title='" + title + '\'' + // '}'; // } // } // // Path: app/src/main/java/io/github/emanual/app/entity/QuestionEntity.java // public class QuestionEntity extends BaseEntity { // /** // * 回答 // */ // private final static String TYPE_REPLY = "reply"; // /** // * 选择 // */ // private final static String TYPE_CHOICE = "choice"; // /** // * 判断 // */ // private final static String TYPE_JUDGMENT = "judgment"; // private String type; // private String tag; // private int difficulty; // private String from; // private String description; // private String answer; // private List<String> options; // // public String getAnswer() { // return answer; // } // // public void setAnswer(String answer) { // this.answer = answer; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // public int getDifficulty() { // return difficulty; // } // // public void setDifficulty(int difficulty) { // this.difficulty = difficulty; // } // // public String getFrom() { // return from; // } // // public void setFrom(String from) { // this.from = from; // } // // public List<String> getOptions() { // return options; // } // // public void setOptions(List<String> options) { // this.options = options; // } // // public String getTag() { // return tag; // } // // public void setTag(String tag) { // this.tag = tag; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // @Override public String toString() { // return "QuestionEntity{" + // "answer='" + answer + '\'' + // ", type='" + type + '\'' + // ", tag='" + tag + '\'' + // ", difficulty=" + difficulty + // ", from='" + from + '\'' + // ", description='" + description + '\'' + // ", options=" + options + // '}'; // } // }
import android.content.Context; import android.util.Log; import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import io.github.emanual.app.entity.InterviewJSONEntity; import io.github.emanual.app.entity.QuestionEntity;
package io.github.emanual.app.utils; /** * Author: jayin * Date: 2/25/16 */ public class InterviewResource { /** * 获取所有interviews/* 所有文件名(英文名)列表 * @param context * @return */ public static List<String> getInterviewNameList(Context context) { List<String> books = new ArrayList<>(); File bookDir = new File(AppPath.getInterviewsPath(context)); if (!bookDir.exists()) { bookDir.mkdirs(); } books.addAll(Arrays.asList(bookDir.list())); return books; } /** * 获取所有interviews/<name>/interview/interview.json * @param context * @return */
// Path: app/src/main/java/io/github/emanual/app/entity/InterviewJSONEntity.java // public class InterviewJSONEntity extends BaseEntity { // // private String title; // private InterviewInfoEntity info; // // public InterviewInfoEntity getInfo() { // return info; // } // // public void setInfo(InterviewInfoEntity info) { // this.info = info; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // @Override public String toString() { // return "InterviewJSONEntity{" + // "info=" + info + // ", title='" + title + '\'' + // '}'; // } // } // // Path: app/src/main/java/io/github/emanual/app/entity/QuestionEntity.java // public class QuestionEntity extends BaseEntity { // /** // * 回答 // */ // private final static String TYPE_REPLY = "reply"; // /** // * 选择 // */ // private final static String TYPE_CHOICE = "choice"; // /** // * 判断 // */ // private final static String TYPE_JUDGMENT = "judgment"; // private String type; // private String tag; // private int difficulty; // private String from; // private String description; // private String answer; // private List<String> options; // // public String getAnswer() { // return answer; // } // // public void setAnswer(String answer) { // this.answer = answer; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // public int getDifficulty() { // return difficulty; // } // // public void setDifficulty(int difficulty) { // this.difficulty = difficulty; // } // // public String getFrom() { // return from; // } // // public void setFrom(String from) { // this.from = from; // } // // public List<String> getOptions() { // return options; // } // // public void setOptions(List<String> options) { // this.options = options; // } // // public String getTag() { // return tag; // } // // public void setTag(String tag) { // this.tag = tag; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // @Override public String toString() { // return "QuestionEntity{" + // "answer='" + answer + '\'' + // ", type='" + type + '\'' + // ", tag='" + tag + '\'' + // ", difficulty=" + difficulty + // ", from='" + from + '\'' + // ", description='" + description + '\'' + // ", options=" + options + // '}'; // } // } // Path: app/src/main/java/io/github/emanual/app/utils/InterviewResource.java import android.content.Context; import android.util.Log; import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import io.github.emanual.app.entity.InterviewJSONEntity; import io.github.emanual.app.entity.QuestionEntity; package io.github.emanual.app.utils; /** * Author: jayin * Date: 2/25/16 */ public class InterviewResource { /** * 获取所有interviews/* 所有文件名(英文名)列表 * @param context * @return */ public static List<String> getInterviewNameList(Context context) { List<String> books = new ArrayList<>(); File bookDir = new File(AppPath.getInterviewsPath(context)); if (!bookDir.exists()) { bookDir.mkdirs(); } books.addAll(Arrays.asList(bookDir.list())); return books; } /** * 获取所有interviews/<name>/interview/interview.json * @param context * @return */
public static List<InterviewJSONEntity> getInterviewJSONList(Context context) {
EManual/EManual-Android
app/src/main/java/io/github/emanual/app/utils/InterviewResource.java
// Path: app/src/main/java/io/github/emanual/app/entity/InterviewJSONEntity.java // public class InterviewJSONEntity extends BaseEntity { // // private String title; // private InterviewInfoEntity info; // // public InterviewInfoEntity getInfo() { // return info; // } // // public void setInfo(InterviewInfoEntity info) { // this.info = info; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // @Override public String toString() { // return "InterviewJSONEntity{" + // "info=" + info + // ", title='" + title + '\'' + // '}'; // } // } // // Path: app/src/main/java/io/github/emanual/app/entity/QuestionEntity.java // public class QuestionEntity extends BaseEntity { // /** // * 回答 // */ // private final static String TYPE_REPLY = "reply"; // /** // * 选择 // */ // private final static String TYPE_CHOICE = "choice"; // /** // * 判断 // */ // private final static String TYPE_JUDGMENT = "judgment"; // private String type; // private String tag; // private int difficulty; // private String from; // private String description; // private String answer; // private List<String> options; // // public String getAnswer() { // return answer; // } // // public void setAnswer(String answer) { // this.answer = answer; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // public int getDifficulty() { // return difficulty; // } // // public void setDifficulty(int difficulty) { // this.difficulty = difficulty; // } // // public String getFrom() { // return from; // } // // public void setFrom(String from) { // this.from = from; // } // // public List<String> getOptions() { // return options; // } // // public void setOptions(List<String> options) { // this.options = options; // } // // public String getTag() { // return tag; // } // // public void setTag(String tag) { // this.tag = tag; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // @Override public String toString() { // return "QuestionEntity{" + // "answer='" + answer + '\'' + // ", type='" + type + '\'' + // ", tag='" + tag + '\'' + // ", difficulty=" + difficulty + // ", from='" + from + '\'' + // ", description='" + description + '\'' + // ", options=" + options + // '}'; // } // }
import android.content.Context; import android.util.Log; import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import io.github.emanual.app.entity.InterviewJSONEntity; import io.github.emanual.app.entity.QuestionEntity;
package io.github.emanual.app.utils; /** * Author: jayin * Date: 2/25/16 */ public class InterviewResource { /** * 获取所有interviews/* 所有文件名(英文名)列表 * @param context * @return */ public static List<String> getInterviewNameList(Context context) { List<String> books = new ArrayList<>(); File bookDir = new File(AppPath.getInterviewsPath(context)); if (!bookDir.exists()) { bookDir.mkdirs(); } books.addAll(Arrays.asList(bookDir.list())); return books; } /** * 获取所有interviews/<name>/interview/interview.json * @param context * @return */ public static List<InterviewJSONEntity> getInterviewJSONList(Context context) { List<InterviewJSONEntity> interviewJSONEntities = new ArrayList<>(); File interviewDir = new File(AppPath.getInterviewsPath(context)); if (!interviewDir.exists()) { interviewDir.mkdirs(); } for (String interviewName : interviewDir.list()) { String json = _.readFile(AppPath.getInterviewJSONFilePath(context, interviewName)); InterviewJSONEntity interviewJSONEntity = InterviewJSONEntity.createByJSON(json, InterviewJSONEntity.class); interviewJSONEntities.add(interviewJSONEntity); } return interviewJSONEntities; } /** * 获取Questions * 获取所有interviews/<name>/interview/questions/*.json * @param context * @param interviewName * @return */
// Path: app/src/main/java/io/github/emanual/app/entity/InterviewJSONEntity.java // public class InterviewJSONEntity extends BaseEntity { // // private String title; // private InterviewInfoEntity info; // // public InterviewInfoEntity getInfo() { // return info; // } // // public void setInfo(InterviewInfoEntity info) { // this.info = info; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // @Override public String toString() { // return "InterviewJSONEntity{" + // "info=" + info + // ", title='" + title + '\'' + // '}'; // } // } // // Path: app/src/main/java/io/github/emanual/app/entity/QuestionEntity.java // public class QuestionEntity extends BaseEntity { // /** // * 回答 // */ // private final static String TYPE_REPLY = "reply"; // /** // * 选择 // */ // private final static String TYPE_CHOICE = "choice"; // /** // * 判断 // */ // private final static String TYPE_JUDGMENT = "judgment"; // private String type; // private String tag; // private int difficulty; // private String from; // private String description; // private String answer; // private List<String> options; // // public String getAnswer() { // return answer; // } // // public void setAnswer(String answer) { // this.answer = answer; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // public int getDifficulty() { // return difficulty; // } // // public void setDifficulty(int difficulty) { // this.difficulty = difficulty; // } // // public String getFrom() { // return from; // } // // public void setFrom(String from) { // this.from = from; // } // // public List<String> getOptions() { // return options; // } // // public void setOptions(List<String> options) { // this.options = options; // } // // public String getTag() { // return tag; // } // // public void setTag(String tag) { // this.tag = tag; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // @Override public String toString() { // return "QuestionEntity{" + // "answer='" + answer + '\'' + // ", type='" + type + '\'' + // ", tag='" + tag + '\'' + // ", difficulty=" + difficulty + // ", from='" + from + '\'' + // ", description='" + description + '\'' + // ", options=" + options + // '}'; // } // } // Path: app/src/main/java/io/github/emanual/app/utils/InterviewResource.java import android.content.Context; import android.util.Log; import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import io.github.emanual.app.entity.InterviewJSONEntity; import io.github.emanual.app.entity.QuestionEntity; package io.github.emanual.app.utils; /** * Author: jayin * Date: 2/25/16 */ public class InterviewResource { /** * 获取所有interviews/* 所有文件名(英文名)列表 * @param context * @return */ public static List<String> getInterviewNameList(Context context) { List<String> books = new ArrayList<>(); File bookDir = new File(AppPath.getInterviewsPath(context)); if (!bookDir.exists()) { bookDir.mkdirs(); } books.addAll(Arrays.asList(bookDir.list())); return books; } /** * 获取所有interviews/<name>/interview/interview.json * @param context * @return */ public static List<InterviewJSONEntity> getInterviewJSONList(Context context) { List<InterviewJSONEntity> interviewJSONEntities = new ArrayList<>(); File interviewDir = new File(AppPath.getInterviewsPath(context)); if (!interviewDir.exists()) { interviewDir.mkdirs(); } for (String interviewName : interviewDir.list()) { String json = _.readFile(AppPath.getInterviewJSONFilePath(context, interviewName)); InterviewJSONEntity interviewJSONEntity = InterviewJSONEntity.createByJSON(json, InterviewJSONEntity.class); interviewJSONEntities.add(interviewJSONEntity); } return interviewJSONEntities; } /** * 获取Questions * 获取所有interviews/<name>/interview/questions/*.json * @param context * @param interviewName * @return */
public static List<QuestionEntity> getQuestionList(Context context, String interviewName){
EManual/EManual-Android
app/src/main/java/io/github/emanual/app/CoreService.java
// Path: app/src/main/java/io/github/emanual/app/api/EmanualAPI.java // public class EmanualAPI { // /** // * 下载对应的语言 // * // * @param lang // * @param responseHandler // */ // @SuppressLint("DefaultLocale") public static void downloadLang(String lang, AsyncHttpResponseHandler responseHandler) { // RestClient.get(String.format("/md-%s/dist/%s.zip", lang.toLowerCase(), lang.toLowerCase()), null, responseHandler); // } // // /** // * 获得最新版本的信息 // * // * @param responseHandler // */ // public static void getVersionInfo(AsyncHttpResponseHandler responseHandler) { // RestClient.get("/md-release/dist/info.json", null, responseHandler); // } // // /** // * 获取对应语言的信息 // * @param lang // * @param responseHandler // */ // public static void getLangInfo(String lang, AsyncHttpResponseHandler responseHandler ){ // RestClient.get(String.format("/md-%s/dist/%s/info.json", lang.toLowerCase(), lang.toLowerCase()), null, responseHandler); // } // // /** // * 获取Book feeds // * @param responseHandler // */ // public static void getBookFeeds(AsyncHttpResponseHandler responseHandler){ // RestClient.get(RestClient.URL_FEEDS,"/feeds-book/feeds/all.min.json", null, responseHandler); // } // // /** // * 获取Interview feeds // * @param responseHandler // */ // public static void getInterviewFeeds(AsyncHttpResponseHandler responseHandler){ // RestClient.get(RestClient.URL_FEEDS,"/feeds-interview/feeds/all.min.json", null, responseHandler); // } // }
import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.util.Log; import com.loopj.android.http.JsonHttpResponseHandler; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import cz.msebera.android.httpclient.Header; import io.github.emanual.app.api.EmanualAPI;
package io.github.emanual.app; public class CoreService extends Service { public static final String Action_CheckVersion = "Action_CheckVersion"; @Override public int onStartCommand(Intent intent, int flags, int startId) { String action = null; if (intent != null) { action = intent.getAction(); } if (action != null) { Log.d("debug", "CoreService-->action-->" + action); if (action.equals(Action_CheckVersion)) { checkVersion(); } } return Service.START_NOT_STICKY; } private void checkVersion() {
// Path: app/src/main/java/io/github/emanual/app/api/EmanualAPI.java // public class EmanualAPI { // /** // * 下载对应的语言 // * // * @param lang // * @param responseHandler // */ // @SuppressLint("DefaultLocale") public static void downloadLang(String lang, AsyncHttpResponseHandler responseHandler) { // RestClient.get(String.format("/md-%s/dist/%s.zip", lang.toLowerCase(), lang.toLowerCase()), null, responseHandler); // } // // /** // * 获得最新版本的信息 // * // * @param responseHandler // */ // public static void getVersionInfo(AsyncHttpResponseHandler responseHandler) { // RestClient.get("/md-release/dist/info.json", null, responseHandler); // } // // /** // * 获取对应语言的信息 // * @param lang // * @param responseHandler // */ // public static void getLangInfo(String lang, AsyncHttpResponseHandler responseHandler ){ // RestClient.get(String.format("/md-%s/dist/%s/info.json", lang.toLowerCase(), lang.toLowerCase()), null, responseHandler); // } // // /** // * 获取Book feeds // * @param responseHandler // */ // public static void getBookFeeds(AsyncHttpResponseHandler responseHandler){ // RestClient.get(RestClient.URL_FEEDS,"/feeds-book/feeds/all.min.json", null, responseHandler); // } // // /** // * 获取Interview feeds // * @param responseHandler // */ // public static void getInterviewFeeds(AsyncHttpResponseHandler responseHandler){ // RestClient.get(RestClient.URL_FEEDS,"/feeds-interview/feeds/all.min.json", null, responseHandler); // } // } // Path: app/src/main/java/io/github/emanual/app/CoreService.java import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.util.Log; import com.loopj.android.http.JsonHttpResponseHandler; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import cz.msebera.android.httpclient.Header; import io.github.emanual.app.api.EmanualAPI; package io.github.emanual.app; public class CoreService extends Service { public static final String Action_CheckVersion = "Action_CheckVersion"; @Override public int onStartCommand(Intent intent, int flags, int startId) { String action = null; if (intent != null) { action = intent.getAction(); } if (action != null) { Log.d("debug", "CoreService-->action-->" + action); if (action.equals(Action_CheckVersion)) { checkVersion(); } } return Service.START_NOT_STICKY; } private void checkVersion() {
EmanualAPI.getVersionInfo(new JsonHttpResponseHandler() {
EManual/EManual-Android
app/src/main/java/io/github/emanual/app/ui/adapter/ArticleListAdapter.java
// Path: app/src/main/java/io/github/emanual/app/utils/ParseUtils.java // public class ParseUtils { // // public static int getArticleId(String filename) { // return Integer.parseInt(filename.split("-")[0]); // } // // // [(2013-1-1,0010)]title].md // public static String getArticleName(String filename) { // String[] s = filename.replaceAll("\\.[Mm]{1}[Dd]{1}", "").split("-"); // //这是日期开头 // if (_.isNumber(s[0]) && _.isNumber(s[1]) && _.isNumber(s[2])) { // return s[3]; // } else { //这是文章编号 // return s[1]; // } // } // // // http:xxxxx/assets/preview.html?path=/a/b/[(2013-1-1,0010)]title].md // // public static String getArticleNameByUrl(String url) { // // String[] s = url.split("=")[1].split("/"); // // return getArticleName(s[s.length - 1]); // // } // // // http:xxxxx/a/b/[(2013-1-1,0010)]title].md // public static String getArticleNameByUrl(String url) { // String[] s = url.split("/"); // return getArticleName(s[s.length - 1]); // } // // public static String encodeArticleURL(String url) { // try { // StringBuilder sb = new StringBuilder(RestClient.URL_Preview // + "?path="); // for (String s : url.split("=")[1].split("/")) { // sb.append(URLEncoder.encode(s, "UTF-8")).append("/"); // } // sb.deleteCharAt(sb.length() - 1); // return sb.toString(); // } catch (UnsupportedEncodingException e) { // e.printStackTrace(); // } // return url; // } // }
import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.TextView; import java.util.List; import butterknife.Bind; import butterknife.ButterKnife; import io.github.emanual.app.R; import io.github.emanual.app.utils.ParseUtils;
this.context = context; } @Override public int getCount() { return data.size(); } @Override public Object getItem(int position) { return data.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder h = null; if (convertView == null) { convertView = LayoutInflater.from(context).inflate( R.layout.adapter_articlelist, null); h = new ViewHolder(convertView); convertView.setTag(h); } else { h = (ViewHolder) convertView.getTag(); }
// Path: app/src/main/java/io/github/emanual/app/utils/ParseUtils.java // public class ParseUtils { // // public static int getArticleId(String filename) { // return Integer.parseInt(filename.split("-")[0]); // } // // // [(2013-1-1,0010)]title].md // public static String getArticleName(String filename) { // String[] s = filename.replaceAll("\\.[Mm]{1}[Dd]{1}", "").split("-"); // //这是日期开头 // if (_.isNumber(s[0]) && _.isNumber(s[1]) && _.isNumber(s[2])) { // return s[3]; // } else { //这是文章编号 // return s[1]; // } // } // // // http:xxxxx/assets/preview.html?path=/a/b/[(2013-1-1,0010)]title].md // // public static String getArticleNameByUrl(String url) { // // String[] s = url.split("=")[1].split("/"); // // return getArticleName(s[s.length - 1]); // // } // // // http:xxxxx/a/b/[(2013-1-1,0010)]title].md // public static String getArticleNameByUrl(String url) { // String[] s = url.split("/"); // return getArticleName(s[s.length - 1]); // } // // public static String encodeArticleURL(String url) { // try { // StringBuilder sb = new StringBuilder(RestClient.URL_Preview // + "?path="); // for (String s : url.split("=")[1].split("/")) { // sb.append(URLEncoder.encode(s, "UTF-8")).append("/"); // } // sb.deleteCharAt(sb.length() - 1); // return sb.toString(); // } catch (UnsupportedEncodingException e) { // e.printStackTrace(); // } // return url; // } // } // Path: app/src/main/java/io/github/emanual/app/ui/adapter/ArticleListAdapter.java import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.TextView; import java.util.List; import butterknife.Bind; import butterknife.ButterKnife; import io.github.emanual.app.R; import io.github.emanual.app.utils.ParseUtils; this.context = context; } @Override public int getCount() { return data.size(); } @Override public Object getItem(int position) { return data.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder h = null; if (convertView == null) { convertView = LayoutInflater.from(context).inflate( R.layout.adapter_articlelist, null); h = new ViewHolder(convertView); convertView.setTag(h); } else { h = (ViewHolder) convertView.getTag(); }
h.title.setText(ParseUtils.getArticleName(data.get(position)));
EManual/EManual-Android
app/src/main/java/io/github/emanual/app/ui/base/activity/BaseActivity.java
// Path: app/src/main/java/io/github/emanual/app/ui/event/EmptyEvent.java // public class EmptyEvent extends BaseEvent { // String message; // // public EmptyEvent(String message) { // this.message = message; // } // }
import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.design.widget.Snackbar; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.MenuItem; import android.widget.Toast; import com.umeng.analytics.MobclickAgent; import java.io.Serializable; import butterknife.ButterKnife; import de.greenrobot.event.EventBus; import de.greenrobot.event.Subscribe; import io.github.emanual.app.R; import io.github.emanual.app.ui.event.EmptyEvent;
package io.github.emanual.app.ui.base.activity; public abstract class BaseActivity extends AppCompatActivity { protected abstract void initData(Bundle savedInstanceState); protected abstract void initLayout(Bundle savedInstanceState); protected abstract int getContentViewId(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(getContentViewId()); ButterKnife.bind(this); if(!EventBus.getDefault().isRegistered(this)){ EventBus.getDefault().register(this); } initData(savedInstanceState); initLayout(savedInstanceState); } /** * EventBus 3必须要有一个@Subscribe */ @Subscribe
// Path: app/src/main/java/io/github/emanual/app/ui/event/EmptyEvent.java // public class EmptyEvent extends BaseEvent { // String message; // // public EmptyEvent(String message) { // this.message = message; // } // } // Path: app/src/main/java/io/github/emanual/app/ui/base/activity/BaseActivity.java import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.design.widget.Snackbar; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.MenuItem; import android.widget.Toast; import com.umeng.analytics.MobclickAgent; import java.io.Serializable; import butterknife.ButterKnife; import de.greenrobot.event.EventBus; import de.greenrobot.event.Subscribe; import io.github.emanual.app.R; import io.github.emanual.app.ui.event.EmptyEvent; package io.github.emanual.app.ui.base.activity; public abstract class BaseActivity extends AppCompatActivity { protected abstract void initData(Bundle savedInstanceState); protected abstract void initLayout(Bundle savedInstanceState); protected abstract int getContentViewId(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(getContentViewId()); ButterKnife.bind(this); if(!EventBus.getDefault().isRegistered(this)){ EventBus.getDefault().register(this); } initData(savedInstanceState); initLayout(savedInstanceState); } /** * EventBus 3必须要有一个@Subscribe */ @Subscribe
public void onEmpty(EmptyEvent event){
EManual/EManual-Android
app/src/main/java/io/github/emanual/app/utils/BookResource.java
// Path: app/src/main/java/io/github/emanual/app/entity/BookJSONEntity.java // public class BookJSONEntity extends BaseEntity implements Serializable { // private String title; // private BookInfoEntity info; // // public BookInfoEntity getInfo() { // return info; // } // // public void setInfo(BookInfoEntity info) { // this.info = info; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // }
import android.content.Context; import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import io.github.emanual.app.entity.BookJSONEntity;
package io.github.emanual.app.utils; /** * Author: jayin * Date: 1/23/16 */ public class BookResource { /** * 获取所有books/* 所有文件名(英文书名)列表 * @param context * @return */ public static List<String> getBookNameList(Context context) { List<String> books = new ArrayList<>(); File bookDir = new File(AppPath.getBooksPath(context)); if (!bookDir.exists()) { bookDir.mkdirs(); } books.addAll(Arrays.asList(bookDir.list())); return books; } /** * 获取所有books/<bookName>/book/book.json * @param context * @return */
// Path: app/src/main/java/io/github/emanual/app/entity/BookJSONEntity.java // public class BookJSONEntity extends BaseEntity implements Serializable { // private String title; // private BookInfoEntity info; // // public BookInfoEntity getInfo() { // return info; // } // // public void setInfo(BookInfoEntity info) { // this.info = info; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // } // Path: app/src/main/java/io/github/emanual/app/utils/BookResource.java import android.content.Context; import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import io.github.emanual.app.entity.BookJSONEntity; package io.github.emanual.app.utils; /** * Author: jayin * Date: 1/23/16 */ public class BookResource { /** * 获取所有books/* 所有文件名(英文书名)列表 * @param context * @return */ public static List<String> getBookNameList(Context context) { List<String> books = new ArrayList<>(); File bookDir = new File(AppPath.getBooksPath(context)); if (!bookDir.exists()) { bookDir.mkdirs(); } books.addAll(Arrays.asList(bookDir.list())); return books; } /** * 获取所有books/<bookName>/book/book.json * @param context * @return */
public static List<BookJSONEntity> getBookJSONList(Context context) {
EManual/EManual-Android
app/src/main/java/io/github/emanual/app/App.java
// Path: app/src/main/java/io/github/emanual/app/api/RestClient.java // public class RestClient { // //http://localhost:63342/examples/EManual // // public static final String BASE_URL = "http://192.168.0.105:8080"; // main // // public static final String BASE_URL ="http://192.168.199.221:8081"; // //http://jayin.github.io/EManual // public static final String BASE_URL = "http://emanual.github.io"; // public static final String URL_Preview = BASE_URL + "/assets/preview.html"; // public static final String URL_NewsFeeds = BASE_URL + "/md-newsfeeds/dist/%s"; // public static final String URL_Java = BASE_URL + "/java"; // public static final String URL_FEEDS = " http://emanualresource.github.io"; // private static int HTTP_Timeout = 12 * 1000; // public static Context context; // // private static AsyncHttpClient client; // // public static AsyncHttpClient getHttpClient() { // if (client == null) { // client = new AsyncHttpClient(); // } // return client; // } // // /** // * 初始化:如果需要调用登录验证记录session的函数前,必须调用这个方法,否则请求失败 // * // * @param context Activity or Application context // */ // public static void init(Context context) { // RestClient.context = context; // client = getHttpClient(); // } // // /** // * get method // * // * @param url 相对的url // * @param params // * @param responseHandler // */ // public static void get(String url, RequestParams params, // AsyncHttpResponseHandler responseHandler) { // get(BASE_URL, url, params, responseHandler); // } // // public static void get(String baseUrl, String url, RequestParams params, // AsyncHttpResponseHandler responseHandler) { // initClient(); // client.get(baseUrl + url, params, responseHandler); // } // // /** // * post method // * // * @param url // * @param params // * @param responseHandler // */ // public static void post(String url, RequestParams params, // AsyncHttpResponseHandler responseHandler) { // initClient(); // client.post(getAbsoluteUrl(url), params, responseHandler); // // } // // /** // * 请求前初始化<br> // * 必须在请求之前初始化,不然cookie失效<br> // * context不为空时带着cookie去访问<br> // */ // private static void initClient() { // if (context != null) // client.setCookieStore(new PersistentCookieStore(context)); // client.setTimeout(HTTP_Timeout); // client.setEnableRedirects(true); // } // // /** // * 获得绝对url // * // * @param relativeUrl // * @return // */ // private static String getAbsoluteUrl(String relativeUrl) { // return BASE_URL + relativeUrl; // } // }
import android.app.Application; import android.os.Build; import android.util.Log; import android.webkit.WebView; import com.avos.avoscloud.AVOSCloud; import com.beardedhen.androidbootstrap.TypefaceProvider; import com.facebook.drawee.backends.pipeline.Fresco; import io.github.emanual.app.api.RestClient; import timber.log.Timber;
package io.github.emanual.app; public class App extends Application { private final String LeanCloud_App_Id = "7hyoc6are05n823dd424ywvf752gem2w96inlkl3yiann6vw"; private final String LeanCloud_App_Key = "tgufkdybjtb4gvsbwcatiwd9wx49adxrmf8qkpwunh0h3wx3"; @Override public void onCreate() { super.onCreate();
// Path: app/src/main/java/io/github/emanual/app/api/RestClient.java // public class RestClient { // //http://localhost:63342/examples/EManual // // public static final String BASE_URL = "http://192.168.0.105:8080"; // main // // public static final String BASE_URL ="http://192.168.199.221:8081"; // //http://jayin.github.io/EManual // public static final String BASE_URL = "http://emanual.github.io"; // public static final String URL_Preview = BASE_URL + "/assets/preview.html"; // public static final String URL_NewsFeeds = BASE_URL + "/md-newsfeeds/dist/%s"; // public static final String URL_Java = BASE_URL + "/java"; // public static final String URL_FEEDS = " http://emanualresource.github.io"; // private static int HTTP_Timeout = 12 * 1000; // public static Context context; // // private static AsyncHttpClient client; // // public static AsyncHttpClient getHttpClient() { // if (client == null) { // client = new AsyncHttpClient(); // } // return client; // } // // /** // * 初始化:如果需要调用登录验证记录session的函数前,必须调用这个方法,否则请求失败 // * // * @param context Activity or Application context // */ // public static void init(Context context) { // RestClient.context = context; // client = getHttpClient(); // } // // /** // * get method // * // * @param url 相对的url // * @param params // * @param responseHandler // */ // public static void get(String url, RequestParams params, // AsyncHttpResponseHandler responseHandler) { // get(BASE_URL, url, params, responseHandler); // } // // public static void get(String baseUrl, String url, RequestParams params, // AsyncHttpResponseHandler responseHandler) { // initClient(); // client.get(baseUrl + url, params, responseHandler); // } // // /** // * post method // * // * @param url // * @param params // * @param responseHandler // */ // public static void post(String url, RequestParams params, // AsyncHttpResponseHandler responseHandler) { // initClient(); // client.post(getAbsoluteUrl(url), params, responseHandler); // // } // // /** // * 请求前初始化<br> // * 必须在请求之前初始化,不然cookie失效<br> // * context不为空时带着cookie去访问<br> // */ // private static void initClient() { // if (context != null) // client.setCookieStore(new PersistentCookieStore(context)); // client.setTimeout(HTTP_Timeout); // client.setEnableRedirects(true); // } // // /** // * 获得绝对url // * // * @param relativeUrl // * @return // */ // private static String getAbsoluteUrl(String relativeUrl) { // return BASE_URL + relativeUrl; // } // } // Path: app/src/main/java/io/github/emanual/app/App.java import android.app.Application; import android.os.Build; import android.util.Log; import android.webkit.WebView; import com.avos.avoscloud.AVOSCloud; import com.beardedhen.androidbootstrap.TypefaceProvider; import com.facebook.drawee.backends.pipeline.Fresco; import io.github.emanual.app.api.RestClient; import timber.log.Timber; package io.github.emanual.app; public class App extends Application { private final String LeanCloud_App_Id = "7hyoc6are05n823dd424ywvf752gem2w96inlkl3yiann6vw"; private final String LeanCloud_App_Key = "tgufkdybjtb4gvsbwcatiwd9wx49adxrmf8qkpwunh0h3wx3"; @Override public void onCreate() { super.onCreate();
RestClient.init(getApplicationContext());
EManual/EManual-Android
app/src/main/java/io/github/emanual/app/ui/base/fragment/BaseFragment.java
// Path: app/src/main/java/io/github/emanual/app/ui/event/EmptyEvent.java // public class EmptyEvent extends BaseEvent { // String message; // // public EmptyEvent(String message) { // this.message = message; // } // }
import android.os.Bundle; import android.support.annotation.Nullable; import android.support.design.widget.Snackbar; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Toast; import butterknife.ButterKnife; import de.greenrobot.event.EventBus; import de.greenrobot.event.Subscribe; import io.github.emanual.app.R; import io.github.emanual.app.ui.event.EmptyEvent;
package io.github.emanual.app.ui.base.fragment; public abstract class BaseFragment extends Fragment { /** * EventBus 3必须要有一个@Subscribe */ @Subscribe
// Path: app/src/main/java/io/github/emanual/app/ui/event/EmptyEvent.java // public class EmptyEvent extends BaseEvent { // String message; // // public EmptyEvent(String message) { // this.message = message; // } // } // Path: app/src/main/java/io/github/emanual/app/ui/base/fragment/BaseFragment.java import android.os.Bundle; import android.support.annotation.Nullable; import android.support.design.widget.Snackbar; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Toast; import butterknife.ButterKnife; import de.greenrobot.event.EventBus; import de.greenrobot.event.Subscribe; import io.github.emanual.app.R; import io.github.emanual.app.ui.event.EmptyEvent; package io.github.emanual.app.ui.base.fragment; public abstract class BaseFragment extends Fragment { /** * EventBus 3必须要有一个@Subscribe */ @Subscribe
public void onEmpty(EmptyEvent event){
oxoooo/mr-mantou-android
app/src/main/java/ooo/oxo/mr/MrSharedState.java
// Path: app/src/main/java/ooo/oxo/mr/model/Image.java // @AVClassName("Image") // public class Image extends AVObject { // // public static final Creator CREATOR = AVObjectCreator.instance; // // private static final String PUBLISHED_AT = "publishedAt"; // // private static final String FILE = "file"; // // private static final String META = "meta"; // // private static final String META_TYPE = "type"; // private static final String META_WIDTH = "width"; // private static final String META_HEIGHT = "height"; // // @SuppressWarnings("unused") // public Image() { // super(); // } // // @SuppressWarnings("unused") // public Image(Parcel in) { // super(in); // } // // public static AVQuery<Image> all() { // return AVObject.getQuery(Image.class) // .orderByDescending(PUBLISHED_AT); // } // // public static AVQuery<Image> since(Image image) { // return AVObject.getQuery(Image.class) // .whereGreaterThan(PUBLISHED_AT, image.getPublishedAt()) // .orderByDescending(PUBLISHED_AT); // } // // public Date getPublishedAt() { // return getDate(PUBLISHED_AT); // } // // public AVFile getFile() { // return getAVFile(FILE); // } // // public String getUrl() { // return getFile().getUrl(); // } // // public String getUrl(int width) { // return QiniuUtil.getUrl(getFile(), width); // } // // public String getMime() { // return getString("mime"); // } // // @SuppressWarnings("unchecked") // public Map<String, Object> getMeta() { // return getMap(META); // } // // public String getType() { // return (String) getMeta().get(META_TYPE); // } // // public int getWidth() { // return (Integer) getMeta().get(META_WIDTH); // } // // public int getHeight() { // return (Integer) getMeta().get(META_HEIGHT); // } // // }
import android.databinding.ObservableArrayList; import ooo.oxo.mr.model.Image;
/* * Mr.Mantou - On the importance of taste * Copyright (C) 2015-2016 XiNGRZ <xxx@oxo.ooo> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package ooo.oxo.mr; public class MrSharedState { private static MrSharedState instance;
// Path: app/src/main/java/ooo/oxo/mr/model/Image.java // @AVClassName("Image") // public class Image extends AVObject { // // public static final Creator CREATOR = AVObjectCreator.instance; // // private static final String PUBLISHED_AT = "publishedAt"; // // private static final String FILE = "file"; // // private static final String META = "meta"; // // private static final String META_TYPE = "type"; // private static final String META_WIDTH = "width"; // private static final String META_HEIGHT = "height"; // // @SuppressWarnings("unused") // public Image() { // super(); // } // // @SuppressWarnings("unused") // public Image(Parcel in) { // super(in); // } // // public static AVQuery<Image> all() { // return AVObject.getQuery(Image.class) // .orderByDescending(PUBLISHED_AT); // } // // public static AVQuery<Image> since(Image image) { // return AVObject.getQuery(Image.class) // .whereGreaterThan(PUBLISHED_AT, image.getPublishedAt()) // .orderByDescending(PUBLISHED_AT); // } // // public Date getPublishedAt() { // return getDate(PUBLISHED_AT); // } // // public AVFile getFile() { // return getAVFile(FILE); // } // // public String getUrl() { // return getFile().getUrl(); // } // // public String getUrl(int width) { // return QiniuUtil.getUrl(getFile(), width); // } // // public String getMime() { // return getString("mime"); // } // // @SuppressWarnings("unchecked") // public Map<String, Object> getMeta() { // return getMap(META); // } // // public String getType() { // return (String) getMeta().get(META_TYPE); // } // // public int getWidth() { // return (Integer) getMeta().get(META_WIDTH); // } // // public int getHeight() { // return (Integer) getMeta().get(META_HEIGHT); // } // // } // Path: app/src/main/java/ooo/oxo/mr/MrSharedState.java import android.databinding.ObservableArrayList; import ooo.oxo.mr.model.Image; /* * Mr.Mantou - On the importance of taste * Copyright (C) 2015-2016 XiNGRZ <xxx@oxo.ooo> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package ooo.oxo.mr; public class MrSharedState { private static MrSharedState instance;
private final ObservableArrayList<Image> images = new ObservableArrayList<>();
oxoooo/mr-mantou-android
app/src/main/java/ooo/oxo/mr/widget/InsetsScrollingViewBehavior.java
// Path: app/src/main/java/ooo/oxo/mr/view/WindowInsetsHelper.java // public class WindowInsetsHelper { // // public static boolean onApplyWindowInsets(View view, Rect insets) { // return view instanceof WindowInsetsHandler && // ((WindowInsetsHandler) view).onApplyWindowInsets(insets); // } // // public static boolean dispatchApplyWindowInsets(ViewGroup parent, Rect insets) { // final int count = parent.getChildCount(); // // for (int i = 0; i < count; i++) { // if (onApplyWindowInsets(parent.getChildAt(i), insets)) { // return true; // } // } // // return false; // } // // }
import android.content.Context; import android.graphics.Rect; import android.support.annotation.Keep; import android.support.design.widget.AppBarLayout; import android.support.design.widget.CoordinatorLayout; import android.support.v4.view.ViewCompat; import android.support.v4.view.WindowInsetsCompat; import android.util.AttributeSet; import android.view.View; import ooo.oxo.mr.view.WindowInsetsHelper;
/* * Mr.Mantou - On the importance of taste * Copyright (C) 2015-2016 XiNGRZ <xxx@oxo.ooo> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package ooo.oxo.mr.widget; @Keep @SuppressWarnings("unused") public class InsetsScrollingViewBehavior extends AppBarLayout.ScrollingViewBehavior implements InsetsCoordinatorLayout.WindowInsetsHandlingBehavior { public InsetsScrollingViewBehavior() { } public InsetsScrollingViewBehavior(Context context, AttributeSet attrs) { super(context, attrs); } @Override public WindowInsetsCompat onApplyWindowInsets(CoordinatorLayout layout, View child, WindowInsetsCompat insets) { return ViewCompat.onApplyWindowInsets(child, insets); } @Override public boolean onApplyWindowInsets(CoordinatorLayout layout, View child, Rect insets) {
// Path: app/src/main/java/ooo/oxo/mr/view/WindowInsetsHelper.java // public class WindowInsetsHelper { // // public static boolean onApplyWindowInsets(View view, Rect insets) { // return view instanceof WindowInsetsHandler && // ((WindowInsetsHandler) view).onApplyWindowInsets(insets); // } // // public static boolean dispatchApplyWindowInsets(ViewGroup parent, Rect insets) { // final int count = parent.getChildCount(); // // for (int i = 0; i < count; i++) { // if (onApplyWindowInsets(parent.getChildAt(i), insets)) { // return true; // } // } // // return false; // } // // } // Path: app/src/main/java/ooo/oxo/mr/widget/InsetsScrollingViewBehavior.java import android.content.Context; import android.graphics.Rect; import android.support.annotation.Keep; import android.support.design.widget.AppBarLayout; import android.support.design.widget.CoordinatorLayout; import android.support.v4.view.ViewCompat; import android.support.v4.view.WindowInsetsCompat; import android.util.AttributeSet; import android.view.View; import ooo.oxo.mr.view.WindowInsetsHelper; /* * Mr.Mantou - On the importance of taste * Copyright (C) 2015-2016 XiNGRZ <xxx@oxo.ooo> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package ooo.oxo.mr.widget; @Keep @SuppressWarnings("unused") public class InsetsScrollingViewBehavior extends AppBarLayout.ScrollingViewBehavior implements InsetsCoordinatorLayout.WindowInsetsHandlingBehavior { public InsetsScrollingViewBehavior() { } public InsetsScrollingViewBehavior(Context context, AttributeSet attrs) { super(context, attrs); } @Override public WindowInsetsCompat onApplyWindowInsets(CoordinatorLayout layout, View child, WindowInsetsCompat insets) { return ViewCompat.onApplyWindowInsets(child, insets); } @Override public boolean onApplyWindowInsets(CoordinatorLayout layout, View child, Rect insets) {
return WindowInsetsHelper.onApplyWindowInsets(child, insets);
oxoooo/mr-mantou-android
app/src/main/java/ooo/oxo/mr/widget/InsetsAppBarLayout.java
// Path: app/src/main/java/ooo/oxo/mr/view/WindowInsetsHandler.java // public interface WindowInsetsHandler { // // boolean onApplyWindowInsets(Rect insets); // // } // // Path: app/src/main/java/ooo/oxo/mr/view/WindowInsetsHelper.java // public class WindowInsetsHelper { // // public static boolean onApplyWindowInsets(View view, Rect insets) { // return view instanceof WindowInsetsHandler && // ((WindowInsetsHandler) view).onApplyWindowInsets(insets); // } // // public static boolean dispatchApplyWindowInsets(ViewGroup parent, Rect insets) { // final int count = parent.getChildCount(); // // for (int i = 0; i < count; i++) { // if (onApplyWindowInsets(parent.getChildAt(i), insets)) { // return true; // } // } // // return false; // } // // }
import android.content.Context; import android.graphics.Rect; import android.support.design.widget.AppBarLayout; import android.support.design.widget.CoordinatorLayout; import android.util.AttributeSet; import android.view.View; import ooo.oxo.mr.view.WindowInsetsHandler; import ooo.oxo.mr.view.WindowInsetsHelper;
/* * Mr.Mantou - On the importance of taste * Copyright (C) 2015-2016 XiNGRZ <xxx@oxo.ooo> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package ooo.oxo.mr.widget; @CoordinatorLayout.DefaultBehavior(InsetsAppBarLayout.Behavior.class) public class InsetsAppBarLayout extends AppBarLayout implements WindowInsetsHandler { public InsetsAppBarLayout(Context context) { super(context); } public InsetsAppBarLayout(Context context, AttributeSet attrs) { super(context, attrs); } @Override public boolean onApplyWindowInsets(Rect insets) {
// Path: app/src/main/java/ooo/oxo/mr/view/WindowInsetsHandler.java // public interface WindowInsetsHandler { // // boolean onApplyWindowInsets(Rect insets); // // } // // Path: app/src/main/java/ooo/oxo/mr/view/WindowInsetsHelper.java // public class WindowInsetsHelper { // // public static boolean onApplyWindowInsets(View view, Rect insets) { // return view instanceof WindowInsetsHandler && // ((WindowInsetsHandler) view).onApplyWindowInsets(insets); // } // // public static boolean dispatchApplyWindowInsets(ViewGroup parent, Rect insets) { // final int count = parent.getChildCount(); // // for (int i = 0; i < count; i++) { // if (onApplyWindowInsets(parent.getChildAt(i), insets)) { // return true; // } // } // // return false; // } // // } // Path: app/src/main/java/ooo/oxo/mr/widget/InsetsAppBarLayout.java import android.content.Context; import android.graphics.Rect; import android.support.design.widget.AppBarLayout; import android.support.design.widget.CoordinatorLayout; import android.util.AttributeSet; import android.view.View; import ooo.oxo.mr.view.WindowInsetsHandler; import ooo.oxo.mr.view.WindowInsetsHelper; /* * Mr.Mantou - On the importance of taste * Copyright (C) 2015-2016 XiNGRZ <xxx@oxo.ooo> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package ooo.oxo.mr.widget; @CoordinatorLayout.DefaultBehavior(InsetsAppBarLayout.Behavior.class) public class InsetsAppBarLayout extends AppBarLayout implements WindowInsetsHandler { public InsetsAppBarLayout(Context context) { super(context); } public InsetsAppBarLayout(Context context, AttributeSet attrs) { super(context, attrs); } @Override public boolean onApplyWindowInsets(Rect insets) {
return WindowInsetsHelper.dispatchApplyWindowInsets(this, insets);
oxoooo/mr-mantou-android
app/src/main/java/ooo/oxo/mr/MrApplication.java
// Path: app/src/main/java/ooo/oxo/mr/model/Image.java // @AVClassName("Image") // public class Image extends AVObject { // // public static final Creator CREATOR = AVObjectCreator.instance; // // private static final String PUBLISHED_AT = "publishedAt"; // // private static final String FILE = "file"; // // private static final String META = "meta"; // // private static final String META_TYPE = "type"; // private static final String META_WIDTH = "width"; // private static final String META_HEIGHT = "height"; // // @SuppressWarnings("unused") // public Image() { // super(); // } // // @SuppressWarnings("unused") // public Image(Parcel in) { // super(in); // } // // public static AVQuery<Image> all() { // return AVObject.getQuery(Image.class) // .orderByDescending(PUBLISHED_AT); // } // // public static AVQuery<Image> since(Image image) { // return AVObject.getQuery(Image.class) // .whereGreaterThan(PUBLISHED_AT, image.getPublishedAt()) // .orderByDescending(PUBLISHED_AT); // } // // public Date getPublishedAt() { // return getDate(PUBLISHED_AT); // } // // public AVFile getFile() { // return getAVFile(FILE); // } // // public String getUrl() { // return getFile().getUrl(); // } // // public String getUrl(int width) { // return QiniuUtil.getUrl(getFile(), width); // } // // public String getMime() { // return getString("mime"); // } // // @SuppressWarnings("unchecked") // public Map<String, Object> getMeta() { // return getMap(META); // } // // public String getType() { // return (String) getMeta().get(META_TYPE); // } // // public int getWidth() { // return (Integer) getMeta().get(META_WIDTH); // } // // public int getHeight() { // return (Integer) getMeta().get(META_HEIGHT); // } // // }
import android.app.Application; import android.content.Context; import com.avos.avoscloud.AVOSCloud; import com.avos.avoscloud.AVObject; import com.umeng.analytics.MobclickAgent; import im.fir.sdk.FIR; import ooo.oxo.mr.model.Image;
/* * Mr.Mantou - On the importance of taste * Copyright (C) 2015-2016 XiNGRZ <xxx@oxo.ooo> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package ooo.oxo.mr; public class MrApplication extends Application { public static MrApplication from(Context context) { Context application = context.getApplicationContext(); if (application instanceof MrApplication) { return (MrApplication) application; } else { throw new IllegalArgumentException("context must be from MrApplication"); } } @Override public void onCreate() { super.onCreate(); MobclickAgent.setDebugMode(BuildConfig.DEBUG); MobclickAgent.setCatchUncaughtExceptions(false); if (BuildConfig.FIR_ENABLED) { FIR.init(this); } MrSharedState.createInstance();
// Path: app/src/main/java/ooo/oxo/mr/model/Image.java // @AVClassName("Image") // public class Image extends AVObject { // // public static final Creator CREATOR = AVObjectCreator.instance; // // private static final String PUBLISHED_AT = "publishedAt"; // // private static final String FILE = "file"; // // private static final String META = "meta"; // // private static final String META_TYPE = "type"; // private static final String META_WIDTH = "width"; // private static final String META_HEIGHT = "height"; // // @SuppressWarnings("unused") // public Image() { // super(); // } // // @SuppressWarnings("unused") // public Image(Parcel in) { // super(in); // } // // public static AVQuery<Image> all() { // return AVObject.getQuery(Image.class) // .orderByDescending(PUBLISHED_AT); // } // // public static AVQuery<Image> since(Image image) { // return AVObject.getQuery(Image.class) // .whereGreaterThan(PUBLISHED_AT, image.getPublishedAt()) // .orderByDescending(PUBLISHED_AT); // } // // public Date getPublishedAt() { // return getDate(PUBLISHED_AT); // } // // public AVFile getFile() { // return getAVFile(FILE); // } // // public String getUrl() { // return getFile().getUrl(); // } // // public String getUrl(int width) { // return QiniuUtil.getUrl(getFile(), width); // } // // public String getMime() { // return getString("mime"); // } // // @SuppressWarnings("unchecked") // public Map<String, Object> getMeta() { // return getMap(META); // } // // public String getType() { // return (String) getMeta().get(META_TYPE); // } // // public int getWidth() { // return (Integer) getMeta().get(META_WIDTH); // } // // public int getHeight() { // return (Integer) getMeta().get(META_HEIGHT); // } // // } // Path: app/src/main/java/ooo/oxo/mr/MrApplication.java import android.app.Application; import android.content.Context; import com.avos.avoscloud.AVOSCloud; import com.avos.avoscloud.AVObject; import com.umeng.analytics.MobclickAgent; import im.fir.sdk.FIR; import ooo.oxo.mr.model.Image; /* * Mr.Mantou - On the importance of taste * Copyright (C) 2015-2016 XiNGRZ <xxx@oxo.ooo> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package ooo.oxo.mr; public class MrApplication extends Application { public static MrApplication from(Context context) { Context application = context.getApplicationContext(); if (application instanceof MrApplication) { return (MrApplication) application; } else { throw new IllegalArgumentException("context must be from MrApplication"); } } @Override public void onCreate() { super.onCreate(); MobclickAgent.setDebugMode(BuildConfig.DEBUG); MobclickAgent.setCatchUncaughtExceptions(false); if (BuildConfig.FIR_ENABLED) { FIR.init(this); } MrSharedState.createInstance();
AVObject.registerSubclass(Image.class);
oxoooo/mr-mantou-android
app/src/main/java/ooo/oxo/mr/binding/RatioImageViewBindingUtil.java
// Path: app/src/main/java/ooo/oxo/mr/widget/RatioImageView.java // public class RatioImageView extends ImageView { // // private int originalWidth; // private int originalHeight; // // public RatioImageView(Context context) { // this(context, null); // } // // public RatioImageView(Context context, AttributeSet attrs) { // this(context, attrs, 0); // } // // public RatioImageView(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // } // // public void setOriginalSize(int originalWidth, int originalHeight) { // this.originalWidth = originalWidth; // this.originalHeight = originalHeight; // } // // @Override // protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // if (originalWidth > 0 && originalHeight > 0) { // float ratio = (float) originalWidth / (float) originalHeight; // // int width = MeasureSpec.getSize(widthMeasureSpec); // int height = MeasureSpec.getSize(heightMeasureSpec); // // if (width > 0) { // height = (int) ((float) width / ratio); // } else if (height > 0) { // width = (int) ((float) height * ratio); // } // // setMeasuredDimension(width, height); // } else { // super.onMeasure(widthMeasureSpec, heightMeasureSpec); // } // } // // }
import android.databinding.BindingAdapter; import ooo.oxo.mr.widget.RatioImageView;
/* * Mr.Mantou - On the importance of taste * Copyright (C) 2015-2016 XiNGRZ <xxx@oxo.ooo> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package ooo.oxo.mr.binding; @SuppressWarnings("unused") public class RatioImageViewBindingUtil { @BindingAdapter({"originalWidth", "originalHeight"})
// Path: app/src/main/java/ooo/oxo/mr/widget/RatioImageView.java // public class RatioImageView extends ImageView { // // private int originalWidth; // private int originalHeight; // // public RatioImageView(Context context) { // this(context, null); // } // // public RatioImageView(Context context, AttributeSet attrs) { // this(context, attrs, 0); // } // // public RatioImageView(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // } // // public void setOriginalSize(int originalWidth, int originalHeight) { // this.originalWidth = originalWidth; // this.originalHeight = originalHeight; // } // // @Override // protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // if (originalWidth > 0 && originalHeight > 0) { // float ratio = (float) originalWidth / (float) originalHeight; // // int width = MeasureSpec.getSize(widthMeasureSpec); // int height = MeasureSpec.getSize(heightMeasureSpec); // // if (width > 0) { // height = (int) ((float) width / ratio); // } else if (height > 0) { // width = (int) ((float) height * ratio); // } // // setMeasuredDimension(width, height); // } else { // super.onMeasure(widthMeasureSpec, heightMeasureSpec); // } // } // // } // Path: app/src/main/java/ooo/oxo/mr/binding/RatioImageViewBindingUtil.java import android.databinding.BindingAdapter; import ooo.oxo.mr.widget.RatioImageView; /* * Mr.Mantou - On the importance of taste * Copyright (C) 2015-2016 XiNGRZ <xxx@oxo.ooo> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package ooo.oxo.mr.binding; @SuppressWarnings("unused") public class RatioImageViewBindingUtil { @BindingAdapter({"originalWidth", "originalHeight"})
public static void setOriginalSize(RatioImageView view, int originalWidth, int originalHeight) {
oxoooo/mr-mantou-android
app/src/main/java/ooo/oxo/mr/model/Image.java
// Path: app/src/main/java/ooo/oxo/mr/net/QiniuUtil.java // public class QiniuUtil { // // public static String getUrl(String url, int width) { // return String.format(Locale.US, "%s?imageView2/2/w/%d/format/webp", url, width); // } // // public static String getUrl(AVFile file, int width) { // if (AVOSCloud.getStorageType() == AVOSCloud.StorageType.StorageTypeQiniu) { // return getUrl(file.getUrl(), width); // } else { // return file.getUrl(); // } // } // // }
import android.os.Parcel; import com.avos.avoscloud.AVClassName; import com.avos.avoscloud.AVFile; import com.avos.avoscloud.AVObject; import com.avos.avoscloud.AVQuery; import java.util.Date; import java.util.Map; import ooo.oxo.mr.net.QiniuUtil;
@SuppressWarnings("unused") public Image(Parcel in) { super(in); } public static AVQuery<Image> all() { return AVObject.getQuery(Image.class) .orderByDescending(PUBLISHED_AT); } public static AVQuery<Image> since(Image image) { return AVObject.getQuery(Image.class) .whereGreaterThan(PUBLISHED_AT, image.getPublishedAt()) .orderByDescending(PUBLISHED_AT); } public Date getPublishedAt() { return getDate(PUBLISHED_AT); } public AVFile getFile() { return getAVFile(FILE); } public String getUrl() { return getFile().getUrl(); } public String getUrl(int width) {
// Path: app/src/main/java/ooo/oxo/mr/net/QiniuUtil.java // public class QiniuUtil { // // public static String getUrl(String url, int width) { // return String.format(Locale.US, "%s?imageView2/2/w/%d/format/webp", url, width); // } // // public static String getUrl(AVFile file, int width) { // if (AVOSCloud.getStorageType() == AVOSCloud.StorageType.StorageTypeQiniu) { // return getUrl(file.getUrl(), width); // } else { // return file.getUrl(); // } // } // // } // Path: app/src/main/java/ooo/oxo/mr/model/Image.java import android.os.Parcel; import com.avos.avoscloud.AVClassName; import com.avos.avoscloud.AVFile; import com.avos.avoscloud.AVObject; import com.avos.avoscloud.AVQuery; import java.util.Date; import java.util.Map; import ooo.oxo.mr.net.QiniuUtil; @SuppressWarnings("unused") public Image(Parcel in) { super(in); } public static AVQuery<Image> all() { return AVObject.getQuery(Image.class) .orderByDescending(PUBLISHED_AT); } public static AVQuery<Image> since(Image image) { return AVObject.getQuery(Image.class) .whereGreaterThan(PUBLISHED_AT, image.getPublishedAt()) .orderByDescending(PUBLISHED_AT); } public Date getPublishedAt() { return getDate(PUBLISHED_AT); } public AVFile getFile() { return getAVFile(FILE); } public String getUrl() { return getFile().getUrl(); } public String getUrl(int width) {
return QiniuUtil.getUrl(getFile(), width);
oxoooo/mr-mantou-android
app/src/main/java/ooo/oxo/mr/widget/InsetsSwipeRefreshLayout.java
// Path: app/src/main/java/ooo/oxo/mr/view/WindowInsetsHandler.java // public interface WindowInsetsHandler { // // boolean onApplyWindowInsets(Rect insets); // // } // // Path: app/src/main/java/ooo/oxo/mr/view/WindowInsetsHelper.java // public class WindowInsetsHelper { // // public static boolean onApplyWindowInsets(View view, Rect insets) { // return view instanceof WindowInsetsHandler && // ((WindowInsetsHandler) view).onApplyWindowInsets(insets); // } // // public static boolean dispatchApplyWindowInsets(ViewGroup parent, Rect insets) { // final int count = parent.getChildCount(); // // for (int i = 0; i < count; i++) { // if (onApplyWindowInsets(parent.getChildAt(i), insets)) { // return true; // } // } // // return false; // } // // }
import android.content.Context; import android.graphics.Rect; import android.support.v4.widget.SwipeRefreshLayout; import android.util.AttributeSet; import ooo.oxo.mr.view.WindowInsetsHandler; import ooo.oxo.mr.view.WindowInsetsHelper;
/* * Mr.Mantou - On the importance of taste * Copyright (C) 2015-2016 XiNGRZ <xxx@oxo.ooo> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package ooo.oxo.mr.widget; public class InsetsSwipeRefreshLayout extends SwipeRefreshLayout implements WindowInsetsHandler { public InsetsSwipeRefreshLayout(Context context) { super(context); } public InsetsSwipeRefreshLayout(Context context, AttributeSet attrs) { super(context, attrs); } @Override public boolean onApplyWindowInsets(Rect insets) {
// Path: app/src/main/java/ooo/oxo/mr/view/WindowInsetsHandler.java // public interface WindowInsetsHandler { // // boolean onApplyWindowInsets(Rect insets); // // } // // Path: app/src/main/java/ooo/oxo/mr/view/WindowInsetsHelper.java // public class WindowInsetsHelper { // // public static boolean onApplyWindowInsets(View view, Rect insets) { // return view instanceof WindowInsetsHandler && // ((WindowInsetsHandler) view).onApplyWindowInsets(insets); // } // // public static boolean dispatchApplyWindowInsets(ViewGroup parent, Rect insets) { // final int count = parent.getChildCount(); // // for (int i = 0; i < count; i++) { // if (onApplyWindowInsets(parent.getChildAt(i), insets)) { // return true; // } // } // // return false; // } // // } // Path: app/src/main/java/ooo/oxo/mr/widget/InsetsSwipeRefreshLayout.java import android.content.Context; import android.graphics.Rect; import android.support.v4.widget.SwipeRefreshLayout; import android.util.AttributeSet; import ooo.oxo.mr.view.WindowInsetsHandler; import ooo.oxo.mr.view.WindowInsetsHelper; /* * Mr.Mantou - On the importance of taste * Copyright (C) 2015-2016 XiNGRZ <xxx@oxo.ooo> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package ooo.oxo.mr.widget; public class InsetsSwipeRefreshLayout extends SwipeRefreshLayout implements WindowInsetsHandler { public InsetsSwipeRefreshLayout(Context context) { super(context); } public InsetsSwipeRefreshLayout(Context context, AttributeSet attrs) { super(context, attrs); } @Override public boolean onApplyWindowInsets(Rect insets) {
return WindowInsetsHelper.dispatchApplyWindowInsets(this, insets);
oxoooo/mr-mantou-android
app/src/main/java/ooo/oxo/mr/widget/InsetsCoordinatorLayout.java
// Path: app/src/main/java/ooo/oxo/mr/util/WindowInsetsCompatUtil.java // public class WindowInsetsCompatUtil { // // public static WindowInsetsCompat copy(WindowInsetsCompat source) { // return copyExcluded(source, Gravity.NO_GRAVITY); // } // // @SuppressLint("RtlHardcoded") // public static WindowInsetsCompat copyExcluded(WindowInsetsCompat source, int gravity) { // int l = (gravity & Gravity.LEFT) == Gravity.LEFT ? 0 : source.getSystemWindowInsetLeft(); // int t = (gravity & Gravity.TOP) == Gravity.TOP ? 0 : source.getSystemWindowInsetTop(); // int r = (gravity & Gravity.RIGHT) == Gravity.RIGHT ? 0 : source.getSystemWindowInsetRight(); // int b = (gravity & Gravity.BOTTOM) == Gravity.BOTTOM ? 0 : source.getSystemWindowInsetBottom(); // return source.replaceSystemWindowInsets(l, t, r, b); // } // // }
import android.content.Context; import android.graphics.Rect; import android.os.Build; import android.support.design.widget.CoordinatorLayout; import android.support.v4.view.ViewCompat; import android.util.AttributeSet; import android.view.View; import ooo.oxo.mr.util.WindowInsetsCompatUtil;
/* * Mr.Mantou - On the importance of taste * Copyright (C) 2015-2016 XiNGRZ <xxx@oxo.ooo> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package ooo.oxo.mr.widget; public class InsetsCoordinatorLayout extends CoordinatorLayout { public InsetsCoordinatorLayout(Context context) { this(context, null); } public InsetsCoordinatorLayout(Context context, AttributeSet attrs) { this(context, attrs, 0); } public InsetsCoordinatorLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); ViewCompat.setOnApplyWindowInsetsListener(this, (v, insets) -> { if (insets.isConsumed()) { return insets; } for (int i = 0, count = getChildCount(); i < count; i++) { final View child = getChildAt(i); final Behavior b = getBehavior(child); if (b == null) { continue; } //noinspection unchecked
// Path: app/src/main/java/ooo/oxo/mr/util/WindowInsetsCompatUtil.java // public class WindowInsetsCompatUtil { // // public static WindowInsetsCompat copy(WindowInsetsCompat source) { // return copyExcluded(source, Gravity.NO_GRAVITY); // } // // @SuppressLint("RtlHardcoded") // public static WindowInsetsCompat copyExcluded(WindowInsetsCompat source, int gravity) { // int l = (gravity & Gravity.LEFT) == Gravity.LEFT ? 0 : source.getSystemWindowInsetLeft(); // int t = (gravity & Gravity.TOP) == Gravity.TOP ? 0 : source.getSystemWindowInsetTop(); // int r = (gravity & Gravity.RIGHT) == Gravity.RIGHT ? 0 : source.getSystemWindowInsetRight(); // int b = (gravity & Gravity.BOTTOM) == Gravity.BOTTOM ? 0 : source.getSystemWindowInsetBottom(); // return source.replaceSystemWindowInsets(l, t, r, b); // } // // } // Path: app/src/main/java/ooo/oxo/mr/widget/InsetsCoordinatorLayout.java import android.content.Context; import android.graphics.Rect; import android.os.Build; import android.support.design.widget.CoordinatorLayout; import android.support.v4.view.ViewCompat; import android.util.AttributeSet; import android.view.View; import ooo.oxo.mr.util.WindowInsetsCompatUtil; /* * Mr.Mantou - On the importance of taste * Copyright (C) 2015-2016 XiNGRZ <xxx@oxo.ooo> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package ooo.oxo.mr.widget; public class InsetsCoordinatorLayout extends CoordinatorLayout { public InsetsCoordinatorLayout(Context context) { this(context, null); } public InsetsCoordinatorLayout(Context context, AttributeSet attrs) { this(context, attrs, 0); } public InsetsCoordinatorLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); ViewCompat.setOnApplyWindowInsetsListener(this, (v, insets) -> { if (insets.isConsumed()) { return insets; } for (int i = 0, count = getChildCount(); i < count; i++) { final View child = getChildAt(i); final Behavior b = getBehavior(child); if (b == null) { continue; } //noinspection unchecked
b.onApplyWindowInsets(this, child, WindowInsetsCompatUtil.copy(insets));
muncus/klaxon-wip
src/org/nerdcircus/android/klaxon/Alert.java
// Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Pages implements BaseColumns // { // public static final String TABLE_NAME = "pages"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/pages"); // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "created DESC"; // // /** // * The subject of the page // * <P>Type: TEXT</P> // */ // public static final String SUBJECT = "subject"; // // /** // * The text of the page // * <P>Type: TEXT</P> // */ // public static final String BODY = "body"; // // /** // * The timestamp for when the page was created // * <P>Type: INTEGER (long)</P> // */ // public static final String CREATED_DATE = "created"; // // /** // * The service center address from which the page was received. // * <P>Type: TEXT</P> // */ // public static final String SERVICE_CENTER = "sc_addr"; // // /** // * The originating address // * <P>Type: TEXT</P> // */ // public static final String SENDER = "sender_addr"; // // /** // * Acknowledgement status // * <P>Type: INTEGER</P> // */ // public static final String ACK_STATUS = "ack_status"; // // /** // * Email From address // * <P>Type: TEXT</P> // */ // public static final String FROM_ADDR = "email_from_addr"; // // /** // * String to identify the transport over which this page was received. // * <P>Type: TEXT</P> // */ // public static final String TRANSPORT = "transport"; // // /** // * Reply Uri - can be used to reply out-of-band to the sender. // * <P>Type: TEXT</P> // */ // public static final String REPLY_URI = "reply_uri"; // }
import android.content.ContentValues; import org.nerdcircus.android.klaxon.Pager.Pages;
package org.nerdcircus.android.klaxon; /** Class representing an Alert Object * abstraction used to get from a received message to an item in PagerProvider */ public class Alert { private ContentValues cv; String DEFAULT_FROM = "Unknown Sender"; String DEFAULT_SUBJECT = "Subject not specified"; String DEFAULT_BODY = "Body not specified"; public Alert(){ cv = new ContentValues(); setFrom(DEFAULT_FROM); setDisplayFrom(DEFAULT_FROM); setSubject(DEFAULT_SUBJECT); setBody(DEFAULT_BODY);
// Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Pages implements BaseColumns // { // public static final String TABLE_NAME = "pages"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/pages"); // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "created DESC"; // // /** // * The subject of the page // * <P>Type: TEXT</P> // */ // public static final String SUBJECT = "subject"; // // /** // * The text of the page // * <P>Type: TEXT</P> // */ // public static final String BODY = "body"; // // /** // * The timestamp for when the page was created // * <P>Type: INTEGER (long)</P> // */ // public static final String CREATED_DATE = "created"; // // /** // * The service center address from which the page was received. // * <P>Type: TEXT</P> // */ // public static final String SERVICE_CENTER = "sc_addr"; // // /** // * The originating address // * <P>Type: TEXT</P> // */ // public static final String SENDER = "sender_addr"; // // /** // * Acknowledgement status // * <P>Type: INTEGER</P> // */ // public static final String ACK_STATUS = "ack_status"; // // /** // * Email From address // * <P>Type: TEXT</P> // */ // public static final String FROM_ADDR = "email_from_addr"; // // /** // * String to identify the transport over which this page was received. // * <P>Type: TEXT</P> // */ // public static final String TRANSPORT = "transport"; // // /** // * Reply Uri - can be used to reply out-of-band to the sender. // * <P>Type: TEXT</P> // */ // public static final String REPLY_URI = "reply_uri"; // } // Path: src/org/nerdcircus/android/klaxon/Alert.java import android.content.ContentValues; import org.nerdcircus.android.klaxon.Pager.Pages; package org.nerdcircus.android.klaxon; /** Class representing an Alert Object * abstraction used to get from a received message to an item in PagerProvider */ public class Alert { private ContentValues cv; String DEFAULT_FROM = "Unknown Sender"; String DEFAULT_SUBJECT = "Subject not specified"; String DEFAULT_BODY = "Body not specified"; public Alert(){ cv = new ContentValues(); setFrom(DEFAULT_FROM); setDisplayFrom(DEFAULT_FROM); setSubject(DEFAULT_SUBJECT); setBody(DEFAULT_BODY);
if( ! cv.containsKey(Pages.ACK_STATUS))
muncus/klaxon-wip
src/org/nerdcircus/android/klaxon/KlaxonList.java
// Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Pages implements BaseColumns // { // public static final String TABLE_NAME = "pages"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/pages"); // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "created DESC"; // // /** // * The subject of the page // * <P>Type: TEXT</P> // */ // public static final String SUBJECT = "subject"; // // /** // * The text of the page // * <P>Type: TEXT</P> // */ // public static final String BODY = "body"; // // /** // * The timestamp for when the page was created // * <P>Type: INTEGER (long)</P> // */ // public static final String CREATED_DATE = "created"; // // /** // * The service center address from which the page was received. // * <P>Type: TEXT</P> // */ // public static final String SERVICE_CENTER = "sc_addr"; // // /** // * The originating address // * <P>Type: TEXT</P> // */ // public static final String SENDER = "sender_addr"; // // /** // * Acknowledgement status // * <P>Type: INTEGER</P> // */ // public static final String ACK_STATUS = "ack_status"; // // /** // * Email From address // * <P>Type: TEXT</P> // */ // public static final String FROM_ADDR = "email_from_addr"; // // /** // * String to identify the transport over which this page was received. // * <P>Type: TEXT</P> // */ // public static final String TRANSPORT = "transport"; // // /** // * Reply Uri - can be used to reply out-of-band to the sender. // * <P>Type: TEXT</P> // */ // public static final String REPLY_URI = "reply_uri"; // } // // Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Replies implements BaseColumns // { // public static final String TABLE_NAME = "replies"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/reply"); // // /** // * Short name of our reply. // */ // public static final String NAME = "name"; // // /** // * content of the reply. // */ // public static final String BODY = "body"; // /** // * new "ack status". integer. // */ // public static final String ACK_STATUS = "ack_status"; // /** // * whether this item should be shown in the menu. // */ // public static final String SHOW_IN_MENU = "show_in_menu"; // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "name ASC"; // }
import android.app.AlertDialog; import android.app.Dialog; import android.app.ListActivity; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.preference.PreferenceManager; import android.util.Log; import android.view.ContextMenu; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.ListAdapter; import android.widget.ListView; import org.nerdcircus.android.klaxon.Pager.Pages; import org.nerdcircus.android.klaxon.Pager.Replies;
/* * Copyright 2008 Google 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 org.nerdcircus.android.klaxon; public class KlaxonList extends ListActivity { private String TAG = "KlaxonList"; public static final String AUTH_PERMISSION_ACTION = "org.nerdcircus.android.klaxon.AUTH_PERMISSION"; //menu constants. private int MENU_ACTIONS_GROUP = Menu.FIRST; private int MENU_ALWAYS_GROUP = Menu.FIRST + 1; private int DIALOG_DELETE_ALL_CONFIRMATION = 1; private int REQUEST_PICK_REPLY = 1; private boolean mPlayServicesMessageShown = false; private GcmHelper mGcmHelper; private Cursor mCursor; protected Dialog onCreateDialog(int id){ if(id == DIALOG_DELETE_ALL_CONFIRMATION){ //Confirm deletion. AlertDialog.OnClickListener delete_all_confirm_listener = new AlertDialog.OnClickListener(){ public void onClick(DialogInterface dialog, int which){ if(which == AlertDialog.BUTTON_POSITIVE){
// Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Pages implements BaseColumns // { // public static final String TABLE_NAME = "pages"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/pages"); // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "created DESC"; // // /** // * The subject of the page // * <P>Type: TEXT</P> // */ // public static final String SUBJECT = "subject"; // // /** // * The text of the page // * <P>Type: TEXT</P> // */ // public static final String BODY = "body"; // // /** // * The timestamp for when the page was created // * <P>Type: INTEGER (long)</P> // */ // public static final String CREATED_DATE = "created"; // // /** // * The service center address from which the page was received. // * <P>Type: TEXT</P> // */ // public static final String SERVICE_CENTER = "sc_addr"; // // /** // * The originating address // * <P>Type: TEXT</P> // */ // public static final String SENDER = "sender_addr"; // // /** // * Acknowledgement status // * <P>Type: INTEGER</P> // */ // public static final String ACK_STATUS = "ack_status"; // // /** // * Email From address // * <P>Type: TEXT</P> // */ // public static final String FROM_ADDR = "email_from_addr"; // // /** // * String to identify the transport over which this page was received. // * <P>Type: TEXT</P> // */ // public static final String TRANSPORT = "transport"; // // /** // * Reply Uri - can be used to reply out-of-band to the sender. // * <P>Type: TEXT</P> // */ // public static final String REPLY_URI = "reply_uri"; // } // // Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Replies implements BaseColumns // { // public static final String TABLE_NAME = "replies"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/reply"); // // /** // * Short name of our reply. // */ // public static final String NAME = "name"; // // /** // * content of the reply. // */ // public static final String BODY = "body"; // /** // * new "ack status". integer. // */ // public static final String ACK_STATUS = "ack_status"; // /** // * whether this item should be shown in the menu. // */ // public static final String SHOW_IN_MENU = "show_in_menu"; // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "name ASC"; // } // Path: src/org/nerdcircus/android/klaxon/KlaxonList.java import android.app.AlertDialog; import android.app.Dialog; import android.app.ListActivity; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.preference.PreferenceManager; import android.util.Log; import android.view.ContextMenu; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.ListAdapter; import android.widget.ListView; import org.nerdcircus.android.klaxon.Pager.Pages; import org.nerdcircus.android.klaxon.Pager.Replies; /* * Copyright 2008 Google 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 org.nerdcircus.android.klaxon; public class KlaxonList extends ListActivity { private String TAG = "KlaxonList"; public static final String AUTH_PERMISSION_ACTION = "org.nerdcircus.android.klaxon.AUTH_PERMISSION"; //menu constants. private int MENU_ACTIONS_GROUP = Menu.FIRST; private int MENU_ALWAYS_GROUP = Menu.FIRST + 1; private int DIALOG_DELETE_ALL_CONFIRMATION = 1; private int REQUEST_PICK_REPLY = 1; private boolean mPlayServicesMessageShown = false; private GcmHelper mGcmHelper; private Cursor mCursor; protected Dialog onCreateDialog(int id){ if(id == DIALOG_DELETE_ALL_CONFIRMATION){ //Confirm deletion. AlertDialog.OnClickListener delete_all_confirm_listener = new AlertDialog.OnClickListener(){ public void onClick(DialogInterface dialog, int which){ if(which == AlertDialog.BUTTON_POSITIVE){
getContentResolver().delete(Pages.CONTENT_URI, null, null);
muncus/klaxon-wip
src/org/nerdcircus/android/klaxon/KlaxonList.java
// Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Pages implements BaseColumns // { // public static final String TABLE_NAME = "pages"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/pages"); // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "created DESC"; // // /** // * The subject of the page // * <P>Type: TEXT</P> // */ // public static final String SUBJECT = "subject"; // // /** // * The text of the page // * <P>Type: TEXT</P> // */ // public static final String BODY = "body"; // // /** // * The timestamp for when the page was created // * <P>Type: INTEGER (long)</P> // */ // public static final String CREATED_DATE = "created"; // // /** // * The service center address from which the page was received. // * <P>Type: TEXT</P> // */ // public static final String SERVICE_CENTER = "sc_addr"; // // /** // * The originating address // * <P>Type: TEXT</P> // */ // public static final String SENDER = "sender_addr"; // // /** // * Acknowledgement status // * <P>Type: INTEGER</P> // */ // public static final String ACK_STATUS = "ack_status"; // // /** // * Email From address // * <P>Type: TEXT</P> // */ // public static final String FROM_ADDR = "email_from_addr"; // // /** // * String to identify the transport over which this page was received. // * <P>Type: TEXT</P> // */ // public static final String TRANSPORT = "transport"; // // /** // * Reply Uri - can be used to reply out-of-band to the sender. // * <P>Type: TEXT</P> // */ // public static final String REPLY_URI = "reply_uri"; // } // // Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Replies implements BaseColumns // { // public static final String TABLE_NAME = "replies"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/reply"); // // /** // * Short name of our reply. // */ // public static final String NAME = "name"; // // /** // * content of the reply. // */ // public static final String BODY = "body"; // /** // * new "ack status". integer. // */ // public static final String ACK_STATUS = "ack_status"; // /** // * whether this item should be shown in the menu. // */ // public static final String SHOW_IN_MENU = "show_in_menu"; // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "name ASC"; // }
import android.app.AlertDialog; import android.app.Dialog; import android.app.ListActivity; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.preference.PreferenceManager; import android.util.Log; import android.view.ContextMenu; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.ListAdapter; import android.widget.ListView; import org.nerdcircus.android.klaxon.Pager.Pages; import org.nerdcircus.android.klaxon.Pager.Replies;
Log.d(TAG, "oncreate done."); registerForContextMenu(getListView()); mGcmHelper = new GcmHelper(this); } public void onResume(){ if(mGcmHelper.checkForPlayServices(mPlayServicesMessageShown)){ Log.d(TAG, "play services found."); mGcmHelper.maybePromptForLoginPermission(); } else { Log.d(TAG, "play services not found."); } super.onResume(); //if they're active, cancel any alarms and notifications. Intent i = new Intent(Pager.SILENCE_ACTION); sendBroadcast(i); } public void onListItemClick(ListView parent, View v, int position, long id){ Log.d(TAG, "Item clicked!"); Uri pageUri = Uri.withAppendedPath(Pager.Pages.CONTENT_URI, ""+id); Intent i = new Intent(Intent.ACTION_VIEW, pageUri); startActivity(i); } @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu);
// Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Pages implements BaseColumns // { // public static final String TABLE_NAME = "pages"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/pages"); // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "created DESC"; // // /** // * The subject of the page // * <P>Type: TEXT</P> // */ // public static final String SUBJECT = "subject"; // // /** // * The text of the page // * <P>Type: TEXT</P> // */ // public static final String BODY = "body"; // // /** // * The timestamp for when the page was created // * <P>Type: INTEGER (long)</P> // */ // public static final String CREATED_DATE = "created"; // // /** // * The service center address from which the page was received. // * <P>Type: TEXT</P> // */ // public static final String SERVICE_CENTER = "sc_addr"; // // /** // * The originating address // * <P>Type: TEXT</P> // */ // public static final String SENDER = "sender_addr"; // // /** // * Acknowledgement status // * <P>Type: INTEGER</P> // */ // public static final String ACK_STATUS = "ack_status"; // // /** // * Email From address // * <P>Type: TEXT</P> // */ // public static final String FROM_ADDR = "email_from_addr"; // // /** // * String to identify the transport over which this page was received. // * <P>Type: TEXT</P> // */ // public static final String TRANSPORT = "transport"; // // /** // * Reply Uri - can be used to reply out-of-band to the sender. // * <P>Type: TEXT</P> // */ // public static final String REPLY_URI = "reply_uri"; // } // // Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Replies implements BaseColumns // { // public static final String TABLE_NAME = "replies"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/reply"); // // /** // * Short name of our reply. // */ // public static final String NAME = "name"; // // /** // * content of the reply. // */ // public static final String BODY = "body"; // /** // * new "ack status". integer. // */ // public static final String ACK_STATUS = "ack_status"; // /** // * whether this item should be shown in the menu. // */ // public static final String SHOW_IN_MENU = "show_in_menu"; // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "name ASC"; // } // Path: src/org/nerdcircus/android/klaxon/KlaxonList.java import android.app.AlertDialog; import android.app.Dialog; import android.app.ListActivity; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.preference.PreferenceManager; import android.util.Log; import android.view.ContextMenu; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.ListAdapter; import android.widget.ListView; import org.nerdcircus.android.klaxon.Pager.Pages; import org.nerdcircus.android.klaxon.Pager.Replies; Log.d(TAG, "oncreate done."); registerForContextMenu(getListView()); mGcmHelper = new GcmHelper(this); } public void onResume(){ if(mGcmHelper.checkForPlayServices(mPlayServicesMessageShown)){ Log.d(TAG, "play services found."); mGcmHelper.maybePromptForLoginPermission(); } else { Log.d(TAG, "play services not found."); } super.onResume(); //if they're active, cancel any alarms and notifications. Intent i = new Intent(Pager.SILENCE_ACTION); sendBroadcast(i); } public void onListItemClick(ListView parent, View v, int position, long id){ Log.d(TAG, "Item clicked!"); Uri pageUri = Uri.withAppendedPath(Pager.Pages.CONTENT_URI, ""+id); Intent i = new Intent(Intent.ACTION_VIEW, pageUri); startActivity(i); } @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu);
Cursor c = managedQuery(Replies.CONTENT_URI,
muncus/klaxon-wip
src/org/nerdcircus/android/klaxon/pageparser/Standard.java
// Path: src/org/nerdcircus/android/klaxon/Alert.java // public class Alert { // private ContentValues cv; // String DEFAULT_FROM = "Unknown Sender"; // String DEFAULT_SUBJECT = "Subject not specified"; // String DEFAULT_BODY = "Body not specified"; // // public Alert(){ // cv = new ContentValues(); // setFrom(DEFAULT_FROM); // setDisplayFrom(DEFAULT_FROM); // setSubject(DEFAULT_SUBJECT); // setBody(DEFAULT_BODY); // if( ! cv.containsKey(Pages.ACK_STATUS)) // cv.put(Pages.ACK_STATUS, 0); //default to no response. // } // // //clone contentvalues, so we can start passing around Alerts instead. // public Alert(ContentValues v){ // cv = v; // } // // public Alert(String from, String subj, String body){ // setFrom(from); // setDisplayFrom(from); // setSubject(subj); // setBody(body); // setTransport("sms"); // } // // // "raw" from address, for use in replying. // public void setFrom(String from){ // cv.put(Pages.SENDER, from); // } // public String getFrom(){ // return cv.getAsString(Pages.SENDER); // } // // // Intended to be used with Intent.ACTION_SEND // public void setReplyUri(String uri){ // cv.put(Pages.REPLY_URI, uri); // } // // "DisplayName" analog - phone number, or email addr. // public void setDisplayFrom(String from){ // cv.put(Pages.FROM_ADDR, from); // } // public String getDisplayFrom(){ // return cv.getAsString(Pages.FROM_ADDR); // } // // // subject line of the alert // public void setSubject(String from){ // cv.put(Pages.SUBJECT, from); // } // public String getSubject(){ // return cv.getAsString(Pages.SUBJECT); // } // // // body of the alert. // public void setBody(String body){ // cv.put(Pages.BODY, body); // } // public String getBody(){ // return cv.getAsString(Pages.BODY); // } // // public void setTransport(String t){ // cv.put(Pages.TRANSPORT, t); // } // // // used for inserting this alert into our contentprovider // public ContentValues asContentValues(){ // return cv; // } // } // // Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Pages implements BaseColumns // { // public static final String TABLE_NAME = "pages"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/pages"); // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "created DESC"; // // /** // * The subject of the page // * <P>Type: TEXT</P> // */ // public static final String SUBJECT = "subject"; // // /** // * The text of the page // * <P>Type: TEXT</P> // */ // public static final String BODY = "body"; // // /** // * The timestamp for when the page was created // * <P>Type: INTEGER (long)</P> // */ // public static final String CREATED_DATE = "created"; // // /** // * The service center address from which the page was received. // * <P>Type: TEXT</P> // */ // public static final String SERVICE_CENTER = "sc_addr"; // // /** // * The originating address // * <P>Type: TEXT</P> // */ // public static final String SENDER = "sender_addr"; // // /** // * Acknowledgement status // * <P>Type: INTEGER</P> // */ // public static final String ACK_STATUS = "ack_status"; // // /** // * Email From address // * <P>Type: TEXT</P> // */ // public static final String FROM_ADDR = "email_from_addr"; // // /** // * String to identify the transport over which this page was received. // * <P>Type: TEXT</P> // */ // public static final String TRANSPORT = "transport"; // // /** // * Reply Uri - can be used to reply out-of-band to the sender. // * <P>Type: TEXT</P> // */ // public static final String REPLY_URI = "reply_uri"; // }
import android.content.ContentValues; import android.telephony.SmsMessage; import android.util.Log; import org.nerdcircus.android.klaxon.Alert; import org.nerdcircus.android.klaxon.Pager.Pages;
package org.nerdcircus.android.klaxon.pageparser; public class Standard { /* The Standard Sms Parser * * Messages for this parser should look like this: * "sender@example.com\nsubject\nbody" * (\n may be \r\n as well) */ public static String TAG = "PageParser-Standard";
// Path: src/org/nerdcircus/android/klaxon/Alert.java // public class Alert { // private ContentValues cv; // String DEFAULT_FROM = "Unknown Sender"; // String DEFAULT_SUBJECT = "Subject not specified"; // String DEFAULT_BODY = "Body not specified"; // // public Alert(){ // cv = new ContentValues(); // setFrom(DEFAULT_FROM); // setDisplayFrom(DEFAULT_FROM); // setSubject(DEFAULT_SUBJECT); // setBody(DEFAULT_BODY); // if( ! cv.containsKey(Pages.ACK_STATUS)) // cv.put(Pages.ACK_STATUS, 0); //default to no response. // } // // //clone contentvalues, so we can start passing around Alerts instead. // public Alert(ContentValues v){ // cv = v; // } // // public Alert(String from, String subj, String body){ // setFrom(from); // setDisplayFrom(from); // setSubject(subj); // setBody(body); // setTransport("sms"); // } // // // "raw" from address, for use in replying. // public void setFrom(String from){ // cv.put(Pages.SENDER, from); // } // public String getFrom(){ // return cv.getAsString(Pages.SENDER); // } // // // Intended to be used with Intent.ACTION_SEND // public void setReplyUri(String uri){ // cv.put(Pages.REPLY_URI, uri); // } // // "DisplayName" analog - phone number, or email addr. // public void setDisplayFrom(String from){ // cv.put(Pages.FROM_ADDR, from); // } // public String getDisplayFrom(){ // return cv.getAsString(Pages.FROM_ADDR); // } // // // subject line of the alert // public void setSubject(String from){ // cv.put(Pages.SUBJECT, from); // } // public String getSubject(){ // return cv.getAsString(Pages.SUBJECT); // } // // // body of the alert. // public void setBody(String body){ // cv.put(Pages.BODY, body); // } // public String getBody(){ // return cv.getAsString(Pages.BODY); // } // // public void setTransport(String t){ // cv.put(Pages.TRANSPORT, t); // } // // // used for inserting this alert into our contentprovider // public ContentValues asContentValues(){ // return cv; // } // } // // Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Pages implements BaseColumns // { // public static final String TABLE_NAME = "pages"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/pages"); // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "created DESC"; // // /** // * The subject of the page // * <P>Type: TEXT</P> // */ // public static final String SUBJECT = "subject"; // // /** // * The text of the page // * <P>Type: TEXT</P> // */ // public static final String BODY = "body"; // // /** // * The timestamp for when the page was created // * <P>Type: INTEGER (long)</P> // */ // public static final String CREATED_DATE = "created"; // // /** // * The service center address from which the page was received. // * <P>Type: TEXT</P> // */ // public static final String SERVICE_CENTER = "sc_addr"; // // /** // * The originating address // * <P>Type: TEXT</P> // */ // public static final String SENDER = "sender_addr"; // // /** // * Acknowledgement status // * <P>Type: INTEGER</P> // */ // public static final String ACK_STATUS = "ack_status"; // // /** // * Email From address // * <P>Type: TEXT</P> // */ // public static final String FROM_ADDR = "email_from_addr"; // // /** // * String to identify the transport over which this page was received. // * <P>Type: TEXT</P> // */ // public static final String TRANSPORT = "transport"; // // /** // * Reply Uri - can be used to reply out-of-band to the sender. // * <P>Type: TEXT</P> // */ // public static final String REPLY_URI = "reply_uri"; // } // Path: src/org/nerdcircus/android/klaxon/pageparser/Standard.java import android.content.ContentValues; import android.telephony.SmsMessage; import android.util.Log; import org.nerdcircus.android.klaxon.Alert; import org.nerdcircus.android.klaxon.Pager.Pages; package org.nerdcircus.android.klaxon.pageparser; public class Standard { /* The Standard Sms Parser * * Messages for this parser should look like this: * "sender@example.com\nsubject\nbody" * (\n may be \r\n as well) */ public static String TAG = "PageParser-Standard";
public Alert parse(SmsMessage[] msgs){
muncus/klaxon-wip
src/org/nerdcircus/android/klaxon/pageparser/Standard.java
// Path: src/org/nerdcircus/android/klaxon/Alert.java // public class Alert { // private ContentValues cv; // String DEFAULT_FROM = "Unknown Sender"; // String DEFAULT_SUBJECT = "Subject not specified"; // String DEFAULT_BODY = "Body not specified"; // // public Alert(){ // cv = new ContentValues(); // setFrom(DEFAULT_FROM); // setDisplayFrom(DEFAULT_FROM); // setSubject(DEFAULT_SUBJECT); // setBody(DEFAULT_BODY); // if( ! cv.containsKey(Pages.ACK_STATUS)) // cv.put(Pages.ACK_STATUS, 0); //default to no response. // } // // //clone contentvalues, so we can start passing around Alerts instead. // public Alert(ContentValues v){ // cv = v; // } // // public Alert(String from, String subj, String body){ // setFrom(from); // setDisplayFrom(from); // setSubject(subj); // setBody(body); // setTransport("sms"); // } // // // "raw" from address, for use in replying. // public void setFrom(String from){ // cv.put(Pages.SENDER, from); // } // public String getFrom(){ // return cv.getAsString(Pages.SENDER); // } // // // Intended to be used with Intent.ACTION_SEND // public void setReplyUri(String uri){ // cv.put(Pages.REPLY_URI, uri); // } // // "DisplayName" analog - phone number, or email addr. // public void setDisplayFrom(String from){ // cv.put(Pages.FROM_ADDR, from); // } // public String getDisplayFrom(){ // return cv.getAsString(Pages.FROM_ADDR); // } // // // subject line of the alert // public void setSubject(String from){ // cv.put(Pages.SUBJECT, from); // } // public String getSubject(){ // return cv.getAsString(Pages.SUBJECT); // } // // // body of the alert. // public void setBody(String body){ // cv.put(Pages.BODY, body); // } // public String getBody(){ // return cv.getAsString(Pages.BODY); // } // // public void setTransport(String t){ // cv.put(Pages.TRANSPORT, t); // } // // // used for inserting this alert into our contentprovider // public ContentValues asContentValues(){ // return cv; // } // } // // Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Pages implements BaseColumns // { // public static final String TABLE_NAME = "pages"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/pages"); // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "created DESC"; // // /** // * The subject of the page // * <P>Type: TEXT</P> // */ // public static final String SUBJECT = "subject"; // // /** // * The text of the page // * <P>Type: TEXT</P> // */ // public static final String BODY = "body"; // // /** // * The timestamp for when the page was created // * <P>Type: INTEGER (long)</P> // */ // public static final String CREATED_DATE = "created"; // // /** // * The service center address from which the page was received. // * <P>Type: TEXT</P> // */ // public static final String SERVICE_CENTER = "sc_addr"; // // /** // * The originating address // * <P>Type: TEXT</P> // */ // public static final String SENDER = "sender_addr"; // // /** // * Acknowledgement status // * <P>Type: INTEGER</P> // */ // public static final String ACK_STATUS = "ack_status"; // // /** // * Email From address // * <P>Type: TEXT</P> // */ // public static final String FROM_ADDR = "email_from_addr"; // // /** // * String to identify the transport over which this page was received. // * <P>Type: TEXT</P> // */ // public static final String TRANSPORT = "transport"; // // /** // * Reply Uri - can be used to reply out-of-band to the sender. // * <P>Type: TEXT</P> // */ // public static final String REPLY_URI = "reply_uri"; // }
import android.content.ContentValues; import android.telephony.SmsMessage; import android.util.Log; import org.nerdcircus.android.klaxon.Alert; import org.nerdcircus.android.klaxon.Pager.Pages;
package org.nerdcircus.android.klaxon.pageparser; public class Standard { /* The Standard Sms Parser * * Messages for this parser should look like this: * "sender@example.com\nsubject\nbody" * (\n may be \r\n as well) */ public static String TAG = "PageParser-Standard"; public Alert parse(SmsMessage[] msgs){ ContentValues cv = new ContentValues();
// Path: src/org/nerdcircus/android/klaxon/Alert.java // public class Alert { // private ContentValues cv; // String DEFAULT_FROM = "Unknown Sender"; // String DEFAULT_SUBJECT = "Subject not specified"; // String DEFAULT_BODY = "Body not specified"; // // public Alert(){ // cv = new ContentValues(); // setFrom(DEFAULT_FROM); // setDisplayFrom(DEFAULT_FROM); // setSubject(DEFAULT_SUBJECT); // setBody(DEFAULT_BODY); // if( ! cv.containsKey(Pages.ACK_STATUS)) // cv.put(Pages.ACK_STATUS, 0); //default to no response. // } // // //clone contentvalues, so we can start passing around Alerts instead. // public Alert(ContentValues v){ // cv = v; // } // // public Alert(String from, String subj, String body){ // setFrom(from); // setDisplayFrom(from); // setSubject(subj); // setBody(body); // setTransport("sms"); // } // // // "raw" from address, for use in replying. // public void setFrom(String from){ // cv.put(Pages.SENDER, from); // } // public String getFrom(){ // return cv.getAsString(Pages.SENDER); // } // // // Intended to be used with Intent.ACTION_SEND // public void setReplyUri(String uri){ // cv.put(Pages.REPLY_URI, uri); // } // // "DisplayName" analog - phone number, or email addr. // public void setDisplayFrom(String from){ // cv.put(Pages.FROM_ADDR, from); // } // public String getDisplayFrom(){ // return cv.getAsString(Pages.FROM_ADDR); // } // // // subject line of the alert // public void setSubject(String from){ // cv.put(Pages.SUBJECT, from); // } // public String getSubject(){ // return cv.getAsString(Pages.SUBJECT); // } // // // body of the alert. // public void setBody(String body){ // cv.put(Pages.BODY, body); // } // public String getBody(){ // return cv.getAsString(Pages.BODY); // } // // public void setTransport(String t){ // cv.put(Pages.TRANSPORT, t); // } // // // used for inserting this alert into our contentprovider // public ContentValues asContentValues(){ // return cv; // } // } // // Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Pages implements BaseColumns // { // public static final String TABLE_NAME = "pages"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/pages"); // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "created DESC"; // // /** // * The subject of the page // * <P>Type: TEXT</P> // */ // public static final String SUBJECT = "subject"; // // /** // * The text of the page // * <P>Type: TEXT</P> // */ // public static final String BODY = "body"; // // /** // * The timestamp for when the page was created // * <P>Type: INTEGER (long)</P> // */ // public static final String CREATED_DATE = "created"; // // /** // * The service center address from which the page was received. // * <P>Type: TEXT</P> // */ // public static final String SERVICE_CENTER = "sc_addr"; // // /** // * The originating address // * <P>Type: TEXT</P> // */ // public static final String SENDER = "sender_addr"; // // /** // * Acknowledgement status // * <P>Type: INTEGER</P> // */ // public static final String ACK_STATUS = "ack_status"; // // /** // * Email From address // * <P>Type: TEXT</P> // */ // public static final String FROM_ADDR = "email_from_addr"; // // /** // * String to identify the transport over which this page was received. // * <P>Type: TEXT</P> // */ // public static final String TRANSPORT = "transport"; // // /** // * Reply Uri - can be used to reply out-of-band to the sender. // * <P>Type: TEXT</P> // */ // public static final String REPLY_URI = "reply_uri"; // } // Path: src/org/nerdcircus/android/klaxon/pageparser/Standard.java import android.content.ContentValues; import android.telephony.SmsMessage; import android.util.Log; import org.nerdcircus.android.klaxon.Alert; import org.nerdcircus.android.klaxon.Pager.Pages; package org.nerdcircus.android.klaxon.pageparser; public class Standard { /* The Standard Sms Parser * * Messages for this parser should look like this: * "sender@example.com\nsubject\nbody" * (\n may be \r\n as well) */ public static String TAG = "PageParser-Standard"; public Alert parse(SmsMessage[] msgs){ ContentValues cv = new ContentValues();
cv.put(Pages.SERVICE_CENTER, msgs[0].getServiceCenterAddress());
muncus/klaxon-wip
src/org/nerdcircus/android/klaxon/PagerProvider.java
// Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Pages implements BaseColumns // { // public static final String TABLE_NAME = "pages"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/pages"); // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "created DESC"; // // /** // * The subject of the page // * <P>Type: TEXT</P> // */ // public static final String SUBJECT = "subject"; // // /** // * The text of the page // * <P>Type: TEXT</P> // */ // public static final String BODY = "body"; // // /** // * The timestamp for when the page was created // * <P>Type: INTEGER (long)</P> // */ // public static final String CREATED_DATE = "created"; // // /** // * The service center address from which the page was received. // * <P>Type: TEXT</P> // */ // public static final String SERVICE_CENTER = "sc_addr"; // // /** // * The originating address // * <P>Type: TEXT</P> // */ // public static final String SENDER = "sender_addr"; // // /** // * Acknowledgement status // * <P>Type: INTEGER</P> // */ // public static final String ACK_STATUS = "ack_status"; // // /** // * Email From address // * <P>Type: TEXT</P> // */ // public static final String FROM_ADDR = "email_from_addr"; // // /** // * String to identify the transport over which this page was received. // * <P>Type: TEXT</P> // */ // public static final String TRANSPORT = "transport"; // // /** // * Reply Uri - can be used to reply out-of-band to the sender. // * <P>Type: TEXT</P> // */ // public static final String REPLY_URI = "reply_uri"; // } // // Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Replies implements BaseColumns // { // public static final String TABLE_NAME = "replies"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/reply"); // // /** // * Short name of our reply. // */ // public static final String NAME = "name"; // // /** // * content of the reply. // */ // public static final String BODY = "body"; // /** // * new "ack status". integer. // */ // public static final String ACK_STATUS = "ack_status"; // /** // * whether this item should be shown in the menu. // */ // public static final String SHOW_IN_MENU = "show_in_menu"; // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "name ASC"; // }
import android.text.TextUtils; import android.util.Log; import org.nerdcircus.android.klaxon.Pager.Pages; import org.nerdcircus.android.klaxon.Pager.Replies; import android.content.ContentProvider; import android.content.ContentValues; import android.content.Context; import android.content.UriMatcher; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteQueryBuilder; import android.net.Uri;
default: throw new IllegalArgumentException("Unknown URL " + url); } } /** insert function that can be reused by all types */ private Uri insert(Uri base_uri, ContentValues values, String table){ SQLiteDatabase db = mDbHelper.getWritableDatabase(); long rowID = db.insert(table, null, values); Log.d(TAG, "Got row id: " + rowID ); if (rowID > 0) { Uri uri = Uri.withAppendedPath(base_uri, ""+rowID); getContext().getContentResolver().notifyChange(uri, null); return uri; } throw new SQLException("Failed to insert row into " + base_uri); } @Override public Uri insert(Uri url, ContentValues initialValues) { ContentValues values; if (initialValues != null) { values = new ContentValues(initialValues); } else { values = new ContentValues(); } switch(URL_MATCHER.match(url)){ case PAGES:
// Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Pages implements BaseColumns // { // public static final String TABLE_NAME = "pages"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/pages"); // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "created DESC"; // // /** // * The subject of the page // * <P>Type: TEXT</P> // */ // public static final String SUBJECT = "subject"; // // /** // * The text of the page // * <P>Type: TEXT</P> // */ // public static final String BODY = "body"; // // /** // * The timestamp for when the page was created // * <P>Type: INTEGER (long)</P> // */ // public static final String CREATED_DATE = "created"; // // /** // * The service center address from which the page was received. // * <P>Type: TEXT</P> // */ // public static final String SERVICE_CENTER = "sc_addr"; // // /** // * The originating address // * <P>Type: TEXT</P> // */ // public static final String SENDER = "sender_addr"; // // /** // * Acknowledgement status // * <P>Type: INTEGER</P> // */ // public static final String ACK_STATUS = "ack_status"; // // /** // * Email From address // * <P>Type: TEXT</P> // */ // public static final String FROM_ADDR = "email_from_addr"; // // /** // * String to identify the transport over which this page was received. // * <P>Type: TEXT</P> // */ // public static final String TRANSPORT = "transport"; // // /** // * Reply Uri - can be used to reply out-of-band to the sender. // * <P>Type: TEXT</P> // */ // public static final String REPLY_URI = "reply_uri"; // } // // Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Replies implements BaseColumns // { // public static final String TABLE_NAME = "replies"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/reply"); // // /** // * Short name of our reply. // */ // public static final String NAME = "name"; // // /** // * content of the reply. // */ // public static final String BODY = "body"; // /** // * new "ack status". integer. // */ // public static final String ACK_STATUS = "ack_status"; // /** // * whether this item should be shown in the menu. // */ // public static final String SHOW_IN_MENU = "show_in_menu"; // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "name ASC"; // } // Path: src/org/nerdcircus/android/klaxon/PagerProvider.java import android.text.TextUtils; import android.util.Log; import org.nerdcircus.android.klaxon.Pager.Pages; import org.nerdcircus.android.klaxon.Pager.Replies; import android.content.ContentProvider; import android.content.ContentValues; import android.content.Context; import android.content.UriMatcher; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteQueryBuilder; import android.net.Uri; default: throw new IllegalArgumentException("Unknown URL " + url); } } /** insert function that can be reused by all types */ private Uri insert(Uri base_uri, ContentValues values, String table){ SQLiteDatabase db = mDbHelper.getWritableDatabase(); long rowID = db.insert(table, null, values); Log.d(TAG, "Got row id: " + rowID ); if (rowID > 0) { Uri uri = Uri.withAppendedPath(base_uri, ""+rowID); getContext().getContentResolver().notifyChange(uri, null); return uri; } throw new SQLException("Failed to insert row into " + base_uri); } @Override public Uri insert(Uri url, ContentValues initialValues) { ContentValues values; if (initialValues != null) { values = new ContentValues(initialValues); } else { values = new ContentValues(); } switch(URL_MATCHER.match(url)){ case PAGES:
return insert(url, validatePageValues(values), Pages.TABLE_NAME);
muncus/klaxon-wip
src/org/nerdcircus/android/klaxon/PagerProvider.java
// Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Pages implements BaseColumns // { // public static final String TABLE_NAME = "pages"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/pages"); // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "created DESC"; // // /** // * The subject of the page // * <P>Type: TEXT</P> // */ // public static final String SUBJECT = "subject"; // // /** // * The text of the page // * <P>Type: TEXT</P> // */ // public static final String BODY = "body"; // // /** // * The timestamp for when the page was created // * <P>Type: INTEGER (long)</P> // */ // public static final String CREATED_DATE = "created"; // // /** // * The service center address from which the page was received. // * <P>Type: TEXT</P> // */ // public static final String SERVICE_CENTER = "sc_addr"; // // /** // * The originating address // * <P>Type: TEXT</P> // */ // public static final String SENDER = "sender_addr"; // // /** // * Acknowledgement status // * <P>Type: INTEGER</P> // */ // public static final String ACK_STATUS = "ack_status"; // // /** // * Email From address // * <P>Type: TEXT</P> // */ // public static final String FROM_ADDR = "email_from_addr"; // // /** // * String to identify the transport over which this page was received. // * <P>Type: TEXT</P> // */ // public static final String TRANSPORT = "transport"; // // /** // * Reply Uri - can be used to reply out-of-band to the sender. // * <P>Type: TEXT</P> // */ // public static final String REPLY_URI = "reply_uri"; // } // // Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Replies implements BaseColumns // { // public static final String TABLE_NAME = "replies"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/reply"); // // /** // * Short name of our reply. // */ // public static final String NAME = "name"; // // /** // * content of the reply. // */ // public static final String BODY = "body"; // /** // * new "ack status". integer. // */ // public static final String ACK_STATUS = "ack_status"; // /** // * whether this item should be shown in the menu. // */ // public static final String SHOW_IN_MENU = "show_in_menu"; // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "name ASC"; // }
import android.text.TextUtils; import android.util.Log; import org.nerdcircus.android.klaxon.Pager.Pages; import org.nerdcircus.android.klaxon.Pager.Replies; import android.content.ContentProvider; import android.content.ContentValues; import android.content.Context; import android.content.UriMatcher; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteQueryBuilder; import android.net.Uri;
throw new IllegalArgumentException("Unknown URL " + url); } } /** insert function that can be reused by all types */ private Uri insert(Uri base_uri, ContentValues values, String table){ SQLiteDatabase db = mDbHelper.getWritableDatabase(); long rowID = db.insert(table, null, values); Log.d(TAG, "Got row id: " + rowID ); if (rowID > 0) { Uri uri = Uri.withAppendedPath(base_uri, ""+rowID); getContext().getContentResolver().notifyChange(uri, null); return uri; } throw new SQLException("Failed to insert row into " + base_uri); } @Override public Uri insert(Uri url, ContentValues initialValues) { ContentValues values; if (initialValues != null) { values = new ContentValues(initialValues); } else { values = new ContentValues(); } switch(URL_MATCHER.match(url)){ case PAGES: return insert(url, validatePageValues(values), Pages.TABLE_NAME); case REPLIES:
// Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Pages implements BaseColumns // { // public static final String TABLE_NAME = "pages"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/pages"); // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "created DESC"; // // /** // * The subject of the page // * <P>Type: TEXT</P> // */ // public static final String SUBJECT = "subject"; // // /** // * The text of the page // * <P>Type: TEXT</P> // */ // public static final String BODY = "body"; // // /** // * The timestamp for when the page was created // * <P>Type: INTEGER (long)</P> // */ // public static final String CREATED_DATE = "created"; // // /** // * The service center address from which the page was received. // * <P>Type: TEXT</P> // */ // public static final String SERVICE_CENTER = "sc_addr"; // // /** // * The originating address // * <P>Type: TEXT</P> // */ // public static final String SENDER = "sender_addr"; // // /** // * Acknowledgement status // * <P>Type: INTEGER</P> // */ // public static final String ACK_STATUS = "ack_status"; // // /** // * Email From address // * <P>Type: TEXT</P> // */ // public static final String FROM_ADDR = "email_from_addr"; // // /** // * String to identify the transport over which this page was received. // * <P>Type: TEXT</P> // */ // public static final String TRANSPORT = "transport"; // // /** // * Reply Uri - can be used to reply out-of-band to the sender. // * <P>Type: TEXT</P> // */ // public static final String REPLY_URI = "reply_uri"; // } // // Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Replies implements BaseColumns // { // public static final String TABLE_NAME = "replies"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/reply"); // // /** // * Short name of our reply. // */ // public static final String NAME = "name"; // // /** // * content of the reply. // */ // public static final String BODY = "body"; // /** // * new "ack status". integer. // */ // public static final String ACK_STATUS = "ack_status"; // /** // * whether this item should be shown in the menu. // */ // public static final String SHOW_IN_MENU = "show_in_menu"; // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "name ASC"; // } // Path: src/org/nerdcircus/android/klaxon/PagerProvider.java import android.text.TextUtils; import android.util.Log; import org.nerdcircus.android.klaxon.Pager.Pages; import org.nerdcircus.android.klaxon.Pager.Replies; import android.content.ContentProvider; import android.content.ContentValues; import android.content.Context; import android.content.UriMatcher; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteQueryBuilder; import android.net.Uri; throw new IllegalArgumentException("Unknown URL " + url); } } /** insert function that can be reused by all types */ private Uri insert(Uri base_uri, ContentValues values, String table){ SQLiteDatabase db = mDbHelper.getWritableDatabase(); long rowID = db.insert(table, null, values); Log.d(TAG, "Got row id: " + rowID ); if (rowID > 0) { Uri uri = Uri.withAppendedPath(base_uri, ""+rowID); getContext().getContentResolver().notifyChange(uri, null); return uri; } throw new SQLException("Failed to insert row into " + base_uri); } @Override public Uri insert(Uri url, ContentValues initialValues) { ContentValues values; if (initialValues != null) { values = new ContentValues(initialValues); } else { values = new ContentValues(); } switch(URL_MATCHER.match(url)){ case PAGES: return insert(url, validatePageValues(values), Pages.TABLE_NAME); case REPLIES:
return insert(url, validateReplyValues(values), Replies.TABLE_NAME);
muncus/klaxon-wip
tests/src/org/nerdcircus/android/klaxon/tests/app/ReplyListTest.java
// Path: src/org/nerdcircus/android/klaxon/ReplyList.java // public class ReplyList extends ListActivity // { // private String TAG = "ReplyList"; // // //menu constants. // private int MENU_ACTIONS_GROUP = Menu.FIRST; // private int MENU_ALWAYS_GROUP = Menu.FIRST + 1; // private int MENU_ADD = Menu.FIRST + 2; // // private Cursor mCursor; // // @Override // public void onCreate(Bundle icicle) // { // super.onCreate(icicle); // // setContentView(R.layout.replylist); // // String[] cols = new String[] {Replies._ID, Replies.NAME, Replies.BODY, Replies.ACK_STATUS }; // mCursor = Pager.Replies.query(this.getContentResolver(), cols); // startManagingCursor(mCursor); // ListAdapter adapter = new ReplyAdapter(this, // R.layout.replylist_item, // mCursor); // setListAdapter(adapter); // } // // public void onListItemClick(ListView parent, View v, int position, long id){ // Log.d(TAG, "Item clicked!"); // Uri uri = Uri.withAppendedPath(Pager.Replies.CONTENT_URI, ""+id); // Log.d(TAG, "intent that started us: " + this.getIntent().getAction()); // if( this.getIntent().getAction().equals(Intent.ACTION_PICK) ){ // //we're picking responses, not editing them. // Log.d(TAG, "pick action. returning result."); // //Note: this reuses the sent Intent, so we dont lose the 'page_uri' data, if included. // setResult(RESULT_OK, new Intent(this.getIntent()).setData(uri)); // finish(); // } // else { // Log.d(TAG, "not picking, edit."); // Intent i = new Intent(Intent.ACTION_EDIT, uri); // startActivity(i); // } // } // // @Override // public boolean onCreateOptionsMenu(Menu menu) { // super.onCreateOptionsMenu(menu); // final Context appcontext = (Context)this; // MenuItem mi; // mi = menu.add(MENU_ACTIONS_GROUP, MENU_ADD, Menu.NONE, R.string.add_reply); // Intent i = new Intent(Intent.ACTION_INSERT, // Replies.CONTENT_URI); // mi.setIntent(i); // // return true; // } // // @Override // public boolean onPrepareOptionsMenu(Menu menu){ // Log.d(TAG, "preparing options menu"); // super.onPrepareOptionsMenu(menu); // final boolean haveItems = mCursor.getCount() > 0; // menu.setGroupVisible(MENU_ACTIONS_GROUP, haveItems); // menu.setGroupVisible(MENU_ALWAYS_GROUP, true); // return true; // } // // }
import android.test.ActivityInstrumentationTestCase2; import android.test.InstrumentationTestCase; import android.os.Bundle; import org.nerdcircus.android.klaxon.ReplyList;
package org.nerdcircus.android.klaxon.tests.app; public class ReplyListTest extends ActivityInstrumentationTestCase2 { public ReplyListTest(){
// Path: src/org/nerdcircus/android/klaxon/ReplyList.java // public class ReplyList extends ListActivity // { // private String TAG = "ReplyList"; // // //menu constants. // private int MENU_ACTIONS_GROUP = Menu.FIRST; // private int MENU_ALWAYS_GROUP = Menu.FIRST + 1; // private int MENU_ADD = Menu.FIRST + 2; // // private Cursor mCursor; // // @Override // public void onCreate(Bundle icicle) // { // super.onCreate(icicle); // // setContentView(R.layout.replylist); // // String[] cols = new String[] {Replies._ID, Replies.NAME, Replies.BODY, Replies.ACK_STATUS }; // mCursor = Pager.Replies.query(this.getContentResolver(), cols); // startManagingCursor(mCursor); // ListAdapter adapter = new ReplyAdapter(this, // R.layout.replylist_item, // mCursor); // setListAdapter(adapter); // } // // public void onListItemClick(ListView parent, View v, int position, long id){ // Log.d(TAG, "Item clicked!"); // Uri uri = Uri.withAppendedPath(Pager.Replies.CONTENT_URI, ""+id); // Log.d(TAG, "intent that started us: " + this.getIntent().getAction()); // if( this.getIntent().getAction().equals(Intent.ACTION_PICK) ){ // //we're picking responses, not editing them. // Log.d(TAG, "pick action. returning result."); // //Note: this reuses the sent Intent, so we dont lose the 'page_uri' data, if included. // setResult(RESULT_OK, new Intent(this.getIntent()).setData(uri)); // finish(); // } // else { // Log.d(TAG, "not picking, edit."); // Intent i = new Intent(Intent.ACTION_EDIT, uri); // startActivity(i); // } // } // // @Override // public boolean onCreateOptionsMenu(Menu menu) { // super.onCreateOptionsMenu(menu); // final Context appcontext = (Context)this; // MenuItem mi; // mi = menu.add(MENU_ACTIONS_GROUP, MENU_ADD, Menu.NONE, R.string.add_reply); // Intent i = new Intent(Intent.ACTION_INSERT, // Replies.CONTENT_URI); // mi.setIntent(i); // // return true; // } // // @Override // public boolean onPrepareOptionsMenu(Menu menu){ // Log.d(TAG, "preparing options menu"); // super.onPrepareOptionsMenu(menu); // final boolean haveItems = mCursor.getCount() > 0; // menu.setGroupVisible(MENU_ACTIONS_GROUP, haveItems); // menu.setGroupVisible(MENU_ALWAYS_GROUP, true); // return true; // } // // } // Path: tests/src/org/nerdcircus/android/klaxon/tests/app/ReplyListTest.java import android.test.ActivityInstrumentationTestCase2; import android.test.InstrumentationTestCase; import android.os.Bundle; import org.nerdcircus.android.klaxon.ReplyList; package org.nerdcircus.android.klaxon.tests.app; public class ReplyListTest extends ActivityInstrumentationTestCase2 { public ReplyListTest(){
super("org.nerdcircus.android.klaxon", ReplyList.class);
muncus/klaxon-wip
src/org/nerdcircus/android/klaxon/ReplyEditor.java
// Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Replies implements BaseColumns // { // public static final String TABLE_NAME = "replies"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/reply"); // // /** // * Short name of our reply. // */ // public static final String NAME = "name"; // // /** // * content of the reply. // */ // public static final String BODY = "body"; // /** // * new "ack status". integer. // */ // public static final String ACK_STATUS = "ack_status"; // /** // * whether this item should be shown in the menu. // */ // public static final String SHOW_IN_MENU = "show_in_menu"; // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "name ASC"; // }
import android.app.Activity; import android.content.ContentValues; import android.content.Intent; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.*; import org.nerdcircus.android.klaxon.Pager.Replies; import java.util.ArrayList;
/* * Copyright 2008 Google 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 org.nerdcircus.android.klaxon; public class ReplyEditor extends Activity { private String TAG = "ReplyEditor"; private Uri mContentURI; private Cursor mCursor; private EditText mSubjectView; private EditText mBodyView; private ImageView mIconView; private CheckBox mCheckBox; private Spinner mAckStatusSpinner; private ArrayList<Integer> mAckStatusList = new ArrayList<Integer>(); @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.replyeditor); /* stash our statuses in the ack status list*/ mAckStatusList.add(Integer.valueOf(0)); mAckStatusList.add(Integer.valueOf(1)); mAckStatusList.add(Integer.valueOf(2)); mSubjectView = (EditText) findViewById(R.id.subject); mBodyView = (EditText) findViewById(R.id.body); mCheckBox = (CheckBox) findViewById(R.id.show_in_menu); mAckStatusSpinner = (Spinner) findViewById(R.id.ack_status_spinner); mAckStatusSpinner.setAdapter(new AckStatusAdapter(this, R.layout.ackstatusspinner, mAckStatusList)); Intent i = getIntent(); mContentURI = i.getData(); /* add onclick listeners for cancel and delete. */ Button button = (Button) findViewById(R.id.delete_button); if(i.getAction().equals(Intent.ACTION_EDIT)){ button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { doDelete(); finish(); } }); } else { button.setVisibility(View.GONE); } //dont show the button if not editing. button = (Button) findViewById(R.id.cancel_button); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { finish(); } }); button = (Button) findViewById(R.id.save_button); if(i.getAction().equals(Intent.ACTION_EDIT)){ button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { doSave(); finish(); } }); } else { button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { doInsert(); finish(); } }); } if(i.getAction().equals(Intent.ACTION_EDIT)){ Log.d(TAG, "displaying: "+mContentURI.toString()); mCursor = managedQuery(mContentURI,
// Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Replies implements BaseColumns // { // public static final String TABLE_NAME = "replies"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/reply"); // // /** // * Short name of our reply. // */ // public static final String NAME = "name"; // // /** // * content of the reply. // */ // public static final String BODY = "body"; // /** // * new "ack status". integer. // */ // public static final String ACK_STATUS = "ack_status"; // /** // * whether this item should be shown in the menu. // */ // public static final String SHOW_IN_MENU = "show_in_menu"; // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "name ASC"; // } // Path: src/org/nerdcircus/android/klaxon/ReplyEditor.java import android.app.Activity; import android.content.ContentValues; import android.content.Intent; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.*; import org.nerdcircus.android.klaxon.Pager.Replies; import java.util.ArrayList; /* * Copyright 2008 Google 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 org.nerdcircus.android.klaxon; public class ReplyEditor extends Activity { private String TAG = "ReplyEditor"; private Uri mContentURI; private Cursor mCursor; private EditText mSubjectView; private EditText mBodyView; private ImageView mIconView; private CheckBox mCheckBox; private Spinner mAckStatusSpinner; private ArrayList<Integer> mAckStatusList = new ArrayList<Integer>(); @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.replyeditor); /* stash our statuses in the ack status list*/ mAckStatusList.add(Integer.valueOf(0)); mAckStatusList.add(Integer.valueOf(1)); mAckStatusList.add(Integer.valueOf(2)); mSubjectView = (EditText) findViewById(R.id.subject); mBodyView = (EditText) findViewById(R.id.body); mCheckBox = (CheckBox) findViewById(R.id.show_in_menu); mAckStatusSpinner = (Spinner) findViewById(R.id.ack_status_spinner); mAckStatusSpinner.setAdapter(new AckStatusAdapter(this, R.layout.ackstatusspinner, mAckStatusList)); Intent i = getIntent(); mContentURI = i.getData(); /* add onclick listeners for cancel and delete. */ Button button = (Button) findViewById(R.id.delete_button); if(i.getAction().equals(Intent.ACTION_EDIT)){ button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { doDelete(); finish(); } }); } else { button.setVisibility(View.GONE); } //dont show the button if not editing. button = (Button) findViewById(R.id.cancel_button); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { finish(); } }); button = (Button) findViewById(R.id.save_button); if(i.getAction().equals(Intent.ACTION_EDIT)){ button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { doSave(); finish(); } }); } else { button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { doInsert(); finish(); } }); } if(i.getAction().equals(Intent.ACTION_EDIT)){ Log.d(TAG, "displaying: "+mContentURI.toString()); mCursor = managedQuery(mContentURI,
new String[] {Replies._ID, Replies.NAME, Replies.BODY, Replies.ACK_STATUS, Replies.SHOW_IN_MENU},
muncus/klaxon-wip
src/org/nerdcircus/android/klaxon/pageparser/LabeledFields.java
// Path: src/org/nerdcircus/android/klaxon/Alert.java // public class Alert { // private ContentValues cv; // String DEFAULT_FROM = "Unknown Sender"; // String DEFAULT_SUBJECT = "Subject not specified"; // String DEFAULT_BODY = "Body not specified"; // // public Alert(){ // cv = new ContentValues(); // setFrom(DEFAULT_FROM); // setDisplayFrom(DEFAULT_FROM); // setSubject(DEFAULT_SUBJECT); // setBody(DEFAULT_BODY); // if( ! cv.containsKey(Pages.ACK_STATUS)) // cv.put(Pages.ACK_STATUS, 0); //default to no response. // } // // //clone contentvalues, so we can start passing around Alerts instead. // public Alert(ContentValues v){ // cv = v; // } // // public Alert(String from, String subj, String body){ // setFrom(from); // setDisplayFrom(from); // setSubject(subj); // setBody(body); // setTransport("sms"); // } // // // "raw" from address, for use in replying. // public void setFrom(String from){ // cv.put(Pages.SENDER, from); // } // public String getFrom(){ // return cv.getAsString(Pages.SENDER); // } // // // Intended to be used with Intent.ACTION_SEND // public void setReplyUri(String uri){ // cv.put(Pages.REPLY_URI, uri); // } // // "DisplayName" analog - phone number, or email addr. // public void setDisplayFrom(String from){ // cv.put(Pages.FROM_ADDR, from); // } // public String getDisplayFrom(){ // return cv.getAsString(Pages.FROM_ADDR); // } // // // subject line of the alert // public void setSubject(String from){ // cv.put(Pages.SUBJECT, from); // } // public String getSubject(){ // return cv.getAsString(Pages.SUBJECT); // } // // // body of the alert. // public void setBody(String body){ // cv.put(Pages.BODY, body); // } // public String getBody(){ // return cv.getAsString(Pages.BODY); // } // // public void setTransport(String t){ // cv.put(Pages.TRANSPORT, t); // } // // // used for inserting this alert into our contentprovider // public ContentValues asContentValues(){ // return cv; // } // } // // Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Pages implements BaseColumns // { // public static final String TABLE_NAME = "pages"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/pages"); // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "created DESC"; // // /** // * The subject of the page // * <P>Type: TEXT</P> // */ // public static final String SUBJECT = "subject"; // // /** // * The text of the page // * <P>Type: TEXT</P> // */ // public static final String BODY = "body"; // // /** // * The timestamp for when the page was created // * <P>Type: INTEGER (long)</P> // */ // public static final String CREATED_DATE = "created"; // // /** // * The service center address from which the page was received. // * <P>Type: TEXT</P> // */ // public static final String SERVICE_CENTER = "sc_addr"; // // /** // * The originating address // * <P>Type: TEXT</P> // */ // public static final String SENDER = "sender_addr"; // // /** // * Acknowledgement status // * <P>Type: INTEGER</P> // */ // public static final String ACK_STATUS = "ack_status"; // // /** // * Email From address // * <P>Type: TEXT</P> // */ // public static final String FROM_ADDR = "email_from_addr"; // // /** // * String to identify the transport over which this page was received. // * <P>Type: TEXT</P> // */ // public static final String TRANSPORT = "transport"; // // /** // * Reply Uri - can be used to reply out-of-band to the sender. // * <P>Type: TEXT</P> // */ // public static final String REPLY_URI = "reply_uri"; // }
import java.util.Locale; import android.content.ContentValues; import android.telephony.SmsMessage; import org.nerdcircus.android.klaxon.Alert; import org.nerdcircus.android.klaxon.Pager.Pages;
package org.nerdcircus.android.klaxon.pageparser; public class LabeledFields extends Standard { /* pageparser for gateways which include labels like "subj:", etc. */ public static String TAG = "PageParser-Labeled";
// Path: src/org/nerdcircus/android/klaxon/Alert.java // public class Alert { // private ContentValues cv; // String DEFAULT_FROM = "Unknown Sender"; // String DEFAULT_SUBJECT = "Subject not specified"; // String DEFAULT_BODY = "Body not specified"; // // public Alert(){ // cv = new ContentValues(); // setFrom(DEFAULT_FROM); // setDisplayFrom(DEFAULT_FROM); // setSubject(DEFAULT_SUBJECT); // setBody(DEFAULT_BODY); // if( ! cv.containsKey(Pages.ACK_STATUS)) // cv.put(Pages.ACK_STATUS, 0); //default to no response. // } // // //clone contentvalues, so we can start passing around Alerts instead. // public Alert(ContentValues v){ // cv = v; // } // // public Alert(String from, String subj, String body){ // setFrom(from); // setDisplayFrom(from); // setSubject(subj); // setBody(body); // setTransport("sms"); // } // // // "raw" from address, for use in replying. // public void setFrom(String from){ // cv.put(Pages.SENDER, from); // } // public String getFrom(){ // return cv.getAsString(Pages.SENDER); // } // // // Intended to be used with Intent.ACTION_SEND // public void setReplyUri(String uri){ // cv.put(Pages.REPLY_URI, uri); // } // // "DisplayName" analog - phone number, or email addr. // public void setDisplayFrom(String from){ // cv.put(Pages.FROM_ADDR, from); // } // public String getDisplayFrom(){ // return cv.getAsString(Pages.FROM_ADDR); // } // // // subject line of the alert // public void setSubject(String from){ // cv.put(Pages.SUBJECT, from); // } // public String getSubject(){ // return cv.getAsString(Pages.SUBJECT); // } // // // body of the alert. // public void setBody(String body){ // cv.put(Pages.BODY, body); // } // public String getBody(){ // return cv.getAsString(Pages.BODY); // } // // public void setTransport(String t){ // cv.put(Pages.TRANSPORT, t); // } // // // used for inserting this alert into our contentprovider // public ContentValues asContentValues(){ // return cv; // } // } // // Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Pages implements BaseColumns // { // public static final String TABLE_NAME = "pages"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/pages"); // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "created DESC"; // // /** // * The subject of the page // * <P>Type: TEXT</P> // */ // public static final String SUBJECT = "subject"; // // /** // * The text of the page // * <P>Type: TEXT</P> // */ // public static final String BODY = "body"; // // /** // * The timestamp for when the page was created // * <P>Type: INTEGER (long)</P> // */ // public static final String CREATED_DATE = "created"; // // /** // * The service center address from which the page was received. // * <P>Type: TEXT</P> // */ // public static final String SERVICE_CENTER = "sc_addr"; // // /** // * The originating address // * <P>Type: TEXT</P> // */ // public static final String SENDER = "sender_addr"; // // /** // * Acknowledgement status // * <P>Type: INTEGER</P> // */ // public static final String ACK_STATUS = "ack_status"; // // /** // * Email From address // * <P>Type: TEXT</P> // */ // public static final String FROM_ADDR = "email_from_addr"; // // /** // * String to identify the transport over which this page was received. // * <P>Type: TEXT</P> // */ // public static final String TRANSPORT = "transport"; // // /** // * Reply Uri - can be used to reply out-of-band to the sender. // * <P>Type: TEXT</P> // */ // public static final String REPLY_URI = "reply_uri"; // } // Path: src/org/nerdcircus/android/klaxon/pageparser/LabeledFields.java import java.util.Locale; import android.content.ContentValues; import android.telephony.SmsMessage; import org.nerdcircus.android.klaxon.Alert; import org.nerdcircus.android.klaxon.Pager.Pages; package org.nerdcircus.android.klaxon.pageparser; public class LabeledFields extends Standard { /* pageparser for gateways which include labels like "subj:", etc. */ public static String TAG = "PageParser-Labeled";
public Alert parse(SmsMessage[] msgs){
muncus/klaxon-wip
src/org/nerdcircus/android/klaxon/pageparser/LabeledFields.java
// Path: src/org/nerdcircus/android/klaxon/Alert.java // public class Alert { // private ContentValues cv; // String DEFAULT_FROM = "Unknown Sender"; // String DEFAULT_SUBJECT = "Subject not specified"; // String DEFAULT_BODY = "Body not specified"; // // public Alert(){ // cv = new ContentValues(); // setFrom(DEFAULT_FROM); // setDisplayFrom(DEFAULT_FROM); // setSubject(DEFAULT_SUBJECT); // setBody(DEFAULT_BODY); // if( ! cv.containsKey(Pages.ACK_STATUS)) // cv.put(Pages.ACK_STATUS, 0); //default to no response. // } // // //clone contentvalues, so we can start passing around Alerts instead. // public Alert(ContentValues v){ // cv = v; // } // // public Alert(String from, String subj, String body){ // setFrom(from); // setDisplayFrom(from); // setSubject(subj); // setBody(body); // setTransport("sms"); // } // // // "raw" from address, for use in replying. // public void setFrom(String from){ // cv.put(Pages.SENDER, from); // } // public String getFrom(){ // return cv.getAsString(Pages.SENDER); // } // // // Intended to be used with Intent.ACTION_SEND // public void setReplyUri(String uri){ // cv.put(Pages.REPLY_URI, uri); // } // // "DisplayName" analog - phone number, or email addr. // public void setDisplayFrom(String from){ // cv.put(Pages.FROM_ADDR, from); // } // public String getDisplayFrom(){ // return cv.getAsString(Pages.FROM_ADDR); // } // // // subject line of the alert // public void setSubject(String from){ // cv.put(Pages.SUBJECT, from); // } // public String getSubject(){ // return cv.getAsString(Pages.SUBJECT); // } // // // body of the alert. // public void setBody(String body){ // cv.put(Pages.BODY, body); // } // public String getBody(){ // return cv.getAsString(Pages.BODY); // } // // public void setTransport(String t){ // cv.put(Pages.TRANSPORT, t); // } // // // used for inserting this alert into our contentprovider // public ContentValues asContentValues(){ // return cv; // } // } // // Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Pages implements BaseColumns // { // public static final String TABLE_NAME = "pages"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/pages"); // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "created DESC"; // // /** // * The subject of the page // * <P>Type: TEXT</P> // */ // public static final String SUBJECT = "subject"; // // /** // * The text of the page // * <P>Type: TEXT</P> // */ // public static final String BODY = "body"; // // /** // * The timestamp for when the page was created // * <P>Type: INTEGER (long)</P> // */ // public static final String CREATED_DATE = "created"; // // /** // * The service center address from which the page was received. // * <P>Type: TEXT</P> // */ // public static final String SERVICE_CENTER = "sc_addr"; // // /** // * The originating address // * <P>Type: TEXT</P> // */ // public static final String SENDER = "sender_addr"; // // /** // * Acknowledgement status // * <P>Type: INTEGER</P> // */ // public static final String ACK_STATUS = "ack_status"; // // /** // * Email From address // * <P>Type: TEXT</P> // */ // public static final String FROM_ADDR = "email_from_addr"; // // /** // * String to identify the transport over which this page was received. // * <P>Type: TEXT</P> // */ // public static final String TRANSPORT = "transport"; // // /** // * Reply Uri - can be used to reply out-of-band to the sender. // * <P>Type: TEXT</P> // */ // public static final String REPLY_URI = "reply_uri"; // }
import java.util.Locale; import android.content.ContentValues; import android.telephony.SmsMessage; import org.nerdcircus.android.klaxon.Alert; import org.nerdcircus.android.klaxon.Pager.Pages;
package org.nerdcircus.android.klaxon.pageparser; public class LabeledFields extends Standard { /* pageparser for gateways which include labels like "subj:", etc. */ public static String TAG = "PageParser-Labeled"; public Alert parse(SmsMessage[] msgs){ Alert a = super.parse(msgs); //XXX: this should probably just use the Alert return new Alert(doCleanup(a.asContentValues())); } public Alert parse(String from, String subj, String message_text){ Alert a = super.parse(from, subj, message_text); return new Alert(doCleanup(a.asContentValues())); } protected ContentValues doCleanup(ContentValues cv){ cv = super.doCleanup(cv); cv = cleanupLabeledFields(cv); return cv; } /* * Message Cleanup Functions * functions below are intended to "clean up" messages that may not parse correctly. * they should be called in the doCleanup() function above */ private ContentValues cleanupLabeledFields(ContentValues cv){
// Path: src/org/nerdcircus/android/klaxon/Alert.java // public class Alert { // private ContentValues cv; // String DEFAULT_FROM = "Unknown Sender"; // String DEFAULT_SUBJECT = "Subject not specified"; // String DEFAULT_BODY = "Body not specified"; // // public Alert(){ // cv = new ContentValues(); // setFrom(DEFAULT_FROM); // setDisplayFrom(DEFAULT_FROM); // setSubject(DEFAULT_SUBJECT); // setBody(DEFAULT_BODY); // if( ! cv.containsKey(Pages.ACK_STATUS)) // cv.put(Pages.ACK_STATUS, 0); //default to no response. // } // // //clone contentvalues, so we can start passing around Alerts instead. // public Alert(ContentValues v){ // cv = v; // } // // public Alert(String from, String subj, String body){ // setFrom(from); // setDisplayFrom(from); // setSubject(subj); // setBody(body); // setTransport("sms"); // } // // // "raw" from address, for use in replying. // public void setFrom(String from){ // cv.put(Pages.SENDER, from); // } // public String getFrom(){ // return cv.getAsString(Pages.SENDER); // } // // // Intended to be used with Intent.ACTION_SEND // public void setReplyUri(String uri){ // cv.put(Pages.REPLY_URI, uri); // } // // "DisplayName" analog - phone number, or email addr. // public void setDisplayFrom(String from){ // cv.put(Pages.FROM_ADDR, from); // } // public String getDisplayFrom(){ // return cv.getAsString(Pages.FROM_ADDR); // } // // // subject line of the alert // public void setSubject(String from){ // cv.put(Pages.SUBJECT, from); // } // public String getSubject(){ // return cv.getAsString(Pages.SUBJECT); // } // // // body of the alert. // public void setBody(String body){ // cv.put(Pages.BODY, body); // } // public String getBody(){ // return cv.getAsString(Pages.BODY); // } // // public void setTransport(String t){ // cv.put(Pages.TRANSPORT, t); // } // // // used for inserting this alert into our contentprovider // public ContentValues asContentValues(){ // return cv; // } // } // // Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Pages implements BaseColumns // { // public static final String TABLE_NAME = "pages"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/pages"); // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "created DESC"; // // /** // * The subject of the page // * <P>Type: TEXT</P> // */ // public static final String SUBJECT = "subject"; // // /** // * The text of the page // * <P>Type: TEXT</P> // */ // public static final String BODY = "body"; // // /** // * The timestamp for when the page was created // * <P>Type: INTEGER (long)</P> // */ // public static final String CREATED_DATE = "created"; // // /** // * The service center address from which the page was received. // * <P>Type: TEXT</P> // */ // public static final String SERVICE_CENTER = "sc_addr"; // // /** // * The originating address // * <P>Type: TEXT</P> // */ // public static final String SENDER = "sender_addr"; // // /** // * Acknowledgement status // * <P>Type: INTEGER</P> // */ // public static final String ACK_STATUS = "ack_status"; // // /** // * Email From address // * <P>Type: TEXT</P> // */ // public static final String FROM_ADDR = "email_from_addr"; // // /** // * String to identify the transport over which this page was received. // * <P>Type: TEXT</P> // */ // public static final String TRANSPORT = "transport"; // // /** // * Reply Uri - can be used to reply out-of-band to the sender. // * <P>Type: TEXT</P> // */ // public static final String REPLY_URI = "reply_uri"; // } // Path: src/org/nerdcircus/android/klaxon/pageparser/LabeledFields.java import java.util.Locale; import android.content.ContentValues; import android.telephony.SmsMessage; import org.nerdcircus.android.klaxon.Alert; import org.nerdcircus.android.klaxon.Pager.Pages; package org.nerdcircus.android.klaxon.pageparser; public class LabeledFields extends Standard { /* pageparser for gateways which include labels like "subj:", etc. */ public static String TAG = "PageParser-Labeled"; public Alert parse(SmsMessage[] msgs){ Alert a = super.parse(msgs); //XXX: this should probably just use the Alert return new Alert(doCleanup(a.asContentValues())); } public Alert parse(String from, String subj, String message_text){ Alert a = super.parse(from, subj, message_text); return new Alert(doCleanup(a.asContentValues())); } protected ContentValues doCleanup(ContentValues cv){ cv = super.doCleanup(cv); cv = cleanupLabeledFields(cv); return cv; } /* * Message Cleanup Functions * functions below are intended to "clean up" messages that may not parse correctly. * they should be called in the doCleanup() function above */ private ContentValues cleanupLabeledFields(ContentValues cv){
String body = cv.getAsString(Pages.BODY);
muncus/klaxon-wip
src/org/nerdcircus/android/klaxon/pageparser/Go2Mobile.java
// Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Pages implements BaseColumns // { // public static final String TABLE_NAME = "pages"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/pages"); // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "created DESC"; // // /** // * The subject of the page // * <P>Type: TEXT</P> // */ // public static final String SUBJECT = "subject"; // // /** // * The text of the page // * <P>Type: TEXT</P> // */ // public static final String BODY = "body"; // // /** // * The timestamp for when the page was created // * <P>Type: INTEGER (long)</P> // */ // public static final String CREATED_DATE = "created"; // // /** // * The service center address from which the page was received. // * <P>Type: TEXT</P> // */ // public static final String SERVICE_CENTER = "sc_addr"; // // /** // * The originating address // * <P>Type: TEXT</P> // */ // public static final String SENDER = "sender_addr"; // // /** // * Acknowledgement status // * <P>Type: INTEGER</P> // */ // public static final String ACK_STATUS = "ack_status"; // // /** // * Email From address // * <P>Type: TEXT</P> // */ // public static final String FROM_ADDR = "email_from_addr"; // // /** // * String to identify the transport over which this page was received. // * <P>Type: TEXT</P> // */ // public static final String TRANSPORT = "transport"; // // /** // * Reply Uri - can be used to reply out-of-band to the sender. // * <P>Type: TEXT</P> // */ // public static final String REPLY_URI = "reply_uri"; // }
import android.content.ContentValues; import android.util.Log; import org.nerdcircus.android.klaxon.Pager.Pages;
package org.nerdcircus.android.klaxon.pageparser; public class Go2Mobile extends Standard { /* pageparser for go2mobile.com * basically just Standard, but with ':' as a linebreak * * Messages for this parser should look like this: * "sender@example.com:subject:body" */ public static String TAG = "PageParser-Go2Mobile"; protected ContentValues doCleanup(ContentValues cv){ cv = parseColonLineEndings(cv); Log.d(TAG, "after go2mobile parsing:");
// Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Pages implements BaseColumns // { // public static final String TABLE_NAME = "pages"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/pages"); // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "created DESC"; // // /** // * The subject of the page // * <P>Type: TEXT</P> // */ // public static final String SUBJECT = "subject"; // // /** // * The text of the page // * <P>Type: TEXT</P> // */ // public static final String BODY = "body"; // // /** // * The timestamp for when the page was created // * <P>Type: INTEGER (long)</P> // */ // public static final String CREATED_DATE = "created"; // // /** // * The service center address from which the page was received. // * <P>Type: TEXT</P> // */ // public static final String SERVICE_CENTER = "sc_addr"; // // /** // * The originating address // * <P>Type: TEXT</P> // */ // public static final String SENDER = "sender_addr"; // // /** // * Acknowledgement status // * <P>Type: INTEGER</P> // */ // public static final String ACK_STATUS = "ack_status"; // // /** // * Email From address // * <P>Type: TEXT</P> // */ // public static final String FROM_ADDR = "email_from_addr"; // // /** // * String to identify the transport over which this page was received. // * <P>Type: TEXT</P> // */ // public static final String TRANSPORT = "transport"; // // /** // * Reply Uri - can be used to reply out-of-band to the sender. // * <P>Type: TEXT</P> // */ // public static final String REPLY_URI = "reply_uri"; // } // Path: src/org/nerdcircus/android/klaxon/pageparser/Go2Mobile.java import android.content.ContentValues; import android.util.Log; import org.nerdcircus.android.klaxon.Pager.Pages; package org.nerdcircus.android.klaxon.pageparser; public class Go2Mobile extends Standard { /* pageparser for go2mobile.com * basically just Standard, but with ':' as a linebreak * * Messages for this parser should look like this: * "sender@example.com:subject:body" */ public static String TAG = "PageParser-Go2Mobile"; protected ContentValues doCleanup(ContentValues cv){ cv = parseColonLineEndings(cv); Log.d(TAG, "after go2mobile parsing:");
Log.d(TAG, "From: " + cv.getAsString(Pages.FROM_ADDR));
muncus/klaxon-wip
tests/src/org/nerdcircus/android/klaxon/tests/app/PreferencesTest.java
// Path: src/org/nerdcircus/android/klaxon/Preferences.java // public class Preferences extends PreferenceActivity { // // private final String TAG = "KlaxonPreferences"; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // // Load the preferences from an XML resource // addPreferencesFromResource(R.xml.preferences); // // Preference replylist = this.findPreference("edit_replies"); // if(replylist != null){ // Intent i = new Intent(Intent.ACTION_MAIN); // i.setClass(this, ReplyList.class); // replylist.setIntent(i); // } // // // rig up the Changelog // replylist = this.findPreference("changelog"); // if(replylist != null){ // Intent i = new Intent(Intent.ACTION_MAIN); // i.setClass(this, Changelog.class); // replylist.setIntent(i); // } // // replylist = this.findPreference("gcm_prefs"); // if(replylist != null){ // Intent i = new Intent(Intent.ACTION_MAIN); // i.setClass(this, PushMessageSetup.class); // replylist.setIntent(i); // } // // replylist = this.findPreference("version"); // replylist.setSummary(getAppVersion(this)); // // replylist = this.findPreference("sendfeedback"); // replylist.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { // public boolean onPreferenceClick(Preference p){ // Preferences.sendDebugEmail(p.getContext()); // return true; // }}); // // //disable the "Consume SMS" option if the build is too low // //NB: there's no code to act on this, since the abortBroadcast() // // call will not break anything when called in < 1.6 // // It will also fail to have any effect with KitKat and above. // Log.d("BUILDVERSION", Build.VERSION.CODENAME); // if(Build.VERSION.SDK_INT <= Build.VERSION_CODES.DONUT || // Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){ // CheckBoxPreference csp = (CheckBoxPreference) this.findPreference("consume_sms_message"); // if(csp != null){ // csp.setChecked(false); // csp.setEnabled(false); // } // } // } // // /** Fires the intent to send an email with some debugging info. // */ // public static void sendDebugEmail(Context context){ // Intent send = new Intent(Intent.ACTION_SEND); // send.setType("message/rfc822"); // send.putExtra(Intent.EXTRA_EMAIL, new String[] {"klaxon-users@googlegroups.com"}); // send.putExtra(Intent.EXTRA_SUBJECT, "Debug Email Report"); // send.putExtra(Intent.EXTRA_TEXT, getDebugMessageBody(context)); // context.startActivity(Intent.createChooser(send, "Send Debugging Email")); // } // public static String getAppVersion(Context context){ // String version = "unknown"; // try { // PackageManager manager = context.getPackageManager(); // PackageInfo info = manager.getPackageInfo( // context.getPackageName(), 0); // version = info.versionName; // } // catch(Exception e){} // return version; // } // public static String getDebugMessageBody(Context context){ // //Put some useful debug data in here. // return "\n" + // "** System Info:\n" + // "Android Version: " + Build.VERSION.RELEASE + "\n" + // "Device: " + Build.MODEL + "\n" + // "Build Info: " + Build.FINGERPRINT + "\n" + // "** App Info:\n" + // "App Version: " + getAppVersion(context) + "\n"; // } // // }
import android.test.ActivityInstrumentationTestCase2; import android.test.InstrumentationTestCase; import android.os.Bundle; import org.nerdcircus.android.klaxon.Preferences;
package org.nerdcircus.android.klaxon.tests.app; public class PreferencesTest extends ActivityInstrumentationTestCase2 { public PreferencesTest(){
// Path: src/org/nerdcircus/android/klaxon/Preferences.java // public class Preferences extends PreferenceActivity { // // private final String TAG = "KlaxonPreferences"; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // // Load the preferences from an XML resource // addPreferencesFromResource(R.xml.preferences); // // Preference replylist = this.findPreference("edit_replies"); // if(replylist != null){ // Intent i = new Intent(Intent.ACTION_MAIN); // i.setClass(this, ReplyList.class); // replylist.setIntent(i); // } // // // rig up the Changelog // replylist = this.findPreference("changelog"); // if(replylist != null){ // Intent i = new Intent(Intent.ACTION_MAIN); // i.setClass(this, Changelog.class); // replylist.setIntent(i); // } // // replylist = this.findPreference("gcm_prefs"); // if(replylist != null){ // Intent i = new Intent(Intent.ACTION_MAIN); // i.setClass(this, PushMessageSetup.class); // replylist.setIntent(i); // } // // replylist = this.findPreference("version"); // replylist.setSummary(getAppVersion(this)); // // replylist = this.findPreference("sendfeedback"); // replylist.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { // public boolean onPreferenceClick(Preference p){ // Preferences.sendDebugEmail(p.getContext()); // return true; // }}); // // //disable the "Consume SMS" option if the build is too low // //NB: there's no code to act on this, since the abortBroadcast() // // call will not break anything when called in < 1.6 // // It will also fail to have any effect with KitKat and above. // Log.d("BUILDVERSION", Build.VERSION.CODENAME); // if(Build.VERSION.SDK_INT <= Build.VERSION_CODES.DONUT || // Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){ // CheckBoxPreference csp = (CheckBoxPreference) this.findPreference("consume_sms_message"); // if(csp != null){ // csp.setChecked(false); // csp.setEnabled(false); // } // } // } // // /** Fires the intent to send an email with some debugging info. // */ // public static void sendDebugEmail(Context context){ // Intent send = new Intent(Intent.ACTION_SEND); // send.setType("message/rfc822"); // send.putExtra(Intent.EXTRA_EMAIL, new String[] {"klaxon-users@googlegroups.com"}); // send.putExtra(Intent.EXTRA_SUBJECT, "Debug Email Report"); // send.putExtra(Intent.EXTRA_TEXT, getDebugMessageBody(context)); // context.startActivity(Intent.createChooser(send, "Send Debugging Email")); // } // public static String getAppVersion(Context context){ // String version = "unknown"; // try { // PackageManager manager = context.getPackageManager(); // PackageInfo info = manager.getPackageInfo( // context.getPackageName(), 0); // version = info.versionName; // } // catch(Exception e){} // return version; // } // public static String getDebugMessageBody(Context context){ // //Put some useful debug data in here. // return "\n" + // "** System Info:\n" + // "Android Version: " + Build.VERSION.RELEASE + "\n" + // "Device: " + Build.MODEL + "\n" + // "Build Info: " + Build.FINGERPRINT + "\n" + // "** App Info:\n" + // "App Version: " + getAppVersion(context) + "\n"; // } // // } // Path: tests/src/org/nerdcircus/android/klaxon/tests/app/PreferencesTest.java import android.test.ActivityInstrumentationTestCase2; import android.test.InstrumentationTestCase; import android.os.Bundle; import org.nerdcircus.android.klaxon.Preferences; package org.nerdcircus.android.klaxon.tests.app; public class PreferencesTest extends ActivityInstrumentationTestCase2 { public PreferencesTest(){
super("org.nerdcircus.android.klaxon", Preferences.class);
muncus/klaxon-wip
src/org/nerdcircus/android/klaxon/GCMIntentService.java
// Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Pages implements BaseColumns // { // public static final String TABLE_NAME = "pages"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/pages"); // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "created DESC"; // // /** // * The subject of the page // * <P>Type: TEXT</P> // */ // public static final String SUBJECT = "subject"; // // /** // * The text of the page // * <P>Type: TEXT</P> // */ // public static final String BODY = "body"; // // /** // * The timestamp for when the page was created // * <P>Type: INTEGER (long)</P> // */ // public static final String CREATED_DATE = "created"; // // /** // * The service center address from which the page was received. // * <P>Type: TEXT</P> // */ // public static final String SERVICE_CENTER = "sc_addr"; // // /** // * The originating address // * <P>Type: TEXT</P> // */ // public static final String SENDER = "sender_addr"; // // /** // * Acknowledgement status // * <P>Type: INTEGER</P> // */ // public static final String ACK_STATUS = "ack_status"; // // /** // * Email From address // * <P>Type: TEXT</P> // */ // public static final String FROM_ADDR = "email_from_addr"; // // /** // * String to identify the transport over which this page was received. // * <P>Type: TEXT</P> // */ // public static final String TRANSPORT = "transport"; // // /** // * Reply Uri - can be used to reply out-of-band to the sender. // * <P>Type: TEXT</P> // */ // public static final String REPLY_URI = "reply_uri"; // }
import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.net.Uri; import android.os.Bundle; import android.preference.PreferenceManager; import android.util.Log; import com.google.android.gcm.GCMBaseIntentService; import org.nerdcircus.android.klaxon.Pager.Pages;
if( intent.getAction().equals(Pager.REPLY_ACTION)){ Log.d(TAG, "Replying!"); //TODO: actually reply. in the short term, an email to the DisplayFrom might work. return; } //check to see if we want to intercept. SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); if( ! prefs.getBoolean("is_oncall", true) ){ Log.d(TAG, "not oncall. not bothering with incoming c2dm push."); return; } Bundle extras = intent.getExtras(); if (extras == null) return; Alert incoming = new Alert(); if(extras.containsKey("url")) //incoming.setReplyUri(extras.getString("url")); incoming.setDisplayFrom(extras.getString("url")); incoming.setFrom(extras.getString("url")); if(extras.containsKey("subject")) incoming.setSubject(extras.getString("subject")); if(extras.containsKey("body")) incoming.setBody(extras.getString("body")); incoming.setTransport(MY_TRANSPORT);
// Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Pages implements BaseColumns // { // public static final String TABLE_NAME = "pages"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/pages"); // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "created DESC"; // // /** // * The subject of the page // * <P>Type: TEXT</P> // */ // public static final String SUBJECT = "subject"; // // /** // * The text of the page // * <P>Type: TEXT</P> // */ // public static final String BODY = "body"; // // /** // * The timestamp for when the page was created // * <P>Type: INTEGER (long)</P> // */ // public static final String CREATED_DATE = "created"; // // /** // * The service center address from which the page was received. // * <P>Type: TEXT</P> // */ // public static final String SERVICE_CENTER = "sc_addr"; // // /** // * The originating address // * <P>Type: TEXT</P> // */ // public static final String SENDER = "sender_addr"; // // /** // * Acknowledgement status // * <P>Type: INTEGER</P> // */ // public static final String ACK_STATUS = "ack_status"; // // /** // * Email From address // * <P>Type: TEXT</P> // */ // public static final String FROM_ADDR = "email_from_addr"; // // /** // * String to identify the transport over which this page was received. // * <P>Type: TEXT</P> // */ // public static final String TRANSPORT = "transport"; // // /** // * Reply Uri - can be used to reply out-of-band to the sender. // * <P>Type: TEXT</P> // */ // public static final String REPLY_URI = "reply_uri"; // } // Path: src/org/nerdcircus/android/klaxon/GCMIntentService.java import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.net.Uri; import android.os.Bundle; import android.preference.PreferenceManager; import android.util.Log; import com.google.android.gcm.GCMBaseIntentService; import org.nerdcircus.android.klaxon.Pager.Pages; if( intent.getAction().equals(Pager.REPLY_ACTION)){ Log.d(TAG, "Replying!"); //TODO: actually reply. in the short term, an email to the DisplayFrom might work. return; } //check to see if we want to intercept. SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); if( ! prefs.getBoolean("is_oncall", true) ){ Log.d(TAG, "not oncall. not bothering with incoming c2dm push."); return; } Bundle extras = intent.getExtras(); if (extras == null) return; Alert incoming = new Alert(); if(extras.containsKey("url")) //incoming.setReplyUri(extras.getString("url")); incoming.setDisplayFrom(extras.getString("url")); incoming.setFrom(extras.getString("url")); if(extras.containsKey("subject")) incoming.setSubject(extras.getString("subject")); if(extras.containsKey("body")) incoming.setBody(extras.getString("body")); incoming.setTransport(MY_TRANSPORT);
Uri newpage = context.getContentResolver().insert(Pages.CONTENT_URI, incoming.asContentValues());
muncus/klaxon-wip
src/org/nerdcircus/android/klaxon/PageViewer.java
// Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Replies implements BaseColumns // { // public static final String TABLE_NAME = "replies"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/reply"); // // /** // * Short name of our reply. // */ // public static final String NAME = "name"; // // /** // * content of the reply. // */ // public static final String BODY = "body"; // /** // * new "ack status". integer. // */ // public static final String ACK_STATUS = "ack_status"; // /** // * whether this item should be shown in the menu. // */ // public static final String SHOW_IN_MENU = "show_in_menu"; // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "name ASC"; // }
import android.app.Activity; import android.content.Intent; import android.database.Cursor; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.widget.TextView; import org.nerdcircus.android.klaxon.Pager.Replies; import java.text.SimpleDateFormat; import java.util.Date;
Intent i = getIntent(); mContentURI = i.getData(); Log.d(TAG, "displaying: "+mContentURI.toString()); mCursor = managedQuery(mContentURI, new String[] {Pager.Pages._ID, Pager.Pages.SUBJECT, Pager.Pages.BODY, Pager.Pages.ACK_STATUS, Pager.Pages.CREATED_DATE, Pager.Pages.SENDER}, null, null, null); mCursor.moveToNext(); mSubjectView.setText(mCursor.getString(mCursor.getColumnIndex(Pager.Pages.SUBJECT))); mBodyView.setText(mCursor.getString(mCursor.getColumnIndex(Pager.Pages.BODY))); //make a pretty date stamp. Date d = new Date(mCursor.getLong(mCursor.getColumnIndex(Pager.Pages.CREATED_DATE))); SimpleDateFormat df = new SimpleDateFormat(); //FIXME: use a resource for this.. mDateView.setText("Received: " + df.format(d)); mSenderView.setText("Sender: "+ mCursor.getString(mCursor.getColumnIndex(Pager.Pages.SENDER))); int status = mCursor.getInt(mCursor.getColumnIndex(Pager.Pages.ACK_STATUS)); Drawable icon = getResources().getDrawable(Pager.getStatusResId(status)); mSubjectView.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null); //TODO: define drawableStateChanged(), to update the icon when ack_status changes. } @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu);
// Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Replies implements BaseColumns // { // public static final String TABLE_NAME = "replies"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/reply"); // // /** // * Short name of our reply. // */ // public static final String NAME = "name"; // // /** // * content of the reply. // */ // public static final String BODY = "body"; // /** // * new "ack status". integer. // */ // public static final String ACK_STATUS = "ack_status"; // /** // * whether this item should be shown in the menu. // */ // public static final String SHOW_IN_MENU = "show_in_menu"; // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "name ASC"; // } // Path: src/org/nerdcircus/android/klaxon/PageViewer.java import android.app.Activity; import android.content.Intent; import android.database.Cursor; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.widget.TextView; import org.nerdcircus.android.klaxon.Pager.Replies; import java.text.SimpleDateFormat; import java.util.Date; Intent i = getIntent(); mContentURI = i.getData(); Log.d(TAG, "displaying: "+mContentURI.toString()); mCursor = managedQuery(mContentURI, new String[] {Pager.Pages._ID, Pager.Pages.SUBJECT, Pager.Pages.BODY, Pager.Pages.ACK_STATUS, Pager.Pages.CREATED_DATE, Pager.Pages.SENDER}, null, null, null); mCursor.moveToNext(); mSubjectView.setText(mCursor.getString(mCursor.getColumnIndex(Pager.Pages.SUBJECT))); mBodyView.setText(mCursor.getString(mCursor.getColumnIndex(Pager.Pages.BODY))); //make a pretty date stamp. Date d = new Date(mCursor.getLong(mCursor.getColumnIndex(Pager.Pages.CREATED_DATE))); SimpleDateFormat df = new SimpleDateFormat(); //FIXME: use a resource for this.. mDateView.setText("Received: " + df.format(d)); mSenderView.setText("Sender: "+ mCursor.getString(mCursor.getColumnIndex(Pager.Pages.SENDER))); int status = mCursor.getInt(mCursor.getColumnIndex(Pager.Pages.ACK_STATUS)); Drawable icon = getResources().getDrawable(Pager.getStatusResId(status)); mSubjectView.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null); //TODO: define drawableStateChanged(), to update the icon when ack_status changes. } @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu);
Cursor c = managedQuery(Replies.CONTENT_URI,
muncus/klaxon-wip
src/org/nerdcircus/android/klaxon/ReplyList.java
// Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Replies implements BaseColumns // { // public static final String TABLE_NAME = "replies"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/reply"); // // /** // * Short name of our reply. // */ // public static final String NAME = "name"; // // /** // * content of the reply. // */ // public static final String BODY = "body"; // /** // * new "ack status". integer. // */ // public static final String ACK_STATUS = "ack_status"; // /** // * whether this item should be shown in the menu. // */ // public static final String SHOW_IN_MENU = "show_in_menu"; // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "name ASC"; // }
import android.app.ListActivity; import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.ListAdapter; import android.widget.ListView; import org.nerdcircus.android.klaxon.Pager.Replies; import android.util.Log;
/* * Copyright 2008 Google 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 org.nerdcircus.android.klaxon; public class ReplyList extends ListActivity { private String TAG = "ReplyList"; //menu constants. private int MENU_ACTIONS_GROUP = Menu.FIRST; private int MENU_ALWAYS_GROUP = Menu.FIRST + 1; private int MENU_ADD = Menu.FIRST + 2; private Cursor mCursor; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.replylist);
// Path: src/org/nerdcircus/android/klaxon/Pager.java // public static final class Replies implements BaseColumns // { // public static final String TABLE_NAME = "replies"; // public static final Cursor query(ContentResolver cr, String[] projection) // { // return cr.query(CONTENT_URI, // projection, // null, // null, // DEFAULT_SORT_ORDER); // } // // public static final Cursor query(ContentResolver cr, String[] projection, // String where, String orderBy) // { // return cr.query(CONTENT_URI, projection, where, null, // orderBy == null ? DEFAULT_SORT_ORDER : orderBy); // } // // /** // * The content:// style URL for this table // */ // public static final Uri CONTENT_URI = // Uri.parse("content://org.nerdcircus.android.klaxon/reply"); // // /** // * Short name of our reply. // */ // public static final String NAME = "name"; // // /** // * content of the reply. // */ // public static final String BODY = "body"; // /** // * new "ack status". integer. // */ // public static final String ACK_STATUS = "ack_status"; // /** // * whether this item should be shown in the menu. // */ // public static final String SHOW_IN_MENU = "show_in_menu"; // // /** // * The default sort order for this table // */ // public static final String DEFAULT_SORT_ORDER = "name ASC"; // } // Path: src/org/nerdcircus/android/klaxon/ReplyList.java import android.app.ListActivity; import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.ListAdapter; import android.widget.ListView; import org.nerdcircus.android.klaxon.Pager.Replies; import android.util.Log; /* * Copyright 2008 Google 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 org.nerdcircus.android.klaxon; public class ReplyList extends ListActivity { private String TAG = "ReplyList"; //menu constants. private int MENU_ACTIONS_GROUP = Menu.FIRST; private int MENU_ALWAYS_GROUP = Menu.FIRST + 1; private int MENU_ADD = Menu.FIRST + 2; private Cursor mCursor; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.replylist);
String[] cols = new String[] {Replies._ID, Replies.NAME, Replies.BODY, Replies.ACK_STATUS };
canyinghao/CanRefresh
app/src/main/java/com/canyinghao/canrefreshdemo/ui/MainActivity.java
// Path: app/src/main/java/com/canyinghao/canrefreshdemo/model/MainBean.java // public class MainBean { // // // public String title ; // public String content ; // // // public static List<MainBean> getList(){ // // List<MainBean> list = new ArrayList<>(); // // // for (int i = 0; i < 50; i++) { // // MainBean bean = new MainBean(); // // bean.title = "this is a canadapter title "+i; // bean.content = "this is a canadapter content "+i; // // list.add(bean); // // } // // return list; // // } // // public static List<MainBean> getMainList(){ // // List<MainBean> list = new ArrayList<>(); // // // MainBean bean1 = new MainBean(); // bean1.title = "不可滚动的视图"; // bean1.content = "TextView ImageView FrameLayout 等"; // // MainBean bean2 = new MainBean(); // bean2.title = "可滚动的视图"; // bean2.content = "ListView ScrollView GridView 等"; // // MainBean bean3 = new MainBean(); // bean3.title = "RecyclerView"; // bean3.content = "RecyclerView的各种刷新方式"; // // MainBean bean4 = new MainBean(); // bean4.title = "CoordinatorLayout"; // bean4.content = "支持CoordinatorLayout"; // // // list.add(bean1); // list.add(bean2); // list.add(bean3); // list.add(bean4); // // // return list; // // } // // }
import android.content.Intent; import android.os.Bundle; import android.view.View; import com.canyinghao.canadapter.CanHolderHelper; import com.canyinghao.canadapter.CanOnItemListener; import com.canyinghao.canadapter.CanRVAdapter; import com.canyinghao.canrefreshdemo.R; import com.canyinghao.canrefreshdemo.model.MainBean; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView;
package com.canyinghao.canrefreshdemo.ui; /** * Created by canyinghao on 16/1/24. */ public class MainActivity extends AppCompatActivity { Toolbar toolbar; RecyclerView viewPager; View cd; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); toolbar = findViewById(R.id.toolbar); viewPager = findViewById(R.id.viewPager); cd = findViewById(R.id.cd); toolbar.setTitle("CanRefreshDemo"); LinearLayoutManager mLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
// Path: app/src/main/java/com/canyinghao/canrefreshdemo/model/MainBean.java // public class MainBean { // // // public String title ; // public String content ; // // // public static List<MainBean> getList(){ // // List<MainBean> list = new ArrayList<>(); // // // for (int i = 0; i < 50; i++) { // // MainBean bean = new MainBean(); // // bean.title = "this is a canadapter title "+i; // bean.content = "this is a canadapter content "+i; // // list.add(bean); // // } // // return list; // // } // // public static List<MainBean> getMainList(){ // // List<MainBean> list = new ArrayList<>(); // // // MainBean bean1 = new MainBean(); // bean1.title = "不可滚动的视图"; // bean1.content = "TextView ImageView FrameLayout 等"; // // MainBean bean2 = new MainBean(); // bean2.title = "可滚动的视图"; // bean2.content = "ListView ScrollView GridView 等"; // // MainBean bean3 = new MainBean(); // bean3.title = "RecyclerView"; // bean3.content = "RecyclerView的各种刷新方式"; // // MainBean bean4 = new MainBean(); // bean4.title = "CoordinatorLayout"; // bean4.content = "支持CoordinatorLayout"; // // // list.add(bean1); // list.add(bean2); // list.add(bean3); // list.add(bean4); // // // return list; // // } // // } // Path: app/src/main/java/com/canyinghao/canrefreshdemo/ui/MainActivity.java import android.content.Intent; import android.os.Bundle; import android.view.View; import com.canyinghao.canadapter.CanHolderHelper; import com.canyinghao.canadapter.CanOnItemListener; import com.canyinghao.canadapter.CanRVAdapter; import com.canyinghao.canrefreshdemo.R; import com.canyinghao.canrefreshdemo.model.MainBean; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; package com.canyinghao.canrefreshdemo.ui; /** * Created by canyinghao on 16/1/24. */ public class MainActivity extends AppCompatActivity { Toolbar toolbar; RecyclerView viewPager; View cd; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); toolbar = findViewById(R.id.toolbar); viewPager = findViewById(R.id.viewPager); cd = findViewById(R.id.cd); toolbar.setTitle("CanRefreshDemo"); LinearLayoutManager mLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
final CanRVAdapter adapter = new CanRVAdapter<MainBean>(viewPager, R.layout.item_main) {
cm-heclouds/JAVA-HTTP-SDK
javaSDK/src/main/java/cmcc/iot/onenet/javasdk/api/bindata/GetBindataApi.java
// Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/api/AbstractAPI.java // public abstract class AbstractAPI<T> { // public String key; // public String url; // public Method method; // public ObjectMapper mapper = initObjectMapper(); // // private ObjectMapper initObjectMapper() { // ObjectMapper objectMapper = new ObjectMapper(); // //关闭字段不识别报错 // objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); // //调整默认时区为北京时间 // TimeZone timeZone = TimeZone.getTimeZone("GMT+8"); // DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA); // dateFormat.setTimeZone(timeZone); // objectMapper.setDateFormat(dateFormat); // objectMapper.setTimeZone(timeZone); // return objectMapper; // } // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/exception/OnenetApiException.java // public class OnenetApiException extends RuntimeException { // private String message = null; // public String getMessage() { // return message; // } // public OnenetApiException( String message) { // this.message = message; // } // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/http/HttpGetMethod.java // public class HttpGetMethod extends BasicHttpMethod { // // private final Logger logger = LoggerFactory.getLogger(this.getClass()); // HttpGet httpGet; // // public HttpGetMethod(Method method) { // super(method); // // } // // public HttpResponse execute() throws Exception { // HttpResponse httpResponse = null; // httpClient = HttpClients.createDefault(); // // httpResponse = httpClient.execute(httpRequestBase); // int statusCode = httpResponse.getStatusLine().getStatusCode(); // if (statusCode != HttpStatus.SC_OK && statusCode != 221) { // String response = EntityUtils.toString(httpResponse.getEntity()); // logger.error("request failed status:{}, response::{}",statusCode, response); // throw new OnenetApiException("request failed: " + response); // } // // return httpResponse; // } // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/request/RequestInfo.java // public enum Method{ // POST,GET,DELETE,PUT // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/utils/Config.java // public class Config { // private final static Properties properties; // private static org.slf4j.Logger logger = LoggerFactory.getLogger(Config.class); // static { // // Logger.getRootLogger().setLevel(Level.OFF); // InputStream in = Config.class.getClassLoader().getResourceAsStream("config.properties"); // properties = new Properties(); // try { // properties.load(in); // } catch (IOException e) { // logger.error("init config error", e); // } // } // // /** // * 读取以逗号分割的字符串,作为字符串数组返回 // * // * @param conf // * @return // */ // public static List<String> getStringList(String conf) { // return Arrays.asList(StringUtils.split(properties.getProperty(conf), ",")); // } // // /** // * 读取字符串 // * // * @param conf // * @return // */ // public static String getString(String conf) { // return properties.getProperty(conf); // } // // /** // * 读取整数 // * // * @param conf // * @return // */ // public static int getInt(String conf) { // int ret = 0; // try { // ret = Integer.parseInt(getString(conf)); // } catch (NumberFormatException e) { // logger.error("format error", e); // } // return ret; // } // // /** // * 读取布尔值 // * // * @param conf // * @return // */ // public static boolean getBoolean(String conf) { // return Boolean.parseBoolean(getString(conf)); // } // }
import java.util.HashMap; import java.util.Map; import org.apache.http.HttpResponse; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import cmcc.iot.onenet.javasdk.api.AbstractAPI; import cmcc.iot.onenet.javasdk.exception.OnenetApiException; import cmcc.iot.onenet.javasdk.http.HttpGetMethod; import cmcc.iot.onenet.javasdk.request.RequestInfo.Method; import cmcc.iot.onenet.javasdk.utils.Config;
package cmcc.iot.onenet.javasdk.api.bindata; public class GetBindataApi extends AbstractAPI{ private final Logger logger = LoggerFactory.getLogger(this.getClass());
// Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/api/AbstractAPI.java // public abstract class AbstractAPI<T> { // public String key; // public String url; // public Method method; // public ObjectMapper mapper = initObjectMapper(); // // private ObjectMapper initObjectMapper() { // ObjectMapper objectMapper = new ObjectMapper(); // //关闭字段不识别报错 // objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); // //调整默认时区为北京时间 // TimeZone timeZone = TimeZone.getTimeZone("GMT+8"); // DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA); // dateFormat.setTimeZone(timeZone); // objectMapper.setDateFormat(dateFormat); // objectMapper.setTimeZone(timeZone); // return objectMapper; // } // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/exception/OnenetApiException.java // public class OnenetApiException extends RuntimeException { // private String message = null; // public String getMessage() { // return message; // } // public OnenetApiException( String message) { // this.message = message; // } // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/http/HttpGetMethod.java // public class HttpGetMethod extends BasicHttpMethod { // // private final Logger logger = LoggerFactory.getLogger(this.getClass()); // HttpGet httpGet; // // public HttpGetMethod(Method method) { // super(method); // // } // // public HttpResponse execute() throws Exception { // HttpResponse httpResponse = null; // httpClient = HttpClients.createDefault(); // // httpResponse = httpClient.execute(httpRequestBase); // int statusCode = httpResponse.getStatusLine().getStatusCode(); // if (statusCode != HttpStatus.SC_OK && statusCode != 221) { // String response = EntityUtils.toString(httpResponse.getEntity()); // logger.error("request failed status:{}, response::{}",statusCode, response); // throw new OnenetApiException("request failed: " + response); // } // // return httpResponse; // } // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/request/RequestInfo.java // public enum Method{ // POST,GET,DELETE,PUT // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/utils/Config.java // public class Config { // private final static Properties properties; // private static org.slf4j.Logger logger = LoggerFactory.getLogger(Config.class); // static { // // Logger.getRootLogger().setLevel(Level.OFF); // InputStream in = Config.class.getClassLoader().getResourceAsStream("config.properties"); // properties = new Properties(); // try { // properties.load(in); // } catch (IOException e) { // logger.error("init config error", e); // } // } // // /** // * 读取以逗号分割的字符串,作为字符串数组返回 // * // * @param conf // * @return // */ // public static List<String> getStringList(String conf) { // return Arrays.asList(StringUtils.split(properties.getProperty(conf), ",")); // } // // /** // * 读取字符串 // * // * @param conf // * @return // */ // public static String getString(String conf) { // return properties.getProperty(conf); // } // // /** // * 读取整数 // * // * @param conf // * @return // */ // public static int getInt(String conf) { // int ret = 0; // try { // ret = Integer.parseInt(getString(conf)); // } catch (NumberFormatException e) { // logger.error("format error", e); // } // return ret; // } // // /** // * 读取布尔值 // * // * @param conf // * @return // */ // public static boolean getBoolean(String conf) { // return Boolean.parseBoolean(getString(conf)); // } // } // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/api/bindata/GetBindataApi.java import java.util.HashMap; import java.util.Map; import org.apache.http.HttpResponse; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import cmcc.iot.onenet.javasdk.api.AbstractAPI; import cmcc.iot.onenet.javasdk.exception.OnenetApiException; import cmcc.iot.onenet.javasdk.http.HttpGetMethod; import cmcc.iot.onenet.javasdk.request.RequestInfo.Method; import cmcc.iot.onenet.javasdk.utils.Config; package cmcc.iot.onenet.javasdk.api.bindata; public class GetBindataApi extends AbstractAPI{ private final Logger logger = LoggerFactory.getLogger(this.getClass());
private HttpGetMethod HttpMethod;
cm-heclouds/JAVA-HTTP-SDK
javaSDK/src/main/java/cmcc/iot/onenet/javasdk/api/bindata/GetBindataApi.java
// Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/api/AbstractAPI.java // public abstract class AbstractAPI<T> { // public String key; // public String url; // public Method method; // public ObjectMapper mapper = initObjectMapper(); // // private ObjectMapper initObjectMapper() { // ObjectMapper objectMapper = new ObjectMapper(); // //关闭字段不识别报错 // objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); // //调整默认时区为北京时间 // TimeZone timeZone = TimeZone.getTimeZone("GMT+8"); // DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA); // dateFormat.setTimeZone(timeZone); // objectMapper.setDateFormat(dateFormat); // objectMapper.setTimeZone(timeZone); // return objectMapper; // } // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/exception/OnenetApiException.java // public class OnenetApiException extends RuntimeException { // private String message = null; // public String getMessage() { // return message; // } // public OnenetApiException( String message) { // this.message = message; // } // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/http/HttpGetMethod.java // public class HttpGetMethod extends BasicHttpMethod { // // private final Logger logger = LoggerFactory.getLogger(this.getClass()); // HttpGet httpGet; // // public HttpGetMethod(Method method) { // super(method); // // } // // public HttpResponse execute() throws Exception { // HttpResponse httpResponse = null; // httpClient = HttpClients.createDefault(); // // httpResponse = httpClient.execute(httpRequestBase); // int statusCode = httpResponse.getStatusLine().getStatusCode(); // if (statusCode != HttpStatus.SC_OK && statusCode != 221) { // String response = EntityUtils.toString(httpResponse.getEntity()); // logger.error("request failed status:{}, response::{}",statusCode, response); // throw new OnenetApiException("request failed: " + response); // } // // return httpResponse; // } // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/request/RequestInfo.java // public enum Method{ // POST,GET,DELETE,PUT // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/utils/Config.java // public class Config { // private final static Properties properties; // private static org.slf4j.Logger logger = LoggerFactory.getLogger(Config.class); // static { // // Logger.getRootLogger().setLevel(Level.OFF); // InputStream in = Config.class.getClassLoader().getResourceAsStream("config.properties"); // properties = new Properties(); // try { // properties.load(in); // } catch (IOException e) { // logger.error("init config error", e); // } // } // // /** // * 读取以逗号分割的字符串,作为字符串数组返回 // * // * @param conf // * @return // */ // public static List<String> getStringList(String conf) { // return Arrays.asList(StringUtils.split(properties.getProperty(conf), ",")); // } // // /** // * 读取字符串 // * // * @param conf // * @return // */ // public static String getString(String conf) { // return properties.getProperty(conf); // } // // /** // * 读取整数 // * // * @param conf // * @return // */ // public static int getInt(String conf) { // int ret = 0; // try { // ret = Integer.parseInt(getString(conf)); // } catch (NumberFormatException e) { // logger.error("format error", e); // } // return ret; // } // // /** // * 读取布尔值 // * // * @param conf // * @return // */ // public static boolean getBoolean(String conf) { // return Boolean.parseBoolean(getString(conf)); // } // }
import java.util.HashMap; import java.util.Map; import org.apache.http.HttpResponse; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import cmcc.iot.onenet.javasdk.api.AbstractAPI; import cmcc.iot.onenet.javasdk.exception.OnenetApiException; import cmcc.iot.onenet.javasdk.http.HttpGetMethod; import cmcc.iot.onenet.javasdk.request.RequestInfo.Method; import cmcc.iot.onenet.javasdk.utils.Config;
package cmcc.iot.onenet.javasdk.api.bindata; public class GetBindataApi extends AbstractAPI{ private final Logger logger = LoggerFactory.getLogger(this.getClass()); private HttpGetMethod HttpMethod; private String index; /** * @param index:二进制数据索引号,String * @param key:masterkey 或者 该设备的设备key */ public GetBindataApi(String index,String key) { this.index = index; this.key=key;
// Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/api/AbstractAPI.java // public abstract class AbstractAPI<T> { // public String key; // public String url; // public Method method; // public ObjectMapper mapper = initObjectMapper(); // // private ObjectMapper initObjectMapper() { // ObjectMapper objectMapper = new ObjectMapper(); // //关闭字段不识别报错 // objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); // //调整默认时区为北京时间 // TimeZone timeZone = TimeZone.getTimeZone("GMT+8"); // DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA); // dateFormat.setTimeZone(timeZone); // objectMapper.setDateFormat(dateFormat); // objectMapper.setTimeZone(timeZone); // return objectMapper; // } // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/exception/OnenetApiException.java // public class OnenetApiException extends RuntimeException { // private String message = null; // public String getMessage() { // return message; // } // public OnenetApiException( String message) { // this.message = message; // } // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/http/HttpGetMethod.java // public class HttpGetMethod extends BasicHttpMethod { // // private final Logger logger = LoggerFactory.getLogger(this.getClass()); // HttpGet httpGet; // // public HttpGetMethod(Method method) { // super(method); // // } // // public HttpResponse execute() throws Exception { // HttpResponse httpResponse = null; // httpClient = HttpClients.createDefault(); // // httpResponse = httpClient.execute(httpRequestBase); // int statusCode = httpResponse.getStatusLine().getStatusCode(); // if (statusCode != HttpStatus.SC_OK && statusCode != 221) { // String response = EntityUtils.toString(httpResponse.getEntity()); // logger.error("request failed status:{}, response::{}",statusCode, response); // throw new OnenetApiException("request failed: " + response); // } // // return httpResponse; // } // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/request/RequestInfo.java // public enum Method{ // POST,GET,DELETE,PUT // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/utils/Config.java // public class Config { // private final static Properties properties; // private static org.slf4j.Logger logger = LoggerFactory.getLogger(Config.class); // static { // // Logger.getRootLogger().setLevel(Level.OFF); // InputStream in = Config.class.getClassLoader().getResourceAsStream("config.properties"); // properties = new Properties(); // try { // properties.load(in); // } catch (IOException e) { // logger.error("init config error", e); // } // } // // /** // * 读取以逗号分割的字符串,作为字符串数组返回 // * // * @param conf // * @return // */ // public static List<String> getStringList(String conf) { // return Arrays.asList(StringUtils.split(properties.getProperty(conf), ",")); // } // // /** // * 读取字符串 // * // * @param conf // * @return // */ // public static String getString(String conf) { // return properties.getProperty(conf); // } // // /** // * 读取整数 // * // * @param conf // * @return // */ // public static int getInt(String conf) { // int ret = 0; // try { // ret = Integer.parseInt(getString(conf)); // } catch (NumberFormatException e) { // logger.error("format error", e); // } // return ret; // } // // /** // * 读取布尔值 // * // * @param conf // * @return // */ // public static boolean getBoolean(String conf) { // return Boolean.parseBoolean(getString(conf)); // } // } // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/api/bindata/GetBindataApi.java import java.util.HashMap; import java.util.Map; import org.apache.http.HttpResponse; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import cmcc.iot.onenet.javasdk.api.AbstractAPI; import cmcc.iot.onenet.javasdk.exception.OnenetApiException; import cmcc.iot.onenet.javasdk.http.HttpGetMethod; import cmcc.iot.onenet.javasdk.request.RequestInfo.Method; import cmcc.iot.onenet.javasdk.utils.Config; package cmcc.iot.onenet.javasdk.api.bindata; public class GetBindataApi extends AbstractAPI{ private final Logger logger = LoggerFactory.getLogger(this.getClass()); private HttpGetMethod HttpMethod; private String index; /** * @param index:二进制数据索引号,String * @param key:masterkey 或者 该设备的设备key */ public GetBindataApi(String index,String key) { this.index = index; this.key=key;
this.method= Method.GET;
cm-heclouds/JAVA-HTTP-SDK
javaSDK/src/main/java/cmcc/iot/onenet/javasdk/api/bindata/GetBindataApi.java
// Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/api/AbstractAPI.java // public abstract class AbstractAPI<T> { // public String key; // public String url; // public Method method; // public ObjectMapper mapper = initObjectMapper(); // // private ObjectMapper initObjectMapper() { // ObjectMapper objectMapper = new ObjectMapper(); // //关闭字段不识别报错 // objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); // //调整默认时区为北京时间 // TimeZone timeZone = TimeZone.getTimeZone("GMT+8"); // DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA); // dateFormat.setTimeZone(timeZone); // objectMapper.setDateFormat(dateFormat); // objectMapper.setTimeZone(timeZone); // return objectMapper; // } // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/exception/OnenetApiException.java // public class OnenetApiException extends RuntimeException { // private String message = null; // public String getMessage() { // return message; // } // public OnenetApiException( String message) { // this.message = message; // } // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/http/HttpGetMethod.java // public class HttpGetMethod extends BasicHttpMethod { // // private final Logger logger = LoggerFactory.getLogger(this.getClass()); // HttpGet httpGet; // // public HttpGetMethod(Method method) { // super(method); // // } // // public HttpResponse execute() throws Exception { // HttpResponse httpResponse = null; // httpClient = HttpClients.createDefault(); // // httpResponse = httpClient.execute(httpRequestBase); // int statusCode = httpResponse.getStatusLine().getStatusCode(); // if (statusCode != HttpStatus.SC_OK && statusCode != 221) { // String response = EntityUtils.toString(httpResponse.getEntity()); // logger.error("request failed status:{}, response::{}",statusCode, response); // throw new OnenetApiException("request failed: " + response); // } // // return httpResponse; // } // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/request/RequestInfo.java // public enum Method{ // POST,GET,DELETE,PUT // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/utils/Config.java // public class Config { // private final static Properties properties; // private static org.slf4j.Logger logger = LoggerFactory.getLogger(Config.class); // static { // // Logger.getRootLogger().setLevel(Level.OFF); // InputStream in = Config.class.getClassLoader().getResourceAsStream("config.properties"); // properties = new Properties(); // try { // properties.load(in); // } catch (IOException e) { // logger.error("init config error", e); // } // } // // /** // * 读取以逗号分割的字符串,作为字符串数组返回 // * // * @param conf // * @return // */ // public static List<String> getStringList(String conf) { // return Arrays.asList(StringUtils.split(properties.getProperty(conf), ",")); // } // // /** // * 读取字符串 // * // * @param conf // * @return // */ // public static String getString(String conf) { // return properties.getProperty(conf); // } // // /** // * 读取整数 // * // * @param conf // * @return // */ // public static int getInt(String conf) { // int ret = 0; // try { // ret = Integer.parseInt(getString(conf)); // } catch (NumberFormatException e) { // logger.error("format error", e); // } // return ret; // } // // /** // * 读取布尔值 // * // * @param conf // * @return // */ // public static boolean getBoolean(String conf) { // return Boolean.parseBoolean(getString(conf)); // } // }
import java.util.HashMap; import java.util.Map; import org.apache.http.HttpResponse; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import cmcc.iot.onenet.javasdk.api.AbstractAPI; import cmcc.iot.onenet.javasdk.exception.OnenetApiException; import cmcc.iot.onenet.javasdk.http.HttpGetMethod; import cmcc.iot.onenet.javasdk.request.RequestInfo.Method; import cmcc.iot.onenet.javasdk.utils.Config;
package cmcc.iot.onenet.javasdk.api.bindata; public class GetBindataApi extends AbstractAPI{ private final Logger logger = LoggerFactory.getLogger(this.getClass()); private HttpGetMethod HttpMethod; private String index; /** * @param index:二进制数据索引号,String * @param key:masterkey 或者 该设备的设备key */ public GetBindataApi(String index,String key) { this.index = index; this.key=key; this.method= Method.GET; this.HttpMethod=new HttpGetMethod(method); Map<String, Object> headmap = new HashMap<String, Object>(); headmap.put("api-key", key); HttpMethod.setHeader(headmap);
// Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/api/AbstractAPI.java // public abstract class AbstractAPI<T> { // public String key; // public String url; // public Method method; // public ObjectMapper mapper = initObjectMapper(); // // private ObjectMapper initObjectMapper() { // ObjectMapper objectMapper = new ObjectMapper(); // //关闭字段不识别报错 // objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); // //调整默认时区为北京时间 // TimeZone timeZone = TimeZone.getTimeZone("GMT+8"); // DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA); // dateFormat.setTimeZone(timeZone); // objectMapper.setDateFormat(dateFormat); // objectMapper.setTimeZone(timeZone); // return objectMapper; // } // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/exception/OnenetApiException.java // public class OnenetApiException extends RuntimeException { // private String message = null; // public String getMessage() { // return message; // } // public OnenetApiException( String message) { // this.message = message; // } // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/http/HttpGetMethod.java // public class HttpGetMethod extends BasicHttpMethod { // // private final Logger logger = LoggerFactory.getLogger(this.getClass()); // HttpGet httpGet; // // public HttpGetMethod(Method method) { // super(method); // // } // // public HttpResponse execute() throws Exception { // HttpResponse httpResponse = null; // httpClient = HttpClients.createDefault(); // // httpResponse = httpClient.execute(httpRequestBase); // int statusCode = httpResponse.getStatusLine().getStatusCode(); // if (statusCode != HttpStatus.SC_OK && statusCode != 221) { // String response = EntityUtils.toString(httpResponse.getEntity()); // logger.error("request failed status:{}, response::{}",statusCode, response); // throw new OnenetApiException("request failed: " + response); // } // // return httpResponse; // } // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/request/RequestInfo.java // public enum Method{ // POST,GET,DELETE,PUT // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/utils/Config.java // public class Config { // private final static Properties properties; // private static org.slf4j.Logger logger = LoggerFactory.getLogger(Config.class); // static { // // Logger.getRootLogger().setLevel(Level.OFF); // InputStream in = Config.class.getClassLoader().getResourceAsStream("config.properties"); // properties = new Properties(); // try { // properties.load(in); // } catch (IOException e) { // logger.error("init config error", e); // } // } // // /** // * 读取以逗号分割的字符串,作为字符串数组返回 // * // * @param conf // * @return // */ // public static List<String> getStringList(String conf) { // return Arrays.asList(StringUtils.split(properties.getProperty(conf), ",")); // } // // /** // * 读取字符串 // * // * @param conf // * @return // */ // public static String getString(String conf) { // return properties.getProperty(conf); // } // // /** // * 读取整数 // * // * @param conf // * @return // */ // public static int getInt(String conf) { // int ret = 0; // try { // ret = Integer.parseInt(getString(conf)); // } catch (NumberFormatException e) { // logger.error("format error", e); // } // return ret; // } // // /** // * 读取布尔值 // * // * @param conf // * @return // */ // public static boolean getBoolean(String conf) { // return Boolean.parseBoolean(getString(conf)); // } // } // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/api/bindata/GetBindataApi.java import java.util.HashMap; import java.util.Map; import org.apache.http.HttpResponse; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import cmcc.iot.onenet.javasdk.api.AbstractAPI; import cmcc.iot.onenet.javasdk.exception.OnenetApiException; import cmcc.iot.onenet.javasdk.http.HttpGetMethod; import cmcc.iot.onenet.javasdk.request.RequestInfo.Method; import cmcc.iot.onenet.javasdk.utils.Config; package cmcc.iot.onenet.javasdk.api.bindata; public class GetBindataApi extends AbstractAPI{ private final Logger logger = LoggerFactory.getLogger(this.getClass()); private HttpGetMethod HttpMethod; private String index; /** * @param index:二进制数据索引号,String * @param key:masterkey 或者 该设备的设备key */ public GetBindataApi(String index,String key) { this.index = index; this.key=key; this.method= Method.GET; this.HttpMethod=new HttpGetMethod(method); Map<String, Object> headmap = new HashMap<String, Object>(); headmap.put("api-key", key); HttpMethod.setHeader(headmap);
this.url = Config.getString("test.url") + "/bindata" + "/" + index;
cm-heclouds/JAVA-HTTP-SDK
javaSDK/src/main/java/cmcc/iot/onenet/javasdk/api/AbstractAPI.java
// Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/request/RequestInfo.java // public enum Method{ // POST,GET,DELETE,PUT // }
import cmcc.iot.onenet.javasdk.request.RequestInfo.Method; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Locale; import java.util.TimeZone;
package cmcc.iot.onenet.javasdk.api; public abstract class AbstractAPI<T> { public String key; public String url;
// Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/request/RequestInfo.java // public enum Method{ // POST,GET,DELETE,PUT // } // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/api/AbstractAPI.java import cmcc.iot.onenet.javasdk.request.RequestInfo.Method; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Locale; import java.util.TimeZone; package cmcc.iot.onenet.javasdk.api; public abstract class AbstractAPI<T> { public String key; public String url;
public Method method;
cm-heclouds/JAVA-HTTP-SDK
javaSDK/src/main/java/cmcc/iot/onenet/javasdk/http/HttpGetMethod.java
// Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/exception/OnenetApiException.java // public class OnenetApiException extends RuntimeException { // private String message = null; // public String getMessage() { // return message; // } // public OnenetApiException( String message) { // this.message = message; // } // }
import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import cmcc.iot.onenet.javasdk.exception.OnenetApiException;
package cmcc.iot.onenet.javasdk.http; public class HttpGetMethod extends BasicHttpMethod { private final Logger logger = LoggerFactory.getLogger(this.getClass()); HttpGet httpGet; public HttpGetMethod(Method method) { super(method); } public HttpResponse execute() throws Exception { HttpResponse httpResponse = null; httpClient = HttpClients.createDefault(); httpResponse = httpClient.execute(httpRequestBase); int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK && statusCode != 221) { String response = EntityUtils.toString(httpResponse.getEntity()); logger.error("request failed status:{}, response::{}",statusCode, response);
// Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/exception/OnenetApiException.java // public class OnenetApiException extends RuntimeException { // private String message = null; // public String getMessage() { // return message; // } // public OnenetApiException( String message) { // this.message = message; // } // } // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/http/HttpGetMethod.java import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import cmcc.iot.onenet.javasdk.exception.OnenetApiException; package cmcc.iot.onenet.javasdk.http; public class HttpGetMethod extends BasicHttpMethod { private final Logger logger = LoggerFactory.getLogger(this.getClass()); HttpGet httpGet; public HttpGetMethod(Method method) { super(method); } public HttpResponse execute() throws Exception { HttpResponse httpResponse = null; httpClient = HttpClients.createDefault(); httpResponse = httpClient.execute(httpRequestBase); int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK && statusCode != 221) { String response = EntityUtils.toString(httpResponse.getEntity()); logger.error("request failed status:{}, response::{}",statusCode, response);
throw new OnenetApiException("request failed: " + response);
cm-heclouds/JAVA-HTTP-SDK
javaSDK/src/main/java/cmcc/iot/onenet/javasdk/http/HttpPutMethod.java
// Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/exception/OnenetApiException.java // public class OnenetApiException extends RuntimeException { // private String message = null; // public String getMessage() { // return message; // } // public OnenetApiException( String message) { // this.message = message; // } // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/response/BasicResponse.java // public class BasicResponse<T> { // public int errno; // public String error; // @JsonProperty("data") // public Object dataInternal; // public T data; // @JsonIgnore // public String json; // // public String getJson() { // return json; // } // // public void setJson(String json) { // this.json = json; // } // // public int getErrno() { // return errno; // } // // public void setErrno(int errno) { // this.errno = errno; // } // // public String getError() { // return error; // } // // public void setError(String error) { // this.error = error; // } // // @JsonGetter("data") // public Object getDataInternal() { // return dataInternal; // } // @JsonSetter("data") // public void setDataInternal(Object dataInternal) { // this.dataInternal = dataInternal; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // }
import java.io.File; import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.Map.Entry; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.client.methods.HttpPut; import org.apache.http.entity.StringEntity; import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.entity.mime.content.FileBody; import org.apache.http.entity.mime.content.StringBody; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import cmcc.iot.onenet.javasdk.exception.OnenetApiException; import cmcc.iot.onenet.javasdk.response.BasicResponse;
package cmcc.iot.onenet.javasdk.http; public class HttpPutMethod extends BasicHttpMethod { private final Logger logger = LoggerFactory.getLogger(this.getClass()); public HttpPutMethod(Method method) { super(method); // TODO Auto-generated constructor stub } public void setEntity(String json) { // TODO Auto-generated method stub if (json != null) { StringEntity entity = new StringEntity(json, Charset.forName("UTF-8")); ((HttpPut) httpRequestBase).setEntity(entity);// 向下转型 } } public void setEntity(Map<String, String> stringMap, Map<String, String> fileMap) { // TODO Auto-generated method stub this.upload = true; Set<Entry<String, String>> stringSet = stringMap.entrySet(); Set<Entry<String, String>> fileSet = fileMap.entrySet(); Map<String, StringBody> stringEntityMap = new HashMap<String, StringBody>(); Map<String, FileBody> fileBodyMap = new HashMap<String, FileBody>(); for (Entry<String, String> entry : stringSet) { try { stringEntityMap.put(entry.getKey(), new StringBody(entry.getValue(), Charset.forName("UTF-8"))); } catch (UnsupportedEncodingException e) { logger.error("error:" + e.getMessage());
// Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/exception/OnenetApiException.java // public class OnenetApiException extends RuntimeException { // private String message = null; // public String getMessage() { // return message; // } // public OnenetApiException( String message) { // this.message = message; // } // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/response/BasicResponse.java // public class BasicResponse<T> { // public int errno; // public String error; // @JsonProperty("data") // public Object dataInternal; // public T data; // @JsonIgnore // public String json; // // public String getJson() { // return json; // } // // public void setJson(String json) { // this.json = json; // } // // public int getErrno() { // return errno; // } // // public void setErrno(int errno) { // this.errno = errno; // } // // public String getError() { // return error; // } // // public void setError(String error) { // this.error = error; // } // // @JsonGetter("data") // public Object getDataInternal() { // return dataInternal; // } // @JsonSetter("data") // public void setDataInternal(Object dataInternal) { // this.dataInternal = dataInternal; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/http/HttpPutMethod.java import java.io.File; import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.Map.Entry; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.client.methods.HttpPut; import org.apache.http.entity.StringEntity; import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.entity.mime.content.FileBody; import org.apache.http.entity.mime.content.StringBody; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import cmcc.iot.onenet.javasdk.exception.OnenetApiException; import cmcc.iot.onenet.javasdk.response.BasicResponse; package cmcc.iot.onenet.javasdk.http; public class HttpPutMethod extends BasicHttpMethod { private final Logger logger = LoggerFactory.getLogger(this.getClass()); public HttpPutMethod(Method method) { super(method); // TODO Auto-generated constructor stub } public void setEntity(String json) { // TODO Auto-generated method stub if (json != null) { StringEntity entity = new StringEntity(json, Charset.forName("UTF-8")); ((HttpPut) httpRequestBase).setEntity(entity);// 向下转型 } } public void setEntity(Map<String, String> stringMap, Map<String, String> fileMap) { // TODO Auto-generated method stub this.upload = true; Set<Entry<String, String>> stringSet = stringMap.entrySet(); Set<Entry<String, String>> fileSet = fileMap.entrySet(); Map<String, StringBody> stringEntityMap = new HashMap<String, StringBody>(); Map<String, FileBody> fileBodyMap = new HashMap<String, FileBody>(); for (Entry<String, String> entry : stringSet) { try { stringEntityMap.put(entry.getKey(), new StringBody(entry.getValue(), Charset.forName("UTF-8"))); } catch (UnsupportedEncodingException e) { logger.error("error:" + e.getMessage());
throw new OnenetApiException(e.getMessage());
cm-heclouds/JAVA-HTTP-SDK
javaSDK/src/main/java/cmcc/iot/onenet/javasdk/http/BasicHttpMethod.java
// Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/exception/OnenetApiException.java // public class OnenetApiException extends RuntimeException { // private String message = null; // public String getMessage() { // return message; // } // public OnenetApiException( String message) { // this.message = message; // } // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/request/RequestInfo.java // public interface RequestInfo { // //定义一个枚举 // public enum Method{ // POST,GET,DELETE,PUT // } // public void setHeader(Map<String,Object> params); // public void setEntity(Object json); // public void setEntity(Map<String, String> stringMap,Map<String,String> fileMap); // public void setcompleteUrl(String completeUrl,Map<String,Object> params); // public void sethttpMethod(Method method); // public void setType(boolean upload); // // }
import java.net.URI; import java.net.URISyntaxException; import java.util.Map; import java.util.Set; import java.util.Map.Entry; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPut; import org.apache.http.client.methods.HttpDelete; import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.impl.client.CloseableHttpClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.fasterxml.jackson.databind.ObjectMapper; import cmcc.iot.onenet.javasdk.exception.OnenetApiException; import cmcc.iot.onenet.javasdk.request.RequestInfo;
httpRequestBase= new HttpGet(); break; } } public HttpRequestBase setHttpRequestBase() { return null; } public void setHttpRequestBase(HttpRequestBase httpRequestBase) { this.httpRequestBase = httpRequestBase; } public void setcompleteUrl(String url,Map<String, Object> params) { // TODO Auto-generated method stub if(params!=null) { url+="?"; Set<Entry<String,Object>> entrys=params.entrySet(); int size=entrys.size(); int index=0; for(Entry<String,Object> entry:entrys) { url+=entry.getKey()+"="+entry.getValue(); if(++index<size) url+="&"; } } try { httpRequestBase.setURI(new URI(url)); } catch (URISyntaxException e) { logger.error("url error: {}",e.getMessage());
// Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/exception/OnenetApiException.java // public class OnenetApiException extends RuntimeException { // private String message = null; // public String getMessage() { // return message; // } // public OnenetApiException( String message) { // this.message = message; // } // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/request/RequestInfo.java // public interface RequestInfo { // //定义一个枚举 // public enum Method{ // POST,GET,DELETE,PUT // } // public void setHeader(Map<String,Object> params); // public void setEntity(Object json); // public void setEntity(Map<String, String> stringMap,Map<String,String> fileMap); // public void setcompleteUrl(String completeUrl,Map<String,Object> params); // public void sethttpMethod(Method method); // public void setType(boolean upload); // // } // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/http/BasicHttpMethod.java import java.net.URI; import java.net.URISyntaxException; import java.util.Map; import java.util.Set; import java.util.Map.Entry; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPut; import org.apache.http.client.methods.HttpDelete; import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.impl.client.CloseableHttpClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.fasterxml.jackson.databind.ObjectMapper; import cmcc.iot.onenet.javasdk.exception.OnenetApiException; import cmcc.iot.onenet.javasdk.request.RequestInfo; httpRequestBase= new HttpGet(); break; } } public HttpRequestBase setHttpRequestBase() { return null; } public void setHttpRequestBase(HttpRequestBase httpRequestBase) { this.httpRequestBase = httpRequestBase; } public void setcompleteUrl(String url,Map<String, Object> params) { // TODO Auto-generated method stub if(params!=null) { url+="?"; Set<Entry<String,Object>> entrys=params.entrySet(); int size=entrys.size(); int index=0; for(Entry<String,Object> entry:entrys) { url+=entry.getKey()+"="+entry.getValue(); if(++index<size) url+="&"; } } try { httpRequestBase.setURI(new URI(url)); } catch (URISyntaxException e) { logger.error("url error: {}",e.getMessage());
throw new OnenetApiException(e.getMessage());
cm-heclouds/JAVA-HTTP-SDK
javaSDK/src/main/java/cmcc/iot/onenet/javasdk/http/HttpPostMethod.java
// Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/exception/OnenetApiException.java // public class OnenetApiException extends RuntimeException { // private String message = null; // public String getMessage() { // return message; // } // public OnenetApiException( String message) { // this.message = message; // } // }
import java.io.File; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ByteArrayEntity; import org.apache.http.entity.StringEntity; import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.entity.mime.content.FileBody; import org.apache.http.entity.mime.content.StringBody; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import cmcc.iot.onenet.javasdk.exception.OnenetApiException;
package cmcc.iot.onenet.javasdk.http; public class HttpPostMethod extends BasicHttpMethod { public HttpPostMethod(Method method) { super(method); } private final Logger logger = LoggerFactory.getLogger(this.getClass()); @Override public void setEntity(Object json) { if (json != null) { if (json instanceof String) { StringEntity entity = new StringEntity(json.toString(), Charset.forName("UTF-8")); ((HttpPost) httpRequestBase).setEntity(entity);// 向下转型 } if (json instanceof byte[]) { ((HttpPost) httpRequestBase).setEntity(new ByteArrayEntity((byte[]) json)); } } } public void setEntity(Map<String, String> stringMap, Map<String, String> fileMap) { this.upload = true; Set<Entry<String, StringBody>> stringBodySet = null; if (stringMap != null) { Set<Entry<String, String>> stringSet = stringMap.entrySet(); Map<String, StringBody> stringEntityMap = new HashMap<String, StringBody>(); for (Entry<String, String> entry : stringSet) { try { stringEntityMap.put(entry.getKey(), new StringBody(entry.getValue(), Charset.forName("UTF-8"))); } catch (UnsupportedEncodingException e) { logger.error("error:" + e.getMessage());
// Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/exception/OnenetApiException.java // public class OnenetApiException extends RuntimeException { // private String message = null; // public String getMessage() { // return message; // } // public OnenetApiException( String message) { // this.message = message; // } // } // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/http/HttpPostMethod.java import java.io.File; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ByteArrayEntity; import org.apache.http.entity.StringEntity; import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.entity.mime.content.FileBody; import org.apache.http.entity.mime.content.StringBody; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import cmcc.iot.onenet.javasdk.exception.OnenetApiException; package cmcc.iot.onenet.javasdk.http; public class HttpPostMethod extends BasicHttpMethod { public HttpPostMethod(Method method) { super(method); } private final Logger logger = LoggerFactory.getLogger(this.getClass()); @Override public void setEntity(Object json) { if (json != null) { if (json instanceof String) { StringEntity entity = new StringEntity(json.toString(), Charset.forName("UTF-8")); ((HttpPost) httpRequestBase).setEntity(entity);// 向下转型 } if (json instanceof byte[]) { ((HttpPost) httpRequestBase).setEntity(new ByteArrayEntity((byte[]) json)); } } } public void setEntity(Map<String, String> stringMap, Map<String, String> fileMap) { this.upload = true; Set<Entry<String, StringBody>> stringBodySet = null; if (stringMap != null) { Set<Entry<String, String>> stringSet = stringMap.entrySet(); Map<String, StringBody> stringEntityMap = new HashMap<String, StringBody>(); for (Entry<String, String> entry : stringSet) { try { stringEntityMap.put(entry.getKey(), new StringBody(entry.getValue(), Charset.forName("UTF-8"))); } catch (UnsupportedEncodingException e) { logger.error("error:" + e.getMessage());
throw new OnenetApiException(e.getMessage());
cm-heclouds/JAVA-HTTP-SDK
javaSDK/src/main/java/cmcc/iot/onenet/javasdk/http/HttpDeleteMethod.java
// Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/exception/OnenetApiException.java // public class OnenetApiException extends RuntimeException { // private String message = null; // public String getMessage() { // return message; // } // public OnenetApiException( String message) { // this.message = message; // } // }
import java.util.Map; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import cmcc.iot.onenet.javasdk.exception.OnenetApiException;
package cmcc.iot.onenet.javasdk.http; public class HttpDeleteMethod extends BasicHttpMethod { private final Logger logger = LoggerFactory.getLogger(this.getClass()); public HttpDeleteMethod(Method method) { super(method); // TODO Auto-generated constructor stub } public void setEntity(String json) { // TODO Auto-generated method stub } public void setEntity(Map<String, String> stringMap, Map<String, String> fileMap) { // TODO Auto-generated method stub } public void sethttpMethod(Method method) { // TODO Auto-generated method stub } public HttpResponse execute() throws Exception { HttpResponse httpResponse = null; httpClient = HttpClients.createDefault(); httpResponse = httpClient.execute(httpRequestBase); int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK && statusCode != 221) { String response = EntityUtils.toString(httpResponse.getEntity()); logger.error("request failed status:{}, response::{}",statusCode, response);
// Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/exception/OnenetApiException.java // public class OnenetApiException extends RuntimeException { // private String message = null; // public String getMessage() { // return message; // } // public OnenetApiException( String message) { // this.message = message; // } // } // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/http/HttpDeleteMethod.java import java.util.Map; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import cmcc.iot.onenet.javasdk.exception.OnenetApiException; package cmcc.iot.onenet.javasdk.http; public class HttpDeleteMethod extends BasicHttpMethod { private final Logger logger = LoggerFactory.getLogger(this.getClass()); public HttpDeleteMethod(Method method) { super(method); // TODO Auto-generated constructor stub } public void setEntity(String json) { // TODO Auto-generated method stub } public void setEntity(Map<String, String> stringMap, Map<String, String> fileMap) { // TODO Auto-generated method stub } public void sethttpMethod(Method method) { // TODO Auto-generated method stub } public HttpResponse execute() throws Exception { HttpResponse httpResponse = null; httpClient = HttpClients.createDefault(); httpResponse = httpClient.execute(httpRequestBase); int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK && statusCode != 221) { String response = EntityUtils.toString(httpResponse.getEntity()); logger.error("request failed status:{}, response::{}",statusCode, response);
throw new OnenetApiException("request failed: " + response);
cm-heclouds/JAVA-HTTP-SDK
javaSDK/src/test/java/com/cmcciot/onenet/api/ApiTest.java
// Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/api/dtu/DeleteDtuParser.java // public class DeleteDtuParser extends AbstractAPI { // private final Logger logger = LoggerFactory.getLogger(this.getClass()); // private Integer id; // private HttpDeleteMethod HttpMethod; // // /** // * TCP透传parser删除 // * @param id:parser_id,Integer // * @param key:masterkey 或者 设备key // */ // public DeleteDtuParser(Integer id, String key) { // this.id = id; // this.key = key; // this.method = Method.DELETE; // Map<String, Object> headmap = new HashMap<String, Object>(); // HttpMethod = new HttpDeleteMethod(method); // headmap.put("api-key", key); // HttpMethod.setHeader(headmap); // if (id == null) { // throw new OnenetApiException("parser id is required "); // } // this.url = Config.getString("test.url") + "/dtu/parser/" +id; // HttpMethod.setcompleteUrl(url, null); // } // public BasicResponse<Void> executeApi() { // BasicResponse response = null; // try { // HttpResponse httpResponse = HttpMethod.execute(); // response = mapper.readValue(httpResponse.getEntity().getContent(), BasicResponse.class); // response.setJson(mapper.writeValueAsString(response)); // return response; // } catch (Exception e) { // logger.error("json error {}", e.getMessage()); // throw new OnenetApiException(e.getMessage()); // }finally { // try { // HttpMethod.httpClient.close(); // } catch (Exception e) { // logger.error("http close error: {}", e.getMessage()); // throw new OnenetApiException(e.getMessage()); // } // } // // } // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/response/BasicResponse.java // public class BasicResponse<T> { // public int errno; // public String error; // @JsonProperty("data") // public Object dataInternal; // public T data; // @JsonIgnore // public String json; // // public String getJson() { // return json; // } // // public void setJson(String json) { // this.json = json; // } // // public int getErrno() { // return errno; // } // // public void setErrno(int errno) { // this.errno = errno; // } // // public String getError() { // return error; // } // // public void setError(String error) { // this.error = error; // } // // @JsonGetter("data") // public Object getDataInternal() { // return dataInternal; // } // @JsonSetter("data") // public void setDataInternal(Object dataInternal) { // this.dataInternal = dataInternal; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // }
import cmcc.iot.onenet.javasdk.api.dtu.DeleteDtuParser; import cmcc.iot.onenet.javasdk.response.BasicResponse; import org.junit.Test;
package com.cmcciot.onenet.api; public class ApiTest { @Test public void testDeleteDtuParserApi() { String key = "m4EubNp9WCeAxjFu4lVw=kn2idE="; Integer id = 385; /** * TCP透传查询 * @param name: 名字,精确匹配名字(可选),String * @param key:masterkey 或者 该设备的设备apikey */
// Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/api/dtu/DeleteDtuParser.java // public class DeleteDtuParser extends AbstractAPI { // private final Logger logger = LoggerFactory.getLogger(this.getClass()); // private Integer id; // private HttpDeleteMethod HttpMethod; // // /** // * TCP透传parser删除 // * @param id:parser_id,Integer // * @param key:masterkey 或者 设备key // */ // public DeleteDtuParser(Integer id, String key) { // this.id = id; // this.key = key; // this.method = Method.DELETE; // Map<String, Object> headmap = new HashMap<String, Object>(); // HttpMethod = new HttpDeleteMethod(method); // headmap.put("api-key", key); // HttpMethod.setHeader(headmap); // if (id == null) { // throw new OnenetApiException("parser id is required "); // } // this.url = Config.getString("test.url") + "/dtu/parser/" +id; // HttpMethod.setcompleteUrl(url, null); // } // public BasicResponse<Void> executeApi() { // BasicResponse response = null; // try { // HttpResponse httpResponse = HttpMethod.execute(); // response = mapper.readValue(httpResponse.getEntity().getContent(), BasicResponse.class); // response.setJson(mapper.writeValueAsString(response)); // return response; // } catch (Exception e) { // logger.error("json error {}", e.getMessage()); // throw new OnenetApiException(e.getMessage()); // }finally { // try { // HttpMethod.httpClient.close(); // } catch (Exception e) { // logger.error("http close error: {}", e.getMessage()); // throw new OnenetApiException(e.getMessage()); // } // } // // } // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/response/BasicResponse.java // public class BasicResponse<T> { // public int errno; // public String error; // @JsonProperty("data") // public Object dataInternal; // public T data; // @JsonIgnore // public String json; // // public String getJson() { // return json; // } // // public void setJson(String json) { // this.json = json; // } // // public int getErrno() { // return errno; // } // // public void setErrno(int errno) { // this.errno = errno; // } // // public String getError() { // return error; // } // // public void setError(String error) { // this.error = error; // } // // @JsonGetter("data") // public Object getDataInternal() { // return dataInternal; // } // @JsonSetter("data") // public void setDataInternal(Object dataInternal) { // this.dataInternal = dataInternal; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // Path: javaSDK/src/test/java/com/cmcciot/onenet/api/ApiTest.java import cmcc.iot.onenet.javasdk.api.dtu.DeleteDtuParser; import cmcc.iot.onenet.javasdk.response.BasicResponse; import org.junit.Test; package com.cmcciot.onenet.api; public class ApiTest { @Test public void testDeleteDtuParserApi() { String key = "m4EubNp9WCeAxjFu4lVw=kn2idE="; Integer id = 385; /** * TCP透传查询 * @param name: 名字,精确匹配名字(可选),String * @param key:masterkey 或者 该设备的设备apikey */
DeleteDtuParser api = new DeleteDtuParser(id, key);
cm-heclouds/JAVA-HTTP-SDK
javaSDK/src/test/java/com/cmcciot/onenet/api/ApiTest.java
// Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/api/dtu/DeleteDtuParser.java // public class DeleteDtuParser extends AbstractAPI { // private final Logger logger = LoggerFactory.getLogger(this.getClass()); // private Integer id; // private HttpDeleteMethod HttpMethod; // // /** // * TCP透传parser删除 // * @param id:parser_id,Integer // * @param key:masterkey 或者 设备key // */ // public DeleteDtuParser(Integer id, String key) { // this.id = id; // this.key = key; // this.method = Method.DELETE; // Map<String, Object> headmap = new HashMap<String, Object>(); // HttpMethod = new HttpDeleteMethod(method); // headmap.put("api-key", key); // HttpMethod.setHeader(headmap); // if (id == null) { // throw new OnenetApiException("parser id is required "); // } // this.url = Config.getString("test.url") + "/dtu/parser/" +id; // HttpMethod.setcompleteUrl(url, null); // } // public BasicResponse<Void> executeApi() { // BasicResponse response = null; // try { // HttpResponse httpResponse = HttpMethod.execute(); // response = mapper.readValue(httpResponse.getEntity().getContent(), BasicResponse.class); // response.setJson(mapper.writeValueAsString(response)); // return response; // } catch (Exception e) { // logger.error("json error {}", e.getMessage()); // throw new OnenetApiException(e.getMessage()); // }finally { // try { // HttpMethod.httpClient.close(); // } catch (Exception e) { // logger.error("http close error: {}", e.getMessage()); // throw new OnenetApiException(e.getMessage()); // } // } // // } // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/response/BasicResponse.java // public class BasicResponse<T> { // public int errno; // public String error; // @JsonProperty("data") // public Object dataInternal; // public T data; // @JsonIgnore // public String json; // // public String getJson() { // return json; // } // // public void setJson(String json) { // this.json = json; // } // // public int getErrno() { // return errno; // } // // public void setErrno(int errno) { // this.errno = errno; // } // // public String getError() { // return error; // } // // public void setError(String error) { // this.error = error; // } // // @JsonGetter("data") // public Object getDataInternal() { // return dataInternal; // } // @JsonSetter("data") // public void setDataInternal(Object dataInternal) { // this.dataInternal = dataInternal; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // }
import cmcc.iot.onenet.javasdk.api.dtu.DeleteDtuParser; import cmcc.iot.onenet.javasdk.response.BasicResponse; import org.junit.Test;
package com.cmcciot.onenet.api; public class ApiTest { @Test public void testDeleteDtuParserApi() { String key = "m4EubNp9WCeAxjFu4lVw=kn2idE="; Integer id = 385; /** * TCP透传查询 * @param name: 名字,精确匹配名字(可选),String * @param key:masterkey 或者 该设备的设备apikey */ DeleteDtuParser api = new DeleteDtuParser(id, key);
// Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/api/dtu/DeleteDtuParser.java // public class DeleteDtuParser extends AbstractAPI { // private final Logger logger = LoggerFactory.getLogger(this.getClass()); // private Integer id; // private HttpDeleteMethod HttpMethod; // // /** // * TCP透传parser删除 // * @param id:parser_id,Integer // * @param key:masterkey 或者 设备key // */ // public DeleteDtuParser(Integer id, String key) { // this.id = id; // this.key = key; // this.method = Method.DELETE; // Map<String, Object> headmap = new HashMap<String, Object>(); // HttpMethod = new HttpDeleteMethod(method); // headmap.put("api-key", key); // HttpMethod.setHeader(headmap); // if (id == null) { // throw new OnenetApiException("parser id is required "); // } // this.url = Config.getString("test.url") + "/dtu/parser/" +id; // HttpMethod.setcompleteUrl(url, null); // } // public BasicResponse<Void> executeApi() { // BasicResponse response = null; // try { // HttpResponse httpResponse = HttpMethod.execute(); // response = mapper.readValue(httpResponse.getEntity().getContent(), BasicResponse.class); // response.setJson(mapper.writeValueAsString(response)); // return response; // } catch (Exception e) { // logger.error("json error {}", e.getMessage()); // throw new OnenetApiException(e.getMessage()); // }finally { // try { // HttpMethod.httpClient.close(); // } catch (Exception e) { // logger.error("http close error: {}", e.getMessage()); // throw new OnenetApiException(e.getMessage()); // } // } // // } // } // // Path: javaSDK/src/main/java/cmcc/iot/onenet/javasdk/response/BasicResponse.java // public class BasicResponse<T> { // public int errno; // public String error; // @JsonProperty("data") // public Object dataInternal; // public T data; // @JsonIgnore // public String json; // // public String getJson() { // return json; // } // // public void setJson(String json) { // this.json = json; // } // // public int getErrno() { // return errno; // } // // public void setErrno(int errno) { // this.errno = errno; // } // // public String getError() { // return error; // } // // public void setError(String error) { // this.error = error; // } // // @JsonGetter("data") // public Object getDataInternal() { // return dataInternal; // } // @JsonSetter("data") // public void setDataInternal(Object dataInternal) { // this.dataInternal = dataInternal; // } // // public T getData() { // return data; // } // // public void setData(T data) { // this.data = data; // } // } // Path: javaSDK/src/test/java/com/cmcciot/onenet/api/ApiTest.java import cmcc.iot.onenet.javasdk.api.dtu.DeleteDtuParser; import cmcc.iot.onenet.javasdk.response.BasicResponse; import org.junit.Test; package com.cmcciot.onenet.api; public class ApiTest { @Test public void testDeleteDtuParserApi() { String key = "m4EubNp9WCeAxjFu4lVw=kn2idE="; Integer id = 385; /** * TCP透传查询 * @param name: 名字,精确匹配名字(可选),String * @param key:masterkey 或者 该设备的设备apikey */ DeleteDtuParser api = new DeleteDtuParser(id, key);
BasicResponse<Void> response = api.executeApi();
aarddict/android
src/aarddict/android/LookupActivity.java
// Path: src/aarddict/Entry.java // public final class Entry implements Serializable { // // public String title; // public String section; // public long articlePointer; // public String volumeId; // // public Entry(String volumeId, String title) { // this(volumeId, title, -1); // } // // public Entry(String volumeId, String title, long articlePointer) { // this.volumeId = volumeId; // this.title = title == null ? "" : title; // this.articlePointer = articlePointer; // } // // @Override // public String toString() { // return title; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result // + (int) (articlePointer ^ (articlePointer >>> 32)); // result = prime * result + ((section == null) ? 0 : section.hashCode()); // result = prime * result + ((title == null) ? 0 : title.hashCode()); // result = prime * result // + ((volumeId == null) ? 0 : volumeId.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Entry other = (Entry) obj; // if (articlePointer != other.articlePointer) // return false; // if (section == null) { // if (other.section != null) // return false; // } else if (!section.equals(other.section)) // return false; // if (title == null) { // if (other.title != null) // return false; // } else if (!title.equals(other.title)) // return false; // if (volumeId == null) { // if (other.volumeId != null) // return false; // } else if (!volumeId.equals(other.volumeId)) // return false; // return true; // } // // }
import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Timer; import java.util.TimerTask; import aarddict.Entry; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Resources; import android.net.Uri; import android.text.Editable; import android.text.Html; import android.text.InputType; import android.text.TextUtils; import android.text.TextWatcher; import android.text.method.LinkMovementMethod; import android.util.Log; import android.view.Gravity; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.View.OnKeyListener; import android.view.ViewGroup; import android.view.Window; import android.view.inputmethod.InputMethodManager; import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; import android.widget.TwoLineListItem;
/* This file is part of Aard Dictionary for Android <http://aarddict.org>. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License <http://www.gnu.org/licenses/gpl-3.0.txt> * for more details. * * Copyright (C) 2010 Igor Tkach */ package aarddict.android; public class LookupActivity extends BaseDictionaryActivity { private final static String TAG = LookupActivity.class.getName(); private Timer timer; private ListView listView;
// Path: src/aarddict/Entry.java // public final class Entry implements Serializable { // // public String title; // public String section; // public long articlePointer; // public String volumeId; // // public Entry(String volumeId, String title) { // this(volumeId, title, -1); // } // // public Entry(String volumeId, String title, long articlePointer) { // this.volumeId = volumeId; // this.title = title == null ? "" : title; // this.articlePointer = articlePointer; // } // // @Override // public String toString() { // return title; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result // + (int) (articlePointer ^ (articlePointer >>> 32)); // result = prime * result + ((section == null) ? 0 : section.hashCode()); // result = prime * result + ((title == null) ? 0 : title.hashCode()); // result = prime * result // + ((volumeId == null) ? 0 : volumeId.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Entry other = (Entry) obj; // if (articlePointer != other.articlePointer) // return false; // if (section == null) { // if (other.section != null) // return false; // } else if (!section.equals(other.section)) // return false; // if (title == null) { // if (other.title != null) // return false; // } else if (!title.equals(other.title)) // return false; // if (volumeId == null) { // if (other.volumeId != null) // return false; // } else if (!volumeId.equals(other.volumeId)) // return false; // return true; // } // // } // Path: src/aarddict/android/LookupActivity.java import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Timer; import java.util.TimerTask; import aarddict.Entry; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Resources; import android.net.Uri; import android.text.Editable; import android.text.Html; import android.text.InputType; import android.text.TextUtils; import android.text.TextWatcher; import android.text.method.LinkMovementMethod; import android.util.Log; import android.view.Gravity; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.View.OnKeyListener; import android.view.ViewGroup; import android.view.Window; import android.view.inputmethod.InputMethodManager; import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; import android.widget.TwoLineListItem; /* This file is part of Aard Dictionary for Android <http://aarddict.org>. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License <http://www.gnu.org/licenses/gpl-3.0.txt> * for more details. * * Copyright (C) 2010 Igor Tkach */ package aarddict.android; public class LookupActivity extends BaseDictionaryActivity { private final static String TAG = LookupActivity.class.getName(); private Timer timer; private ListView listView;
private Iterator<Entry> empty = new ArrayList<Entry>().iterator();
aarddict/android
src/aarddict/android/SectionMatcher.java
// Path: src/aarddict/Entry.java // public final class Entry implements Serializable { // // public String title; // public String section; // public long articlePointer; // public String volumeId; // // public Entry(String volumeId, String title) { // this(volumeId, title, -1); // } // // public Entry(String volumeId, String title, long articlePointer) { // this.volumeId = volumeId; // this.title = title == null ? "" : title; // this.articlePointer = articlePointer; // } // // @Override // public String toString() { // return title; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result // + (int) (articlePointer ^ (articlePointer >>> 32)); // result = prime * result + ((section == null) ? 0 : section.hashCode()); // result = prime * result + ((title == null) ? 0 : title.hashCode()); // result = prime * result // + ((volumeId == null) ? 0 : volumeId.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Entry other = (Entry) obj; // if (articlePointer != other.articlePointer) // return false; // if (section == null) { // if (other.section != null) // return false; // } else if (!section.equals(other.section)) // return false; // if (title == null) { // if (other.title != null) // return false; // } else if (!title.equals(other.title)) // return false; // if (volumeId == null) { // if (other.volumeId != null) // return false; // } else if (!volumeId.equals(other.volumeId)) // return false; // return true; // } // // } // // Path: src/aarddict/EntryComparators.java // public class EntryComparators { // // final static EntryComparator FULL1 = new EntryComparator(Collator.PRIMARY); // final static EntryComparator FULL2 = new EntryComparator(Collator.SECONDARY); // final static EntryComparator FULL3 = new EntryComparator(Collator.TERTIARY); // // final static EntryStartComparator START1 = new EntryStartComparator(Collator.PRIMARY); // final static EntryStartComparator START2 = new EntryStartComparator(Collator.SECONDARY); // final static EntryStartComparator START3 = new EntryStartComparator(Collator.TERTIARY); // // @SuppressWarnings("unchecked") // public static Comparator<Entry>[] ALL = new Comparator[] { // FULL3, FULL2, FULL1, START3, START2, START1 // }; // // @SuppressWarnings("unchecked") // public static Comparator<Entry>[] ALL_FULL = new Comparator[] { // FULL3, FULL2, FULL1 // }; // // @SuppressWarnings("unchecked") // public static Comparator<Entry>[] EXACT_IGNORE_CASE = new Comparator[] { // FULL3, FULL2 // }; // // @SuppressWarnings("unchecked") // public static Comparator<Entry>[] EXACT = new Comparator[] { // FULL3 // }; // }
import java.util.Comparator; import aarddict.Entry; import aarddict.EntryComparators; import android.util.Log; import android.webkit.JavascriptInterface;
/* This file is part of Aard Dictionary for Android <http://aarddict.org>. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License <http://www.gnu.org/licenses/gpl-3.0.txt> * for more details. * * Copyright (C) 2010 Igor Tkach */ package aarddict.android; final class SectionMatcher { final static String TAG = "aarddict.SectionMatcher"; public SectionMatcher() { } @JavascriptInterface public boolean match(String section, String candidate, int strength) {
// Path: src/aarddict/Entry.java // public final class Entry implements Serializable { // // public String title; // public String section; // public long articlePointer; // public String volumeId; // // public Entry(String volumeId, String title) { // this(volumeId, title, -1); // } // // public Entry(String volumeId, String title, long articlePointer) { // this.volumeId = volumeId; // this.title = title == null ? "" : title; // this.articlePointer = articlePointer; // } // // @Override // public String toString() { // return title; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result // + (int) (articlePointer ^ (articlePointer >>> 32)); // result = prime * result + ((section == null) ? 0 : section.hashCode()); // result = prime * result + ((title == null) ? 0 : title.hashCode()); // result = prime * result // + ((volumeId == null) ? 0 : volumeId.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Entry other = (Entry) obj; // if (articlePointer != other.articlePointer) // return false; // if (section == null) { // if (other.section != null) // return false; // } else if (!section.equals(other.section)) // return false; // if (title == null) { // if (other.title != null) // return false; // } else if (!title.equals(other.title)) // return false; // if (volumeId == null) { // if (other.volumeId != null) // return false; // } else if (!volumeId.equals(other.volumeId)) // return false; // return true; // } // // } // // Path: src/aarddict/EntryComparators.java // public class EntryComparators { // // final static EntryComparator FULL1 = new EntryComparator(Collator.PRIMARY); // final static EntryComparator FULL2 = new EntryComparator(Collator.SECONDARY); // final static EntryComparator FULL3 = new EntryComparator(Collator.TERTIARY); // // final static EntryStartComparator START1 = new EntryStartComparator(Collator.PRIMARY); // final static EntryStartComparator START2 = new EntryStartComparator(Collator.SECONDARY); // final static EntryStartComparator START3 = new EntryStartComparator(Collator.TERTIARY); // // @SuppressWarnings("unchecked") // public static Comparator<Entry>[] ALL = new Comparator[] { // FULL3, FULL2, FULL1, START3, START2, START1 // }; // // @SuppressWarnings("unchecked") // public static Comparator<Entry>[] ALL_FULL = new Comparator[] { // FULL3, FULL2, FULL1 // }; // // @SuppressWarnings("unchecked") // public static Comparator<Entry>[] EXACT_IGNORE_CASE = new Comparator[] { // FULL3, FULL2 // }; // // @SuppressWarnings("unchecked") // public static Comparator<Entry>[] EXACT = new Comparator[] { // FULL3 // }; // } // Path: src/aarddict/android/SectionMatcher.java import java.util.Comparator; import aarddict.Entry; import aarddict.EntryComparators; import android.util.Log; import android.webkit.JavascriptInterface; /* This file is part of Aard Dictionary for Android <http://aarddict.org>. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License <http://www.gnu.org/licenses/gpl-3.0.txt> * for more details. * * Copyright (C) 2010 Igor Tkach */ package aarddict.android; final class SectionMatcher { final static String TAG = "aarddict.SectionMatcher"; public SectionMatcher() { } @JavascriptInterface public boolean match(String section, String candidate, int strength) {
Comparator<Entry> c = EntryComparators.ALL[strength];
aarddict/android
src/aarddict/android/SectionMatcher.java
// Path: src/aarddict/Entry.java // public final class Entry implements Serializable { // // public String title; // public String section; // public long articlePointer; // public String volumeId; // // public Entry(String volumeId, String title) { // this(volumeId, title, -1); // } // // public Entry(String volumeId, String title, long articlePointer) { // this.volumeId = volumeId; // this.title = title == null ? "" : title; // this.articlePointer = articlePointer; // } // // @Override // public String toString() { // return title; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result // + (int) (articlePointer ^ (articlePointer >>> 32)); // result = prime * result + ((section == null) ? 0 : section.hashCode()); // result = prime * result + ((title == null) ? 0 : title.hashCode()); // result = prime * result // + ((volumeId == null) ? 0 : volumeId.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Entry other = (Entry) obj; // if (articlePointer != other.articlePointer) // return false; // if (section == null) { // if (other.section != null) // return false; // } else if (!section.equals(other.section)) // return false; // if (title == null) { // if (other.title != null) // return false; // } else if (!title.equals(other.title)) // return false; // if (volumeId == null) { // if (other.volumeId != null) // return false; // } else if (!volumeId.equals(other.volumeId)) // return false; // return true; // } // // } // // Path: src/aarddict/EntryComparators.java // public class EntryComparators { // // final static EntryComparator FULL1 = new EntryComparator(Collator.PRIMARY); // final static EntryComparator FULL2 = new EntryComparator(Collator.SECONDARY); // final static EntryComparator FULL3 = new EntryComparator(Collator.TERTIARY); // // final static EntryStartComparator START1 = new EntryStartComparator(Collator.PRIMARY); // final static EntryStartComparator START2 = new EntryStartComparator(Collator.SECONDARY); // final static EntryStartComparator START3 = new EntryStartComparator(Collator.TERTIARY); // // @SuppressWarnings("unchecked") // public static Comparator<Entry>[] ALL = new Comparator[] { // FULL3, FULL2, FULL1, START3, START2, START1 // }; // // @SuppressWarnings("unchecked") // public static Comparator<Entry>[] ALL_FULL = new Comparator[] { // FULL3, FULL2, FULL1 // }; // // @SuppressWarnings("unchecked") // public static Comparator<Entry>[] EXACT_IGNORE_CASE = new Comparator[] { // FULL3, FULL2 // }; // // @SuppressWarnings("unchecked") // public static Comparator<Entry>[] EXACT = new Comparator[] { // FULL3 // }; // }
import java.util.Comparator; import aarddict.Entry; import aarddict.EntryComparators; import android.util.Log; import android.webkit.JavascriptInterface;
/* This file is part of Aard Dictionary for Android <http://aarddict.org>. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License <http://www.gnu.org/licenses/gpl-3.0.txt> * for more details. * * Copyright (C) 2010 Igor Tkach */ package aarddict.android; final class SectionMatcher { final static String TAG = "aarddict.SectionMatcher"; public SectionMatcher() { } @JavascriptInterface public boolean match(String section, String candidate, int strength) {
// Path: src/aarddict/Entry.java // public final class Entry implements Serializable { // // public String title; // public String section; // public long articlePointer; // public String volumeId; // // public Entry(String volumeId, String title) { // this(volumeId, title, -1); // } // // public Entry(String volumeId, String title, long articlePointer) { // this.volumeId = volumeId; // this.title = title == null ? "" : title; // this.articlePointer = articlePointer; // } // // @Override // public String toString() { // return title; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result // + (int) (articlePointer ^ (articlePointer >>> 32)); // result = prime * result + ((section == null) ? 0 : section.hashCode()); // result = prime * result + ((title == null) ? 0 : title.hashCode()); // result = prime * result // + ((volumeId == null) ? 0 : volumeId.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Entry other = (Entry) obj; // if (articlePointer != other.articlePointer) // return false; // if (section == null) { // if (other.section != null) // return false; // } else if (!section.equals(other.section)) // return false; // if (title == null) { // if (other.title != null) // return false; // } else if (!title.equals(other.title)) // return false; // if (volumeId == null) { // if (other.volumeId != null) // return false; // } else if (!volumeId.equals(other.volumeId)) // return false; // return true; // } // // } // // Path: src/aarddict/EntryComparators.java // public class EntryComparators { // // final static EntryComparator FULL1 = new EntryComparator(Collator.PRIMARY); // final static EntryComparator FULL2 = new EntryComparator(Collator.SECONDARY); // final static EntryComparator FULL3 = new EntryComparator(Collator.TERTIARY); // // final static EntryStartComparator START1 = new EntryStartComparator(Collator.PRIMARY); // final static EntryStartComparator START2 = new EntryStartComparator(Collator.SECONDARY); // final static EntryStartComparator START3 = new EntryStartComparator(Collator.TERTIARY); // // @SuppressWarnings("unchecked") // public static Comparator<Entry>[] ALL = new Comparator[] { // FULL3, FULL2, FULL1, START3, START2, START1 // }; // // @SuppressWarnings("unchecked") // public static Comparator<Entry>[] ALL_FULL = new Comparator[] { // FULL3, FULL2, FULL1 // }; // // @SuppressWarnings("unchecked") // public static Comparator<Entry>[] EXACT_IGNORE_CASE = new Comparator[] { // FULL3, FULL2 // }; // // @SuppressWarnings("unchecked") // public static Comparator<Entry>[] EXACT = new Comparator[] { // FULL3 // }; // } // Path: src/aarddict/android/SectionMatcher.java import java.util.Comparator; import aarddict.Entry; import aarddict.EntryComparators; import android.util.Log; import android.webkit.JavascriptInterface; /* This file is part of Aard Dictionary for Android <http://aarddict.org>. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License <http://www.gnu.org/licenses/gpl-3.0.txt> * for more details. * * Copyright (C) 2010 Igor Tkach */ package aarddict.android; final class SectionMatcher { final static String TAG = "aarddict.SectionMatcher"; public SectionMatcher() { } @JavascriptInterface public boolean match(String section, String candidate, int strength) {
Comparator<Entry> c = EntryComparators.ALL[strength];
aarddict/android
src/aarddict/android/HistoryItem.java
// Path: src/aarddict/Article.java // public final class Article implements Serializable { // // public UUID dictionaryUUID; // public String volumeId; // public String title; // public String section; // public long pointer; // private String redirect; // public String text; // public String redirectedFromTitle; // // public Article() { // } // // public Article(Article that) { // this.dictionaryUUID = that.dictionaryUUID; // this.volumeId = that.volumeId; // this.title = that.title; // this.section = that.section; // this.pointer = that.pointer; // this.redirect = that.redirect; // this.text = that.text; // this.redirectedFromTitle = that.redirectedFromTitle; // } // // @SuppressWarnings("rawtypes") // static Article fromJsonStr(String serializedArticle) throws IOException { // Object[] articleTuple = Volume.mapper.readValue(serializedArticle, Object[].class); // Article article = new Article(); // article.text = String.valueOf(articleTuple[0]); // if (articleTuple.length == 3) { // Map metadata = (Map)articleTuple[2]; // if (metadata.containsKey("r")) { // article.redirect = String.valueOf(metadata.get("r")); // } // else if (metadata.containsKey("redirect")) { // article.redirect = String.valueOf(metadata.get("redirect")); // } // } // return article; // } // // public String getRedirect() { // if (this.redirect != null && this.section != null) { // return this.redirect + "#" + this.section; // } // return this.redirect; // } // // public boolean isRedirect() { // return this.redirect != null; // } // // public boolean equalsIgnoreSection(Article other) { // return volumeId.equals(other.volumeId) && pointer == other.pointer; // } // // public boolean sectionEquals(Article other) { // return (section == null && other.section == null) || // (section !=null && other.section != null && section.equals(other.section)); // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + (int) (pointer ^ (pointer >>> 32)); // result = prime * result + ((section == null) ? 0 : section.hashCode()); // result = prime * result // + ((volumeId == null) ? 0 : volumeId.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Article other = (Article) obj; // if (pointer != other.pointer) // return false; // if (section == null) { // if (other.section != null) // return false; // } else if (!section.equals(other.section)) // return false; // if (volumeId == null) { // if (other.volumeId != null) // return false; // } else if (!volumeId.equals(other.volumeId)) // return false; // return true; // } // } // // Path: src/aarddict/Entry.java // public final class Entry implements Serializable { // // public String title; // public String section; // public long articlePointer; // public String volumeId; // // public Entry(String volumeId, String title) { // this(volumeId, title, -1); // } // // public Entry(String volumeId, String title, long articlePointer) { // this.volumeId = volumeId; // this.title = title == null ? "" : title; // this.articlePointer = articlePointer; // } // // @Override // public String toString() { // return title; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result // + (int) (articlePointer ^ (articlePointer >>> 32)); // result = prime * result + ((section == null) ? 0 : section.hashCode()); // result = prime * result + ((title == null) ? 0 : title.hashCode()); // result = prime * result // + ((volumeId == null) ? 0 : volumeId.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Entry other = (Entry) obj; // if (articlePointer != other.articlePointer) // return false; // if (section == null) { // if (other.section != null) // return false; // } else if (!section.equals(other.section)) // return false; // if (title == null) { // if (other.title != null) // return false; // } else if (!title.equals(other.title)) // return false; // if (volumeId == null) { // if (other.volumeId != null) // return false; // } else if (!volumeId.equals(other.volumeId)) // return false; // return true; // } // // }
import java.io.Serializable; import java.util.ArrayList; import java.util.List; import aarddict.Article; import aarddict.Entry;
/* This file is part of Aard Dictionary for Android <http://aarddict.org>. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License <http://www.gnu.org/licenses/gpl-3.0.txt> * for more details. * * Copyright (C) 2010 Igor Tkach */ package aarddict.android; final class HistoryItem implements Serializable { List<Entry> entries; int entryIndex;
// Path: src/aarddict/Article.java // public final class Article implements Serializable { // // public UUID dictionaryUUID; // public String volumeId; // public String title; // public String section; // public long pointer; // private String redirect; // public String text; // public String redirectedFromTitle; // // public Article() { // } // // public Article(Article that) { // this.dictionaryUUID = that.dictionaryUUID; // this.volumeId = that.volumeId; // this.title = that.title; // this.section = that.section; // this.pointer = that.pointer; // this.redirect = that.redirect; // this.text = that.text; // this.redirectedFromTitle = that.redirectedFromTitle; // } // // @SuppressWarnings("rawtypes") // static Article fromJsonStr(String serializedArticle) throws IOException { // Object[] articleTuple = Volume.mapper.readValue(serializedArticle, Object[].class); // Article article = new Article(); // article.text = String.valueOf(articleTuple[0]); // if (articleTuple.length == 3) { // Map metadata = (Map)articleTuple[2]; // if (metadata.containsKey("r")) { // article.redirect = String.valueOf(metadata.get("r")); // } // else if (metadata.containsKey("redirect")) { // article.redirect = String.valueOf(metadata.get("redirect")); // } // } // return article; // } // // public String getRedirect() { // if (this.redirect != null && this.section != null) { // return this.redirect + "#" + this.section; // } // return this.redirect; // } // // public boolean isRedirect() { // return this.redirect != null; // } // // public boolean equalsIgnoreSection(Article other) { // return volumeId.equals(other.volumeId) && pointer == other.pointer; // } // // public boolean sectionEquals(Article other) { // return (section == null && other.section == null) || // (section !=null && other.section != null && section.equals(other.section)); // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + (int) (pointer ^ (pointer >>> 32)); // result = prime * result + ((section == null) ? 0 : section.hashCode()); // result = prime * result // + ((volumeId == null) ? 0 : volumeId.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Article other = (Article) obj; // if (pointer != other.pointer) // return false; // if (section == null) { // if (other.section != null) // return false; // } else if (!section.equals(other.section)) // return false; // if (volumeId == null) { // if (other.volumeId != null) // return false; // } else if (!volumeId.equals(other.volumeId)) // return false; // return true; // } // } // // Path: src/aarddict/Entry.java // public final class Entry implements Serializable { // // public String title; // public String section; // public long articlePointer; // public String volumeId; // // public Entry(String volumeId, String title) { // this(volumeId, title, -1); // } // // public Entry(String volumeId, String title, long articlePointer) { // this.volumeId = volumeId; // this.title = title == null ? "" : title; // this.articlePointer = articlePointer; // } // // @Override // public String toString() { // return title; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result // + (int) (articlePointer ^ (articlePointer >>> 32)); // result = prime * result + ((section == null) ? 0 : section.hashCode()); // result = prime * result + ((title == null) ? 0 : title.hashCode()); // result = prime * result // + ((volumeId == null) ? 0 : volumeId.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Entry other = (Entry) obj; // if (articlePointer != other.articlePointer) // return false; // if (section == null) { // if (other.section != null) // return false; // } else if (!section.equals(other.section)) // return false; // if (title == null) { // if (other.title != null) // return false; // } else if (!title.equals(other.title)) // return false; // if (volumeId == null) { // if (other.volumeId != null) // return false; // } else if (!volumeId.equals(other.volumeId)) // return false; // return true; // } // // } // Path: src/aarddict/android/HistoryItem.java import java.io.Serializable; import java.util.ArrayList; import java.util.List; import aarddict.Article; import aarddict.Entry; /* This file is part of Aard Dictionary for Android <http://aarddict.org>. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License <http://www.gnu.org/licenses/gpl-3.0.txt> * for more details. * * Copyright (C) 2010 Igor Tkach */ package aarddict.android; final class HistoryItem implements Serializable { List<Entry> entries; int entryIndex;
Article article;
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/glasses/GuiCaptureControl.java
// Path: src/main/java/openperipheral/addons/Config.java // public class Config { // @OnLineModifiable // @ConfigProperty(category = "sensor", name = "rangeInStorm") // public static int sensorRangeInStorm = 5; // // @OnLineModifiable // @ConfigProperty(category = "sensor", name = "normalRange") // public static int sensorRange = 5; // // @OnLineModifiable // @ConfigProperty(category = "misc", comment = "Should turtles with OPA updates be visible in creative") // public static boolean addTurtlesToCreative = true; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Should glasses listen to all chat (not just prefixed with $$)") // public static boolean listenToAllChat = true; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Minimal difference in mouse position (in pixels) needed before drag event is sent to server") // public static int minimalDragThreshold = 5; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Minimal time (in ticks) between two drag events") // public static int minimalDragPeriod = 10; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Default difference in mouse position (in pixels) needed before drag event is sent to server") // public static int defaultDragThreshold = 5; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Default time (in ticks) between two drag events") // public static int defaultDragPeriod = 10; // // } // // Path: src/main/java/openperipheral/addons/glasses/GlassesEvent.java // @NetworkEventMeta(direction = EventDirection.S2C) // public static class GlassesChangeBackgroundEvent extends GlassesEvent { // // @Serialize // public int backgroundColor; // // public GlassesChangeBackgroundEvent(long guid, int backgroundColor) { // super(guid); // this.backgroundColor = backgroundColor; // } // } // // Path: src/main/java/openperipheral/addons/glasses/GlassesEvent.java // @NetworkEventMeta(direction = EventDirection.S2C) // public static class GlassesSetDragParamsEvent extends GlassesEvent { // // @Serialize // public int period; // // @Serialize // public int threshold; // // public GlassesSetDragParamsEvent(long guid, int period, int threshold) { // super(guid); // this.period = period; // this.threshold = threshold; // } // // } // // Path: src/main/java/openperipheral/addons/glasses/GlassesEvent.java // @NetworkEventMeta(direction = EventDirection.S2C) // public static class GlassesSetGuiVisibilityEvent extends GlassesEvent { // // @Serialize // public Map<GuiElements, Boolean> visibility; // // public GlassesSetGuiVisibilityEvent(long guid, Map<GuiElements, Boolean> visibility) { // super(guid); // this.visibility = visibility; // } // } // // Path: src/main/java/openperipheral/addons/glasses/GlassesEvent.java // @NetworkEventMeta(direction = EventDirection.S2C) // public static class GlassesSetKeyRepeatEvent extends GlassesEvent { // // @Serialize // public boolean repeat; // // public GlassesSetKeyRepeatEvent(long guid, boolean repeat) { // super(guid); // this.repeat = repeat; // } // } // // Path: src/main/java/openperipheral/addons/glasses/GlassesEvent.java // @NetworkEventMeta(direction = EventDirection.S2C) // public static class GlassesStopCaptureEvent extends GlassesEvent { // // public GlassesStopCaptureEvent(long guid) { // super(guid); // } // } // // Path: src/main/java/openperipheral/addons/utils/GuiUtils.java // public static enum GuiElements { // OVERLAY, // PORTAL, // HOTBAR, // CROSSHAIRS, // BOSS_HEALTH, // HEALTH, // ARMOR, // FOOD, // MOUNT_HEALTH, // AIR, // EXPERIENCE, // JUMP_BAR, // OBJECTIVES; // }
import com.google.common.base.Preconditions; import java.lang.ref.WeakReference; import java.util.Map; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import openperipheral.addons.Config; import openperipheral.addons.glasses.GlassesEvent.GlassesChangeBackgroundEvent; import openperipheral.addons.glasses.GlassesEvent.GlassesSetDragParamsEvent; import openperipheral.addons.glasses.GlassesEvent.GlassesSetGuiVisibilityEvent; import openperipheral.addons.glasses.GlassesEvent.GlassesSetKeyRepeatEvent; import openperipheral.addons.glasses.GlassesEvent.GlassesStopCaptureEvent; import openperipheral.addons.utils.GuiUtils.GuiElements; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.Asynchronous; import openperipheral.api.adapter.method.Arg; import openperipheral.api.adapter.method.Optionals; import openperipheral.api.adapter.method.ScriptCallable; import openperipheral.api.adapter.method.ScriptObject;
package openperipheral.addons.glasses; @ScriptObject @Asynchronous @AdapterSourceName("glasses_capture") public class GuiCaptureControl { private final long guid; private final WeakReference<EntityPlayerMP> player; public GuiCaptureControl(long guid, WeakReference<EntityPlayerMP> player) { this.guid = guid; this.player = player; } protected EntityPlayer getPlayer() { EntityPlayer player = this.player.get(); if (player == null) throw new IllegalStateException("Object is no longer valid"); return player; } @ScriptCallable(description = "Stops capture for player") public void stopCapturing() { EntityPlayer player = getPlayer();
// Path: src/main/java/openperipheral/addons/Config.java // public class Config { // @OnLineModifiable // @ConfigProperty(category = "sensor", name = "rangeInStorm") // public static int sensorRangeInStorm = 5; // // @OnLineModifiable // @ConfigProperty(category = "sensor", name = "normalRange") // public static int sensorRange = 5; // // @OnLineModifiable // @ConfigProperty(category = "misc", comment = "Should turtles with OPA updates be visible in creative") // public static boolean addTurtlesToCreative = true; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Should glasses listen to all chat (not just prefixed with $$)") // public static boolean listenToAllChat = true; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Minimal difference in mouse position (in pixels) needed before drag event is sent to server") // public static int minimalDragThreshold = 5; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Minimal time (in ticks) between two drag events") // public static int minimalDragPeriod = 10; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Default difference in mouse position (in pixels) needed before drag event is sent to server") // public static int defaultDragThreshold = 5; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Default time (in ticks) between two drag events") // public static int defaultDragPeriod = 10; // // } // // Path: src/main/java/openperipheral/addons/glasses/GlassesEvent.java // @NetworkEventMeta(direction = EventDirection.S2C) // public static class GlassesChangeBackgroundEvent extends GlassesEvent { // // @Serialize // public int backgroundColor; // // public GlassesChangeBackgroundEvent(long guid, int backgroundColor) { // super(guid); // this.backgroundColor = backgroundColor; // } // } // // Path: src/main/java/openperipheral/addons/glasses/GlassesEvent.java // @NetworkEventMeta(direction = EventDirection.S2C) // public static class GlassesSetDragParamsEvent extends GlassesEvent { // // @Serialize // public int period; // // @Serialize // public int threshold; // // public GlassesSetDragParamsEvent(long guid, int period, int threshold) { // super(guid); // this.period = period; // this.threshold = threshold; // } // // } // // Path: src/main/java/openperipheral/addons/glasses/GlassesEvent.java // @NetworkEventMeta(direction = EventDirection.S2C) // public static class GlassesSetGuiVisibilityEvent extends GlassesEvent { // // @Serialize // public Map<GuiElements, Boolean> visibility; // // public GlassesSetGuiVisibilityEvent(long guid, Map<GuiElements, Boolean> visibility) { // super(guid); // this.visibility = visibility; // } // } // // Path: src/main/java/openperipheral/addons/glasses/GlassesEvent.java // @NetworkEventMeta(direction = EventDirection.S2C) // public static class GlassesSetKeyRepeatEvent extends GlassesEvent { // // @Serialize // public boolean repeat; // // public GlassesSetKeyRepeatEvent(long guid, boolean repeat) { // super(guid); // this.repeat = repeat; // } // } // // Path: src/main/java/openperipheral/addons/glasses/GlassesEvent.java // @NetworkEventMeta(direction = EventDirection.S2C) // public static class GlassesStopCaptureEvent extends GlassesEvent { // // public GlassesStopCaptureEvent(long guid) { // super(guid); // } // } // // Path: src/main/java/openperipheral/addons/utils/GuiUtils.java // public static enum GuiElements { // OVERLAY, // PORTAL, // HOTBAR, // CROSSHAIRS, // BOSS_HEALTH, // HEALTH, // ARMOR, // FOOD, // MOUNT_HEALTH, // AIR, // EXPERIENCE, // JUMP_BAR, // OBJECTIVES; // } // Path: src/main/java/openperipheral/addons/glasses/GuiCaptureControl.java import com.google.common.base.Preconditions; import java.lang.ref.WeakReference; import java.util.Map; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import openperipheral.addons.Config; import openperipheral.addons.glasses.GlassesEvent.GlassesChangeBackgroundEvent; import openperipheral.addons.glasses.GlassesEvent.GlassesSetDragParamsEvent; import openperipheral.addons.glasses.GlassesEvent.GlassesSetGuiVisibilityEvent; import openperipheral.addons.glasses.GlassesEvent.GlassesSetKeyRepeatEvent; import openperipheral.addons.glasses.GlassesEvent.GlassesStopCaptureEvent; import openperipheral.addons.utils.GuiUtils.GuiElements; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.Asynchronous; import openperipheral.api.adapter.method.Arg; import openperipheral.api.adapter.method.Optionals; import openperipheral.api.adapter.method.ScriptCallable; import openperipheral.api.adapter.method.ScriptObject; package openperipheral.addons.glasses; @ScriptObject @Asynchronous @AdapterSourceName("glasses_capture") public class GuiCaptureControl { private final long guid; private final WeakReference<EntityPlayerMP> player; public GuiCaptureControl(long guid, WeakReference<EntityPlayerMP> player) { this.guid = guid; this.player = player; } protected EntityPlayer getPlayer() { EntityPlayer player = this.player.get(); if (player == null) throw new IllegalStateException("Object is no longer valid"); return player; } @ScriptCallable(description = "Stops capture for player") public void stopCapturing() { EntityPlayer player = getPlayer();
new GlassesStopCaptureEvent(guid).sendToPlayer(player);
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/glasses/GuiCaptureControl.java
// Path: src/main/java/openperipheral/addons/Config.java // public class Config { // @OnLineModifiable // @ConfigProperty(category = "sensor", name = "rangeInStorm") // public static int sensorRangeInStorm = 5; // // @OnLineModifiable // @ConfigProperty(category = "sensor", name = "normalRange") // public static int sensorRange = 5; // // @OnLineModifiable // @ConfigProperty(category = "misc", comment = "Should turtles with OPA updates be visible in creative") // public static boolean addTurtlesToCreative = true; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Should glasses listen to all chat (not just prefixed with $$)") // public static boolean listenToAllChat = true; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Minimal difference in mouse position (in pixels) needed before drag event is sent to server") // public static int minimalDragThreshold = 5; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Minimal time (in ticks) between two drag events") // public static int minimalDragPeriod = 10; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Default difference in mouse position (in pixels) needed before drag event is sent to server") // public static int defaultDragThreshold = 5; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Default time (in ticks) between two drag events") // public static int defaultDragPeriod = 10; // // } // // Path: src/main/java/openperipheral/addons/glasses/GlassesEvent.java // @NetworkEventMeta(direction = EventDirection.S2C) // public static class GlassesChangeBackgroundEvent extends GlassesEvent { // // @Serialize // public int backgroundColor; // // public GlassesChangeBackgroundEvent(long guid, int backgroundColor) { // super(guid); // this.backgroundColor = backgroundColor; // } // } // // Path: src/main/java/openperipheral/addons/glasses/GlassesEvent.java // @NetworkEventMeta(direction = EventDirection.S2C) // public static class GlassesSetDragParamsEvent extends GlassesEvent { // // @Serialize // public int period; // // @Serialize // public int threshold; // // public GlassesSetDragParamsEvent(long guid, int period, int threshold) { // super(guid); // this.period = period; // this.threshold = threshold; // } // // } // // Path: src/main/java/openperipheral/addons/glasses/GlassesEvent.java // @NetworkEventMeta(direction = EventDirection.S2C) // public static class GlassesSetGuiVisibilityEvent extends GlassesEvent { // // @Serialize // public Map<GuiElements, Boolean> visibility; // // public GlassesSetGuiVisibilityEvent(long guid, Map<GuiElements, Boolean> visibility) { // super(guid); // this.visibility = visibility; // } // } // // Path: src/main/java/openperipheral/addons/glasses/GlassesEvent.java // @NetworkEventMeta(direction = EventDirection.S2C) // public static class GlassesSetKeyRepeatEvent extends GlassesEvent { // // @Serialize // public boolean repeat; // // public GlassesSetKeyRepeatEvent(long guid, boolean repeat) { // super(guid); // this.repeat = repeat; // } // } // // Path: src/main/java/openperipheral/addons/glasses/GlassesEvent.java // @NetworkEventMeta(direction = EventDirection.S2C) // public static class GlassesStopCaptureEvent extends GlassesEvent { // // public GlassesStopCaptureEvent(long guid) { // super(guid); // } // } // // Path: src/main/java/openperipheral/addons/utils/GuiUtils.java // public static enum GuiElements { // OVERLAY, // PORTAL, // HOTBAR, // CROSSHAIRS, // BOSS_HEALTH, // HEALTH, // ARMOR, // FOOD, // MOUNT_HEALTH, // AIR, // EXPERIENCE, // JUMP_BAR, // OBJECTIVES; // }
import com.google.common.base.Preconditions; import java.lang.ref.WeakReference; import java.util.Map; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import openperipheral.addons.Config; import openperipheral.addons.glasses.GlassesEvent.GlassesChangeBackgroundEvent; import openperipheral.addons.glasses.GlassesEvent.GlassesSetDragParamsEvent; import openperipheral.addons.glasses.GlassesEvent.GlassesSetGuiVisibilityEvent; import openperipheral.addons.glasses.GlassesEvent.GlassesSetKeyRepeatEvent; import openperipheral.addons.glasses.GlassesEvent.GlassesStopCaptureEvent; import openperipheral.addons.utils.GuiUtils.GuiElements; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.Asynchronous; import openperipheral.api.adapter.method.Arg; import openperipheral.api.adapter.method.Optionals; import openperipheral.api.adapter.method.ScriptCallable; import openperipheral.api.adapter.method.ScriptObject;
package openperipheral.addons.glasses; @ScriptObject @Asynchronous @AdapterSourceName("glasses_capture") public class GuiCaptureControl { private final long guid; private final WeakReference<EntityPlayerMP> player; public GuiCaptureControl(long guid, WeakReference<EntityPlayerMP> player) { this.guid = guid; this.player = player; } protected EntityPlayer getPlayer() { EntityPlayer player = this.player.get(); if (player == null) throw new IllegalStateException("Object is no longer valid"); return player; } @ScriptCallable(description = "Stops capture for player") public void stopCapturing() { EntityPlayer player = getPlayer(); new GlassesStopCaptureEvent(guid).sendToPlayer(player); } @ScriptCallable(description = "Set background on capture mode screen") public void setBackground(@Arg(name = "background") int background, @Optionals @Arg(name = "alpha") Integer alpha) { EntityPlayer player = getPlayer(); final int a = alpha != null? (alpha << 24) : 0x2A000000;
// Path: src/main/java/openperipheral/addons/Config.java // public class Config { // @OnLineModifiable // @ConfigProperty(category = "sensor", name = "rangeInStorm") // public static int sensorRangeInStorm = 5; // // @OnLineModifiable // @ConfigProperty(category = "sensor", name = "normalRange") // public static int sensorRange = 5; // // @OnLineModifiable // @ConfigProperty(category = "misc", comment = "Should turtles with OPA updates be visible in creative") // public static boolean addTurtlesToCreative = true; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Should glasses listen to all chat (not just prefixed with $$)") // public static boolean listenToAllChat = true; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Minimal difference in mouse position (in pixels) needed before drag event is sent to server") // public static int minimalDragThreshold = 5; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Minimal time (in ticks) between two drag events") // public static int minimalDragPeriod = 10; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Default difference in mouse position (in pixels) needed before drag event is sent to server") // public static int defaultDragThreshold = 5; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Default time (in ticks) between two drag events") // public static int defaultDragPeriod = 10; // // } // // Path: src/main/java/openperipheral/addons/glasses/GlassesEvent.java // @NetworkEventMeta(direction = EventDirection.S2C) // public static class GlassesChangeBackgroundEvent extends GlassesEvent { // // @Serialize // public int backgroundColor; // // public GlassesChangeBackgroundEvent(long guid, int backgroundColor) { // super(guid); // this.backgroundColor = backgroundColor; // } // } // // Path: src/main/java/openperipheral/addons/glasses/GlassesEvent.java // @NetworkEventMeta(direction = EventDirection.S2C) // public static class GlassesSetDragParamsEvent extends GlassesEvent { // // @Serialize // public int period; // // @Serialize // public int threshold; // // public GlassesSetDragParamsEvent(long guid, int period, int threshold) { // super(guid); // this.period = period; // this.threshold = threshold; // } // // } // // Path: src/main/java/openperipheral/addons/glasses/GlassesEvent.java // @NetworkEventMeta(direction = EventDirection.S2C) // public static class GlassesSetGuiVisibilityEvent extends GlassesEvent { // // @Serialize // public Map<GuiElements, Boolean> visibility; // // public GlassesSetGuiVisibilityEvent(long guid, Map<GuiElements, Boolean> visibility) { // super(guid); // this.visibility = visibility; // } // } // // Path: src/main/java/openperipheral/addons/glasses/GlassesEvent.java // @NetworkEventMeta(direction = EventDirection.S2C) // public static class GlassesSetKeyRepeatEvent extends GlassesEvent { // // @Serialize // public boolean repeat; // // public GlassesSetKeyRepeatEvent(long guid, boolean repeat) { // super(guid); // this.repeat = repeat; // } // } // // Path: src/main/java/openperipheral/addons/glasses/GlassesEvent.java // @NetworkEventMeta(direction = EventDirection.S2C) // public static class GlassesStopCaptureEvent extends GlassesEvent { // // public GlassesStopCaptureEvent(long guid) { // super(guid); // } // } // // Path: src/main/java/openperipheral/addons/utils/GuiUtils.java // public static enum GuiElements { // OVERLAY, // PORTAL, // HOTBAR, // CROSSHAIRS, // BOSS_HEALTH, // HEALTH, // ARMOR, // FOOD, // MOUNT_HEALTH, // AIR, // EXPERIENCE, // JUMP_BAR, // OBJECTIVES; // } // Path: src/main/java/openperipheral/addons/glasses/GuiCaptureControl.java import com.google.common.base.Preconditions; import java.lang.ref.WeakReference; import java.util.Map; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import openperipheral.addons.Config; import openperipheral.addons.glasses.GlassesEvent.GlassesChangeBackgroundEvent; import openperipheral.addons.glasses.GlassesEvent.GlassesSetDragParamsEvent; import openperipheral.addons.glasses.GlassesEvent.GlassesSetGuiVisibilityEvent; import openperipheral.addons.glasses.GlassesEvent.GlassesSetKeyRepeatEvent; import openperipheral.addons.glasses.GlassesEvent.GlassesStopCaptureEvent; import openperipheral.addons.utils.GuiUtils.GuiElements; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.Asynchronous; import openperipheral.api.adapter.method.Arg; import openperipheral.api.adapter.method.Optionals; import openperipheral.api.adapter.method.ScriptCallable; import openperipheral.api.adapter.method.ScriptObject; package openperipheral.addons.glasses; @ScriptObject @Asynchronous @AdapterSourceName("glasses_capture") public class GuiCaptureControl { private final long guid; private final WeakReference<EntityPlayerMP> player; public GuiCaptureControl(long guid, WeakReference<EntityPlayerMP> player) { this.guid = guid; this.player = player; } protected EntityPlayer getPlayer() { EntityPlayer player = this.player.get(); if (player == null) throw new IllegalStateException("Object is no longer valid"); return player; } @ScriptCallable(description = "Stops capture for player") public void stopCapturing() { EntityPlayer player = getPlayer(); new GlassesStopCaptureEvent(guid).sendToPlayer(player); } @ScriptCallable(description = "Set background on capture mode screen") public void setBackground(@Arg(name = "background") int background, @Optionals @Arg(name = "alpha") Integer alpha) { EntityPlayer player = getPlayer(); final int a = alpha != null? (alpha << 24) : 0x2A000000;
new GlassesChangeBackgroundEvent(guid, background & 0x00FFFFFF | a).sendToPlayer(player);
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/Recipes.java
// Path: src/main/java/openperipheral/addons/glasses/TerminalAddonRecipe.java // public class TerminalAddonRecipe implements IRecipe { // // private static boolean isSuitableItem(ItemStack itemStack) { // return EntityLiving.getArmorPosition(itemStack) == 4 && // itemStack.stackSize == 1 && // !NbtGuidProviders.hasTerminalCapabilities(itemStack); // } // // @Override // public boolean matches(InventoryCrafting inv, World world) { // boolean glassesFound = false; // boolean targetFound = false; // // for (ItemStack itemStack : InventoryUtils.asIterable(inv)) { // if (itemStack != null) { // if (itemStack.getItem() instanceof ItemGlasses) { // if (glassesFound) return false; // glassesFound = true; // } else if (isSuitableItem(itemStack)) { // if (targetFound) return false; // targetFound = true; // } else return false; // } // } // // return glassesFound && targetFound; // } // // @Override // public ItemStack getCraftingResult(InventoryCrafting inv) { // ItemStack targetStack = null; // ItemStack glassesStack = null; // // for (ItemStack itemStack : InventoryUtils.asIterable(inv)) { // if (itemStack != null) { // if (itemStack.getItem() instanceof ItemGlasses) { // if (glassesStack != null) return null; // glassesStack = itemStack; // } else if (isSuitableItem(itemStack)) { // if (targetStack != null) return null; // targetStack = itemStack; // } else return null; // } // } // // if (glassesStack == null || targetStack == null) return null; // // final ItemGlasses glassesItem = (ItemGlasses)glassesStack.getItem(); // Optional<Long> guid = Optional.fromNullable(glassesItem.getTerminalGuid(glassesStack)); // // final ItemStack result = targetStack.copy(); // NbtGuidProviders.setTerminalGuid(result, guid); // // return result; // } // // @Override // public int getRecipeSize() { // return 2; // } // // @Override // public ItemStack getRecipeOutput() { // return null; // } // // }
import cpw.mods.fml.common.Loader; import java.util.List; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; import net.minecraftforge.oredict.RecipeSorter; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; import openmods.Mods; import openperipheral.addons.glasses.TerminalAddonRecipe;
package openperipheral.addons; public class Recipes { public static void register() { final ItemStack duckAntenna = MetasGeneric.duckAntenna.newItemStack(); @SuppressWarnings("unchecked") final List<IRecipe> recipeList = CraftingManager.getInstance().getRecipeList(); if (OpenPeripheralAddons.Blocks.pim != null) { recipeList.add(new ShapedOreRecipe(OpenPeripheralAddons.Blocks.pim, "ooo", "rcr", 'o', Blocks.obsidian, 'r', Items.redstone, 'c', Blocks.chest)); } if (OpenPeripheralAddons.Blocks.sensor != null) { recipeList.add(new ShapedOreRecipe(OpenPeripheralAddons.Blocks.sensor, "ooo", " w ", "sss", 'o', Blocks.obsidian, 'w', "stickWood", 's', Blocks.stone_slab)); } if (OpenPeripheralAddons.Blocks.glassesBridge != null) { recipeList.add(new ShapedOreRecipe(OpenPeripheralAddons.Blocks.glassesBridge, "sas", "ses", "srs", 's', Blocks.stone, 'r', Blocks.redstone_block, 'e', Items.ender_pearl, 'a', duckAntenna.copy())); } if (OpenPeripheralAddons.Blocks.selector != null) { recipeList.add(new ShapedOreRecipe(OpenPeripheralAddons.Blocks.selector, "sss", "scs", "sgs", 's', Blocks.stone, 'c', Blocks.trapped_chest, 'g', Blocks.glass_pane)); } if (OpenPeripheralAddons.Items.glasses != null) { recipeList.add(new ShapedOreRecipe(OpenPeripheralAddons.Items.glasses, "igi", "aei", "prp", 'g', Blocks.glowstone, 'i', Items.iron_ingot, 'e', Items.ender_pearl, 'p', Blocks.glass_pane, 'r', Items.redstone, 'a', duckAntenna.copy())); recipeList.add(new ShapedOreRecipe(OpenPeripheralAddons.Items.glasses, "igi", "iea", "prp", 'g', Blocks.glowstone, 'i', Items.iron_ingot, 'e', Items.ender_pearl, 'p', Blocks.glass_pane, 'r', Items.redstone, 'a', duckAntenna.copy()));
// Path: src/main/java/openperipheral/addons/glasses/TerminalAddonRecipe.java // public class TerminalAddonRecipe implements IRecipe { // // private static boolean isSuitableItem(ItemStack itemStack) { // return EntityLiving.getArmorPosition(itemStack) == 4 && // itemStack.stackSize == 1 && // !NbtGuidProviders.hasTerminalCapabilities(itemStack); // } // // @Override // public boolean matches(InventoryCrafting inv, World world) { // boolean glassesFound = false; // boolean targetFound = false; // // for (ItemStack itemStack : InventoryUtils.asIterable(inv)) { // if (itemStack != null) { // if (itemStack.getItem() instanceof ItemGlasses) { // if (glassesFound) return false; // glassesFound = true; // } else if (isSuitableItem(itemStack)) { // if (targetFound) return false; // targetFound = true; // } else return false; // } // } // // return glassesFound && targetFound; // } // // @Override // public ItemStack getCraftingResult(InventoryCrafting inv) { // ItemStack targetStack = null; // ItemStack glassesStack = null; // // for (ItemStack itemStack : InventoryUtils.asIterable(inv)) { // if (itemStack != null) { // if (itemStack.getItem() instanceof ItemGlasses) { // if (glassesStack != null) return null; // glassesStack = itemStack; // } else if (isSuitableItem(itemStack)) { // if (targetStack != null) return null; // targetStack = itemStack; // } else return null; // } // } // // if (glassesStack == null || targetStack == null) return null; // // final ItemGlasses glassesItem = (ItemGlasses)glassesStack.getItem(); // Optional<Long> guid = Optional.fromNullable(glassesItem.getTerminalGuid(glassesStack)); // // final ItemStack result = targetStack.copy(); // NbtGuidProviders.setTerminalGuid(result, guid); // // return result; // } // // @Override // public int getRecipeSize() { // return 2; // } // // @Override // public ItemStack getRecipeOutput() { // return null; // } // // } // Path: src/main/java/openperipheral/addons/Recipes.java import cpw.mods.fml.common.Loader; import java.util.List; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; import net.minecraftforge.oredict.RecipeSorter; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; import openmods.Mods; import openperipheral.addons.glasses.TerminalAddonRecipe; package openperipheral.addons; public class Recipes { public static void register() { final ItemStack duckAntenna = MetasGeneric.duckAntenna.newItemStack(); @SuppressWarnings("unchecked") final List<IRecipe> recipeList = CraftingManager.getInstance().getRecipeList(); if (OpenPeripheralAddons.Blocks.pim != null) { recipeList.add(new ShapedOreRecipe(OpenPeripheralAddons.Blocks.pim, "ooo", "rcr", 'o', Blocks.obsidian, 'r', Items.redstone, 'c', Blocks.chest)); } if (OpenPeripheralAddons.Blocks.sensor != null) { recipeList.add(new ShapedOreRecipe(OpenPeripheralAddons.Blocks.sensor, "ooo", " w ", "sss", 'o', Blocks.obsidian, 'w', "stickWood", 's', Blocks.stone_slab)); } if (OpenPeripheralAddons.Blocks.glassesBridge != null) { recipeList.add(new ShapedOreRecipe(OpenPeripheralAddons.Blocks.glassesBridge, "sas", "ses", "srs", 's', Blocks.stone, 'r', Blocks.redstone_block, 'e', Items.ender_pearl, 'a', duckAntenna.copy())); } if (OpenPeripheralAddons.Blocks.selector != null) { recipeList.add(new ShapedOreRecipe(OpenPeripheralAddons.Blocks.selector, "sss", "scs", "sgs", 's', Blocks.stone, 'c', Blocks.trapped_chest, 'g', Blocks.glass_pane)); } if (OpenPeripheralAddons.Items.glasses != null) { recipeList.add(new ShapedOreRecipe(OpenPeripheralAddons.Items.glasses, "igi", "aei", "prp", 'g', Blocks.glowstone, 'i', Items.iron_ingot, 'e', Items.ender_pearl, 'p', Blocks.glass_pane, 'r', Items.redstone, 'a', duckAntenna.copy())); recipeList.add(new ShapedOreRecipe(OpenPeripheralAddons.Items.glasses, "igi", "iea", "prp", 'g', Blocks.glowstone, 'i', Items.iron_ingot, 'e', Items.ender_pearl, 'p', Blocks.glass_pane, 'r', Items.redstone, 'a', duckAntenna.copy()));
recipeList.add(new TerminalAddonRecipe());
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/glasses/TerminalIdAccess.java
// Path: src/main/java/openperipheral/addons/api/ITerminalIdAccess.java // public interface ITerminalIdAccess extends IApiInterface { // public Optional<Long> getIdFrom(EntityPlayer player); // // public boolean setIdFor(EntityPlayer player, long guid); // // public void register(ITerminalIdGetter getter); // // public void register(ITerminalIdSetter setter); // } // // Path: src/main/java/openperipheral/addons/api/ITerminalIdGetter.java // public interface ITerminalIdGetter { // public Optional<Long> getFor(EntityPlayer player); // // public int getPriority(); // } // // Path: src/main/java/openperipheral/addons/api/ITerminalIdSetter.java // public interface ITerminalIdSetter { // public boolean setFor(EntityPlayer player, long terminalId); // // public int getPriority(); // } // // Path: src/main/java/openperipheral/addons/api/ITerminalItem.java // public interface ITerminalItem { // public Long getTerminalGuid(ItemStack stack); // // public void bindToTerminal(ItemStack stack, long guid); // }
import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.primitives.Ints; import java.util.Arrays; import java.util.Comparator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import openmods.access.ApiSingleton; import openperipheral.addons.api.ITerminalIdAccess; import openperipheral.addons.api.ITerminalIdGetter; import openperipheral.addons.api.ITerminalIdSetter; import openperipheral.addons.api.ITerminalItem; import org.apache.commons.lang3.ArrayUtils;
package openperipheral.addons.glasses; @ApiSingleton public class TerminalIdAccess implements ITerminalIdAccess {
// Path: src/main/java/openperipheral/addons/api/ITerminalIdAccess.java // public interface ITerminalIdAccess extends IApiInterface { // public Optional<Long> getIdFrom(EntityPlayer player); // // public boolean setIdFor(EntityPlayer player, long guid); // // public void register(ITerminalIdGetter getter); // // public void register(ITerminalIdSetter setter); // } // // Path: src/main/java/openperipheral/addons/api/ITerminalIdGetter.java // public interface ITerminalIdGetter { // public Optional<Long> getFor(EntityPlayer player); // // public int getPriority(); // } // // Path: src/main/java/openperipheral/addons/api/ITerminalIdSetter.java // public interface ITerminalIdSetter { // public boolean setFor(EntityPlayer player, long terminalId); // // public int getPriority(); // } // // Path: src/main/java/openperipheral/addons/api/ITerminalItem.java // public interface ITerminalItem { // public Long getTerminalGuid(ItemStack stack); // // public void bindToTerminal(ItemStack stack, long guid); // } // Path: src/main/java/openperipheral/addons/glasses/TerminalIdAccess.java import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.primitives.Ints; import java.util.Arrays; import java.util.Comparator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import openmods.access.ApiSingleton; import openperipheral.addons.api.ITerminalIdAccess; import openperipheral.addons.api.ITerminalIdGetter; import openperipheral.addons.api.ITerminalIdSetter; import openperipheral.addons.api.ITerminalItem; import org.apache.commons.lang3.ArrayUtils; package openperipheral.addons.glasses; @ApiSingleton public class TerminalIdAccess implements ITerminalIdAccess {
abstract static class HelmetGetterAdapter implements ITerminalIdGetter {
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/glasses/TerminalIdAccess.java
// Path: src/main/java/openperipheral/addons/api/ITerminalIdAccess.java // public interface ITerminalIdAccess extends IApiInterface { // public Optional<Long> getIdFrom(EntityPlayer player); // // public boolean setIdFor(EntityPlayer player, long guid); // // public void register(ITerminalIdGetter getter); // // public void register(ITerminalIdSetter setter); // } // // Path: src/main/java/openperipheral/addons/api/ITerminalIdGetter.java // public interface ITerminalIdGetter { // public Optional<Long> getFor(EntityPlayer player); // // public int getPriority(); // } // // Path: src/main/java/openperipheral/addons/api/ITerminalIdSetter.java // public interface ITerminalIdSetter { // public boolean setFor(EntityPlayer player, long terminalId); // // public int getPriority(); // } // // Path: src/main/java/openperipheral/addons/api/ITerminalItem.java // public interface ITerminalItem { // public Long getTerminalGuid(ItemStack stack); // // public void bindToTerminal(ItemStack stack, long guid); // }
import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.primitives.Ints; import java.util.Arrays; import java.util.Comparator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import openmods.access.ApiSingleton; import openperipheral.addons.api.ITerminalIdAccess; import openperipheral.addons.api.ITerminalIdGetter; import openperipheral.addons.api.ITerminalIdSetter; import openperipheral.addons.api.ITerminalItem; import org.apache.commons.lang3.ArrayUtils;
package openperipheral.addons.glasses; @ApiSingleton public class TerminalIdAccess implements ITerminalIdAccess { abstract static class HelmetGetterAdapter implements ITerminalIdGetter { @Override public Optional<Long> getFor(EntityPlayer player) { final ItemStack stack = TerminalUtils.getHeadSlot(player); return stack != null? getFor(stack) : Optional.<Long> absent(); } protected abstract Optional<Long> getFor(ItemStack helmet); @Override public int getPriority() { return 0; } }
// Path: src/main/java/openperipheral/addons/api/ITerminalIdAccess.java // public interface ITerminalIdAccess extends IApiInterface { // public Optional<Long> getIdFrom(EntityPlayer player); // // public boolean setIdFor(EntityPlayer player, long guid); // // public void register(ITerminalIdGetter getter); // // public void register(ITerminalIdSetter setter); // } // // Path: src/main/java/openperipheral/addons/api/ITerminalIdGetter.java // public interface ITerminalIdGetter { // public Optional<Long> getFor(EntityPlayer player); // // public int getPriority(); // } // // Path: src/main/java/openperipheral/addons/api/ITerminalIdSetter.java // public interface ITerminalIdSetter { // public boolean setFor(EntityPlayer player, long terminalId); // // public int getPriority(); // } // // Path: src/main/java/openperipheral/addons/api/ITerminalItem.java // public interface ITerminalItem { // public Long getTerminalGuid(ItemStack stack); // // public void bindToTerminal(ItemStack stack, long guid); // } // Path: src/main/java/openperipheral/addons/glasses/TerminalIdAccess.java import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.primitives.Ints; import java.util.Arrays; import java.util.Comparator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import openmods.access.ApiSingleton; import openperipheral.addons.api.ITerminalIdAccess; import openperipheral.addons.api.ITerminalIdGetter; import openperipheral.addons.api.ITerminalIdSetter; import openperipheral.addons.api.ITerminalItem; import org.apache.commons.lang3.ArrayUtils; package openperipheral.addons.glasses; @ApiSingleton public class TerminalIdAccess implements ITerminalIdAccess { abstract static class HelmetGetterAdapter implements ITerminalIdGetter { @Override public Optional<Long> getFor(EntityPlayer player) { final ItemStack stack = TerminalUtils.getHeadSlot(player); return stack != null? getFor(stack) : Optional.<Long> absent(); } protected abstract Optional<Long> getFor(ItemStack helmet); @Override public int getPriority() { return 0; } }
abstract static class HandSetterAdapter implements ITerminalIdSetter {
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/glasses/TerminalIdAccess.java
// Path: src/main/java/openperipheral/addons/api/ITerminalIdAccess.java // public interface ITerminalIdAccess extends IApiInterface { // public Optional<Long> getIdFrom(EntityPlayer player); // // public boolean setIdFor(EntityPlayer player, long guid); // // public void register(ITerminalIdGetter getter); // // public void register(ITerminalIdSetter setter); // } // // Path: src/main/java/openperipheral/addons/api/ITerminalIdGetter.java // public interface ITerminalIdGetter { // public Optional<Long> getFor(EntityPlayer player); // // public int getPriority(); // } // // Path: src/main/java/openperipheral/addons/api/ITerminalIdSetter.java // public interface ITerminalIdSetter { // public boolean setFor(EntityPlayer player, long terminalId); // // public int getPriority(); // } // // Path: src/main/java/openperipheral/addons/api/ITerminalItem.java // public interface ITerminalItem { // public Long getTerminalGuid(ItemStack stack); // // public void bindToTerminal(ItemStack stack, long guid); // }
import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.primitives.Ints; import java.util.Arrays; import java.util.Comparator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import openmods.access.ApiSingleton; import openperipheral.addons.api.ITerminalIdAccess; import openperipheral.addons.api.ITerminalIdGetter; import openperipheral.addons.api.ITerminalIdSetter; import openperipheral.addons.api.ITerminalItem; import org.apache.commons.lang3.ArrayUtils;
return stack != null? getFor(stack) : Optional.<Long> absent(); } protected abstract Optional<Long> getFor(ItemStack helmet); @Override public int getPriority() { return 0; } } abstract static class HandSetterAdapter implements ITerminalIdSetter { @Override public boolean setFor(EntityPlayer player, long guid) { final ItemStack stack = player.getHeldItem(); return stack != null? setFor(stack, guid) : false; } protected abstract boolean setFor(ItemStack helmet, long guid); @Override public int getPriority() { return 0; } } public static class InterfaceGetter extends HelmetGetterAdapter { @Override public Optional<Long> getFor(ItemStack stack) { final Item item = stack.getItem();
// Path: src/main/java/openperipheral/addons/api/ITerminalIdAccess.java // public interface ITerminalIdAccess extends IApiInterface { // public Optional<Long> getIdFrom(EntityPlayer player); // // public boolean setIdFor(EntityPlayer player, long guid); // // public void register(ITerminalIdGetter getter); // // public void register(ITerminalIdSetter setter); // } // // Path: src/main/java/openperipheral/addons/api/ITerminalIdGetter.java // public interface ITerminalIdGetter { // public Optional<Long> getFor(EntityPlayer player); // // public int getPriority(); // } // // Path: src/main/java/openperipheral/addons/api/ITerminalIdSetter.java // public interface ITerminalIdSetter { // public boolean setFor(EntityPlayer player, long terminalId); // // public int getPriority(); // } // // Path: src/main/java/openperipheral/addons/api/ITerminalItem.java // public interface ITerminalItem { // public Long getTerminalGuid(ItemStack stack); // // public void bindToTerminal(ItemStack stack, long guid); // } // Path: src/main/java/openperipheral/addons/glasses/TerminalIdAccess.java import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.primitives.Ints; import java.util.Arrays; import java.util.Comparator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import openmods.access.ApiSingleton; import openperipheral.addons.api.ITerminalIdAccess; import openperipheral.addons.api.ITerminalIdGetter; import openperipheral.addons.api.ITerminalIdSetter; import openperipheral.addons.api.ITerminalItem; import org.apache.commons.lang3.ArrayUtils; return stack != null? getFor(stack) : Optional.<Long> absent(); } protected abstract Optional<Long> getFor(ItemStack helmet); @Override public int getPriority() { return 0; } } abstract static class HandSetterAdapter implements ITerminalIdSetter { @Override public boolean setFor(EntityPlayer player, long guid) { final ItemStack stack = player.getHeldItem(); return stack != null? setFor(stack, guid) : false; } protected abstract boolean setFor(ItemStack helmet, long guid); @Override public int getPriority() { return 0; } } public static class InterfaceGetter extends HelmetGetterAdapter { @Override public Optional<Long> getFor(ItemStack stack) { final Item item = stack.getItem();
if (item instanceof ITerminalItem) {
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/narcissistic/TurtleInventoryDelegate.java
// Path: src/main/java/openperipheral/addons/utils/CCUtils.java // public final class CCUtils { // private static final int NUMBER_OF_TURTLE_TOOLS = 7; // // public static Object[] wrap(Object... args) { // return args; // } // // public static ItemStack getExpandedTurtleItemStack() { // return GameRegistry.findItemStack(Mods.COMPUTERCRAFT, "CC-TurtleExpanded", 1); // } // // public static ItemStack getAdvancedTurtleItemStack() { // return GameRegistry.findItemStack(Mods.COMPUTERCRAFT, "CC-TurtleAdvanced", 1); // } // // public static void createTurtleItemStack(List<ItemStack> result, boolean isAdvanced, Short left, Short right) { // ItemStack turtle = isAdvanced? getAdvancedTurtleItemStack() : getExpandedTurtleItemStack(); // // if (turtle == null) return; // // NBTTagCompound tag = turtle.getTagCompound(); // if (tag == null) { // tag = new NBTTagCompound(); // turtle.setTagCompound(tag); // } // // if (left != null) tag.setShort("leftUpgrade", left); // // if (right != null) tag.setShort("rightUpgrade", right); // // result.add(turtle); // } // // private static void addUpgradedTurtles(List<ItemStack> result, ITurtleUpgrade upgrade, boolean isAdvanced) { // short upgradeId = (short)upgrade.getUpgradeID(); // createTurtleItemStack(result, isAdvanced, upgradeId, null); // for (int i = 1; i < NUMBER_OF_TURTLE_TOOLS; i++) // createTurtleItemStack(result, isAdvanced, upgradeId, (short)i); // } // // public static void addUpgradedTurtles(List<ItemStack> result, ITurtleUpgrade upgrade) { // addUpgradedTurtles(result, upgrade, false); // addUpgradedTurtles(result, upgrade, true); // } // // public static boolean isTurtleValid(ITurtleAccess access) { // World world = access.getWorld(); // if (world == null) return false; // ChunkCoordinates coords = access.getPosition(); // return world.blockExists(coords.posX, coords.posY, coords.posZ); // } // // }
import dan200.computercraft.api.turtle.ITurtleAccess; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import openperipheral.addons.utils.CCUtils; import openperipheral.api.adapter.IWorldPosProvider;
return inventory().getInventoryStackLimit(); } @Override public void markDirty() { inventory().markDirty(); } @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { return inventory().isUseableByPlayer(entityplayer); } @Override public void openInventory() { inventory().openInventory(); } @Override public void closeInventory() { inventory().closeInventory(); } @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { return inventory().isItemValidForSlot(i, itemstack); } @Override public boolean isValid() {
// Path: src/main/java/openperipheral/addons/utils/CCUtils.java // public final class CCUtils { // private static final int NUMBER_OF_TURTLE_TOOLS = 7; // // public static Object[] wrap(Object... args) { // return args; // } // // public static ItemStack getExpandedTurtleItemStack() { // return GameRegistry.findItemStack(Mods.COMPUTERCRAFT, "CC-TurtleExpanded", 1); // } // // public static ItemStack getAdvancedTurtleItemStack() { // return GameRegistry.findItemStack(Mods.COMPUTERCRAFT, "CC-TurtleAdvanced", 1); // } // // public static void createTurtleItemStack(List<ItemStack> result, boolean isAdvanced, Short left, Short right) { // ItemStack turtle = isAdvanced? getAdvancedTurtleItemStack() : getExpandedTurtleItemStack(); // // if (turtle == null) return; // // NBTTagCompound tag = turtle.getTagCompound(); // if (tag == null) { // tag = new NBTTagCompound(); // turtle.setTagCompound(tag); // } // // if (left != null) tag.setShort("leftUpgrade", left); // // if (right != null) tag.setShort("rightUpgrade", right); // // result.add(turtle); // } // // private static void addUpgradedTurtles(List<ItemStack> result, ITurtleUpgrade upgrade, boolean isAdvanced) { // short upgradeId = (short)upgrade.getUpgradeID(); // createTurtleItemStack(result, isAdvanced, upgradeId, null); // for (int i = 1; i < NUMBER_OF_TURTLE_TOOLS; i++) // createTurtleItemStack(result, isAdvanced, upgradeId, (short)i); // } // // public static void addUpgradedTurtles(List<ItemStack> result, ITurtleUpgrade upgrade) { // addUpgradedTurtles(result, upgrade, false); // addUpgradedTurtles(result, upgrade, true); // } // // public static boolean isTurtleValid(ITurtleAccess access) { // World world = access.getWorld(); // if (world == null) return false; // ChunkCoordinates coords = access.getPosition(); // return world.blockExists(coords.posX, coords.posY, coords.posZ); // } // // } // Path: src/main/java/openperipheral/addons/narcissistic/TurtleInventoryDelegate.java import dan200.computercraft.api.turtle.ITurtleAccess; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import openperipheral.addons.utils.CCUtils; import openperipheral.api.adapter.IWorldPosProvider; return inventory().getInventoryStackLimit(); } @Override public void markDirty() { inventory().markDirty(); } @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { return inventory().isUseableByPlayer(entityplayer); } @Override public void openInventory() { inventory().openInventory(); } @Override public void closeInventory() { inventory().closeInventory(); } @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { return inventory().isItemValidForSlot(i, itemstack); } @Override public boolean isValid() {
return CCUtils.isTurtleValid(wrapped);
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/sensors/TileEntitySensor.java
// Path: src/main/java/openperipheral/addons/Config.java // public class Config { // @OnLineModifiable // @ConfigProperty(category = "sensor", name = "rangeInStorm") // public static int sensorRangeInStorm = 5; // // @OnLineModifiable // @ConfigProperty(category = "sensor", name = "normalRange") // public static int sensorRange = 5; // // @OnLineModifiable // @ConfigProperty(category = "misc", comment = "Should turtles with OPA updates be visible in creative") // public static boolean addTurtlesToCreative = true; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Should glasses listen to all chat (not just prefixed with $$)") // public static boolean listenToAllChat = true; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Minimal difference in mouse position (in pixels) needed before drag event is sent to server") // public static int minimalDragThreshold = 5; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Minimal time (in ticks) between two drag events") // public static int minimalDragPeriod = 10; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Default difference in mouse position (in pixels) needed before drag event is sent to server") // public static int defaultDragThreshold = 5; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Default time (in ticks) between two drag events") // public static int defaultDragPeriod = 10; // // }
import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Vec3; import net.minecraft.world.World; import openmods.utils.WorldUtils; import openperipheral.addons.Config;
package openperipheral.addons.sensors; public class TileEntitySensor extends TileEntity implements ISensorEnvironment { private static final int ROTATION_SPEED = 3; private int rotation; public TileEntitySensor() {} public int getRotation() { return rotation; } @Override public void updateEntity() { rotation = (rotation + ROTATION_SPEED) % 360; } @Override public boolean isTurtle() { return false; } @Override public Vec3 getLocation() { return Vec3.createVectorHelper(xCoord, yCoord, zCoord); } @Override public World getWorld() { return worldObj; } @Override public int getSensorRange() { final World world = getWorld();
// Path: src/main/java/openperipheral/addons/Config.java // public class Config { // @OnLineModifiable // @ConfigProperty(category = "sensor", name = "rangeInStorm") // public static int sensorRangeInStorm = 5; // // @OnLineModifiable // @ConfigProperty(category = "sensor", name = "normalRange") // public static int sensorRange = 5; // // @OnLineModifiable // @ConfigProperty(category = "misc", comment = "Should turtles with OPA updates be visible in creative") // public static boolean addTurtlesToCreative = true; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Should glasses listen to all chat (not just prefixed with $$)") // public static boolean listenToAllChat = true; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Minimal difference in mouse position (in pixels) needed before drag event is sent to server") // public static int minimalDragThreshold = 5; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Minimal time (in ticks) between two drag events") // public static int minimalDragPeriod = 10; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Default difference in mouse position (in pixels) needed before drag event is sent to server") // public static int defaultDragThreshold = 5; // // @OnLineModifiable // @ConfigProperty(category = "glasses", comment = "Default time (in ticks) between two drag events") // public static int defaultDragPeriod = 10; // // } // Path: src/main/java/openperipheral/addons/sensors/TileEntitySensor.java import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Vec3; import net.minecraft.world.World; import openmods.utils.WorldUtils; import openperipheral.addons.Config; package openperipheral.addons.sensors; public class TileEntitySensor extends TileEntity implements ISensorEnvironment { private static final int ROTATION_SPEED = 3; private int rotation; public TileEntitySensor() {} public int getRotation() { return rotation; } @Override public void updateEntity() { rotation = (rotation + ROTATION_SPEED) % 360; } @Override public boolean isTurtle() { return false; } @Override public Vec3 getLocation() { return Vec3.createVectorHelper(xCoord, yCoord, zCoord); } @Override public World getWorld() { return worldObj; } @Override public int getSensorRange() { final World world = getWorld();
return (world.isRaining() && world.isThundering())? Config.sensorRangeInStorm : Config.sensorRange;
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/glasses/drawable/GradientLine.java
// Path: src/main/java/openperipheral/addons/glasses/utils/ColorPoint2d.java // @ScriptStruct // @SerializableClass // public class ColorPoint2d { // // public static final ColorPoint2d NULL = new ColorPoint2d(0, 0, 0, 0.0f); // // public ColorPoint2d() {} // // public ColorPoint2d(float x, float y, int rgb, float opacity) { // this.x = x; // this.y = y; // this.rgb = rgb; // this.opacity = opacity; // } // // @Serialize // @StructField(index = 0) // public float x; // // @Serialize // @StructField(index = 1) // public float y; // // @Serialize // @StructField(index = 2, optional = true) // public int rgb = 0xFFFFFF; // // @Serialize // @StructField(index = 3, optional = true) // public float opacity = 1; // // @Override // public String toString() { // return String.format("(%f,%f %06X:%.2f", x, y, rgb, opacity); // } // // } // // Path: src/main/java/openperipheral/addons/glasses/utils/ColorPointListBuilder.java // public class ColorPointListBuilder implements IPointListBuilder<ColorPoint2d> { // // private static class PointListImpl extends PointList<ColorPoint2d> { // // public PointListImpl(List<ColorPoint2d> points) { // super(points); // } // // @Override // protected void drawPoint(RenderState renderState, ColorPoint2d p) { // renderState.setColor(p.rgb, p.opacity); // GL11.glVertex2f(p.x, p.y); // } // // } // // private final List<ColorPoint2d> points = Lists.newArrayList(); // // private final BoundingBoxBuilder bbBuilder = BoundingBoxBuilder.create(); // // @Override // public void add(ColorPoint2d point) { // bbBuilder.addPoint(point.x, point.y); // points.add(point); // } // // private static ColorPoint2d toBoundingBox(Box2d bb, ColorPoint2d point) { // return new ColorPoint2d(point.x - bb.left, point.y - bb.top, point.rgb, point.opacity); // } // // @Override // public IPointList<ColorPoint2d> buildPointList() { // final Box2d bb = bbBuilder.build(); // // List<ColorPoint2d> relPoints = Lists.newArrayList(); // for (ColorPoint2d p : points) // relPoints.add(toBoundingBox(bb, p)); // // return new PointListImpl(relPoints); // } // // @Override // public Box2d buildBoundingBox() { // return bbBuilder.build(); // } // } // // Path: src/main/java/openperipheral/addons/glasses/utils/IPointListBuilder.java // public interface IPointListBuilder<P> { // public void add(P point); // // public IPointList<P> buildPointList(); // // public Box2d buildBoundingBox(); // }
import openperipheral.addons.glasses.utils.ColorPoint2d; import openperipheral.addons.glasses.utils.ColorPointListBuilder; import openperipheral.addons.glasses.utils.IPointListBuilder; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.method.ScriptObject;
package openperipheral.addons.glasses.drawable; @ScriptObject @AdapterSourceName("glasses_gradient_line")
// Path: src/main/java/openperipheral/addons/glasses/utils/ColorPoint2d.java // @ScriptStruct // @SerializableClass // public class ColorPoint2d { // // public static final ColorPoint2d NULL = new ColorPoint2d(0, 0, 0, 0.0f); // // public ColorPoint2d() {} // // public ColorPoint2d(float x, float y, int rgb, float opacity) { // this.x = x; // this.y = y; // this.rgb = rgb; // this.opacity = opacity; // } // // @Serialize // @StructField(index = 0) // public float x; // // @Serialize // @StructField(index = 1) // public float y; // // @Serialize // @StructField(index = 2, optional = true) // public int rgb = 0xFFFFFF; // // @Serialize // @StructField(index = 3, optional = true) // public float opacity = 1; // // @Override // public String toString() { // return String.format("(%f,%f %06X:%.2f", x, y, rgb, opacity); // } // // } // // Path: src/main/java/openperipheral/addons/glasses/utils/ColorPointListBuilder.java // public class ColorPointListBuilder implements IPointListBuilder<ColorPoint2d> { // // private static class PointListImpl extends PointList<ColorPoint2d> { // // public PointListImpl(List<ColorPoint2d> points) { // super(points); // } // // @Override // protected void drawPoint(RenderState renderState, ColorPoint2d p) { // renderState.setColor(p.rgb, p.opacity); // GL11.glVertex2f(p.x, p.y); // } // // } // // private final List<ColorPoint2d> points = Lists.newArrayList(); // // private final BoundingBoxBuilder bbBuilder = BoundingBoxBuilder.create(); // // @Override // public void add(ColorPoint2d point) { // bbBuilder.addPoint(point.x, point.y); // points.add(point); // } // // private static ColorPoint2d toBoundingBox(Box2d bb, ColorPoint2d point) { // return new ColorPoint2d(point.x - bb.left, point.y - bb.top, point.rgb, point.opacity); // } // // @Override // public IPointList<ColorPoint2d> buildPointList() { // final Box2d bb = bbBuilder.build(); // // List<ColorPoint2d> relPoints = Lists.newArrayList(); // for (ColorPoint2d p : points) // relPoints.add(toBoundingBox(bb, p)); // // return new PointListImpl(relPoints); // } // // @Override // public Box2d buildBoundingBox() { // return bbBuilder.build(); // } // } // // Path: src/main/java/openperipheral/addons/glasses/utils/IPointListBuilder.java // public interface IPointListBuilder<P> { // public void add(P point); // // public IPointList<P> buildPointList(); // // public Box2d buildBoundingBox(); // } // Path: src/main/java/openperipheral/addons/glasses/drawable/GradientLine.java import openperipheral.addons.glasses.utils.ColorPoint2d; import openperipheral.addons.glasses.utils.ColorPointListBuilder; import openperipheral.addons.glasses.utils.IPointListBuilder; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.method.ScriptObject; package openperipheral.addons.glasses.drawable; @ScriptObject @AdapterSourceName("glasses_gradient_line")
public class GradientLine extends Line<ColorPoint2d> {
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/glasses/drawable/GradientLine.java
// Path: src/main/java/openperipheral/addons/glasses/utils/ColorPoint2d.java // @ScriptStruct // @SerializableClass // public class ColorPoint2d { // // public static final ColorPoint2d NULL = new ColorPoint2d(0, 0, 0, 0.0f); // // public ColorPoint2d() {} // // public ColorPoint2d(float x, float y, int rgb, float opacity) { // this.x = x; // this.y = y; // this.rgb = rgb; // this.opacity = opacity; // } // // @Serialize // @StructField(index = 0) // public float x; // // @Serialize // @StructField(index = 1) // public float y; // // @Serialize // @StructField(index = 2, optional = true) // public int rgb = 0xFFFFFF; // // @Serialize // @StructField(index = 3, optional = true) // public float opacity = 1; // // @Override // public String toString() { // return String.format("(%f,%f %06X:%.2f", x, y, rgb, opacity); // } // // } // // Path: src/main/java/openperipheral/addons/glasses/utils/ColorPointListBuilder.java // public class ColorPointListBuilder implements IPointListBuilder<ColorPoint2d> { // // private static class PointListImpl extends PointList<ColorPoint2d> { // // public PointListImpl(List<ColorPoint2d> points) { // super(points); // } // // @Override // protected void drawPoint(RenderState renderState, ColorPoint2d p) { // renderState.setColor(p.rgb, p.opacity); // GL11.glVertex2f(p.x, p.y); // } // // } // // private final List<ColorPoint2d> points = Lists.newArrayList(); // // private final BoundingBoxBuilder bbBuilder = BoundingBoxBuilder.create(); // // @Override // public void add(ColorPoint2d point) { // bbBuilder.addPoint(point.x, point.y); // points.add(point); // } // // private static ColorPoint2d toBoundingBox(Box2d bb, ColorPoint2d point) { // return new ColorPoint2d(point.x - bb.left, point.y - bb.top, point.rgb, point.opacity); // } // // @Override // public IPointList<ColorPoint2d> buildPointList() { // final Box2d bb = bbBuilder.build(); // // List<ColorPoint2d> relPoints = Lists.newArrayList(); // for (ColorPoint2d p : points) // relPoints.add(toBoundingBox(bb, p)); // // return new PointListImpl(relPoints); // } // // @Override // public Box2d buildBoundingBox() { // return bbBuilder.build(); // } // } // // Path: src/main/java/openperipheral/addons/glasses/utils/IPointListBuilder.java // public interface IPointListBuilder<P> { // public void add(P point); // // public IPointList<P> buildPointList(); // // public Box2d buildBoundingBox(); // }
import openperipheral.addons.glasses.utils.ColorPoint2d; import openperipheral.addons.glasses.utils.ColorPointListBuilder; import openperipheral.addons.glasses.utils.IPointListBuilder; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.method.ScriptObject;
package openperipheral.addons.glasses.drawable; @ScriptObject @AdapterSourceName("glasses_gradient_line") public class GradientLine extends Line<ColorPoint2d> { public GradientLine() { this(ColorPoint2d.NULL, ColorPoint2d.NULL); } public GradientLine(ColorPoint2d p1, ColorPoint2d p2) { super(p1, p2); } @Override
// Path: src/main/java/openperipheral/addons/glasses/utils/ColorPoint2d.java // @ScriptStruct // @SerializableClass // public class ColorPoint2d { // // public static final ColorPoint2d NULL = new ColorPoint2d(0, 0, 0, 0.0f); // // public ColorPoint2d() {} // // public ColorPoint2d(float x, float y, int rgb, float opacity) { // this.x = x; // this.y = y; // this.rgb = rgb; // this.opacity = opacity; // } // // @Serialize // @StructField(index = 0) // public float x; // // @Serialize // @StructField(index = 1) // public float y; // // @Serialize // @StructField(index = 2, optional = true) // public int rgb = 0xFFFFFF; // // @Serialize // @StructField(index = 3, optional = true) // public float opacity = 1; // // @Override // public String toString() { // return String.format("(%f,%f %06X:%.2f", x, y, rgb, opacity); // } // // } // // Path: src/main/java/openperipheral/addons/glasses/utils/ColorPointListBuilder.java // public class ColorPointListBuilder implements IPointListBuilder<ColorPoint2d> { // // private static class PointListImpl extends PointList<ColorPoint2d> { // // public PointListImpl(List<ColorPoint2d> points) { // super(points); // } // // @Override // protected void drawPoint(RenderState renderState, ColorPoint2d p) { // renderState.setColor(p.rgb, p.opacity); // GL11.glVertex2f(p.x, p.y); // } // // } // // private final List<ColorPoint2d> points = Lists.newArrayList(); // // private final BoundingBoxBuilder bbBuilder = BoundingBoxBuilder.create(); // // @Override // public void add(ColorPoint2d point) { // bbBuilder.addPoint(point.x, point.y); // points.add(point); // } // // private static ColorPoint2d toBoundingBox(Box2d bb, ColorPoint2d point) { // return new ColorPoint2d(point.x - bb.left, point.y - bb.top, point.rgb, point.opacity); // } // // @Override // public IPointList<ColorPoint2d> buildPointList() { // final Box2d bb = bbBuilder.build(); // // List<ColorPoint2d> relPoints = Lists.newArrayList(); // for (ColorPoint2d p : points) // relPoints.add(toBoundingBox(bb, p)); // // return new PointListImpl(relPoints); // } // // @Override // public Box2d buildBoundingBox() { // return bbBuilder.build(); // } // } // // Path: src/main/java/openperipheral/addons/glasses/utils/IPointListBuilder.java // public interface IPointListBuilder<P> { // public void add(P point); // // public IPointList<P> buildPointList(); // // public Box2d buildBoundingBox(); // } // Path: src/main/java/openperipheral/addons/glasses/drawable/GradientLine.java import openperipheral.addons.glasses.utils.ColorPoint2d; import openperipheral.addons.glasses.utils.ColorPointListBuilder; import openperipheral.addons.glasses.utils.IPointListBuilder; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.method.ScriptObject; package openperipheral.addons.glasses.drawable; @ScriptObject @AdapterSourceName("glasses_gradient_line") public class GradientLine extends Line<ColorPoint2d> { public GradientLine() { this(ColorPoint2d.NULL, ColorPoint2d.NULL); } public GradientLine(ColorPoint2d p1, ColorPoint2d p2) { super(p1, p2); } @Override
protected IPointListBuilder<ColorPoint2d> createBuilder() {
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/glasses/drawable/GradientLine.java
// Path: src/main/java/openperipheral/addons/glasses/utils/ColorPoint2d.java // @ScriptStruct // @SerializableClass // public class ColorPoint2d { // // public static final ColorPoint2d NULL = new ColorPoint2d(0, 0, 0, 0.0f); // // public ColorPoint2d() {} // // public ColorPoint2d(float x, float y, int rgb, float opacity) { // this.x = x; // this.y = y; // this.rgb = rgb; // this.opacity = opacity; // } // // @Serialize // @StructField(index = 0) // public float x; // // @Serialize // @StructField(index = 1) // public float y; // // @Serialize // @StructField(index = 2, optional = true) // public int rgb = 0xFFFFFF; // // @Serialize // @StructField(index = 3, optional = true) // public float opacity = 1; // // @Override // public String toString() { // return String.format("(%f,%f %06X:%.2f", x, y, rgb, opacity); // } // // } // // Path: src/main/java/openperipheral/addons/glasses/utils/ColorPointListBuilder.java // public class ColorPointListBuilder implements IPointListBuilder<ColorPoint2d> { // // private static class PointListImpl extends PointList<ColorPoint2d> { // // public PointListImpl(List<ColorPoint2d> points) { // super(points); // } // // @Override // protected void drawPoint(RenderState renderState, ColorPoint2d p) { // renderState.setColor(p.rgb, p.opacity); // GL11.glVertex2f(p.x, p.y); // } // // } // // private final List<ColorPoint2d> points = Lists.newArrayList(); // // private final BoundingBoxBuilder bbBuilder = BoundingBoxBuilder.create(); // // @Override // public void add(ColorPoint2d point) { // bbBuilder.addPoint(point.x, point.y); // points.add(point); // } // // private static ColorPoint2d toBoundingBox(Box2d bb, ColorPoint2d point) { // return new ColorPoint2d(point.x - bb.left, point.y - bb.top, point.rgb, point.opacity); // } // // @Override // public IPointList<ColorPoint2d> buildPointList() { // final Box2d bb = bbBuilder.build(); // // List<ColorPoint2d> relPoints = Lists.newArrayList(); // for (ColorPoint2d p : points) // relPoints.add(toBoundingBox(bb, p)); // // return new PointListImpl(relPoints); // } // // @Override // public Box2d buildBoundingBox() { // return bbBuilder.build(); // } // } // // Path: src/main/java/openperipheral/addons/glasses/utils/IPointListBuilder.java // public interface IPointListBuilder<P> { // public void add(P point); // // public IPointList<P> buildPointList(); // // public Box2d buildBoundingBox(); // }
import openperipheral.addons.glasses.utils.ColorPoint2d; import openperipheral.addons.glasses.utils.ColorPointListBuilder; import openperipheral.addons.glasses.utils.IPointListBuilder; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.method.ScriptObject;
package openperipheral.addons.glasses.drawable; @ScriptObject @AdapterSourceName("glasses_gradient_line") public class GradientLine extends Line<ColorPoint2d> { public GradientLine() { this(ColorPoint2d.NULL, ColorPoint2d.NULL); } public GradientLine(ColorPoint2d p1, ColorPoint2d p2) { super(p1, p2); } @Override protected IPointListBuilder<ColorPoint2d> createBuilder() {
// Path: src/main/java/openperipheral/addons/glasses/utils/ColorPoint2d.java // @ScriptStruct // @SerializableClass // public class ColorPoint2d { // // public static final ColorPoint2d NULL = new ColorPoint2d(0, 0, 0, 0.0f); // // public ColorPoint2d() {} // // public ColorPoint2d(float x, float y, int rgb, float opacity) { // this.x = x; // this.y = y; // this.rgb = rgb; // this.opacity = opacity; // } // // @Serialize // @StructField(index = 0) // public float x; // // @Serialize // @StructField(index = 1) // public float y; // // @Serialize // @StructField(index = 2, optional = true) // public int rgb = 0xFFFFFF; // // @Serialize // @StructField(index = 3, optional = true) // public float opacity = 1; // // @Override // public String toString() { // return String.format("(%f,%f %06X:%.2f", x, y, rgb, opacity); // } // // } // // Path: src/main/java/openperipheral/addons/glasses/utils/ColorPointListBuilder.java // public class ColorPointListBuilder implements IPointListBuilder<ColorPoint2d> { // // private static class PointListImpl extends PointList<ColorPoint2d> { // // public PointListImpl(List<ColorPoint2d> points) { // super(points); // } // // @Override // protected void drawPoint(RenderState renderState, ColorPoint2d p) { // renderState.setColor(p.rgb, p.opacity); // GL11.glVertex2f(p.x, p.y); // } // // } // // private final List<ColorPoint2d> points = Lists.newArrayList(); // // private final BoundingBoxBuilder bbBuilder = BoundingBoxBuilder.create(); // // @Override // public void add(ColorPoint2d point) { // bbBuilder.addPoint(point.x, point.y); // points.add(point); // } // // private static ColorPoint2d toBoundingBox(Box2d bb, ColorPoint2d point) { // return new ColorPoint2d(point.x - bb.left, point.y - bb.top, point.rgb, point.opacity); // } // // @Override // public IPointList<ColorPoint2d> buildPointList() { // final Box2d bb = bbBuilder.build(); // // List<ColorPoint2d> relPoints = Lists.newArrayList(); // for (ColorPoint2d p : points) // relPoints.add(toBoundingBox(bb, p)); // // return new PointListImpl(relPoints); // } // // @Override // public Box2d buildBoundingBox() { // return bbBuilder.build(); // } // } // // Path: src/main/java/openperipheral/addons/glasses/utils/IPointListBuilder.java // public interface IPointListBuilder<P> { // public void add(P point); // // public IPointList<P> buildPointList(); // // public Box2d buildBoundingBox(); // } // Path: src/main/java/openperipheral/addons/glasses/drawable/GradientLine.java import openperipheral.addons.glasses.utils.ColorPoint2d; import openperipheral.addons.glasses.utils.ColorPointListBuilder; import openperipheral.addons.glasses.utils.IPointListBuilder; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.method.ScriptObject; package openperipheral.addons.glasses.drawable; @ScriptObject @AdapterSourceName("glasses_gradient_line") public class GradientLine extends Line<ColorPoint2d> { public GradientLine() { this(ColorPoint2d.NULL, ColorPoint2d.NULL); } public GradientLine(ColorPoint2d p1, ColorPoint2d p2) { super(p1, p2); } @Override protected IPointListBuilder<ColorPoint2d> createBuilder() {
return new ColorPointListBuilder();
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/glasses/drawable/GradientQuad.java
// Path: src/main/java/openperipheral/addons/glasses/utils/ColorPoint2d.java // @ScriptStruct // @SerializableClass // public class ColorPoint2d { // // public static final ColorPoint2d NULL = new ColorPoint2d(0, 0, 0, 0.0f); // // public ColorPoint2d() {} // // public ColorPoint2d(float x, float y, int rgb, float opacity) { // this.x = x; // this.y = y; // this.rgb = rgb; // this.opacity = opacity; // } // // @Serialize // @StructField(index = 0) // public float x; // // @Serialize // @StructField(index = 1) // public float y; // // @Serialize // @StructField(index = 2, optional = true) // public int rgb = 0xFFFFFF; // // @Serialize // @StructField(index = 3, optional = true) // public float opacity = 1; // // @Override // public String toString() { // return String.format("(%f,%f %06X:%.2f", x, y, rgb, opacity); // } // // } // // Path: src/main/java/openperipheral/addons/glasses/utils/ColorPointListBuilder.java // public class ColorPointListBuilder implements IPointListBuilder<ColorPoint2d> { // // private static class PointListImpl extends PointList<ColorPoint2d> { // // public PointListImpl(List<ColorPoint2d> points) { // super(points); // } // // @Override // protected void drawPoint(RenderState renderState, ColorPoint2d p) { // renderState.setColor(p.rgb, p.opacity); // GL11.glVertex2f(p.x, p.y); // } // // } // // private final List<ColorPoint2d> points = Lists.newArrayList(); // // private final BoundingBoxBuilder bbBuilder = BoundingBoxBuilder.create(); // // @Override // public void add(ColorPoint2d point) { // bbBuilder.addPoint(point.x, point.y); // points.add(point); // } // // private static ColorPoint2d toBoundingBox(Box2d bb, ColorPoint2d point) { // return new ColorPoint2d(point.x - bb.left, point.y - bb.top, point.rgb, point.opacity); // } // // @Override // public IPointList<ColorPoint2d> buildPointList() { // final Box2d bb = bbBuilder.build(); // // List<ColorPoint2d> relPoints = Lists.newArrayList(); // for (ColorPoint2d p : points) // relPoints.add(toBoundingBox(bb, p)); // // return new PointListImpl(relPoints); // } // // @Override // public Box2d buildBoundingBox() { // return bbBuilder.build(); // } // } // // Path: src/main/java/openperipheral/addons/glasses/utils/IPointListBuilder.java // public interface IPointListBuilder<P> { // public void add(P point); // // public IPointList<P> buildPointList(); // // public Box2d buildBoundingBox(); // }
import openperipheral.addons.glasses.utils.ColorPoint2d; import openperipheral.addons.glasses.utils.ColorPointListBuilder; import openperipheral.addons.glasses.utils.IPointListBuilder; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.method.ScriptObject;
package openperipheral.addons.glasses.drawable; @ScriptObject @AdapterSourceName("glasses_gradient_quad")
// Path: src/main/java/openperipheral/addons/glasses/utils/ColorPoint2d.java // @ScriptStruct // @SerializableClass // public class ColorPoint2d { // // public static final ColorPoint2d NULL = new ColorPoint2d(0, 0, 0, 0.0f); // // public ColorPoint2d() {} // // public ColorPoint2d(float x, float y, int rgb, float opacity) { // this.x = x; // this.y = y; // this.rgb = rgb; // this.opacity = opacity; // } // // @Serialize // @StructField(index = 0) // public float x; // // @Serialize // @StructField(index = 1) // public float y; // // @Serialize // @StructField(index = 2, optional = true) // public int rgb = 0xFFFFFF; // // @Serialize // @StructField(index = 3, optional = true) // public float opacity = 1; // // @Override // public String toString() { // return String.format("(%f,%f %06X:%.2f", x, y, rgb, opacity); // } // // } // // Path: src/main/java/openperipheral/addons/glasses/utils/ColorPointListBuilder.java // public class ColorPointListBuilder implements IPointListBuilder<ColorPoint2d> { // // private static class PointListImpl extends PointList<ColorPoint2d> { // // public PointListImpl(List<ColorPoint2d> points) { // super(points); // } // // @Override // protected void drawPoint(RenderState renderState, ColorPoint2d p) { // renderState.setColor(p.rgb, p.opacity); // GL11.glVertex2f(p.x, p.y); // } // // } // // private final List<ColorPoint2d> points = Lists.newArrayList(); // // private final BoundingBoxBuilder bbBuilder = BoundingBoxBuilder.create(); // // @Override // public void add(ColorPoint2d point) { // bbBuilder.addPoint(point.x, point.y); // points.add(point); // } // // private static ColorPoint2d toBoundingBox(Box2d bb, ColorPoint2d point) { // return new ColorPoint2d(point.x - bb.left, point.y - bb.top, point.rgb, point.opacity); // } // // @Override // public IPointList<ColorPoint2d> buildPointList() { // final Box2d bb = bbBuilder.build(); // // List<ColorPoint2d> relPoints = Lists.newArrayList(); // for (ColorPoint2d p : points) // relPoints.add(toBoundingBox(bb, p)); // // return new PointListImpl(relPoints); // } // // @Override // public Box2d buildBoundingBox() { // return bbBuilder.build(); // } // } // // Path: src/main/java/openperipheral/addons/glasses/utils/IPointListBuilder.java // public interface IPointListBuilder<P> { // public void add(P point); // // public IPointList<P> buildPointList(); // // public Box2d buildBoundingBox(); // } // Path: src/main/java/openperipheral/addons/glasses/drawable/GradientQuad.java import openperipheral.addons.glasses.utils.ColorPoint2d; import openperipheral.addons.glasses.utils.ColorPointListBuilder; import openperipheral.addons.glasses.utils.IPointListBuilder; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.method.ScriptObject; package openperipheral.addons.glasses.drawable; @ScriptObject @AdapterSourceName("glasses_gradient_quad")
public class GradientQuad extends Quad<ColorPoint2d> {
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/glasses/drawable/GradientQuad.java
// Path: src/main/java/openperipheral/addons/glasses/utils/ColorPoint2d.java // @ScriptStruct // @SerializableClass // public class ColorPoint2d { // // public static final ColorPoint2d NULL = new ColorPoint2d(0, 0, 0, 0.0f); // // public ColorPoint2d() {} // // public ColorPoint2d(float x, float y, int rgb, float opacity) { // this.x = x; // this.y = y; // this.rgb = rgb; // this.opacity = opacity; // } // // @Serialize // @StructField(index = 0) // public float x; // // @Serialize // @StructField(index = 1) // public float y; // // @Serialize // @StructField(index = 2, optional = true) // public int rgb = 0xFFFFFF; // // @Serialize // @StructField(index = 3, optional = true) // public float opacity = 1; // // @Override // public String toString() { // return String.format("(%f,%f %06X:%.2f", x, y, rgb, opacity); // } // // } // // Path: src/main/java/openperipheral/addons/glasses/utils/ColorPointListBuilder.java // public class ColorPointListBuilder implements IPointListBuilder<ColorPoint2d> { // // private static class PointListImpl extends PointList<ColorPoint2d> { // // public PointListImpl(List<ColorPoint2d> points) { // super(points); // } // // @Override // protected void drawPoint(RenderState renderState, ColorPoint2d p) { // renderState.setColor(p.rgb, p.opacity); // GL11.glVertex2f(p.x, p.y); // } // // } // // private final List<ColorPoint2d> points = Lists.newArrayList(); // // private final BoundingBoxBuilder bbBuilder = BoundingBoxBuilder.create(); // // @Override // public void add(ColorPoint2d point) { // bbBuilder.addPoint(point.x, point.y); // points.add(point); // } // // private static ColorPoint2d toBoundingBox(Box2d bb, ColorPoint2d point) { // return new ColorPoint2d(point.x - bb.left, point.y - bb.top, point.rgb, point.opacity); // } // // @Override // public IPointList<ColorPoint2d> buildPointList() { // final Box2d bb = bbBuilder.build(); // // List<ColorPoint2d> relPoints = Lists.newArrayList(); // for (ColorPoint2d p : points) // relPoints.add(toBoundingBox(bb, p)); // // return new PointListImpl(relPoints); // } // // @Override // public Box2d buildBoundingBox() { // return bbBuilder.build(); // } // } // // Path: src/main/java/openperipheral/addons/glasses/utils/IPointListBuilder.java // public interface IPointListBuilder<P> { // public void add(P point); // // public IPointList<P> buildPointList(); // // public Box2d buildBoundingBox(); // }
import openperipheral.addons.glasses.utils.ColorPoint2d; import openperipheral.addons.glasses.utils.ColorPointListBuilder; import openperipheral.addons.glasses.utils.IPointListBuilder; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.method.ScriptObject;
package openperipheral.addons.glasses.drawable; @ScriptObject @AdapterSourceName("glasses_gradient_quad") public class GradientQuad extends Quad<ColorPoint2d> { public GradientQuad() { this(ColorPoint2d.NULL, ColorPoint2d.NULL, ColorPoint2d.NULL, ColorPoint2d.NULL); } public GradientQuad(ColorPoint2d p1, ColorPoint2d p2, ColorPoint2d p3, ColorPoint2d p4) { super(p1, p2, p3, p4); } @Override
// Path: src/main/java/openperipheral/addons/glasses/utils/ColorPoint2d.java // @ScriptStruct // @SerializableClass // public class ColorPoint2d { // // public static final ColorPoint2d NULL = new ColorPoint2d(0, 0, 0, 0.0f); // // public ColorPoint2d() {} // // public ColorPoint2d(float x, float y, int rgb, float opacity) { // this.x = x; // this.y = y; // this.rgb = rgb; // this.opacity = opacity; // } // // @Serialize // @StructField(index = 0) // public float x; // // @Serialize // @StructField(index = 1) // public float y; // // @Serialize // @StructField(index = 2, optional = true) // public int rgb = 0xFFFFFF; // // @Serialize // @StructField(index = 3, optional = true) // public float opacity = 1; // // @Override // public String toString() { // return String.format("(%f,%f %06X:%.2f", x, y, rgb, opacity); // } // // } // // Path: src/main/java/openperipheral/addons/glasses/utils/ColorPointListBuilder.java // public class ColorPointListBuilder implements IPointListBuilder<ColorPoint2d> { // // private static class PointListImpl extends PointList<ColorPoint2d> { // // public PointListImpl(List<ColorPoint2d> points) { // super(points); // } // // @Override // protected void drawPoint(RenderState renderState, ColorPoint2d p) { // renderState.setColor(p.rgb, p.opacity); // GL11.glVertex2f(p.x, p.y); // } // // } // // private final List<ColorPoint2d> points = Lists.newArrayList(); // // private final BoundingBoxBuilder bbBuilder = BoundingBoxBuilder.create(); // // @Override // public void add(ColorPoint2d point) { // bbBuilder.addPoint(point.x, point.y); // points.add(point); // } // // private static ColorPoint2d toBoundingBox(Box2d bb, ColorPoint2d point) { // return new ColorPoint2d(point.x - bb.left, point.y - bb.top, point.rgb, point.opacity); // } // // @Override // public IPointList<ColorPoint2d> buildPointList() { // final Box2d bb = bbBuilder.build(); // // List<ColorPoint2d> relPoints = Lists.newArrayList(); // for (ColorPoint2d p : points) // relPoints.add(toBoundingBox(bb, p)); // // return new PointListImpl(relPoints); // } // // @Override // public Box2d buildBoundingBox() { // return bbBuilder.build(); // } // } // // Path: src/main/java/openperipheral/addons/glasses/utils/IPointListBuilder.java // public interface IPointListBuilder<P> { // public void add(P point); // // public IPointList<P> buildPointList(); // // public Box2d buildBoundingBox(); // } // Path: src/main/java/openperipheral/addons/glasses/drawable/GradientQuad.java import openperipheral.addons.glasses.utils.ColorPoint2d; import openperipheral.addons.glasses.utils.ColorPointListBuilder; import openperipheral.addons.glasses.utils.IPointListBuilder; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.method.ScriptObject; package openperipheral.addons.glasses.drawable; @ScriptObject @AdapterSourceName("glasses_gradient_quad") public class GradientQuad extends Quad<ColorPoint2d> { public GradientQuad() { this(ColorPoint2d.NULL, ColorPoint2d.NULL, ColorPoint2d.NULL, ColorPoint2d.NULL); } public GradientQuad(ColorPoint2d p1, ColorPoint2d p2, ColorPoint2d p3, ColorPoint2d p4) { super(p1, p2, p3, p4); } @Override
protected IPointListBuilder<ColorPoint2d> createBuilder() {
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/glasses/drawable/GradientQuad.java
// Path: src/main/java/openperipheral/addons/glasses/utils/ColorPoint2d.java // @ScriptStruct // @SerializableClass // public class ColorPoint2d { // // public static final ColorPoint2d NULL = new ColorPoint2d(0, 0, 0, 0.0f); // // public ColorPoint2d() {} // // public ColorPoint2d(float x, float y, int rgb, float opacity) { // this.x = x; // this.y = y; // this.rgb = rgb; // this.opacity = opacity; // } // // @Serialize // @StructField(index = 0) // public float x; // // @Serialize // @StructField(index = 1) // public float y; // // @Serialize // @StructField(index = 2, optional = true) // public int rgb = 0xFFFFFF; // // @Serialize // @StructField(index = 3, optional = true) // public float opacity = 1; // // @Override // public String toString() { // return String.format("(%f,%f %06X:%.2f", x, y, rgb, opacity); // } // // } // // Path: src/main/java/openperipheral/addons/glasses/utils/ColorPointListBuilder.java // public class ColorPointListBuilder implements IPointListBuilder<ColorPoint2d> { // // private static class PointListImpl extends PointList<ColorPoint2d> { // // public PointListImpl(List<ColorPoint2d> points) { // super(points); // } // // @Override // protected void drawPoint(RenderState renderState, ColorPoint2d p) { // renderState.setColor(p.rgb, p.opacity); // GL11.glVertex2f(p.x, p.y); // } // // } // // private final List<ColorPoint2d> points = Lists.newArrayList(); // // private final BoundingBoxBuilder bbBuilder = BoundingBoxBuilder.create(); // // @Override // public void add(ColorPoint2d point) { // bbBuilder.addPoint(point.x, point.y); // points.add(point); // } // // private static ColorPoint2d toBoundingBox(Box2d bb, ColorPoint2d point) { // return new ColorPoint2d(point.x - bb.left, point.y - bb.top, point.rgb, point.opacity); // } // // @Override // public IPointList<ColorPoint2d> buildPointList() { // final Box2d bb = bbBuilder.build(); // // List<ColorPoint2d> relPoints = Lists.newArrayList(); // for (ColorPoint2d p : points) // relPoints.add(toBoundingBox(bb, p)); // // return new PointListImpl(relPoints); // } // // @Override // public Box2d buildBoundingBox() { // return bbBuilder.build(); // } // } // // Path: src/main/java/openperipheral/addons/glasses/utils/IPointListBuilder.java // public interface IPointListBuilder<P> { // public void add(P point); // // public IPointList<P> buildPointList(); // // public Box2d buildBoundingBox(); // }
import openperipheral.addons.glasses.utils.ColorPoint2d; import openperipheral.addons.glasses.utils.ColorPointListBuilder; import openperipheral.addons.glasses.utils.IPointListBuilder; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.method.ScriptObject;
package openperipheral.addons.glasses.drawable; @ScriptObject @AdapterSourceName("glasses_gradient_quad") public class GradientQuad extends Quad<ColorPoint2d> { public GradientQuad() { this(ColorPoint2d.NULL, ColorPoint2d.NULL, ColorPoint2d.NULL, ColorPoint2d.NULL); } public GradientQuad(ColorPoint2d p1, ColorPoint2d p2, ColorPoint2d p3, ColorPoint2d p4) { super(p1, p2, p3, p4); } @Override protected IPointListBuilder<ColorPoint2d> createBuilder() {
// Path: src/main/java/openperipheral/addons/glasses/utils/ColorPoint2d.java // @ScriptStruct // @SerializableClass // public class ColorPoint2d { // // public static final ColorPoint2d NULL = new ColorPoint2d(0, 0, 0, 0.0f); // // public ColorPoint2d() {} // // public ColorPoint2d(float x, float y, int rgb, float opacity) { // this.x = x; // this.y = y; // this.rgb = rgb; // this.opacity = opacity; // } // // @Serialize // @StructField(index = 0) // public float x; // // @Serialize // @StructField(index = 1) // public float y; // // @Serialize // @StructField(index = 2, optional = true) // public int rgb = 0xFFFFFF; // // @Serialize // @StructField(index = 3, optional = true) // public float opacity = 1; // // @Override // public String toString() { // return String.format("(%f,%f %06X:%.2f", x, y, rgb, opacity); // } // // } // // Path: src/main/java/openperipheral/addons/glasses/utils/ColorPointListBuilder.java // public class ColorPointListBuilder implements IPointListBuilder<ColorPoint2d> { // // private static class PointListImpl extends PointList<ColorPoint2d> { // // public PointListImpl(List<ColorPoint2d> points) { // super(points); // } // // @Override // protected void drawPoint(RenderState renderState, ColorPoint2d p) { // renderState.setColor(p.rgb, p.opacity); // GL11.glVertex2f(p.x, p.y); // } // // } // // private final List<ColorPoint2d> points = Lists.newArrayList(); // // private final BoundingBoxBuilder bbBuilder = BoundingBoxBuilder.create(); // // @Override // public void add(ColorPoint2d point) { // bbBuilder.addPoint(point.x, point.y); // points.add(point); // } // // private static ColorPoint2d toBoundingBox(Box2d bb, ColorPoint2d point) { // return new ColorPoint2d(point.x - bb.left, point.y - bb.top, point.rgb, point.opacity); // } // // @Override // public IPointList<ColorPoint2d> buildPointList() { // final Box2d bb = bbBuilder.build(); // // List<ColorPoint2d> relPoints = Lists.newArrayList(); // for (ColorPoint2d p : points) // relPoints.add(toBoundingBox(bb, p)); // // return new PointListImpl(relPoints); // } // // @Override // public Box2d buildBoundingBox() { // return bbBuilder.build(); // } // } // // Path: src/main/java/openperipheral/addons/glasses/utils/IPointListBuilder.java // public interface IPointListBuilder<P> { // public void add(P point); // // public IPointList<P> buildPointList(); // // public Box2d buildBoundingBox(); // } // Path: src/main/java/openperipheral/addons/glasses/drawable/GradientQuad.java import openperipheral.addons.glasses.utils.ColorPoint2d; import openperipheral.addons.glasses.utils.ColorPointListBuilder; import openperipheral.addons.glasses.utils.IPointListBuilder; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.method.ScriptObject; package openperipheral.addons.glasses.drawable; @ScriptObject @AdapterSourceName("glasses_gradient_quad") public class GradientQuad extends Quad<ColorPoint2d> { public GradientQuad() { this(ColorPoint2d.NULL, ColorPoint2d.NULL, ColorPoint2d.NULL, ColorPoint2d.NULL); } public GradientQuad(ColorPoint2d p1, ColorPoint2d p2, ColorPoint2d p3, ColorPoint2d p4) { super(p1, p2, p3, p4); } @Override protected IPointListBuilder<ColorPoint2d> createBuilder() {
return new ColorPointListBuilder();
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/glasses/drawable/GradientLineStrip.java
// Path: src/main/java/openperipheral/addons/glasses/utils/ColorPoint2d.java // @ScriptStruct // @SerializableClass // public class ColorPoint2d { // // public static final ColorPoint2d NULL = new ColorPoint2d(0, 0, 0, 0.0f); // // public ColorPoint2d() {} // // public ColorPoint2d(float x, float y, int rgb, float opacity) { // this.x = x; // this.y = y; // this.rgb = rgb; // this.opacity = opacity; // } // // @Serialize // @StructField(index = 0) // public float x; // // @Serialize // @StructField(index = 1) // public float y; // // @Serialize // @StructField(index = 2, optional = true) // public int rgb = 0xFFFFFF; // // @Serialize // @StructField(index = 3, optional = true) // public float opacity = 1; // // @Override // public String toString() { // return String.format("(%f,%f %06X:%.2f", x, y, rgb, opacity); // } // // } // // Path: src/main/java/openperipheral/addons/glasses/utils/ColorPointListBuilder.java // public class ColorPointListBuilder implements IPointListBuilder<ColorPoint2d> { // // private static class PointListImpl extends PointList<ColorPoint2d> { // // public PointListImpl(List<ColorPoint2d> points) { // super(points); // } // // @Override // protected void drawPoint(RenderState renderState, ColorPoint2d p) { // renderState.setColor(p.rgb, p.opacity); // GL11.glVertex2f(p.x, p.y); // } // // } // // private final List<ColorPoint2d> points = Lists.newArrayList(); // // private final BoundingBoxBuilder bbBuilder = BoundingBoxBuilder.create(); // // @Override // public void add(ColorPoint2d point) { // bbBuilder.addPoint(point.x, point.y); // points.add(point); // } // // private static ColorPoint2d toBoundingBox(Box2d bb, ColorPoint2d point) { // return new ColorPoint2d(point.x - bb.left, point.y - bb.top, point.rgb, point.opacity); // } // // @Override // public IPointList<ColorPoint2d> buildPointList() { // final Box2d bb = bbBuilder.build(); // // List<ColorPoint2d> relPoints = Lists.newArrayList(); // for (ColorPoint2d p : points) // relPoints.add(toBoundingBox(bb, p)); // // return new PointListImpl(relPoints); // } // // @Override // public Box2d buildBoundingBox() { // return bbBuilder.build(); // } // } // // Path: src/main/java/openperipheral/addons/glasses/utils/IPointListBuilder.java // public interface IPointListBuilder<P> { // public void add(P point); // // public IPointList<P> buildPointList(); // // public Box2d buildBoundingBox(); // }
import openperipheral.addons.glasses.utils.ColorPoint2d; import openperipheral.addons.glasses.utils.ColorPointListBuilder; import openperipheral.addons.glasses.utils.IPointListBuilder; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.method.ScriptObject;
package openperipheral.addons.glasses.drawable; @ScriptObject @AdapterSourceName("glasses_gradient_line_strip")
// Path: src/main/java/openperipheral/addons/glasses/utils/ColorPoint2d.java // @ScriptStruct // @SerializableClass // public class ColorPoint2d { // // public static final ColorPoint2d NULL = new ColorPoint2d(0, 0, 0, 0.0f); // // public ColorPoint2d() {} // // public ColorPoint2d(float x, float y, int rgb, float opacity) { // this.x = x; // this.y = y; // this.rgb = rgb; // this.opacity = opacity; // } // // @Serialize // @StructField(index = 0) // public float x; // // @Serialize // @StructField(index = 1) // public float y; // // @Serialize // @StructField(index = 2, optional = true) // public int rgb = 0xFFFFFF; // // @Serialize // @StructField(index = 3, optional = true) // public float opacity = 1; // // @Override // public String toString() { // return String.format("(%f,%f %06X:%.2f", x, y, rgb, opacity); // } // // } // // Path: src/main/java/openperipheral/addons/glasses/utils/ColorPointListBuilder.java // public class ColorPointListBuilder implements IPointListBuilder<ColorPoint2d> { // // private static class PointListImpl extends PointList<ColorPoint2d> { // // public PointListImpl(List<ColorPoint2d> points) { // super(points); // } // // @Override // protected void drawPoint(RenderState renderState, ColorPoint2d p) { // renderState.setColor(p.rgb, p.opacity); // GL11.glVertex2f(p.x, p.y); // } // // } // // private final List<ColorPoint2d> points = Lists.newArrayList(); // // private final BoundingBoxBuilder bbBuilder = BoundingBoxBuilder.create(); // // @Override // public void add(ColorPoint2d point) { // bbBuilder.addPoint(point.x, point.y); // points.add(point); // } // // private static ColorPoint2d toBoundingBox(Box2d bb, ColorPoint2d point) { // return new ColorPoint2d(point.x - bb.left, point.y - bb.top, point.rgb, point.opacity); // } // // @Override // public IPointList<ColorPoint2d> buildPointList() { // final Box2d bb = bbBuilder.build(); // // List<ColorPoint2d> relPoints = Lists.newArrayList(); // for (ColorPoint2d p : points) // relPoints.add(toBoundingBox(bb, p)); // // return new PointListImpl(relPoints); // } // // @Override // public Box2d buildBoundingBox() { // return bbBuilder.build(); // } // } // // Path: src/main/java/openperipheral/addons/glasses/utils/IPointListBuilder.java // public interface IPointListBuilder<P> { // public void add(P point); // // public IPointList<P> buildPointList(); // // public Box2d buildBoundingBox(); // } // Path: src/main/java/openperipheral/addons/glasses/drawable/GradientLineStrip.java import openperipheral.addons.glasses.utils.ColorPoint2d; import openperipheral.addons.glasses.utils.ColorPointListBuilder; import openperipheral.addons.glasses.utils.IPointListBuilder; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.method.ScriptObject; package openperipheral.addons.glasses.drawable; @ScriptObject @AdapterSourceName("glasses_gradient_line_strip")
public class GradientLineStrip extends LineStrip<ColorPoint2d> {
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/glasses/drawable/GradientLineStrip.java
// Path: src/main/java/openperipheral/addons/glasses/utils/ColorPoint2d.java // @ScriptStruct // @SerializableClass // public class ColorPoint2d { // // public static final ColorPoint2d NULL = new ColorPoint2d(0, 0, 0, 0.0f); // // public ColorPoint2d() {} // // public ColorPoint2d(float x, float y, int rgb, float opacity) { // this.x = x; // this.y = y; // this.rgb = rgb; // this.opacity = opacity; // } // // @Serialize // @StructField(index = 0) // public float x; // // @Serialize // @StructField(index = 1) // public float y; // // @Serialize // @StructField(index = 2, optional = true) // public int rgb = 0xFFFFFF; // // @Serialize // @StructField(index = 3, optional = true) // public float opacity = 1; // // @Override // public String toString() { // return String.format("(%f,%f %06X:%.2f", x, y, rgb, opacity); // } // // } // // Path: src/main/java/openperipheral/addons/glasses/utils/ColorPointListBuilder.java // public class ColorPointListBuilder implements IPointListBuilder<ColorPoint2d> { // // private static class PointListImpl extends PointList<ColorPoint2d> { // // public PointListImpl(List<ColorPoint2d> points) { // super(points); // } // // @Override // protected void drawPoint(RenderState renderState, ColorPoint2d p) { // renderState.setColor(p.rgb, p.opacity); // GL11.glVertex2f(p.x, p.y); // } // // } // // private final List<ColorPoint2d> points = Lists.newArrayList(); // // private final BoundingBoxBuilder bbBuilder = BoundingBoxBuilder.create(); // // @Override // public void add(ColorPoint2d point) { // bbBuilder.addPoint(point.x, point.y); // points.add(point); // } // // private static ColorPoint2d toBoundingBox(Box2d bb, ColorPoint2d point) { // return new ColorPoint2d(point.x - bb.left, point.y - bb.top, point.rgb, point.opacity); // } // // @Override // public IPointList<ColorPoint2d> buildPointList() { // final Box2d bb = bbBuilder.build(); // // List<ColorPoint2d> relPoints = Lists.newArrayList(); // for (ColorPoint2d p : points) // relPoints.add(toBoundingBox(bb, p)); // // return new PointListImpl(relPoints); // } // // @Override // public Box2d buildBoundingBox() { // return bbBuilder.build(); // } // } // // Path: src/main/java/openperipheral/addons/glasses/utils/IPointListBuilder.java // public interface IPointListBuilder<P> { // public void add(P point); // // public IPointList<P> buildPointList(); // // public Box2d buildBoundingBox(); // }
import openperipheral.addons.glasses.utils.ColorPoint2d; import openperipheral.addons.glasses.utils.ColorPointListBuilder; import openperipheral.addons.glasses.utils.IPointListBuilder; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.method.ScriptObject;
package openperipheral.addons.glasses.drawable; @ScriptObject @AdapterSourceName("glasses_gradient_line_strip") public class GradientLineStrip extends LineStrip<ColorPoint2d> { public GradientLineStrip() {} public GradientLineStrip(ColorPoint2d... points) { super(points); } @Override
// Path: src/main/java/openperipheral/addons/glasses/utils/ColorPoint2d.java // @ScriptStruct // @SerializableClass // public class ColorPoint2d { // // public static final ColorPoint2d NULL = new ColorPoint2d(0, 0, 0, 0.0f); // // public ColorPoint2d() {} // // public ColorPoint2d(float x, float y, int rgb, float opacity) { // this.x = x; // this.y = y; // this.rgb = rgb; // this.opacity = opacity; // } // // @Serialize // @StructField(index = 0) // public float x; // // @Serialize // @StructField(index = 1) // public float y; // // @Serialize // @StructField(index = 2, optional = true) // public int rgb = 0xFFFFFF; // // @Serialize // @StructField(index = 3, optional = true) // public float opacity = 1; // // @Override // public String toString() { // return String.format("(%f,%f %06X:%.2f", x, y, rgb, opacity); // } // // } // // Path: src/main/java/openperipheral/addons/glasses/utils/ColorPointListBuilder.java // public class ColorPointListBuilder implements IPointListBuilder<ColorPoint2d> { // // private static class PointListImpl extends PointList<ColorPoint2d> { // // public PointListImpl(List<ColorPoint2d> points) { // super(points); // } // // @Override // protected void drawPoint(RenderState renderState, ColorPoint2d p) { // renderState.setColor(p.rgb, p.opacity); // GL11.glVertex2f(p.x, p.y); // } // // } // // private final List<ColorPoint2d> points = Lists.newArrayList(); // // private final BoundingBoxBuilder bbBuilder = BoundingBoxBuilder.create(); // // @Override // public void add(ColorPoint2d point) { // bbBuilder.addPoint(point.x, point.y); // points.add(point); // } // // private static ColorPoint2d toBoundingBox(Box2d bb, ColorPoint2d point) { // return new ColorPoint2d(point.x - bb.left, point.y - bb.top, point.rgb, point.opacity); // } // // @Override // public IPointList<ColorPoint2d> buildPointList() { // final Box2d bb = bbBuilder.build(); // // List<ColorPoint2d> relPoints = Lists.newArrayList(); // for (ColorPoint2d p : points) // relPoints.add(toBoundingBox(bb, p)); // // return new PointListImpl(relPoints); // } // // @Override // public Box2d buildBoundingBox() { // return bbBuilder.build(); // } // } // // Path: src/main/java/openperipheral/addons/glasses/utils/IPointListBuilder.java // public interface IPointListBuilder<P> { // public void add(P point); // // public IPointList<P> buildPointList(); // // public Box2d buildBoundingBox(); // } // Path: src/main/java/openperipheral/addons/glasses/drawable/GradientLineStrip.java import openperipheral.addons.glasses.utils.ColorPoint2d; import openperipheral.addons.glasses.utils.ColorPointListBuilder; import openperipheral.addons.glasses.utils.IPointListBuilder; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.method.ScriptObject; package openperipheral.addons.glasses.drawable; @ScriptObject @AdapterSourceName("glasses_gradient_line_strip") public class GradientLineStrip extends LineStrip<ColorPoint2d> { public GradientLineStrip() {} public GradientLineStrip(ColorPoint2d... points) { super(points); } @Override
protected IPointListBuilder<ColorPoint2d> createBuilder() {
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/glasses/drawable/GradientLineStrip.java
// Path: src/main/java/openperipheral/addons/glasses/utils/ColorPoint2d.java // @ScriptStruct // @SerializableClass // public class ColorPoint2d { // // public static final ColorPoint2d NULL = new ColorPoint2d(0, 0, 0, 0.0f); // // public ColorPoint2d() {} // // public ColorPoint2d(float x, float y, int rgb, float opacity) { // this.x = x; // this.y = y; // this.rgb = rgb; // this.opacity = opacity; // } // // @Serialize // @StructField(index = 0) // public float x; // // @Serialize // @StructField(index = 1) // public float y; // // @Serialize // @StructField(index = 2, optional = true) // public int rgb = 0xFFFFFF; // // @Serialize // @StructField(index = 3, optional = true) // public float opacity = 1; // // @Override // public String toString() { // return String.format("(%f,%f %06X:%.2f", x, y, rgb, opacity); // } // // } // // Path: src/main/java/openperipheral/addons/glasses/utils/ColorPointListBuilder.java // public class ColorPointListBuilder implements IPointListBuilder<ColorPoint2d> { // // private static class PointListImpl extends PointList<ColorPoint2d> { // // public PointListImpl(List<ColorPoint2d> points) { // super(points); // } // // @Override // protected void drawPoint(RenderState renderState, ColorPoint2d p) { // renderState.setColor(p.rgb, p.opacity); // GL11.glVertex2f(p.x, p.y); // } // // } // // private final List<ColorPoint2d> points = Lists.newArrayList(); // // private final BoundingBoxBuilder bbBuilder = BoundingBoxBuilder.create(); // // @Override // public void add(ColorPoint2d point) { // bbBuilder.addPoint(point.x, point.y); // points.add(point); // } // // private static ColorPoint2d toBoundingBox(Box2d bb, ColorPoint2d point) { // return new ColorPoint2d(point.x - bb.left, point.y - bb.top, point.rgb, point.opacity); // } // // @Override // public IPointList<ColorPoint2d> buildPointList() { // final Box2d bb = bbBuilder.build(); // // List<ColorPoint2d> relPoints = Lists.newArrayList(); // for (ColorPoint2d p : points) // relPoints.add(toBoundingBox(bb, p)); // // return new PointListImpl(relPoints); // } // // @Override // public Box2d buildBoundingBox() { // return bbBuilder.build(); // } // } // // Path: src/main/java/openperipheral/addons/glasses/utils/IPointListBuilder.java // public interface IPointListBuilder<P> { // public void add(P point); // // public IPointList<P> buildPointList(); // // public Box2d buildBoundingBox(); // }
import openperipheral.addons.glasses.utils.ColorPoint2d; import openperipheral.addons.glasses.utils.ColorPointListBuilder; import openperipheral.addons.glasses.utils.IPointListBuilder; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.method.ScriptObject;
package openperipheral.addons.glasses.drawable; @ScriptObject @AdapterSourceName("glasses_gradient_line_strip") public class GradientLineStrip extends LineStrip<ColorPoint2d> { public GradientLineStrip() {} public GradientLineStrip(ColorPoint2d... points) { super(points); } @Override protected IPointListBuilder<ColorPoint2d> createBuilder() {
// Path: src/main/java/openperipheral/addons/glasses/utils/ColorPoint2d.java // @ScriptStruct // @SerializableClass // public class ColorPoint2d { // // public static final ColorPoint2d NULL = new ColorPoint2d(0, 0, 0, 0.0f); // // public ColorPoint2d() {} // // public ColorPoint2d(float x, float y, int rgb, float opacity) { // this.x = x; // this.y = y; // this.rgb = rgb; // this.opacity = opacity; // } // // @Serialize // @StructField(index = 0) // public float x; // // @Serialize // @StructField(index = 1) // public float y; // // @Serialize // @StructField(index = 2, optional = true) // public int rgb = 0xFFFFFF; // // @Serialize // @StructField(index = 3, optional = true) // public float opacity = 1; // // @Override // public String toString() { // return String.format("(%f,%f %06X:%.2f", x, y, rgb, opacity); // } // // } // // Path: src/main/java/openperipheral/addons/glasses/utils/ColorPointListBuilder.java // public class ColorPointListBuilder implements IPointListBuilder<ColorPoint2d> { // // private static class PointListImpl extends PointList<ColorPoint2d> { // // public PointListImpl(List<ColorPoint2d> points) { // super(points); // } // // @Override // protected void drawPoint(RenderState renderState, ColorPoint2d p) { // renderState.setColor(p.rgb, p.opacity); // GL11.glVertex2f(p.x, p.y); // } // // } // // private final List<ColorPoint2d> points = Lists.newArrayList(); // // private final BoundingBoxBuilder bbBuilder = BoundingBoxBuilder.create(); // // @Override // public void add(ColorPoint2d point) { // bbBuilder.addPoint(point.x, point.y); // points.add(point); // } // // private static ColorPoint2d toBoundingBox(Box2d bb, ColorPoint2d point) { // return new ColorPoint2d(point.x - bb.left, point.y - bb.top, point.rgb, point.opacity); // } // // @Override // public IPointList<ColorPoint2d> buildPointList() { // final Box2d bb = bbBuilder.build(); // // List<ColorPoint2d> relPoints = Lists.newArrayList(); // for (ColorPoint2d p : points) // relPoints.add(toBoundingBox(bb, p)); // // return new PointListImpl(relPoints); // } // // @Override // public Box2d buildBoundingBox() { // return bbBuilder.build(); // } // } // // Path: src/main/java/openperipheral/addons/glasses/utils/IPointListBuilder.java // public interface IPointListBuilder<P> { // public void add(P point); // // public IPointList<P> buildPointList(); // // public Box2d buildBoundingBox(); // } // Path: src/main/java/openperipheral/addons/glasses/drawable/GradientLineStrip.java import openperipheral.addons.glasses.utils.ColorPoint2d; import openperipheral.addons.glasses.utils.ColorPointListBuilder; import openperipheral.addons.glasses.utils.IPointListBuilder; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.method.ScriptObject; package openperipheral.addons.glasses.drawable; @ScriptObject @AdapterSourceName("glasses_gradient_line_strip") public class GradientLineStrip extends LineStrip<ColorPoint2d> { public GradientLineStrip() {} public GradientLineStrip(ColorPoint2d... points) { super(points); } @Override protected IPointListBuilder<ColorPoint2d> createBuilder() {
return new ColorPointListBuilder();
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/glasses/server/SurfaceServer.java
// Path: src/main/java/openperipheral/addons/glasses/IContainer.java // @Asynchronous // @AdapterSourceName("glasses_container") // public interface IContainer<E> extends IClearable { // // public E addObject(E drawable); // // @Alias("getObjectById") // @ScriptCallable(returnTypes = ReturnType.OBJECT, description = "Get object by id") // public E getById(@Arg(name = "id", description = "Id of drawed object") Index id); // // @ScriptCallable(returnTypes = ReturnType.TABLE, description = "Get the ids of all the objects") // public Set<Index> getAllIds(@Env(Constants.ARG_ARCHITECTURE) IArchitecture access); // // @ScriptCallable(returnTypes = ReturnType.TABLE, description = "Get all objects") // public Map<Index, E> getAllObjects(@Env(Constants.ARG_ARCHITECTURE) IArchitecture access); // }
import openmods.include.IncludeInterface; import openperipheral.addons.glasses.IContainer; import openperipheral.api.adapter.method.ScriptObject;
package openperipheral.addons.glasses.server; @ScriptObject public class SurfaceServer {
// Path: src/main/java/openperipheral/addons/glasses/IContainer.java // @Asynchronous // @AdapterSourceName("glasses_container") // public interface IContainer<E> extends IClearable { // // public E addObject(E drawable); // // @Alias("getObjectById") // @ScriptCallable(returnTypes = ReturnType.OBJECT, description = "Get object by id") // public E getById(@Arg(name = "id", description = "Id of drawed object") Index id); // // @ScriptCallable(returnTypes = ReturnType.TABLE, description = "Get the ids of all the objects") // public Set<Index> getAllIds(@Env(Constants.ARG_ARCHITECTURE) IArchitecture access); // // @ScriptCallable(returnTypes = ReturnType.TABLE, description = "Get all objects") // public Map<Index, E> getAllObjects(@Env(Constants.ARG_ARCHITECTURE) IArchitecture access); // } // Path: src/main/java/openperipheral/addons/glasses/server/SurfaceServer.java import openmods.include.IncludeInterface; import openperipheral.addons.glasses.IContainer; import openperipheral.api.adapter.method.ScriptObject; package openperipheral.addons.glasses.server; @ScriptObject public class SurfaceServer {
@IncludeInterface(IContainer.class)
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/glasses/NbtGuidProviders.java
// Path: src/main/java/openperipheral/addons/glasses/TerminalIdAccess.java // abstract static class HandSetterAdapter implements ITerminalIdSetter { // @Override // public boolean setFor(EntityPlayer player, long guid) { // final ItemStack stack = player.getHeldItem(); // return stack != null? setFor(stack, guid) : false; // } // // protected abstract boolean setFor(ItemStack helmet, long guid); // // @Override // public int getPriority() { // return 0; // } // } // // Path: src/main/java/openperipheral/addons/glasses/TerminalIdAccess.java // abstract static class HelmetGetterAdapter implements ITerminalIdGetter { // @Override // public Optional<Long> getFor(EntityPlayer player) { // final ItemStack stack = TerminalUtils.getHeadSlot(player); // return stack != null? getFor(stack) : Optional.<Long> absent(); // } // // protected abstract Optional<Long> getFor(ItemStack helmet); // // @Override // public int getPriority() { // return 0; // } // }
import com.google.common.base.Optional; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.Constants; import openmods.utils.ItemUtils; import openperipheral.addons.glasses.TerminalIdAccess.HandSetterAdapter; import openperipheral.addons.glasses.TerminalIdAccess.HelmetGetterAdapter;
package openperipheral.addons.glasses; public class NbtGuidProviders { private static final String MAIN_TAG = "OPA-Terminal"; private static final String GUID_TAG = "Guid";
// Path: src/main/java/openperipheral/addons/glasses/TerminalIdAccess.java // abstract static class HandSetterAdapter implements ITerminalIdSetter { // @Override // public boolean setFor(EntityPlayer player, long guid) { // final ItemStack stack = player.getHeldItem(); // return stack != null? setFor(stack, guid) : false; // } // // protected abstract boolean setFor(ItemStack helmet, long guid); // // @Override // public int getPriority() { // return 0; // } // } // // Path: src/main/java/openperipheral/addons/glasses/TerminalIdAccess.java // abstract static class HelmetGetterAdapter implements ITerminalIdGetter { // @Override // public Optional<Long> getFor(EntityPlayer player) { // final ItemStack stack = TerminalUtils.getHeadSlot(player); // return stack != null? getFor(stack) : Optional.<Long> absent(); // } // // protected abstract Optional<Long> getFor(ItemStack helmet); // // @Override // public int getPriority() { // return 0; // } // } // Path: src/main/java/openperipheral/addons/glasses/NbtGuidProviders.java import com.google.common.base.Optional; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.Constants; import openmods.utils.ItemUtils; import openperipheral.addons.glasses.TerminalIdAccess.HandSetterAdapter; import openperipheral.addons.glasses.TerminalIdAccess.HelmetGetterAdapter; package openperipheral.addons.glasses; public class NbtGuidProviders { private static final String MAIN_TAG = "OPA-Terminal"; private static final String GUID_TAG = "Guid";
public static class NbtGetter extends HelmetGetterAdapter {
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/glasses/NbtGuidProviders.java
// Path: src/main/java/openperipheral/addons/glasses/TerminalIdAccess.java // abstract static class HandSetterAdapter implements ITerminalIdSetter { // @Override // public boolean setFor(EntityPlayer player, long guid) { // final ItemStack stack = player.getHeldItem(); // return stack != null? setFor(stack, guid) : false; // } // // protected abstract boolean setFor(ItemStack helmet, long guid); // // @Override // public int getPriority() { // return 0; // } // } // // Path: src/main/java/openperipheral/addons/glasses/TerminalIdAccess.java // abstract static class HelmetGetterAdapter implements ITerminalIdGetter { // @Override // public Optional<Long> getFor(EntityPlayer player) { // final ItemStack stack = TerminalUtils.getHeadSlot(player); // return stack != null? getFor(stack) : Optional.<Long> absent(); // } // // protected abstract Optional<Long> getFor(ItemStack helmet); // // @Override // public int getPriority() { // return 0; // } // }
import com.google.common.base.Optional; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.Constants; import openmods.utils.ItemUtils; import openperipheral.addons.glasses.TerminalIdAccess.HandSetterAdapter; import openperipheral.addons.glasses.TerminalIdAccess.HelmetGetterAdapter;
package openperipheral.addons.glasses; public class NbtGuidProviders { private static final String MAIN_TAG = "OPA-Terminal"; private static final String GUID_TAG = "Guid"; public static class NbtGetter extends HelmetGetterAdapter { @Override public Optional<Long> getFor(ItemStack stack) { return getTerminalGuid(stack); } }
// Path: src/main/java/openperipheral/addons/glasses/TerminalIdAccess.java // abstract static class HandSetterAdapter implements ITerminalIdSetter { // @Override // public boolean setFor(EntityPlayer player, long guid) { // final ItemStack stack = player.getHeldItem(); // return stack != null? setFor(stack, guid) : false; // } // // protected abstract boolean setFor(ItemStack helmet, long guid); // // @Override // public int getPriority() { // return 0; // } // } // // Path: src/main/java/openperipheral/addons/glasses/TerminalIdAccess.java // abstract static class HelmetGetterAdapter implements ITerminalIdGetter { // @Override // public Optional<Long> getFor(EntityPlayer player) { // final ItemStack stack = TerminalUtils.getHeadSlot(player); // return stack != null? getFor(stack) : Optional.<Long> absent(); // } // // protected abstract Optional<Long> getFor(ItemStack helmet); // // @Override // public int getPriority() { // return 0; // } // } // Path: src/main/java/openperipheral/addons/glasses/NbtGuidProviders.java import com.google.common.base.Optional; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.Constants; import openmods.utils.ItemUtils; import openperipheral.addons.glasses.TerminalIdAccess.HandSetterAdapter; import openperipheral.addons.glasses.TerminalIdAccess.HelmetGetterAdapter; package openperipheral.addons.glasses; public class NbtGuidProviders { private static final String MAIN_TAG = "OPA-Terminal"; private static final String GUID_TAG = "Guid"; public static class NbtGetter extends HelmetGetterAdapter { @Override public Optional<Long> getFor(ItemStack stack) { return getTerminalGuid(stack); } }
public static class NbtSetter extends HandSetterAdapter {
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/narcissistic/TurtleUpgradeNarcissistic.java
// Path: src/main/java/openperipheral/addons/MetasGeneric.java // public enum MetasGeneric { // duckAntenna { // @Override // public IMetaItem createMetaItem() { // ItemStack result = newItemStack(); // return new MetaGeneric("duckantenna", // new ShapelessOreRecipe(result, Items.redstone, Items.redstone, Items.iron_ingot, Items.slime_ball)) { // @Override // public void addToCreativeList(Item item, int meta, List<ItemStack> result) { // super.addToCreativeList(item, meta, result); // if (Config.addTurtlesToCreative && Loader.isModLoaded(Mods.COMPUTERCRAFT)) ModuleComputerCraft.listNarcissisticTurtles(result); // } // }; // } // }; // // public ItemStack newItemStack(int size) { // return new ItemStack(OpenPeripheralAddons.Items.generic, size, ordinal()); // } // // public ItemStack newItemStack() { // return new ItemStack(OpenPeripheralAddons.Items.generic, 1, ordinal()); // } // // public boolean isA(ItemStack stack) { // return (stack.getItem() instanceof ItemOPGeneric) && (stack.getItemDamage() == ordinal()); // } // // protected abstract IMetaItem createMetaItem(); // // protected boolean isEnabled() { // return true; // } // // public static void registerItems() { // for (MetasGeneric m : values()) // if (m.isEnabled()) OpenPeripheralAddons.Items.generic.registerItem(m.ordinal(), m.createMetaItem()); // } // } // // Path: src/main/java/openperipheral/addons/ModuleComputerCraft.java // public static class Icons { // public static IIcon sensorTurtle; // public static IIcon narcissiticTurtle; // }
import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.turtle.ITurtleAccess; import dan200.computercraft.api.turtle.ITurtleUpgrade; import dan200.computercraft.api.turtle.TurtleCommandResult; import dan200.computercraft.api.turtle.TurtleSide; import dan200.computercraft.api.turtle.TurtleUpgradeType; import dan200.computercraft.api.turtle.TurtleVerb; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import openperipheral.addons.MetasGeneric; import openperipheral.addons.ModuleComputerCraft.Icons; import openperipheral.api.ApiAccess; import openperipheral.api.architecture.cc.IComputerCraftObjectsFactory;
package openperipheral.addons.narcissistic; public class TurtleUpgradeNarcissistic implements ITurtleUpgrade { @Override public int getUpgradeID() { return 181; } @Override public String getUnlocalisedAdjective() { return "openperipheral.turtle.narcissistic.adjective"; } @Override public TurtleUpgradeType getType() { return TurtleUpgradeType.Peripheral; } @Override public ItemStack getCraftingItem() {
// Path: src/main/java/openperipheral/addons/MetasGeneric.java // public enum MetasGeneric { // duckAntenna { // @Override // public IMetaItem createMetaItem() { // ItemStack result = newItemStack(); // return new MetaGeneric("duckantenna", // new ShapelessOreRecipe(result, Items.redstone, Items.redstone, Items.iron_ingot, Items.slime_ball)) { // @Override // public void addToCreativeList(Item item, int meta, List<ItemStack> result) { // super.addToCreativeList(item, meta, result); // if (Config.addTurtlesToCreative && Loader.isModLoaded(Mods.COMPUTERCRAFT)) ModuleComputerCraft.listNarcissisticTurtles(result); // } // }; // } // }; // // public ItemStack newItemStack(int size) { // return new ItemStack(OpenPeripheralAddons.Items.generic, size, ordinal()); // } // // public ItemStack newItemStack() { // return new ItemStack(OpenPeripheralAddons.Items.generic, 1, ordinal()); // } // // public boolean isA(ItemStack stack) { // return (stack.getItem() instanceof ItemOPGeneric) && (stack.getItemDamage() == ordinal()); // } // // protected abstract IMetaItem createMetaItem(); // // protected boolean isEnabled() { // return true; // } // // public static void registerItems() { // for (MetasGeneric m : values()) // if (m.isEnabled()) OpenPeripheralAddons.Items.generic.registerItem(m.ordinal(), m.createMetaItem()); // } // } // // Path: src/main/java/openperipheral/addons/ModuleComputerCraft.java // public static class Icons { // public static IIcon sensorTurtle; // public static IIcon narcissiticTurtle; // } // Path: src/main/java/openperipheral/addons/narcissistic/TurtleUpgradeNarcissistic.java import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.turtle.ITurtleAccess; import dan200.computercraft.api.turtle.ITurtleUpgrade; import dan200.computercraft.api.turtle.TurtleCommandResult; import dan200.computercraft.api.turtle.TurtleSide; import dan200.computercraft.api.turtle.TurtleUpgradeType; import dan200.computercraft.api.turtle.TurtleVerb; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import openperipheral.addons.MetasGeneric; import openperipheral.addons.ModuleComputerCraft.Icons; import openperipheral.api.ApiAccess; import openperipheral.api.architecture.cc.IComputerCraftObjectsFactory; package openperipheral.addons.narcissistic; public class TurtleUpgradeNarcissistic implements ITurtleUpgrade { @Override public int getUpgradeID() { return 181; } @Override public String getUnlocalisedAdjective() { return "openperipheral.turtle.narcissistic.adjective"; } @Override public TurtleUpgradeType getType() { return TurtleUpgradeType.Peripheral; } @Override public ItemStack getCraftingItem() {
return MetasGeneric.duckAntenna.newItemStack();
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/narcissistic/TurtleUpgradeNarcissistic.java
// Path: src/main/java/openperipheral/addons/MetasGeneric.java // public enum MetasGeneric { // duckAntenna { // @Override // public IMetaItem createMetaItem() { // ItemStack result = newItemStack(); // return new MetaGeneric("duckantenna", // new ShapelessOreRecipe(result, Items.redstone, Items.redstone, Items.iron_ingot, Items.slime_ball)) { // @Override // public void addToCreativeList(Item item, int meta, List<ItemStack> result) { // super.addToCreativeList(item, meta, result); // if (Config.addTurtlesToCreative && Loader.isModLoaded(Mods.COMPUTERCRAFT)) ModuleComputerCraft.listNarcissisticTurtles(result); // } // }; // } // }; // // public ItemStack newItemStack(int size) { // return new ItemStack(OpenPeripheralAddons.Items.generic, size, ordinal()); // } // // public ItemStack newItemStack() { // return new ItemStack(OpenPeripheralAddons.Items.generic, 1, ordinal()); // } // // public boolean isA(ItemStack stack) { // return (stack.getItem() instanceof ItemOPGeneric) && (stack.getItemDamage() == ordinal()); // } // // protected abstract IMetaItem createMetaItem(); // // protected boolean isEnabled() { // return true; // } // // public static void registerItems() { // for (MetasGeneric m : values()) // if (m.isEnabled()) OpenPeripheralAddons.Items.generic.registerItem(m.ordinal(), m.createMetaItem()); // } // } // // Path: src/main/java/openperipheral/addons/ModuleComputerCraft.java // public static class Icons { // public static IIcon sensorTurtle; // public static IIcon narcissiticTurtle; // }
import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.turtle.ITurtleAccess; import dan200.computercraft.api.turtle.ITurtleUpgrade; import dan200.computercraft.api.turtle.TurtleCommandResult; import dan200.computercraft.api.turtle.TurtleSide; import dan200.computercraft.api.turtle.TurtleUpgradeType; import dan200.computercraft.api.turtle.TurtleVerb; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import openperipheral.addons.MetasGeneric; import openperipheral.addons.ModuleComputerCraft.Icons; import openperipheral.api.ApiAccess; import openperipheral.api.architecture.cc.IComputerCraftObjectsFactory;
package openperipheral.addons.narcissistic; public class TurtleUpgradeNarcissistic implements ITurtleUpgrade { @Override public int getUpgradeID() { return 181; } @Override public String getUnlocalisedAdjective() { return "openperipheral.turtle.narcissistic.adjective"; } @Override public TurtleUpgradeType getType() { return TurtleUpgradeType.Peripheral; } @Override public ItemStack getCraftingItem() { return MetasGeneric.duckAntenna.newItemStack(); } @Override public IPeripheral createPeripheral(ITurtleAccess turtle, TurtleSide side) { return ApiAccess.getApi(IComputerCraftObjectsFactory.class).createPeripheral(new TurtleInventoryDelegate(turtle)); } @Override public TurtleCommandResult useTool(ITurtleAccess turtle, TurtleSide side, TurtleVerb verb, int direction) { return null; } @Override public IIcon getIcon(ITurtleAccess turtle, TurtleSide side) {
// Path: src/main/java/openperipheral/addons/MetasGeneric.java // public enum MetasGeneric { // duckAntenna { // @Override // public IMetaItem createMetaItem() { // ItemStack result = newItemStack(); // return new MetaGeneric("duckantenna", // new ShapelessOreRecipe(result, Items.redstone, Items.redstone, Items.iron_ingot, Items.slime_ball)) { // @Override // public void addToCreativeList(Item item, int meta, List<ItemStack> result) { // super.addToCreativeList(item, meta, result); // if (Config.addTurtlesToCreative && Loader.isModLoaded(Mods.COMPUTERCRAFT)) ModuleComputerCraft.listNarcissisticTurtles(result); // } // }; // } // }; // // public ItemStack newItemStack(int size) { // return new ItemStack(OpenPeripheralAddons.Items.generic, size, ordinal()); // } // // public ItemStack newItemStack() { // return new ItemStack(OpenPeripheralAddons.Items.generic, 1, ordinal()); // } // // public boolean isA(ItemStack stack) { // return (stack.getItem() instanceof ItemOPGeneric) && (stack.getItemDamage() == ordinal()); // } // // protected abstract IMetaItem createMetaItem(); // // protected boolean isEnabled() { // return true; // } // // public static void registerItems() { // for (MetasGeneric m : values()) // if (m.isEnabled()) OpenPeripheralAddons.Items.generic.registerItem(m.ordinal(), m.createMetaItem()); // } // } // // Path: src/main/java/openperipheral/addons/ModuleComputerCraft.java // public static class Icons { // public static IIcon sensorTurtle; // public static IIcon narcissiticTurtle; // } // Path: src/main/java/openperipheral/addons/narcissistic/TurtleUpgradeNarcissistic.java import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.turtle.ITurtleAccess; import dan200.computercraft.api.turtle.ITurtleUpgrade; import dan200.computercraft.api.turtle.TurtleCommandResult; import dan200.computercraft.api.turtle.TurtleSide; import dan200.computercraft.api.turtle.TurtleUpgradeType; import dan200.computercraft.api.turtle.TurtleVerb; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import openperipheral.addons.MetasGeneric; import openperipheral.addons.ModuleComputerCraft.Icons; import openperipheral.api.ApiAccess; import openperipheral.api.architecture.cc.IComputerCraftObjectsFactory; package openperipheral.addons.narcissistic; public class TurtleUpgradeNarcissistic implements ITurtleUpgrade { @Override public int getUpgradeID() { return 181; } @Override public String getUnlocalisedAdjective() { return "openperipheral.turtle.narcissistic.adjective"; } @Override public TurtleUpgradeType getType() { return TurtleUpgradeType.Peripheral; } @Override public ItemStack getCraftingItem() { return MetasGeneric.duckAntenna.newItemStack(); } @Override public IPeripheral createPeripheral(ITurtleAccess turtle, TurtleSide side) { return ApiAccess.getApi(IComputerCraftObjectsFactory.class).createPeripheral(new TurtleInventoryDelegate(turtle)); } @Override public TurtleCommandResult useTool(ITurtleAccess turtle, TurtleSide side, TurtleVerb verb, int direction) { return null; } @Override public IIcon getIcon(ITurtleAccess turtle, TurtleSide side) {
return Icons.narcissiticTurtle;
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/selector/TileEntitySelectorRenderer.java
// Path: src/main/java/openperipheral/addons/selector/TileEntitySelector.java // public static class ItemSlot { // public final int slot; // public final double x; // public final double y; // public final AxisAlignedBB box; // public final double size; // // public ItemSlot(int absSlot, double size, double x, double y) { // this.slot = absSlot; // this.size = size; // this.x = x; // this.y = y; // this.box = AxisAlignedBB.getBoundingBox(x - size, 1 - size, y - size, x + size, 1 + size, y + size); // } // }
import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import openmods.geometry.Orientation; import openmods.renderer.rotations.TransformProvider; import openperipheral.addons.selector.TileEntitySelector.ItemSlot; import org.lwjgl.opengl.GL11;
package openperipheral.addons.selector; public class TileEntitySelectorRenderer extends TileEntitySpecialRenderer { private final RenderItem renderer = new RenderItem() { @Override public boolean shouldSpreadItems() { return false; } @Override public boolean shouldBob() { return false; } @Override public byte getMiniBlockCount(ItemStack stack, byte original) { return 1; } @Override public byte getMiniItemCount(ItemStack stack, byte original) { return 1; } }; @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) { final TileEntitySelector selector = (TileEntitySelector)tileEntity; final Orientation orientation = selector.getOrientation(); GL11.glPushMatrix(); GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); TransformProvider.instance.multMatrix(orientation); GL11.glTranslated(-0.5, 0.501, -0.5); // 0.001 offset for 2d items in fast mode final int gridSize = selector.getGridSize(); renderer.setRenderManager(RenderManager.instance);
// Path: src/main/java/openperipheral/addons/selector/TileEntitySelector.java // public static class ItemSlot { // public final int slot; // public final double x; // public final double y; // public final AxisAlignedBB box; // public final double size; // // public ItemSlot(int absSlot, double size, double x, double y) { // this.slot = absSlot; // this.size = size; // this.x = x; // this.y = y; // this.box = AxisAlignedBB.getBoundingBox(x - size, 1 - size, y - size, x + size, 1 + size, y + size); // } // } // Path: src/main/java/openperipheral/addons/selector/TileEntitySelectorRenderer.java import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import openmods.geometry.Orientation; import openmods.renderer.rotations.TransformProvider; import openperipheral.addons.selector.TileEntitySelector.ItemSlot; import org.lwjgl.opengl.GL11; package openperipheral.addons.selector; public class TileEntitySelectorRenderer extends TileEntitySpecialRenderer { private final RenderItem renderer = new RenderItem() { @Override public boolean shouldSpreadItems() { return false; } @Override public boolean shouldBob() { return false; } @Override public byte getMiniBlockCount(ItemStack stack, byte original) { return 1; } @Override public byte getMiniItemCount(ItemStack stack, byte original) { return 1; } }; @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) { final TileEntitySelector selector = (TileEntitySelector)tileEntity; final Orientation orientation = selector.getOrientation(); GL11.glPushMatrix(); GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); TransformProvider.instance.multMatrix(orientation); GL11.glTranslated(-0.5, 0.501, -0.5); // 0.001 offset for 2d items in fast mode final int gridSize = selector.getGridSize(); renderer.setRenderManager(RenderManager.instance);
for (ItemSlot slot : selector.getSlots(gridSize)) {
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/glasses/TerminalEvent.java
// Path: src/main/java/openperipheral/addons/glasses/client/SurfaceClient.java // public abstract class SurfaceClient { // // private static final Comparator<Drawable> COMPARATOR = new Comparator<Drawable>() { // @Override // public int compare(Drawable o1, Drawable o2) { // return Ints.compare(o1.z, o2.z); // } // }; // // private class SurfaceClientObserver extends StructureObserver<Drawable, IStructureElement> { // private final List<Drawable> sortedElements = Lists.newArrayList(); // // private final List<Drawable> sortedElementsView; // // public SurfaceClientObserver() { // this.sortedElementsView = Collections.unmodifiableList(sortedElements); // } // // @Override // public void onContainerAdded(int containerId, Drawable container) { // container.setId(containerId); // sortedElements.add(container); // } // // @Override // public void onContainerRemoved(int containerId, Drawable container) { // sortedElements.remove(container); // } // // @Override // public void onContainerUpdated(int containerId, Drawable container) { // container.onUpdate(); // } // // @Override // public void onStructureUpdate() { // Collections.sort(sortedElements, COMPARATOR); // } // // @Override // public void onDataUpdate() { // Collections.sort(sortedElements, COMPARATOR); // } // } // // public final DrawableContainerSlave drawablesContainer; // // private final SurfaceClientObserver surfaceObserver = new SurfaceClientObserver(); // // private SurfaceClient(long guid) { // this.drawablesContainer = createDrawableContainer(guid, surfaceObserver); // // } // // protected abstract DrawableContainerSlave createDrawableContainer(long guid, StructureObserver<Drawable, IStructureElement> observer); // // public static SurfaceClient createPublicSurface(long guid) { // return new SurfaceClient(guid) { // @Override // protected DrawableContainerSlave createDrawableContainer(long guid, StructureObserver<Drawable, IStructureElement> observer) { // return new DrawableContainerSlave.Public(guid, observer); // } // }; // } // // public static SurfaceClient createPrivateSurface(long guid) { // return new SurfaceClient(guid) { // @Override // protected DrawableContainerSlave createDrawableContainer(long guid, StructureObserver<Drawable, IStructureElement> observer) { // return new DrawableContainerSlave.Private(guid, observer); // } // }; // } // // public List<Drawable> getSortedDrawables() { // return surfaceObserver.sortedElementsView; // } // }
import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; import java.util.List; import openmods.network.event.EventDirection; import openmods.network.event.NetworkEvent; import openmods.network.event.NetworkEventMeta; import openmods.structured.Command.CommandList; import openperipheral.addons.glasses.client.SurfaceClient;
} } public abstract static class Data extends TerminalEvent { public final CommandList commands = new CommandList(); public Data() {} public Data(long terminalId) { super(terminalId); } @Override protected void readFromStream(DataInput input) throws IOException { super.readFromStream(input); commands.readFromStream(input); } @Override protected void writeToStream(DataOutput output) throws IOException { super.writeToStream(output); commands.writeToStream(output); } @Override protected void appendLogInfo(List<String> info) { super.appendLogInfo(info); info.add(Integer.toString(commands.size())); }
// Path: src/main/java/openperipheral/addons/glasses/client/SurfaceClient.java // public abstract class SurfaceClient { // // private static final Comparator<Drawable> COMPARATOR = new Comparator<Drawable>() { // @Override // public int compare(Drawable o1, Drawable o2) { // return Ints.compare(o1.z, o2.z); // } // }; // // private class SurfaceClientObserver extends StructureObserver<Drawable, IStructureElement> { // private final List<Drawable> sortedElements = Lists.newArrayList(); // // private final List<Drawable> sortedElementsView; // // public SurfaceClientObserver() { // this.sortedElementsView = Collections.unmodifiableList(sortedElements); // } // // @Override // public void onContainerAdded(int containerId, Drawable container) { // container.setId(containerId); // sortedElements.add(container); // } // // @Override // public void onContainerRemoved(int containerId, Drawable container) { // sortedElements.remove(container); // } // // @Override // public void onContainerUpdated(int containerId, Drawable container) { // container.onUpdate(); // } // // @Override // public void onStructureUpdate() { // Collections.sort(sortedElements, COMPARATOR); // } // // @Override // public void onDataUpdate() { // Collections.sort(sortedElements, COMPARATOR); // } // } // // public final DrawableContainerSlave drawablesContainer; // // private final SurfaceClientObserver surfaceObserver = new SurfaceClientObserver(); // // private SurfaceClient(long guid) { // this.drawablesContainer = createDrawableContainer(guid, surfaceObserver); // // } // // protected abstract DrawableContainerSlave createDrawableContainer(long guid, StructureObserver<Drawable, IStructureElement> observer); // // public static SurfaceClient createPublicSurface(long guid) { // return new SurfaceClient(guid) { // @Override // protected DrawableContainerSlave createDrawableContainer(long guid, StructureObserver<Drawable, IStructureElement> observer) { // return new DrawableContainerSlave.Public(guid, observer); // } // }; // } // // public static SurfaceClient createPrivateSurface(long guid) { // return new SurfaceClient(guid) { // @Override // protected DrawableContainerSlave createDrawableContainer(long guid, StructureObserver<Drawable, IStructureElement> observer) { // return new DrawableContainerSlave.Private(guid, observer); // } // }; // } // // public List<Drawable> getSortedDrawables() { // return surfaceObserver.sortedElementsView; // } // } // Path: src/main/java/openperipheral/addons/glasses/TerminalEvent.java import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; import java.util.List; import openmods.network.event.EventDirection; import openmods.network.event.NetworkEvent; import openmods.network.event.NetworkEventMeta; import openmods.structured.Command.CommandList; import openperipheral.addons.glasses.client.SurfaceClient; } } public abstract static class Data extends TerminalEvent { public final CommandList commands = new CommandList(); public Data() {} public Data(long terminalId) { super(terminalId); } @Override protected void readFromStream(DataInput input) throws IOException { super.readFromStream(input); commands.readFromStream(input); } @Override protected void writeToStream(DataOutput output) throws IOException { super.writeToStream(output); commands.writeToStream(output); } @Override protected void appendLogInfo(List<String> info) { super.appendLogInfo(info); info.add(Integer.toString(commands.size())); }
public SurfaceClient createSurface() {
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/glasses/GlassesEvent.java
// Path: src/main/java/openperipheral/addons/utils/GuiUtils.java // public static enum GuiElements { // OVERLAY, // PORTAL, // HOTBAR, // CROSSHAIRS, // BOSS_HEALTH, // HEALTH, // ARMOR, // FOOD, // MOUNT_HEALTH, // AIR, // EXPERIENCE, // JUMP_BAR, // OBJECTIVES; // }
import java.util.Map; import openmods.network.event.EventDirection; import openmods.network.event.NetworkEventMeta; import openmods.network.event.SerializableNetworkEvent; import openmods.serializable.cls.Serialize; import openperipheral.addons.utils.GuiUtils.GuiElements; import openperipheral.api.architecture.IArchitecture;
@Serialize public boolean repeat; public GlassesSetKeyRepeatEvent(long guid, boolean repeat) { super(guid); this.repeat = repeat; } } @NetworkEventMeta(direction = EventDirection.S2C) public static class GlassesSetDragParamsEvent extends GlassesEvent { @Serialize public int period; @Serialize public int threshold; public GlassesSetDragParamsEvent(long guid, int period, int threshold) { super(guid); this.period = period; this.threshold = threshold; } } @NetworkEventMeta(direction = EventDirection.S2C) public static class GlassesSetGuiVisibilityEvent extends GlassesEvent { @Serialize
// Path: src/main/java/openperipheral/addons/utils/GuiUtils.java // public static enum GuiElements { // OVERLAY, // PORTAL, // HOTBAR, // CROSSHAIRS, // BOSS_HEALTH, // HEALTH, // ARMOR, // FOOD, // MOUNT_HEALTH, // AIR, // EXPERIENCE, // JUMP_BAR, // OBJECTIVES; // } // Path: src/main/java/openperipheral/addons/glasses/GlassesEvent.java import java.util.Map; import openmods.network.event.EventDirection; import openmods.network.event.NetworkEventMeta; import openmods.network.event.SerializableNetworkEvent; import openmods.serializable.cls.Serialize; import openperipheral.addons.utils.GuiUtils.GuiElements; import openperipheral.api.architecture.IArchitecture; @Serialize public boolean repeat; public GlassesSetKeyRepeatEvent(long guid, boolean repeat) { super(guid); this.repeat = repeat; } } @NetworkEventMeta(direction = EventDirection.S2C) public static class GlassesSetDragParamsEvent extends GlassesEvent { @Serialize public int period; @Serialize public int threshold; public GlassesSetDragParamsEvent(long guid, int period, int threshold) { super(guid); this.period = period; this.threshold = threshold; } } @NetworkEventMeta(direction = EventDirection.S2C) public static class GlassesSetGuiVisibilityEvent extends GlassesEvent { @Serialize
public Map<GuiElements, Boolean> visibility;
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/glasses/drawable/GradientTriangle.java
// Path: src/main/java/openperipheral/addons/glasses/utils/ColorPoint2d.java // @ScriptStruct // @SerializableClass // public class ColorPoint2d { // // public static final ColorPoint2d NULL = new ColorPoint2d(0, 0, 0, 0.0f); // // public ColorPoint2d() {} // // public ColorPoint2d(float x, float y, int rgb, float opacity) { // this.x = x; // this.y = y; // this.rgb = rgb; // this.opacity = opacity; // } // // @Serialize // @StructField(index = 0) // public float x; // // @Serialize // @StructField(index = 1) // public float y; // // @Serialize // @StructField(index = 2, optional = true) // public int rgb = 0xFFFFFF; // // @Serialize // @StructField(index = 3, optional = true) // public float opacity = 1; // // @Override // public String toString() { // return String.format("(%f,%f %06X:%.2f", x, y, rgb, opacity); // } // // } // // Path: src/main/java/openperipheral/addons/glasses/utils/ColorPointListBuilder.java // public class ColorPointListBuilder implements IPointListBuilder<ColorPoint2d> { // // private static class PointListImpl extends PointList<ColorPoint2d> { // // public PointListImpl(List<ColorPoint2d> points) { // super(points); // } // // @Override // protected void drawPoint(RenderState renderState, ColorPoint2d p) { // renderState.setColor(p.rgb, p.opacity); // GL11.glVertex2f(p.x, p.y); // } // // } // // private final List<ColorPoint2d> points = Lists.newArrayList(); // // private final BoundingBoxBuilder bbBuilder = BoundingBoxBuilder.create(); // // @Override // public void add(ColorPoint2d point) { // bbBuilder.addPoint(point.x, point.y); // points.add(point); // } // // private static ColorPoint2d toBoundingBox(Box2d bb, ColorPoint2d point) { // return new ColorPoint2d(point.x - bb.left, point.y - bb.top, point.rgb, point.opacity); // } // // @Override // public IPointList<ColorPoint2d> buildPointList() { // final Box2d bb = bbBuilder.build(); // // List<ColorPoint2d> relPoints = Lists.newArrayList(); // for (ColorPoint2d p : points) // relPoints.add(toBoundingBox(bb, p)); // // return new PointListImpl(relPoints); // } // // @Override // public Box2d buildBoundingBox() { // return bbBuilder.build(); // } // } // // Path: src/main/java/openperipheral/addons/glasses/utils/IPointListBuilder.java // public interface IPointListBuilder<P> { // public void add(P point); // // public IPointList<P> buildPointList(); // // public Box2d buildBoundingBox(); // }
import openperipheral.addons.glasses.utils.ColorPoint2d; import openperipheral.addons.glasses.utils.ColorPointListBuilder; import openperipheral.addons.glasses.utils.IPointListBuilder; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.method.ScriptObject;
package openperipheral.addons.glasses.drawable; @ScriptObject @AdapterSourceName("glasses_gradient_triangle")
// Path: src/main/java/openperipheral/addons/glasses/utils/ColorPoint2d.java // @ScriptStruct // @SerializableClass // public class ColorPoint2d { // // public static final ColorPoint2d NULL = new ColorPoint2d(0, 0, 0, 0.0f); // // public ColorPoint2d() {} // // public ColorPoint2d(float x, float y, int rgb, float opacity) { // this.x = x; // this.y = y; // this.rgb = rgb; // this.opacity = opacity; // } // // @Serialize // @StructField(index = 0) // public float x; // // @Serialize // @StructField(index = 1) // public float y; // // @Serialize // @StructField(index = 2, optional = true) // public int rgb = 0xFFFFFF; // // @Serialize // @StructField(index = 3, optional = true) // public float opacity = 1; // // @Override // public String toString() { // return String.format("(%f,%f %06X:%.2f", x, y, rgb, opacity); // } // // } // // Path: src/main/java/openperipheral/addons/glasses/utils/ColorPointListBuilder.java // public class ColorPointListBuilder implements IPointListBuilder<ColorPoint2d> { // // private static class PointListImpl extends PointList<ColorPoint2d> { // // public PointListImpl(List<ColorPoint2d> points) { // super(points); // } // // @Override // protected void drawPoint(RenderState renderState, ColorPoint2d p) { // renderState.setColor(p.rgb, p.opacity); // GL11.glVertex2f(p.x, p.y); // } // // } // // private final List<ColorPoint2d> points = Lists.newArrayList(); // // private final BoundingBoxBuilder bbBuilder = BoundingBoxBuilder.create(); // // @Override // public void add(ColorPoint2d point) { // bbBuilder.addPoint(point.x, point.y); // points.add(point); // } // // private static ColorPoint2d toBoundingBox(Box2d bb, ColorPoint2d point) { // return new ColorPoint2d(point.x - bb.left, point.y - bb.top, point.rgb, point.opacity); // } // // @Override // public IPointList<ColorPoint2d> buildPointList() { // final Box2d bb = bbBuilder.build(); // // List<ColorPoint2d> relPoints = Lists.newArrayList(); // for (ColorPoint2d p : points) // relPoints.add(toBoundingBox(bb, p)); // // return new PointListImpl(relPoints); // } // // @Override // public Box2d buildBoundingBox() { // return bbBuilder.build(); // } // } // // Path: src/main/java/openperipheral/addons/glasses/utils/IPointListBuilder.java // public interface IPointListBuilder<P> { // public void add(P point); // // public IPointList<P> buildPointList(); // // public Box2d buildBoundingBox(); // } // Path: src/main/java/openperipheral/addons/glasses/drawable/GradientTriangle.java import openperipheral.addons.glasses.utils.ColorPoint2d; import openperipheral.addons.glasses.utils.ColorPointListBuilder; import openperipheral.addons.glasses.utils.IPointListBuilder; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.method.ScriptObject; package openperipheral.addons.glasses.drawable; @ScriptObject @AdapterSourceName("glasses_gradient_triangle")
public class GradientTriangle extends Triangle<ColorPoint2d> {
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/glasses/drawable/GradientTriangle.java
// Path: src/main/java/openperipheral/addons/glasses/utils/ColorPoint2d.java // @ScriptStruct // @SerializableClass // public class ColorPoint2d { // // public static final ColorPoint2d NULL = new ColorPoint2d(0, 0, 0, 0.0f); // // public ColorPoint2d() {} // // public ColorPoint2d(float x, float y, int rgb, float opacity) { // this.x = x; // this.y = y; // this.rgb = rgb; // this.opacity = opacity; // } // // @Serialize // @StructField(index = 0) // public float x; // // @Serialize // @StructField(index = 1) // public float y; // // @Serialize // @StructField(index = 2, optional = true) // public int rgb = 0xFFFFFF; // // @Serialize // @StructField(index = 3, optional = true) // public float opacity = 1; // // @Override // public String toString() { // return String.format("(%f,%f %06X:%.2f", x, y, rgb, opacity); // } // // } // // Path: src/main/java/openperipheral/addons/glasses/utils/ColorPointListBuilder.java // public class ColorPointListBuilder implements IPointListBuilder<ColorPoint2d> { // // private static class PointListImpl extends PointList<ColorPoint2d> { // // public PointListImpl(List<ColorPoint2d> points) { // super(points); // } // // @Override // protected void drawPoint(RenderState renderState, ColorPoint2d p) { // renderState.setColor(p.rgb, p.opacity); // GL11.glVertex2f(p.x, p.y); // } // // } // // private final List<ColorPoint2d> points = Lists.newArrayList(); // // private final BoundingBoxBuilder bbBuilder = BoundingBoxBuilder.create(); // // @Override // public void add(ColorPoint2d point) { // bbBuilder.addPoint(point.x, point.y); // points.add(point); // } // // private static ColorPoint2d toBoundingBox(Box2d bb, ColorPoint2d point) { // return new ColorPoint2d(point.x - bb.left, point.y - bb.top, point.rgb, point.opacity); // } // // @Override // public IPointList<ColorPoint2d> buildPointList() { // final Box2d bb = bbBuilder.build(); // // List<ColorPoint2d> relPoints = Lists.newArrayList(); // for (ColorPoint2d p : points) // relPoints.add(toBoundingBox(bb, p)); // // return new PointListImpl(relPoints); // } // // @Override // public Box2d buildBoundingBox() { // return bbBuilder.build(); // } // } // // Path: src/main/java/openperipheral/addons/glasses/utils/IPointListBuilder.java // public interface IPointListBuilder<P> { // public void add(P point); // // public IPointList<P> buildPointList(); // // public Box2d buildBoundingBox(); // }
import openperipheral.addons.glasses.utils.ColorPoint2d; import openperipheral.addons.glasses.utils.ColorPointListBuilder; import openperipheral.addons.glasses.utils.IPointListBuilder; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.method.ScriptObject;
package openperipheral.addons.glasses.drawable; @ScriptObject @AdapterSourceName("glasses_gradient_triangle") public class GradientTriangle extends Triangle<ColorPoint2d> { public GradientTriangle() { this(ColorPoint2d.NULL, ColorPoint2d.NULL, ColorPoint2d.NULL); } public GradientTriangle(ColorPoint2d p1, ColorPoint2d p2, ColorPoint2d p3) { super(p1, p2, p3); } @Override
// Path: src/main/java/openperipheral/addons/glasses/utils/ColorPoint2d.java // @ScriptStruct // @SerializableClass // public class ColorPoint2d { // // public static final ColorPoint2d NULL = new ColorPoint2d(0, 0, 0, 0.0f); // // public ColorPoint2d() {} // // public ColorPoint2d(float x, float y, int rgb, float opacity) { // this.x = x; // this.y = y; // this.rgb = rgb; // this.opacity = opacity; // } // // @Serialize // @StructField(index = 0) // public float x; // // @Serialize // @StructField(index = 1) // public float y; // // @Serialize // @StructField(index = 2, optional = true) // public int rgb = 0xFFFFFF; // // @Serialize // @StructField(index = 3, optional = true) // public float opacity = 1; // // @Override // public String toString() { // return String.format("(%f,%f %06X:%.2f", x, y, rgb, opacity); // } // // } // // Path: src/main/java/openperipheral/addons/glasses/utils/ColorPointListBuilder.java // public class ColorPointListBuilder implements IPointListBuilder<ColorPoint2d> { // // private static class PointListImpl extends PointList<ColorPoint2d> { // // public PointListImpl(List<ColorPoint2d> points) { // super(points); // } // // @Override // protected void drawPoint(RenderState renderState, ColorPoint2d p) { // renderState.setColor(p.rgb, p.opacity); // GL11.glVertex2f(p.x, p.y); // } // // } // // private final List<ColorPoint2d> points = Lists.newArrayList(); // // private final BoundingBoxBuilder bbBuilder = BoundingBoxBuilder.create(); // // @Override // public void add(ColorPoint2d point) { // bbBuilder.addPoint(point.x, point.y); // points.add(point); // } // // private static ColorPoint2d toBoundingBox(Box2d bb, ColorPoint2d point) { // return new ColorPoint2d(point.x - bb.left, point.y - bb.top, point.rgb, point.opacity); // } // // @Override // public IPointList<ColorPoint2d> buildPointList() { // final Box2d bb = bbBuilder.build(); // // List<ColorPoint2d> relPoints = Lists.newArrayList(); // for (ColorPoint2d p : points) // relPoints.add(toBoundingBox(bb, p)); // // return new PointListImpl(relPoints); // } // // @Override // public Box2d buildBoundingBox() { // return bbBuilder.build(); // } // } // // Path: src/main/java/openperipheral/addons/glasses/utils/IPointListBuilder.java // public interface IPointListBuilder<P> { // public void add(P point); // // public IPointList<P> buildPointList(); // // public Box2d buildBoundingBox(); // } // Path: src/main/java/openperipheral/addons/glasses/drawable/GradientTriangle.java import openperipheral.addons.glasses.utils.ColorPoint2d; import openperipheral.addons.glasses.utils.ColorPointListBuilder; import openperipheral.addons.glasses.utils.IPointListBuilder; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.method.ScriptObject; package openperipheral.addons.glasses.drawable; @ScriptObject @AdapterSourceName("glasses_gradient_triangle") public class GradientTriangle extends Triangle<ColorPoint2d> { public GradientTriangle() { this(ColorPoint2d.NULL, ColorPoint2d.NULL, ColorPoint2d.NULL); } public GradientTriangle(ColorPoint2d p1, ColorPoint2d p2, ColorPoint2d p3) { super(p1, p2, p3); } @Override
protected IPointListBuilder<ColorPoint2d> createBuilder() {
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/glasses/drawable/GradientTriangle.java
// Path: src/main/java/openperipheral/addons/glasses/utils/ColorPoint2d.java // @ScriptStruct // @SerializableClass // public class ColorPoint2d { // // public static final ColorPoint2d NULL = new ColorPoint2d(0, 0, 0, 0.0f); // // public ColorPoint2d() {} // // public ColorPoint2d(float x, float y, int rgb, float opacity) { // this.x = x; // this.y = y; // this.rgb = rgb; // this.opacity = opacity; // } // // @Serialize // @StructField(index = 0) // public float x; // // @Serialize // @StructField(index = 1) // public float y; // // @Serialize // @StructField(index = 2, optional = true) // public int rgb = 0xFFFFFF; // // @Serialize // @StructField(index = 3, optional = true) // public float opacity = 1; // // @Override // public String toString() { // return String.format("(%f,%f %06X:%.2f", x, y, rgb, opacity); // } // // } // // Path: src/main/java/openperipheral/addons/glasses/utils/ColorPointListBuilder.java // public class ColorPointListBuilder implements IPointListBuilder<ColorPoint2d> { // // private static class PointListImpl extends PointList<ColorPoint2d> { // // public PointListImpl(List<ColorPoint2d> points) { // super(points); // } // // @Override // protected void drawPoint(RenderState renderState, ColorPoint2d p) { // renderState.setColor(p.rgb, p.opacity); // GL11.glVertex2f(p.x, p.y); // } // // } // // private final List<ColorPoint2d> points = Lists.newArrayList(); // // private final BoundingBoxBuilder bbBuilder = BoundingBoxBuilder.create(); // // @Override // public void add(ColorPoint2d point) { // bbBuilder.addPoint(point.x, point.y); // points.add(point); // } // // private static ColorPoint2d toBoundingBox(Box2d bb, ColorPoint2d point) { // return new ColorPoint2d(point.x - bb.left, point.y - bb.top, point.rgb, point.opacity); // } // // @Override // public IPointList<ColorPoint2d> buildPointList() { // final Box2d bb = bbBuilder.build(); // // List<ColorPoint2d> relPoints = Lists.newArrayList(); // for (ColorPoint2d p : points) // relPoints.add(toBoundingBox(bb, p)); // // return new PointListImpl(relPoints); // } // // @Override // public Box2d buildBoundingBox() { // return bbBuilder.build(); // } // } // // Path: src/main/java/openperipheral/addons/glasses/utils/IPointListBuilder.java // public interface IPointListBuilder<P> { // public void add(P point); // // public IPointList<P> buildPointList(); // // public Box2d buildBoundingBox(); // }
import openperipheral.addons.glasses.utils.ColorPoint2d; import openperipheral.addons.glasses.utils.ColorPointListBuilder; import openperipheral.addons.glasses.utils.IPointListBuilder; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.method.ScriptObject;
package openperipheral.addons.glasses.drawable; @ScriptObject @AdapterSourceName("glasses_gradient_triangle") public class GradientTriangle extends Triangle<ColorPoint2d> { public GradientTriangle() { this(ColorPoint2d.NULL, ColorPoint2d.NULL, ColorPoint2d.NULL); } public GradientTriangle(ColorPoint2d p1, ColorPoint2d p2, ColorPoint2d p3) { super(p1, p2, p3); } @Override protected IPointListBuilder<ColorPoint2d> createBuilder() {
// Path: src/main/java/openperipheral/addons/glasses/utils/ColorPoint2d.java // @ScriptStruct // @SerializableClass // public class ColorPoint2d { // // public static final ColorPoint2d NULL = new ColorPoint2d(0, 0, 0, 0.0f); // // public ColorPoint2d() {} // // public ColorPoint2d(float x, float y, int rgb, float opacity) { // this.x = x; // this.y = y; // this.rgb = rgb; // this.opacity = opacity; // } // // @Serialize // @StructField(index = 0) // public float x; // // @Serialize // @StructField(index = 1) // public float y; // // @Serialize // @StructField(index = 2, optional = true) // public int rgb = 0xFFFFFF; // // @Serialize // @StructField(index = 3, optional = true) // public float opacity = 1; // // @Override // public String toString() { // return String.format("(%f,%f %06X:%.2f", x, y, rgb, opacity); // } // // } // // Path: src/main/java/openperipheral/addons/glasses/utils/ColorPointListBuilder.java // public class ColorPointListBuilder implements IPointListBuilder<ColorPoint2d> { // // private static class PointListImpl extends PointList<ColorPoint2d> { // // public PointListImpl(List<ColorPoint2d> points) { // super(points); // } // // @Override // protected void drawPoint(RenderState renderState, ColorPoint2d p) { // renderState.setColor(p.rgb, p.opacity); // GL11.glVertex2f(p.x, p.y); // } // // } // // private final List<ColorPoint2d> points = Lists.newArrayList(); // // private final BoundingBoxBuilder bbBuilder = BoundingBoxBuilder.create(); // // @Override // public void add(ColorPoint2d point) { // bbBuilder.addPoint(point.x, point.y); // points.add(point); // } // // private static ColorPoint2d toBoundingBox(Box2d bb, ColorPoint2d point) { // return new ColorPoint2d(point.x - bb.left, point.y - bb.top, point.rgb, point.opacity); // } // // @Override // public IPointList<ColorPoint2d> buildPointList() { // final Box2d bb = bbBuilder.build(); // // List<ColorPoint2d> relPoints = Lists.newArrayList(); // for (ColorPoint2d p : points) // relPoints.add(toBoundingBox(bb, p)); // // return new PointListImpl(relPoints); // } // // @Override // public Box2d buildBoundingBox() { // return bbBuilder.build(); // } // } // // Path: src/main/java/openperipheral/addons/glasses/utils/IPointListBuilder.java // public interface IPointListBuilder<P> { // public void add(P point); // // public IPointList<P> buildPointList(); // // public Box2d buildBoundingBox(); // } // Path: src/main/java/openperipheral/addons/glasses/drawable/GradientTriangle.java import openperipheral.addons.glasses.utils.ColorPoint2d; import openperipheral.addons.glasses.utils.ColorPointListBuilder; import openperipheral.addons.glasses.utils.IPointListBuilder; import openperipheral.api.adapter.AdapterSourceName; import openperipheral.api.adapter.method.ScriptObject; package openperipheral.addons.glasses.drawable; @ScriptObject @AdapterSourceName("glasses_gradient_triangle") public class GradientTriangle extends Triangle<ColorPoint2d> { public GradientTriangle() { this(ColorPoint2d.NULL, ColorPoint2d.NULL, ColorPoint2d.NULL); } public GradientTriangle(ColorPoint2d p1, ColorPoint2d p2, ColorPoint2d p3) { super(p1, p2, p3); } @Override protected IPointListBuilder<ColorPoint2d> createBuilder() {
return new ColorPointListBuilder();
OpenMods/OpenPeripheral-Addons
src/main/java/openperipheral/addons/sensors/AdapterSensor.java
// Path: src/main/java/openperipheral/addons/OpcAccess.java // public class OpcAccess { // // @ApiHolder // public static IPeripheralAdapterRegistry adapterRegistry; // // @ApiHolder // public static IItemStackMetaBuilder itemStackMetaBuilder; // // @ApiHolder // public static IEntityPartialMetaBuilder entityMetaBuilder; // // public static void checkApiPresent() { // Preconditions.checkState(adapterRegistry != null, "Adapter Registry not present"); // Preconditions.checkState(itemStackMetaBuilder != null, "Item stack metadata provider not present"); // Preconditions.checkState(entityMetaBuilder != null, "Entity metadata provider not present"); // } // // }
import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.mojang.authlib.GameProfile; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.UUID; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItemFrame; import net.minecraft.entity.item.EntityMinecart; import net.minecraft.entity.item.EntityPainting; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; import net.minecraft.world.World; import openmods.utils.ColorUtils; import openmods.utils.ColorUtils.RGB; import openmods.utils.WorldUtils; import openperipheral.addons.OpcAccess; import openperipheral.api.adapter.IPeripheralAdapter; import openperipheral.api.adapter.method.Arg; import openperipheral.api.adapter.method.ReturnType; import openperipheral.api.adapter.method.ScriptCallable; import openperipheral.api.architecture.FeatureGroup; import openperipheral.api.meta.IMetaProviderProxy;
final AxisAlignedBB aabb = getBoundingBox(env); for (Entity entity : WorldUtils.getEntitiesWithinAABB(env.getWorld(), entityClass, aabb)) ids.add(entity.getEntityId()); return ids; } private static IMetaProviderProxy getEntityInfoById(ISensorEnvironment sensor, int mobId, Class<? extends Entity> cls) { Entity mob = sensor.getWorld().getEntityByID(mobId); Preconditions.checkArgument(cls.isInstance(mob), DONT_EVER_CHANGE_THIS_TEXT_OTHERWISE_YOU_WILL_RUIN_EVERYTHING); return getEntityInfo(sensor, mob); } private static IMetaProviderProxy getPlayerInfo(ISensorEnvironment sensor, String username) { EntityPlayer player = sensor.getWorld().getPlayerEntityByName(username); return getEntityInfo(sensor, player); } private static IMetaProviderProxy getPlayerInfo(ISensorEnvironment sensor, UUID uuid) { EntityPlayer player = sensor.getWorld().func_152378_a(uuid); return getEntityInfo(sensor, player); } private static IMetaProviderProxy getEntityInfo(ISensorEnvironment sensor, Entity mob) { Preconditions.checkNotNull(mob, DONT_EVER_CHANGE_THIS_TEXT_OTHERWISE_YOU_WILL_RUIN_EVERYTHING); final AxisAlignedBB aabb = getBoundingBox(sensor); Preconditions.checkArgument(mob.boundingBox.intersectsWith(aabb), DONT_EVER_CHANGE_THIS_TEXT_OTHERWISE_YOU_WILL_RUIN_EVERYTHING); final Vec3 sensorPos = sensor.getLocation();
// Path: src/main/java/openperipheral/addons/OpcAccess.java // public class OpcAccess { // // @ApiHolder // public static IPeripheralAdapterRegistry adapterRegistry; // // @ApiHolder // public static IItemStackMetaBuilder itemStackMetaBuilder; // // @ApiHolder // public static IEntityPartialMetaBuilder entityMetaBuilder; // // public static void checkApiPresent() { // Preconditions.checkState(adapterRegistry != null, "Adapter Registry not present"); // Preconditions.checkState(itemStackMetaBuilder != null, "Item stack metadata provider not present"); // Preconditions.checkState(entityMetaBuilder != null, "Entity metadata provider not present"); // } // // } // Path: src/main/java/openperipheral/addons/sensors/AdapterSensor.java import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.mojang.authlib.GameProfile; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.UUID; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItemFrame; import net.minecraft.entity.item.EntityMinecart; import net.minecraft.entity.item.EntityPainting; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; import net.minecraft.world.World; import openmods.utils.ColorUtils; import openmods.utils.ColorUtils.RGB; import openmods.utils.WorldUtils; import openperipheral.addons.OpcAccess; import openperipheral.api.adapter.IPeripheralAdapter; import openperipheral.api.adapter.method.Arg; import openperipheral.api.adapter.method.ReturnType; import openperipheral.api.adapter.method.ScriptCallable; import openperipheral.api.architecture.FeatureGroup; import openperipheral.api.meta.IMetaProviderProxy; final AxisAlignedBB aabb = getBoundingBox(env); for (Entity entity : WorldUtils.getEntitiesWithinAABB(env.getWorld(), entityClass, aabb)) ids.add(entity.getEntityId()); return ids; } private static IMetaProviderProxy getEntityInfoById(ISensorEnvironment sensor, int mobId, Class<? extends Entity> cls) { Entity mob = sensor.getWorld().getEntityByID(mobId); Preconditions.checkArgument(cls.isInstance(mob), DONT_EVER_CHANGE_THIS_TEXT_OTHERWISE_YOU_WILL_RUIN_EVERYTHING); return getEntityInfo(sensor, mob); } private static IMetaProviderProxy getPlayerInfo(ISensorEnvironment sensor, String username) { EntityPlayer player = sensor.getWorld().getPlayerEntityByName(username); return getEntityInfo(sensor, player); } private static IMetaProviderProxy getPlayerInfo(ISensorEnvironment sensor, UUID uuid) { EntityPlayer player = sensor.getWorld().func_152378_a(uuid); return getEntityInfo(sensor, player); } private static IMetaProviderProxy getEntityInfo(ISensorEnvironment sensor, Entity mob) { Preconditions.checkNotNull(mob, DONT_EVER_CHANGE_THIS_TEXT_OTHERWISE_YOU_WILL_RUIN_EVERYTHING); final AxisAlignedBB aabb = getBoundingBox(sensor); Preconditions.checkArgument(mob.boundingBox.intersectsWith(aabb), DONT_EVER_CHANGE_THIS_TEXT_OTHERWISE_YOU_WILL_RUIN_EVERYTHING); final Vec3 sensorPos = sensor.getLocation();
return OpcAccess.entityMetaBuilder.createProxy(mob, sensorPos);
gwidgets/gwty-leaflet
src/main/java/com/gwidgets/api/leaflet/options/DivIconOptions.java
// Path: src/main/java/com/gwidgets/api/leaflet/Point.java // @JsType(isNative = true) // public class Point { // // // // /** The x coordinate. */ // @JsProperty // public double x; // // /** The The y coordinate. */ // @JsProperty // public double y; // // // // /** // * Returns the result of addition of the current and the given points. // * // * @param otherPoint the other point // * @return the point // */ // @JsMethod // public native Point add(Point otherPoint); // // /** // * Returns the result of subtraction of the given point from the current. // * // * @param otherPoint the other point // * @return the point // */ // @JsMethod // public native Point subtract(Point otherPoint); // // /** // * Returns the result of multiplication of the current point by the given number. // * // * @param number the number // * @return the point // */ // @JsMethod // public native Point multiplyBy(double number); // // /** // * Returns the result of division of the current point by the given number. If optional round is set to true, returns a rounded result. // * // * @param number the number // * @param round the round // * @return the point // */ // @JsMethod // public native Point divideBy(double number, Boolean round); // // /** // * Returns the distance between the current and the given points. // * // * @param otherPoint the other point // * @return the number // */ // @JsMethod // public native double distanceTo(Point otherPoint); // // /* (non-Javadoc) // * @see java.lang.Object#clone() // */ // /** // * <p>clone.</p> // * // * @return a {@link com.gwidgets.api.leaflet.Point} object // */ // @JsMethod // public native Point clone(); // // /** // * Returns a copy of the current point with rounded coordinates. // * // * @return the point // */ // @JsMethod // public native Point round(); // // // /** // * Returns a copy of the current point with floored coordinates (rounded down). // * // * @return the point // */ // @JsMethod // public native Point floor(); // // // // /** // * Returns true if the both coordinates of the given point are less than the corresponding current point coordinates (in absolute values). // * // * @param point the point // * @return true/false // */ // @JsMethod // public native Boolean contains(Point point); // // /** // * Returns true if the given point has the same coordinates. // * // * @param otherPoint the other point // * @return true/false // */ // @JsMethod // public native Boolean equals(Point otherPoint); // // /* (non-Javadoc) // * @see java.lang.Object#toString() // */ // /** // * <p>toString.</p> // * // * @return a {@link java.lang.String} object // */ // @JsMethod // public native String toString(); // // }
import static jsinterop.annotations.JsPackage.GLOBAL; import com.gwidgets.api.leaflet.Point; import jsinterop.annotations.JsOverlay; import jsinterop.annotations.JsProperty; import jsinterop.annotations.JsType;
/** * Copyright 2016 G-Widgets * 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.gwidgets.api.leaflet.options; /** * The Class DivIconOptions. * * @author <a href="mailto:zakaria.amine88@gmail.com">Zakaria Amine</a> * @version $Id: $Id */ @JsType(isNative=true, namespace=GLOBAL, name="Object") public class DivIconOptions { /** * Instantiates a new div icon options. */ private DivIconOptions() { } @JsProperty
// Path: src/main/java/com/gwidgets/api/leaflet/Point.java // @JsType(isNative = true) // public class Point { // // // // /** The x coordinate. */ // @JsProperty // public double x; // // /** The The y coordinate. */ // @JsProperty // public double y; // // // // /** // * Returns the result of addition of the current and the given points. // * // * @param otherPoint the other point // * @return the point // */ // @JsMethod // public native Point add(Point otherPoint); // // /** // * Returns the result of subtraction of the given point from the current. // * // * @param otherPoint the other point // * @return the point // */ // @JsMethod // public native Point subtract(Point otherPoint); // // /** // * Returns the result of multiplication of the current point by the given number. // * // * @param number the number // * @return the point // */ // @JsMethod // public native Point multiplyBy(double number); // // /** // * Returns the result of division of the current point by the given number. If optional round is set to true, returns a rounded result. // * // * @param number the number // * @param round the round // * @return the point // */ // @JsMethod // public native Point divideBy(double number, Boolean round); // // /** // * Returns the distance between the current and the given points. // * // * @param otherPoint the other point // * @return the number // */ // @JsMethod // public native double distanceTo(Point otherPoint); // // /* (non-Javadoc) // * @see java.lang.Object#clone() // */ // /** // * <p>clone.</p> // * // * @return a {@link com.gwidgets.api.leaflet.Point} object // */ // @JsMethod // public native Point clone(); // // /** // * Returns a copy of the current point with rounded coordinates. // * // * @return the point // */ // @JsMethod // public native Point round(); // // // /** // * Returns a copy of the current point with floored coordinates (rounded down). // * // * @return the point // */ // @JsMethod // public native Point floor(); // // // // /** // * Returns true if the both coordinates of the given point are less than the corresponding current point coordinates (in absolute values). // * // * @param point the point // * @return true/false // */ // @JsMethod // public native Boolean contains(Point point); // // /** // * Returns true if the given point has the same coordinates. // * // * @param otherPoint the other point // * @return true/false // */ // @JsMethod // public native Boolean equals(Point otherPoint); // // /* (non-Javadoc) // * @see java.lang.Object#toString() // */ // /** // * <p>toString.</p> // * // * @return a {@link java.lang.String} object // */ // @JsMethod // public native String toString(); // // } // Path: src/main/java/com/gwidgets/api/leaflet/options/DivIconOptions.java import static jsinterop.annotations.JsPackage.GLOBAL; import com.gwidgets.api.leaflet.Point; import jsinterop.annotations.JsOverlay; import jsinterop.annotations.JsProperty; import jsinterop.annotations.JsType; /** * Copyright 2016 G-Widgets * 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.gwidgets.api.leaflet.options; /** * The Class DivIconOptions. * * @author <a href="mailto:zakaria.amine88@gmail.com">Zakaria Amine</a> * @version $Id: $Id */ @JsType(isNative=true, namespace=GLOBAL, name="Object") public class DivIconOptions { /** * Instantiates a new div icon options. */ private DivIconOptions() { } @JsProperty
private Point iconSize;
gwidgets/gwty-leaflet
src/main/java/com/gwidgets/api/leaflet/events/TileErrorEvent.java
// Path: src/main/java/com/gwidgets/api/leaflet/Point.java // @JsType(isNative = true) // public class Point { // // // // /** The x coordinate. */ // @JsProperty // public double x; // // /** The The y coordinate. */ // @JsProperty // public double y; // // // // /** // * Returns the result of addition of the current and the given points. // * // * @param otherPoint the other point // * @return the point // */ // @JsMethod // public native Point add(Point otherPoint); // // /** // * Returns the result of subtraction of the given point from the current. // * // * @param otherPoint the other point // * @return the point // */ // @JsMethod // public native Point subtract(Point otherPoint); // // /** // * Returns the result of multiplication of the current point by the given number. // * // * @param number the number // * @return the point // */ // @JsMethod // public native Point multiplyBy(double number); // // /** // * Returns the result of division of the current point by the given number. If optional round is set to true, returns a rounded result. // * // * @param number the number // * @param round the round // * @return the point // */ // @JsMethod // public native Point divideBy(double number, Boolean round); // // /** // * Returns the distance between the current and the given points. // * // * @param otherPoint the other point // * @return the number // */ // @JsMethod // public native double distanceTo(Point otherPoint); // // /* (non-Javadoc) // * @see java.lang.Object#clone() // */ // /** // * <p>clone.</p> // * // * @return a {@link com.gwidgets.api.leaflet.Point} object // */ // @JsMethod // public native Point clone(); // // /** // * Returns a copy of the current point with rounded coordinates. // * // * @return the point // */ // @JsMethod // public native Point round(); // // // /** // * Returns a copy of the current point with floored coordinates (rounded down). // * // * @return the point // */ // @JsMethod // public native Point floor(); // // // // /** // * Returns true if the both coordinates of the given point are less than the corresponding current point coordinates (in absolute values). // * // * @param point the point // * @return true/false // */ // @JsMethod // public native Boolean contains(Point point); // // /** // * Returns true if the given point has the same coordinates. // * // * @param otherPoint the other point // * @return true/false // */ // @JsMethod // public native Boolean equals(Point otherPoint); // // /* (non-Javadoc) // * @see java.lang.Object#toString() // */ // /** // * <p>toString.</p> // * // * @return a {@link java.lang.String} object // */ // @JsMethod // public native String toString(); // // }
import com.gwidgets.api.leaflet.Point; import elemental2.dom.HTMLElement; import jsinterop.annotations.JsProperty; import jsinterop.annotations.JsType;
/** * Copyright 2016 G-Widgets * 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.gwidgets.api.leaflet.events; /** * The Class TileErrorEvent. * * @author <a href="mailto:zakaria.amine88@gmail.com">Zakaria Amine</a> * @version $Id: $Id */ @JsType(isNative=true, name="Object", namespace=jsinterop.annotations.JsPackage.GLOBAL) public class TileErrorEvent extends Event { private TileErrorEvent() { } /** * Gets the tile element (image). * * @return the tile */ @JsProperty public final native HTMLElement getTile(); /** * Point object with tile's x, y, and z (zoom level) coordinates. * * @return the coords */ @JsProperty
// Path: src/main/java/com/gwidgets/api/leaflet/Point.java // @JsType(isNative = true) // public class Point { // // // // /** The x coordinate. */ // @JsProperty // public double x; // // /** The The y coordinate. */ // @JsProperty // public double y; // // // // /** // * Returns the result of addition of the current and the given points. // * // * @param otherPoint the other point // * @return the point // */ // @JsMethod // public native Point add(Point otherPoint); // // /** // * Returns the result of subtraction of the given point from the current. // * // * @param otherPoint the other point // * @return the point // */ // @JsMethod // public native Point subtract(Point otherPoint); // // /** // * Returns the result of multiplication of the current point by the given number. // * // * @param number the number // * @return the point // */ // @JsMethod // public native Point multiplyBy(double number); // // /** // * Returns the result of division of the current point by the given number. If optional round is set to true, returns a rounded result. // * // * @param number the number // * @param round the round // * @return the point // */ // @JsMethod // public native Point divideBy(double number, Boolean round); // // /** // * Returns the distance between the current and the given points. // * // * @param otherPoint the other point // * @return the number // */ // @JsMethod // public native double distanceTo(Point otherPoint); // // /* (non-Javadoc) // * @see java.lang.Object#clone() // */ // /** // * <p>clone.</p> // * // * @return a {@link com.gwidgets.api.leaflet.Point} object // */ // @JsMethod // public native Point clone(); // // /** // * Returns a copy of the current point with rounded coordinates. // * // * @return the point // */ // @JsMethod // public native Point round(); // // // /** // * Returns a copy of the current point with floored coordinates (rounded down). // * // * @return the point // */ // @JsMethod // public native Point floor(); // // // // /** // * Returns true if the both coordinates of the given point are less than the corresponding current point coordinates (in absolute values). // * // * @param point the point // * @return true/false // */ // @JsMethod // public native Boolean contains(Point point); // // /** // * Returns true if the given point has the same coordinates. // * // * @param otherPoint the other point // * @return true/false // */ // @JsMethod // public native Boolean equals(Point otherPoint); // // /* (non-Javadoc) // * @see java.lang.Object#toString() // */ // /** // * <p>toString.</p> // * // * @return a {@link java.lang.String} object // */ // @JsMethod // public native String toString(); // // } // Path: src/main/java/com/gwidgets/api/leaflet/events/TileErrorEvent.java import com.gwidgets.api.leaflet.Point; import elemental2.dom.HTMLElement; import jsinterop.annotations.JsProperty; import jsinterop.annotations.JsType; /** * Copyright 2016 G-Widgets * 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.gwidgets.api.leaflet.events; /** * The Class TileErrorEvent. * * @author <a href="mailto:zakaria.amine88@gmail.com">Zakaria Amine</a> * @version $Id: $Id */ @JsType(isNative=true, name="Object", namespace=jsinterop.annotations.JsPackage.GLOBAL) public class TileErrorEvent extends Event { private TileErrorEvent() { } /** * Gets the tile element (image). * * @return the tile */ @JsProperty public final native HTMLElement getTile(); /** * Point object with tile's x, y, and z (zoom level) coordinates. * * @return the coords */ @JsProperty
public final native Point getCoords();
gwidgets/gwty-leaflet
src/main/java/com/gwidgets/api/leaflet/Evented.java
// Path: src/main/java/com/gwidgets/api/leaflet/events/EventCallback.java // @JsFunction // public interface EventCallback<T extends Event> { // // /** // * <p>call.</p> // * // * @param event a T object // */ // void call(T event); // }
import com.gwidgets.api.leaflet.events.EventCallback; import jsinterop.annotations.JsType;
package com.gwidgets.api.leaflet; /** * <p>Evented interface.</p> * * @author zakaria * @version $Id: $Id */ @JsType(isNative = true) public interface Evented { /** * Clear all event listeners. * * @return the L class */ public L clearAllEventListeners(); /** * Adds a set of type/listener pairs. * * @param type the type * @param fn the callback function * @return the L class */
// Path: src/main/java/com/gwidgets/api/leaflet/events/EventCallback.java // @JsFunction // public interface EventCallback<T extends Event> { // // /** // * <p>call.</p> // * // * @param event a T object // */ // void call(T event); // } // Path: src/main/java/com/gwidgets/api/leaflet/Evented.java import com.gwidgets.api.leaflet.events.EventCallback; import jsinterop.annotations.JsType; package com.gwidgets.api.leaflet; /** * <p>Evented interface.</p> * * @author zakaria * @version $Id: $Id */ @JsType(isNative = true) public interface Evented { /** * Clear all event listeners. * * @return the L class */ public L clearAllEventListeners(); /** * Adds a set of type/listener pairs. * * @param type the type * @param fn the callback function * @return the L class */
public L on(String type, EventCallback fn);
gwidgets/gwty-leaflet
src/main/java/com/gwidgets/api/leaflet/options/TooltipOptions.java
// Path: src/main/java/com/gwidgets/api/leaflet/Point.java // @JsType(isNative = true) // public class Point { // // // // /** The x coordinate. */ // @JsProperty // public double x; // // /** The The y coordinate. */ // @JsProperty // public double y; // // // // /** // * Returns the result of addition of the current and the given points. // * // * @param otherPoint the other point // * @return the point // */ // @JsMethod // public native Point add(Point otherPoint); // // /** // * Returns the result of subtraction of the given point from the current. // * // * @param otherPoint the other point // * @return the point // */ // @JsMethod // public native Point subtract(Point otherPoint); // // /** // * Returns the result of multiplication of the current point by the given number. // * // * @param number the number // * @return the point // */ // @JsMethod // public native Point multiplyBy(double number); // // /** // * Returns the result of division of the current point by the given number. If optional round is set to true, returns a rounded result. // * // * @param number the number // * @param round the round // * @return the point // */ // @JsMethod // public native Point divideBy(double number, Boolean round); // // /** // * Returns the distance between the current and the given points. // * // * @param otherPoint the other point // * @return the number // */ // @JsMethod // public native double distanceTo(Point otherPoint); // // /* (non-Javadoc) // * @see java.lang.Object#clone() // */ // /** // * <p>clone.</p> // * // * @return a {@link com.gwidgets.api.leaflet.Point} object // */ // @JsMethod // public native Point clone(); // // /** // * Returns a copy of the current point with rounded coordinates. // * // * @return the point // */ // @JsMethod // public native Point round(); // // // /** // * Returns a copy of the current point with floored coordinates (rounded down). // * // * @return the point // */ // @JsMethod // public native Point floor(); // // // // /** // * Returns true if the both coordinates of the given point are less than the corresponding current point coordinates (in absolute values). // * // * @param point the point // * @return true/false // */ // @JsMethod // public native Boolean contains(Point point); // // /** // * Returns true if the given point has the same coordinates. // * // * @param otherPoint the other point // * @return true/false // */ // @JsMethod // public native Boolean equals(Point otherPoint); // // /* (non-Javadoc) // * @see java.lang.Object#toString() // */ // /** // * <p>toString.</p> // * // * @return a {@link java.lang.String} object // */ // @JsMethod // public native String toString(); // // }
import static jsinterop.annotations.JsPackage.GLOBAL; import com.gwidgets.api.leaflet.Point; import jsinterop.annotations.JsOverlay; import jsinterop.annotations.JsProperty; import jsinterop.annotations.JsType;
/** * Copyright 2016 G-Widgets * 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.gwidgets.api.leaflet.options; /** * The Class TooltipOptions. * * @author <a href="mailto:zakaria.amine88@gmail.com">Zakaria Amine</a> * @version $Id: $Id */ @JsType(isNative=true, namespace=GLOBAL, name="Object") public class TooltipOptions { @JsProperty private String pane; @JsProperty
// Path: src/main/java/com/gwidgets/api/leaflet/Point.java // @JsType(isNative = true) // public class Point { // // // // /** The x coordinate. */ // @JsProperty // public double x; // // /** The The y coordinate. */ // @JsProperty // public double y; // // // // /** // * Returns the result of addition of the current and the given points. // * // * @param otherPoint the other point // * @return the point // */ // @JsMethod // public native Point add(Point otherPoint); // // /** // * Returns the result of subtraction of the given point from the current. // * // * @param otherPoint the other point // * @return the point // */ // @JsMethod // public native Point subtract(Point otherPoint); // // /** // * Returns the result of multiplication of the current point by the given number. // * // * @param number the number // * @return the point // */ // @JsMethod // public native Point multiplyBy(double number); // // /** // * Returns the result of division of the current point by the given number. If optional round is set to true, returns a rounded result. // * // * @param number the number // * @param round the round // * @return the point // */ // @JsMethod // public native Point divideBy(double number, Boolean round); // // /** // * Returns the distance between the current and the given points. // * // * @param otherPoint the other point // * @return the number // */ // @JsMethod // public native double distanceTo(Point otherPoint); // // /* (non-Javadoc) // * @see java.lang.Object#clone() // */ // /** // * <p>clone.</p> // * // * @return a {@link com.gwidgets.api.leaflet.Point} object // */ // @JsMethod // public native Point clone(); // // /** // * Returns a copy of the current point with rounded coordinates. // * // * @return the point // */ // @JsMethod // public native Point round(); // // // /** // * Returns a copy of the current point with floored coordinates (rounded down). // * // * @return the point // */ // @JsMethod // public native Point floor(); // // // // /** // * Returns true if the both coordinates of the given point are less than the corresponding current point coordinates (in absolute values). // * // * @param point the point // * @return true/false // */ // @JsMethod // public native Boolean contains(Point point); // // /** // * Returns true if the given point has the same coordinates. // * // * @param otherPoint the other point // * @return true/false // */ // @JsMethod // public native Boolean equals(Point otherPoint); // // /* (non-Javadoc) // * @see java.lang.Object#toString() // */ // /** // * <p>toString.</p> // * // * @return a {@link java.lang.String} object // */ // @JsMethod // public native String toString(); // // } // Path: src/main/java/com/gwidgets/api/leaflet/options/TooltipOptions.java import static jsinterop.annotations.JsPackage.GLOBAL; import com.gwidgets.api.leaflet.Point; import jsinterop.annotations.JsOverlay; import jsinterop.annotations.JsProperty; import jsinterop.annotations.JsType; /** * Copyright 2016 G-Widgets * 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.gwidgets.api.leaflet.options; /** * The Class TooltipOptions. * * @author <a href="mailto:zakaria.amine88@gmail.com">Zakaria Amine</a> * @version $Id: $Id */ @JsType(isNative=true, namespace=GLOBAL, name="Object") public class TooltipOptions { @JsProperty private String pane; @JsProperty
private Point offset;
gwidgets/gwty-leaflet
src/main/java/com/gwidgets/api/leaflet/options/TileLayerOptions.java
// Path: src/main/java/com/gwidgets/api/leaflet/LatLngBounds.java // @JsType(isNative = true) // public class LatLngBounds { // // // // private LatLngBounds() { // // } // // /** // * Extends the bounds to contain the given point. // * // * @param latlng the latlng // * @return the L class // */ // @JsMethod // public native L extend(LatLng latlng); // // /** // * Extends the bounds to contain the given bounds. // * // * @param latlng the latlng // * @return the L class // */ // @JsMethod // public native L extend(LatLngBounds latlng); // // /** // * Returns the south-west point of the bounds. // * // * @return the south west // */ // @JsMethod // public native LatLng getSouthWest(); // // /** // * Returns the north-east point of the bounds. // * // * @return the north east // */ // @JsMethod // public native LatLng getNorthEast(); // // /** // * Returns the north-west point of the bounds. // * // * @return the north west // */ // @JsMethod // public native LatLng getNorthWest(); // // /** // * Returns the south-east point of the bounds. // * // * @return the south east // */ // @JsMethod // public native LatLng getSouthEast(); // // /** // * Returns the west longitude of the bounds. // * // * @return the west // */ // @JsMethod // public native double getWest(); // // /** // * Returns the south latitude of the bounds. // * // * @return the south // */ // @JsMethod // public native double getSouth(); // // /** // * Returns the east longitude of the bounds. // * // * @return the east // */ // @JsMethod // public native double getEast(); // // /** // * Returns the north latitude of the bounds. // * // * @return the north // */ // @JsMethod // public native double getNorth(); // // /** // * Returns the center point of the bounds. // * // * @return the center // */ // @JsMethod // public native LatLng getCenter(); // // /** // * Returns true if the rectangle contains the given one. // * // * @param otherBounds the other bounds // * @return true/false // */ // @JsMethod // public native Boolean contains(LatLngBounds otherBounds); // // /** // * Returns true if the rectangle contains the given point. // * // * @param latlng the latlng // * @return true/false // */ // @JsMethod // public native Boolean contains(LatLng latlng); // // /** // * Returns true if the rectangle intersects the given bounds. // * // * @param otherBounds the other bounds // * @return true/false // */ // @JsMethod // public native Boolean intersects(LatLngBounds otherBounds); // // /** // * Returns true if the rectangle is equivalent (within a small margin of error) to the given bounds. // * // * @param otherBounds the other bounds // * @return true/flase // */ // @JsMethod // public native Boolean equals(LatLngBounds otherBounds); // // /** // * Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for sending requests to web services that return geo data // * // * @return the string // */ // @JsMethod // public native String toBBoxString(); // // /** // * Returns bigger bounds created by extending the current bounds by a given percentage in each direction. // * // * @param bufferRatio the buffer ratio // * @return the lat lng bounds // */ // @JsMethod // public native LatLngBounds pad(double bufferRatio); // // /** // * Returns true if the bounds are properly initialized. // * // * @return true/false // */ // @JsMethod // public native Boolean isValid(); // // }
import static jsinterop.annotations.JsPackage.GLOBAL; import com.gwidgets.api.leaflet.LatLngBounds; import jsinterop.annotations.JsOverlay; import jsinterop.annotations.JsProperty; import jsinterop.annotations.JsType;
private boolean zoomReverse; @JsProperty private double opacity; @JsProperty private int zIndex; @JsProperty private boolean updateWhenIdle; /***************************************** ********************************************/ @JsProperty private boolean updateWhenZooming; /********************************************** *********************************************/ /***************************************** ********************************************/ @JsProperty private boolean updateInterval; /********************************************** *********************************************/ @JsProperty private boolean detectRetina; @JsProperty
// Path: src/main/java/com/gwidgets/api/leaflet/LatLngBounds.java // @JsType(isNative = true) // public class LatLngBounds { // // // // private LatLngBounds() { // // } // // /** // * Extends the bounds to contain the given point. // * // * @param latlng the latlng // * @return the L class // */ // @JsMethod // public native L extend(LatLng latlng); // // /** // * Extends the bounds to contain the given bounds. // * // * @param latlng the latlng // * @return the L class // */ // @JsMethod // public native L extend(LatLngBounds latlng); // // /** // * Returns the south-west point of the bounds. // * // * @return the south west // */ // @JsMethod // public native LatLng getSouthWest(); // // /** // * Returns the north-east point of the bounds. // * // * @return the north east // */ // @JsMethod // public native LatLng getNorthEast(); // // /** // * Returns the north-west point of the bounds. // * // * @return the north west // */ // @JsMethod // public native LatLng getNorthWest(); // // /** // * Returns the south-east point of the bounds. // * // * @return the south east // */ // @JsMethod // public native LatLng getSouthEast(); // // /** // * Returns the west longitude of the bounds. // * // * @return the west // */ // @JsMethod // public native double getWest(); // // /** // * Returns the south latitude of the bounds. // * // * @return the south // */ // @JsMethod // public native double getSouth(); // // /** // * Returns the east longitude of the bounds. // * // * @return the east // */ // @JsMethod // public native double getEast(); // // /** // * Returns the north latitude of the bounds. // * // * @return the north // */ // @JsMethod // public native double getNorth(); // // /** // * Returns the center point of the bounds. // * // * @return the center // */ // @JsMethod // public native LatLng getCenter(); // // /** // * Returns true if the rectangle contains the given one. // * // * @param otherBounds the other bounds // * @return true/false // */ // @JsMethod // public native Boolean contains(LatLngBounds otherBounds); // // /** // * Returns true if the rectangle contains the given point. // * // * @param latlng the latlng // * @return true/false // */ // @JsMethod // public native Boolean contains(LatLng latlng); // // /** // * Returns true if the rectangle intersects the given bounds. // * // * @param otherBounds the other bounds // * @return true/false // */ // @JsMethod // public native Boolean intersects(LatLngBounds otherBounds); // // /** // * Returns true if the rectangle is equivalent (within a small margin of error) to the given bounds. // * // * @param otherBounds the other bounds // * @return true/flase // */ // @JsMethod // public native Boolean equals(LatLngBounds otherBounds); // // /** // * Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for sending requests to web services that return geo data // * // * @return the string // */ // @JsMethod // public native String toBBoxString(); // // /** // * Returns bigger bounds created by extending the current bounds by a given percentage in each direction. // * // * @param bufferRatio the buffer ratio // * @return the lat lng bounds // */ // @JsMethod // public native LatLngBounds pad(double bufferRatio); // // /** // * Returns true if the bounds are properly initialized. // * // * @return true/false // */ // @JsMethod // public native Boolean isValid(); // // } // Path: src/main/java/com/gwidgets/api/leaflet/options/TileLayerOptions.java import static jsinterop.annotations.JsPackage.GLOBAL; import com.gwidgets.api.leaflet.LatLngBounds; import jsinterop.annotations.JsOverlay; import jsinterop.annotations.JsProperty; import jsinterop.annotations.JsType; private boolean zoomReverse; @JsProperty private double opacity; @JsProperty private int zIndex; @JsProperty private boolean updateWhenIdle; /***************************************** ********************************************/ @JsProperty private boolean updateWhenZooming; /********************************************** *********************************************/ /***************************************** ********************************************/ @JsProperty private boolean updateInterval; /********************************************** *********************************************/ @JsProperty private boolean detectRetina; @JsProperty
private LatLngBounds bounds;
gwidgets/gwty-leaflet
src/main/java/com/gwidgets/api/leaflet/options/IconOptions.java
// Path: src/main/java/com/gwidgets/api/leaflet/Point.java // @JsType(isNative = true) // public class Point { // // // // /** The x coordinate. */ // @JsProperty // public double x; // // /** The The y coordinate. */ // @JsProperty // public double y; // // // // /** // * Returns the result of addition of the current and the given points. // * // * @param otherPoint the other point // * @return the point // */ // @JsMethod // public native Point add(Point otherPoint); // // /** // * Returns the result of subtraction of the given point from the current. // * // * @param otherPoint the other point // * @return the point // */ // @JsMethod // public native Point subtract(Point otherPoint); // // /** // * Returns the result of multiplication of the current point by the given number. // * // * @param number the number // * @return the point // */ // @JsMethod // public native Point multiplyBy(double number); // // /** // * Returns the result of division of the current point by the given number. If optional round is set to true, returns a rounded result. // * // * @param number the number // * @param round the round // * @return the point // */ // @JsMethod // public native Point divideBy(double number, Boolean round); // // /** // * Returns the distance between the current and the given points. // * // * @param otherPoint the other point // * @return the number // */ // @JsMethod // public native double distanceTo(Point otherPoint); // // /* (non-Javadoc) // * @see java.lang.Object#clone() // */ // /** // * <p>clone.</p> // * // * @return a {@link com.gwidgets.api.leaflet.Point} object // */ // @JsMethod // public native Point clone(); // // /** // * Returns a copy of the current point with rounded coordinates. // * // * @return the point // */ // @JsMethod // public native Point round(); // // // /** // * Returns a copy of the current point with floored coordinates (rounded down). // * // * @return the point // */ // @JsMethod // public native Point floor(); // // // // /** // * Returns true if the both coordinates of the given point are less than the corresponding current point coordinates (in absolute values). // * // * @param point the point // * @return true/false // */ // @JsMethod // public native Boolean contains(Point point); // // /** // * Returns true if the given point has the same coordinates. // * // * @param otherPoint the other point // * @return true/false // */ // @JsMethod // public native Boolean equals(Point otherPoint); // // /* (non-Javadoc) // * @see java.lang.Object#toString() // */ // /** // * <p>toString.</p> // * // * @return a {@link java.lang.String} object // */ // @JsMethod // public native String toString(); // // }
import static jsinterop.annotations.JsPackage.GLOBAL; import com.gwidgets.api.leaflet.Point; import jsinterop.annotations.JsOverlay; import jsinterop.annotations.JsProperty; import jsinterop.annotations.JsType;
/** * Copyright 2016 G-Widgets * 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.gwidgets.api.leaflet.options; /** * The Class IconOptions. * * @author <a href="mailto:zakaria.amine88@gmail.com">Zakaria Amine</a> * @version $Id: $Id */ @JsType(isNative=true, namespace=GLOBAL, name="Object") public class IconOptions { private IconOptions(){ } @JsProperty private String iconUrl; @JsProperty private String iconRetinaUrl; @JsProperty
// Path: src/main/java/com/gwidgets/api/leaflet/Point.java // @JsType(isNative = true) // public class Point { // // // // /** The x coordinate. */ // @JsProperty // public double x; // // /** The The y coordinate. */ // @JsProperty // public double y; // // // // /** // * Returns the result of addition of the current and the given points. // * // * @param otherPoint the other point // * @return the point // */ // @JsMethod // public native Point add(Point otherPoint); // // /** // * Returns the result of subtraction of the given point from the current. // * // * @param otherPoint the other point // * @return the point // */ // @JsMethod // public native Point subtract(Point otherPoint); // // /** // * Returns the result of multiplication of the current point by the given number. // * // * @param number the number // * @return the point // */ // @JsMethod // public native Point multiplyBy(double number); // // /** // * Returns the result of division of the current point by the given number. If optional round is set to true, returns a rounded result. // * // * @param number the number // * @param round the round // * @return the point // */ // @JsMethod // public native Point divideBy(double number, Boolean round); // // /** // * Returns the distance between the current and the given points. // * // * @param otherPoint the other point // * @return the number // */ // @JsMethod // public native double distanceTo(Point otherPoint); // // /* (non-Javadoc) // * @see java.lang.Object#clone() // */ // /** // * <p>clone.</p> // * // * @return a {@link com.gwidgets.api.leaflet.Point} object // */ // @JsMethod // public native Point clone(); // // /** // * Returns a copy of the current point with rounded coordinates. // * // * @return the point // */ // @JsMethod // public native Point round(); // // // /** // * Returns a copy of the current point with floored coordinates (rounded down). // * // * @return the point // */ // @JsMethod // public native Point floor(); // // // // /** // * Returns true if the both coordinates of the given point are less than the corresponding current point coordinates (in absolute values). // * // * @param point the point // * @return true/false // */ // @JsMethod // public native Boolean contains(Point point); // // /** // * Returns true if the given point has the same coordinates. // * // * @param otherPoint the other point // * @return true/false // */ // @JsMethod // public native Boolean equals(Point otherPoint); // // /* (non-Javadoc) // * @see java.lang.Object#toString() // */ // /** // * <p>toString.</p> // * // * @return a {@link java.lang.String} object // */ // @JsMethod // public native String toString(); // // } // Path: src/main/java/com/gwidgets/api/leaflet/options/IconOptions.java import static jsinterop.annotations.JsPackage.GLOBAL; import com.gwidgets.api.leaflet.Point; import jsinterop.annotations.JsOverlay; import jsinterop.annotations.JsProperty; import jsinterop.annotations.JsType; /** * Copyright 2016 G-Widgets * 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.gwidgets.api.leaflet.options; /** * The Class IconOptions. * * @author <a href="mailto:zakaria.amine88@gmail.com">Zakaria Amine</a> * @version $Id: $Id */ @JsType(isNative=true, namespace=GLOBAL, name="Object") public class IconOptions { private IconOptions(){ } @JsProperty private String iconUrl; @JsProperty private String iconRetinaUrl; @JsProperty
private Point iconSize;
gwidgets/gwty-leaflet
src/main/java/com/gwidgets/api/leaflet/events/TileEvent.java
// Path: src/main/java/com/gwidgets/api/leaflet/Point.java // @JsType(isNative = true) // public class Point { // // // // /** The x coordinate. */ // @JsProperty // public double x; // // /** The The y coordinate. */ // @JsProperty // public double y; // // // // /** // * Returns the result of addition of the current and the given points. // * // * @param otherPoint the other point // * @return the point // */ // @JsMethod // public native Point add(Point otherPoint); // // /** // * Returns the result of subtraction of the given point from the current. // * // * @param otherPoint the other point // * @return the point // */ // @JsMethod // public native Point subtract(Point otherPoint); // // /** // * Returns the result of multiplication of the current point by the given number. // * // * @param number the number // * @return the point // */ // @JsMethod // public native Point multiplyBy(double number); // // /** // * Returns the result of division of the current point by the given number. If optional round is set to true, returns a rounded result. // * // * @param number the number // * @param round the round // * @return the point // */ // @JsMethod // public native Point divideBy(double number, Boolean round); // // /** // * Returns the distance between the current and the given points. // * // * @param otherPoint the other point // * @return the number // */ // @JsMethod // public native double distanceTo(Point otherPoint); // // /* (non-Javadoc) // * @see java.lang.Object#clone() // */ // /** // * <p>clone.</p> // * // * @return a {@link com.gwidgets.api.leaflet.Point} object // */ // @JsMethod // public native Point clone(); // // /** // * Returns a copy of the current point with rounded coordinates. // * // * @return the point // */ // @JsMethod // public native Point round(); // // // /** // * Returns a copy of the current point with floored coordinates (rounded down). // * // * @return the point // */ // @JsMethod // public native Point floor(); // // // // /** // * Returns true if the both coordinates of the given point are less than the corresponding current point coordinates (in absolute values). // * // * @param point the point // * @return true/false // */ // @JsMethod // public native Boolean contains(Point point); // // /** // * Returns true if the given point has the same coordinates. // * // * @param otherPoint the other point // * @return true/false // */ // @JsMethod // public native Boolean equals(Point otherPoint); // // /* (non-Javadoc) // * @see java.lang.Object#toString() // */ // /** // * <p>toString.</p> // * // * @return a {@link java.lang.String} object // */ // @JsMethod // public native String toString(); // // }
import com.gwidgets.api.leaflet.Point; import elemental2.dom.HTMLElement; import jsinterop.annotations.JsProperty; import jsinterop.annotations.JsType;
/** * Copyright 2016 G-Widgets * 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.gwidgets.api.leaflet.events; /** * The Class TileEvent. * * @author <a href="mailto:zakaria.amine88@gmail.com">Zakaria Amine</a> * @version $Id: $Id */ @JsType(isNative=true, name="Object", namespace=jsinterop.annotations.JsPackage.GLOBAL) public class TileEvent extends Event { private TileEvent() {} /** * Gets the tile element (image). * * @return the tile */ @JsProperty public final native HTMLElement getTile(); /** * Point object with tile's x, y, and z (zoom level) coordinates. * * @return the coords */ @JsProperty
// Path: src/main/java/com/gwidgets/api/leaflet/Point.java // @JsType(isNative = true) // public class Point { // // // // /** The x coordinate. */ // @JsProperty // public double x; // // /** The The y coordinate. */ // @JsProperty // public double y; // // // // /** // * Returns the result of addition of the current and the given points. // * // * @param otherPoint the other point // * @return the point // */ // @JsMethod // public native Point add(Point otherPoint); // // /** // * Returns the result of subtraction of the given point from the current. // * // * @param otherPoint the other point // * @return the point // */ // @JsMethod // public native Point subtract(Point otherPoint); // // /** // * Returns the result of multiplication of the current point by the given number. // * // * @param number the number // * @return the point // */ // @JsMethod // public native Point multiplyBy(double number); // // /** // * Returns the result of division of the current point by the given number. If optional round is set to true, returns a rounded result. // * // * @param number the number // * @param round the round // * @return the point // */ // @JsMethod // public native Point divideBy(double number, Boolean round); // // /** // * Returns the distance between the current and the given points. // * // * @param otherPoint the other point // * @return the number // */ // @JsMethod // public native double distanceTo(Point otherPoint); // // /* (non-Javadoc) // * @see java.lang.Object#clone() // */ // /** // * <p>clone.</p> // * // * @return a {@link com.gwidgets.api.leaflet.Point} object // */ // @JsMethod // public native Point clone(); // // /** // * Returns a copy of the current point with rounded coordinates. // * // * @return the point // */ // @JsMethod // public native Point round(); // // // /** // * Returns a copy of the current point with floored coordinates (rounded down). // * // * @return the point // */ // @JsMethod // public native Point floor(); // // // // /** // * Returns true if the both coordinates of the given point are less than the corresponding current point coordinates (in absolute values). // * // * @param point the point // * @return true/false // */ // @JsMethod // public native Boolean contains(Point point); // // /** // * Returns true if the given point has the same coordinates. // * // * @param otherPoint the other point // * @return true/false // */ // @JsMethod // public native Boolean equals(Point otherPoint); // // /* (non-Javadoc) // * @see java.lang.Object#toString() // */ // /** // * <p>toString.</p> // * // * @return a {@link java.lang.String} object // */ // @JsMethod // public native String toString(); // // } // Path: src/main/java/com/gwidgets/api/leaflet/events/TileEvent.java import com.gwidgets.api.leaflet.Point; import elemental2.dom.HTMLElement; import jsinterop.annotations.JsProperty; import jsinterop.annotations.JsType; /** * Copyright 2016 G-Widgets * 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.gwidgets.api.leaflet.events; /** * The Class TileEvent. * * @author <a href="mailto:zakaria.amine88@gmail.com">Zakaria Amine</a> * @version $Id: $Id */ @JsType(isNative=true, name="Object", namespace=jsinterop.annotations.JsPackage.GLOBAL) public class TileEvent extends Event { private TileEvent() {} /** * Gets the tile element (image). * * @return the tile */ @JsProperty public final native HTMLElement getTile(); /** * Point object with tile's x, y, and z (zoom level) coordinates. * * @return the coords */ @JsProperty
public final native Point getCoords();
gwidgets/gwty-leaflet
src/main/java/com/gwidgets/api/leaflet/GeoJSON.java
// Path: src/main/java/com/gwidgets/api/leaflet/options/GeoJSONOptions.java // @JsType(isNative = true, namespace = GLOBAL, name = "Object") // public class GeoJSONOptions { // // @JsProperty // String attribution; // // @JsProperty // String pane; // // // /** // * By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default. // * // * @return the attribution // */ // @JsOverlay // public final String getAttribution() { // return this.attribution; // } // // /** // * String to be shown in the attribution control, describes the layer data, e.g. "© Mapbox". // * // * @return the attribution // */ // @JsOverlay public final String getPane() { // return this.pane; // } // // /** // * Function that will be used for creating layers for GeoJSON points (if not specified, simple markers will be created). // */ // @JsProperty // public PointToLayerFunction pointToLayer; // // /** // * Function that will be used to get style options for vector layers created for GeoJSON features. // * // */ // @JsProperty // public StyleFunction style; // // /** // * Function that will be called on each created feature layer. Useful for attaching events and popups to features. // * // */ // @JsProperty // public OnEachFeatureFunction onEachFeature; // // /** // * Function that will be used to decide whether to show a feature or not. // */ // @JsProperty // public FilterFunction filter; // // /** // * Function that will be used for converting GeoJSON coordinates to LatLng points (if not specified, coords will be assumed to be WGS84 standard [longitude, latitude] values in degrees). // */ // @JsProperty // public CoordsToLatLngFunction coordsToLatLng; // // @JsFunction // public interface PointToLayerFunction { // // /** // * Function that will be used for creating layers for GeoJSON points (if not specified, simple markers will be created). // * // * @param feature data // * @param latLng the latlng // */ // Marker apply(JsObject feature, LatLng latLng); // // } // // @JsFunction // public interface StyleFunction { // // /** // * Function that will be used to get style options for vector layers created for GeoJSON features. // * // * @param featureData the feature data // * @return the function // */ // JsObject apply(JsObject featureData); // // } // // @JsFunction // public interface OnEachFeatureFunction { // // /** // * Function that will be called on each created feature layer. Useful for attaching events and popups to features. // * // * @param featureData the feature data // * @param layer the layer // */ // JsObject apply(JsObject featureData, Layer layer); // // } // // @JsFunction // public interface FilterFunction { // /** // * Function that will be used to decide whether to show a feature or not. // * // * @param feature the feature data // * @param layer the layer // */ // JsObject apply(JsObject feature, Layer layer); // // } // // @JsFunction // public interface CoordsToLatLngFunction { // // /** // * Function that will be used for converting GeoJSON coordinates to LatLng points (if not specified, coords will be assumed to be WGS84 standard [longitude, latitude] values in degrees). // * // * @param coords the coords // * @param layer layer // */ // LatLng apply(JsObject coords, Layer layer); // } // // }
import com.gwidgets.api.leaflet.options.GeoJSONOptions; import elemental2.core.JsObject; import jsinterop.annotations.JsMethod; import jsinterop.annotations.JsType;
package com.gwidgets.api.leaflet; /** * Copyright 2016 G-Widgets * 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. */ /** *Represents a GeoJSON object or an array of GeoJSON objects. Allows you to parse GeoJSON data and display it on the map. * *@author <a href="mailto:zakaria.amine88@gmail.com">Zakaria Amine</a> * @version $Id: $Id */ @JsType(isNative = true) public class GeoJSON extends FeatureGroup { private GeoJSON() { } /** * Adds a GeoJSON object to the layer. * * @param data the data * @return the L class */ @JsMethod public native L addData(JsObject data); /** * Changes styles of GeoJSON vector layers with the given style function. * * @param style the style function * @return the L class */ @JsMethod
// Path: src/main/java/com/gwidgets/api/leaflet/options/GeoJSONOptions.java // @JsType(isNative = true, namespace = GLOBAL, name = "Object") // public class GeoJSONOptions { // // @JsProperty // String attribution; // // @JsProperty // String pane; // // // /** // * By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default. // * // * @return the attribution // */ // @JsOverlay // public final String getAttribution() { // return this.attribution; // } // // /** // * String to be shown in the attribution control, describes the layer data, e.g. "© Mapbox". // * // * @return the attribution // */ // @JsOverlay public final String getPane() { // return this.pane; // } // // /** // * Function that will be used for creating layers for GeoJSON points (if not specified, simple markers will be created). // */ // @JsProperty // public PointToLayerFunction pointToLayer; // // /** // * Function that will be used to get style options for vector layers created for GeoJSON features. // * // */ // @JsProperty // public StyleFunction style; // // /** // * Function that will be called on each created feature layer. Useful for attaching events and popups to features. // * // */ // @JsProperty // public OnEachFeatureFunction onEachFeature; // // /** // * Function that will be used to decide whether to show a feature or not. // */ // @JsProperty // public FilterFunction filter; // // /** // * Function that will be used for converting GeoJSON coordinates to LatLng points (if not specified, coords will be assumed to be WGS84 standard [longitude, latitude] values in degrees). // */ // @JsProperty // public CoordsToLatLngFunction coordsToLatLng; // // @JsFunction // public interface PointToLayerFunction { // // /** // * Function that will be used for creating layers for GeoJSON points (if not specified, simple markers will be created). // * // * @param feature data // * @param latLng the latlng // */ // Marker apply(JsObject feature, LatLng latLng); // // } // // @JsFunction // public interface StyleFunction { // // /** // * Function that will be used to get style options for vector layers created for GeoJSON features. // * // * @param featureData the feature data // * @return the function // */ // JsObject apply(JsObject featureData); // // } // // @JsFunction // public interface OnEachFeatureFunction { // // /** // * Function that will be called on each created feature layer. Useful for attaching events and popups to features. // * // * @param featureData the feature data // * @param layer the layer // */ // JsObject apply(JsObject featureData, Layer layer); // // } // // @JsFunction // public interface FilterFunction { // /** // * Function that will be used to decide whether to show a feature or not. // * // * @param feature the feature data // * @param layer the layer // */ // JsObject apply(JsObject feature, Layer layer); // // } // // @JsFunction // public interface CoordsToLatLngFunction { // // /** // * Function that will be used for converting GeoJSON coordinates to LatLng points (if not specified, coords will be assumed to be WGS84 standard [longitude, latitude] values in degrees). // * // * @param coords the coords // * @param layer layer // */ // LatLng apply(JsObject coords, Layer layer); // } // // } // Path: src/main/java/com/gwidgets/api/leaflet/GeoJSON.java import com.gwidgets.api.leaflet.options.GeoJSONOptions; import elemental2.core.JsObject; import jsinterop.annotations.JsMethod; import jsinterop.annotations.JsType; package com.gwidgets.api.leaflet; /** * Copyright 2016 G-Widgets * 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. */ /** *Represents a GeoJSON object or an array of GeoJSON objects. Allows you to parse GeoJSON data and display it on the map. * *@author <a href="mailto:zakaria.amine88@gmail.com">Zakaria Amine</a> * @version $Id: $Id */ @JsType(isNative = true) public class GeoJSON extends FeatureGroup { private GeoJSON() { } /** * Adds a GeoJSON object to the layer. * * @param data the data * @return the L class */ @JsMethod public native L addData(JsObject data); /** * Changes styles of GeoJSON vector layers with the given style function. * * @param style the style function * @return the L class */ @JsMethod
public native L setStyle(GeoJSONOptions.StyleFunction style);
gwidgets/gwty-leaflet
src/main/java/com/gwidgets/api/leaflet/options/GridLayerOptions.java
// Path: src/main/java/com/gwidgets/api/leaflet/LatLngBounds.java // @JsType(isNative = true) // public class LatLngBounds { // // // // private LatLngBounds() { // // } // // /** // * Extends the bounds to contain the given point. // * // * @param latlng the latlng // * @return the L class // */ // @JsMethod // public native L extend(LatLng latlng); // // /** // * Extends the bounds to contain the given bounds. // * // * @param latlng the latlng // * @return the L class // */ // @JsMethod // public native L extend(LatLngBounds latlng); // // /** // * Returns the south-west point of the bounds. // * // * @return the south west // */ // @JsMethod // public native LatLng getSouthWest(); // // /** // * Returns the north-east point of the bounds. // * // * @return the north east // */ // @JsMethod // public native LatLng getNorthEast(); // // /** // * Returns the north-west point of the bounds. // * // * @return the north west // */ // @JsMethod // public native LatLng getNorthWest(); // // /** // * Returns the south-east point of the bounds. // * // * @return the south east // */ // @JsMethod // public native LatLng getSouthEast(); // // /** // * Returns the west longitude of the bounds. // * // * @return the west // */ // @JsMethod // public native double getWest(); // // /** // * Returns the south latitude of the bounds. // * // * @return the south // */ // @JsMethod // public native double getSouth(); // // /** // * Returns the east longitude of the bounds. // * // * @return the east // */ // @JsMethod // public native double getEast(); // // /** // * Returns the north latitude of the bounds. // * // * @return the north // */ // @JsMethod // public native double getNorth(); // // /** // * Returns the center point of the bounds. // * // * @return the center // */ // @JsMethod // public native LatLng getCenter(); // // /** // * Returns true if the rectangle contains the given one. // * // * @param otherBounds the other bounds // * @return true/false // */ // @JsMethod // public native Boolean contains(LatLngBounds otherBounds); // // /** // * Returns true if the rectangle contains the given point. // * // * @param latlng the latlng // * @return true/false // */ // @JsMethod // public native Boolean contains(LatLng latlng); // // /** // * Returns true if the rectangle intersects the given bounds. // * // * @param otherBounds the other bounds // * @return true/false // */ // @JsMethod // public native Boolean intersects(LatLngBounds otherBounds); // // /** // * Returns true if the rectangle is equivalent (within a small margin of error) to the given bounds. // * // * @param otherBounds the other bounds // * @return true/flase // */ // @JsMethod // public native Boolean equals(LatLngBounds otherBounds); // // /** // * Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for sending requests to web services that return geo data // * // * @return the string // */ // @JsMethod // public native String toBBoxString(); // // /** // * Returns bigger bounds created by extending the current bounds by a given percentage in each direction. // * // * @param bufferRatio the buffer ratio // * @return the lat lng bounds // */ // @JsMethod // public native LatLngBounds pad(double bufferRatio); // // /** // * Returns true if the bounds are properly initialized. // * // * @return true/false // */ // @JsMethod // public native Boolean isValid(); // // }
import static jsinterop.annotations.JsPackage.GLOBAL; import com.gwidgets.api.leaflet.LatLngBounds; import jsinterop.annotations.JsOverlay; import jsinterop.annotations.JsType;
package com.gwidgets.api.leaflet.options; /** * <p>GridLayerOptions class.</p> * * @author zakaria * @version $Id: $Id */ @JsType(isNative=true, namespace=GLOBAL, name="Object") public class GridLayerOptions { private double tileSize; private double opacity; private boolean updateWhenIdle; private boolean updateWhenZooming; private double updateInterval; private String attribution; private double zIndex;
// Path: src/main/java/com/gwidgets/api/leaflet/LatLngBounds.java // @JsType(isNative = true) // public class LatLngBounds { // // // // private LatLngBounds() { // // } // // /** // * Extends the bounds to contain the given point. // * // * @param latlng the latlng // * @return the L class // */ // @JsMethod // public native L extend(LatLng latlng); // // /** // * Extends the bounds to contain the given bounds. // * // * @param latlng the latlng // * @return the L class // */ // @JsMethod // public native L extend(LatLngBounds latlng); // // /** // * Returns the south-west point of the bounds. // * // * @return the south west // */ // @JsMethod // public native LatLng getSouthWest(); // // /** // * Returns the north-east point of the bounds. // * // * @return the north east // */ // @JsMethod // public native LatLng getNorthEast(); // // /** // * Returns the north-west point of the bounds. // * // * @return the north west // */ // @JsMethod // public native LatLng getNorthWest(); // // /** // * Returns the south-east point of the bounds. // * // * @return the south east // */ // @JsMethod // public native LatLng getSouthEast(); // // /** // * Returns the west longitude of the bounds. // * // * @return the west // */ // @JsMethod // public native double getWest(); // // /** // * Returns the south latitude of the bounds. // * // * @return the south // */ // @JsMethod // public native double getSouth(); // // /** // * Returns the east longitude of the bounds. // * // * @return the east // */ // @JsMethod // public native double getEast(); // // /** // * Returns the north latitude of the bounds. // * // * @return the north // */ // @JsMethod // public native double getNorth(); // // /** // * Returns the center point of the bounds. // * // * @return the center // */ // @JsMethod // public native LatLng getCenter(); // // /** // * Returns true if the rectangle contains the given one. // * // * @param otherBounds the other bounds // * @return true/false // */ // @JsMethod // public native Boolean contains(LatLngBounds otherBounds); // // /** // * Returns true if the rectangle contains the given point. // * // * @param latlng the latlng // * @return true/false // */ // @JsMethod // public native Boolean contains(LatLng latlng); // // /** // * Returns true if the rectangle intersects the given bounds. // * // * @param otherBounds the other bounds // * @return true/false // */ // @JsMethod // public native Boolean intersects(LatLngBounds otherBounds); // // /** // * Returns true if the rectangle is equivalent (within a small margin of error) to the given bounds. // * // * @param otherBounds the other bounds // * @return true/flase // */ // @JsMethod // public native Boolean equals(LatLngBounds otherBounds); // // /** // * Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for sending requests to web services that return geo data // * // * @return the string // */ // @JsMethod // public native String toBBoxString(); // // /** // * Returns bigger bounds created by extending the current bounds by a given percentage in each direction. // * // * @param bufferRatio the buffer ratio // * @return the lat lng bounds // */ // @JsMethod // public native LatLngBounds pad(double bufferRatio); // // /** // * Returns true if the bounds are properly initialized. // * // * @return true/false // */ // @JsMethod // public native Boolean isValid(); // // } // Path: src/main/java/com/gwidgets/api/leaflet/options/GridLayerOptions.java import static jsinterop.annotations.JsPackage.GLOBAL; import com.gwidgets.api.leaflet.LatLngBounds; import jsinterop.annotations.JsOverlay; import jsinterop.annotations.JsType; package com.gwidgets.api.leaflet.options; /** * <p>GridLayerOptions class.</p> * * @author zakaria * @version $Id: $Id */ @JsType(isNative=true, namespace=GLOBAL, name="Object") public class GridLayerOptions { private double tileSize; private double opacity; private boolean updateWhenIdle; private boolean updateWhenZooming; private double updateInterval; private String attribution; private double zIndex;
private LatLngBounds bounds;
gwidgets/gwty-leaflet
src/main/java/com/gwidgets/api/leaflet/events/ResizeEvent.java
// Path: src/main/java/com/gwidgets/api/leaflet/Point.java // @JsType(isNative = true) // public class Point { // // // // /** The x coordinate. */ // @JsProperty // public double x; // // /** The The y coordinate. */ // @JsProperty // public double y; // // // // /** // * Returns the result of addition of the current and the given points. // * // * @param otherPoint the other point // * @return the point // */ // @JsMethod // public native Point add(Point otherPoint); // // /** // * Returns the result of subtraction of the given point from the current. // * // * @param otherPoint the other point // * @return the point // */ // @JsMethod // public native Point subtract(Point otherPoint); // // /** // * Returns the result of multiplication of the current point by the given number. // * // * @param number the number // * @return the point // */ // @JsMethod // public native Point multiplyBy(double number); // // /** // * Returns the result of division of the current point by the given number. If optional round is set to true, returns a rounded result. // * // * @param number the number // * @param round the round // * @return the point // */ // @JsMethod // public native Point divideBy(double number, Boolean round); // // /** // * Returns the distance between the current and the given points. // * // * @param otherPoint the other point // * @return the number // */ // @JsMethod // public native double distanceTo(Point otherPoint); // // /* (non-Javadoc) // * @see java.lang.Object#clone() // */ // /** // * <p>clone.</p> // * // * @return a {@link com.gwidgets.api.leaflet.Point} object // */ // @JsMethod // public native Point clone(); // // /** // * Returns a copy of the current point with rounded coordinates. // * // * @return the point // */ // @JsMethod // public native Point round(); // // // /** // * Returns a copy of the current point with floored coordinates (rounded down). // * // * @return the point // */ // @JsMethod // public native Point floor(); // // // // /** // * Returns true if the both coordinates of the given point are less than the corresponding current point coordinates (in absolute values). // * // * @param point the point // * @return true/false // */ // @JsMethod // public native Boolean contains(Point point); // // /** // * Returns true if the given point has the same coordinates. // * // * @param otherPoint the other point // * @return true/false // */ // @JsMethod // public native Boolean equals(Point otherPoint); // // /* (non-Javadoc) // * @see java.lang.Object#toString() // */ // /** // * <p>toString.</p> // * // * @return a {@link java.lang.String} object // */ // @JsMethod // public native String toString(); // // }
import com.gwidgets.api.leaflet.Point; import jsinterop.annotations.JsProperty; import jsinterop.annotations.JsType;
/** * Copyright 2016 G-Widgets * 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.gwidgets.api.leaflet.events; /** * The Class ResizeEvent. * * @author <a href="mailto:zakaria.amine88@gmail.com">Zakaria Amine</a> * @version $Id: $Id */ @JsType(isNative=true, name="Object", namespace=jsinterop.annotations.JsPackage.GLOBAL) public class ResizeEvent extends Event { /** * Instantiates a new resize event. */ private ResizeEvent(){} /** * Gets the old size before resize event. * * @return the old size */ @JsProperty
// Path: src/main/java/com/gwidgets/api/leaflet/Point.java // @JsType(isNative = true) // public class Point { // // // // /** The x coordinate. */ // @JsProperty // public double x; // // /** The The y coordinate. */ // @JsProperty // public double y; // // // // /** // * Returns the result of addition of the current and the given points. // * // * @param otherPoint the other point // * @return the point // */ // @JsMethod // public native Point add(Point otherPoint); // // /** // * Returns the result of subtraction of the given point from the current. // * // * @param otherPoint the other point // * @return the point // */ // @JsMethod // public native Point subtract(Point otherPoint); // // /** // * Returns the result of multiplication of the current point by the given number. // * // * @param number the number // * @return the point // */ // @JsMethod // public native Point multiplyBy(double number); // // /** // * Returns the result of division of the current point by the given number. If optional round is set to true, returns a rounded result. // * // * @param number the number // * @param round the round // * @return the point // */ // @JsMethod // public native Point divideBy(double number, Boolean round); // // /** // * Returns the distance between the current and the given points. // * // * @param otherPoint the other point // * @return the number // */ // @JsMethod // public native double distanceTo(Point otherPoint); // // /* (non-Javadoc) // * @see java.lang.Object#clone() // */ // /** // * <p>clone.</p> // * // * @return a {@link com.gwidgets.api.leaflet.Point} object // */ // @JsMethod // public native Point clone(); // // /** // * Returns a copy of the current point with rounded coordinates. // * // * @return the point // */ // @JsMethod // public native Point round(); // // // /** // * Returns a copy of the current point with floored coordinates (rounded down). // * // * @return the point // */ // @JsMethod // public native Point floor(); // // // // /** // * Returns true if the both coordinates of the given point are less than the corresponding current point coordinates (in absolute values). // * // * @param point the point // * @return true/false // */ // @JsMethod // public native Boolean contains(Point point); // // /** // * Returns true if the given point has the same coordinates. // * // * @param otherPoint the other point // * @return true/false // */ // @JsMethod // public native Boolean equals(Point otherPoint); // // /* (non-Javadoc) // * @see java.lang.Object#toString() // */ // /** // * <p>toString.</p> // * // * @return a {@link java.lang.String} object // */ // @JsMethod // public native String toString(); // // } // Path: src/main/java/com/gwidgets/api/leaflet/events/ResizeEvent.java import com.gwidgets.api.leaflet.Point; import jsinterop.annotations.JsProperty; import jsinterop.annotations.JsType; /** * Copyright 2016 G-Widgets * 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.gwidgets.api.leaflet.events; /** * The Class ResizeEvent. * * @author <a href="mailto:zakaria.amine88@gmail.com">Zakaria Amine</a> * @version $Id: $Id */ @JsType(isNative=true, name="Object", namespace=jsinterop.annotations.JsPackage.GLOBAL) public class ResizeEvent extends Event { /** * Instantiates a new resize event. */ private ResizeEvent(){} /** * Gets the old size before resize event. * * @return the old size */ @JsProperty
public final native Point getOldSize();
quhfus/DoSeR-Disambiguation
doser-dis-core/src/main/java/doser/word2vec/Word2VecJsonFormat.java
// Path: doser-dis-core/src/main/java/doser/entitydisambiguation/properties/Properties.java // public final class Properties { // private static Properties instance; // private static final String RESOURCE_NAME = "disambiguation.properties"; // // private static final String RESOURCE_NAME = "./disambiguation.properties"; // // public synchronized static Properties getInstance() { // if (instance == null) { // instance = new Properties(); // } // // return instance; // } // // /** // * Provides easy access to property files (e.g. config.getInt()) // */ // PropertiesConfiguration config; // // private Properties() { // try { // this.config = new PropertiesConfiguration(RESOURCE_NAME); // } catch (final ConfigurationException e) { // Logger.getRootLogger().error("Failed to load properties file: " + RESOURCE_NAME, e); // } // } // // /** // * ArtifactId of the application (from maven pom.xml) // * // * @return artifact id // */ // public String getApplicationArtifactId() { // return this.config.getString("application.artifactId"); // } // // /** // * Name of the application (from maven pom.xml) // * // * @return application name // */ // public String getApplicationName() { // return this.config.getString("application.name"); // } // // /** // * Version of the application (from maven pom.xml) // * // * @return application version // */ // public String getApplicationVersion() { // return this.config.getString("application.version"); // } // // public int getDisambiguationResultSize() { // final String size = this.config.getString("disambiguation.returnSize"); // return Integer.valueOf(size); // } // // /** // * Get location of entity-centric knowledge base // */ // public String getEntityCentricKBWikipedia() { // return this.config.getString("disambiguation.entityCentricKBWikipedia"); // } // // public String getEntityCentricKBBiomed() { // return this.config.getString("disambiguation.entityCentricBiomedCalbC"); // } // // public String getWord2VecService() { // return this.config.getString("disambiguation.Word2VecService"); // } // // public String getWord2VecModel() { // return this.config.getString("word2vecmodel"); // } // // public boolean getCandidateExpansion() { // boolean bool = false; // String s = this.config.getString("candidateExpansion"); // if(s.equalsIgnoreCase("true")) { // bool = true; // } // return bool; // } // } // // Path: doser-dis-core/src/main/java/doser/tools/ServiceQueries.java // public class ServiceQueries { // // public static String httpPostRequest(String uri, AbstractHttpEntity entity, // Header[] header) { // DefaultHttpClient httpclient = new DefaultHttpClient(); // HttpPost httppost = new HttpPost(uri); // httppost.setHeaders(header); // httppost.setEntity(entity); // // HttpResponse response; // StringBuffer buffer = new StringBuffer(); // try { // response = httpclient.execute(httppost); // HttpEntity ent = response.getEntity(); // // buffer.append(EntityUtils.toString(ent)); // httpclient.getConnectionManager().shutdown(); // // } catch (ClientProtocolException e) { // Logger.getRootLogger().error("HTTPClient error", e); // } catch (IOException e) { // Logger.getRootLogger().error("HTTPClient error", e); // } // return buffer.toString(); // } // }
import java.io.IOException; import java.util.Set; import org.apache.http.Header; import org.apache.http.entity.ByteArrayEntity; import org.apache.http.entity.ContentType; import org.apache.http.message.BasicHeader; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import doser.entitydisambiguation.properties.Properties; import doser.tools.ServiceQueries;
package doser.word2vec; public class Word2VecJsonFormat { private final static Logger logger = LoggerFactory.getLogger(Word2VecJsonFormat.class); private String domain; private Set<String> data; public Set<String> getData() { return data; } public void setData(Set<String> data) { this.data = data; } public String getDomain() { return domain; } public void setDomain(String domain) { this.domain = domain; } public static JSONArray performquery(Object json, String serviceEndpoint) { final ObjectMapper mapper = new ObjectMapper(); String jsonString = null; JSONArray result = null; try { jsonString = mapper.writeValueAsString(json); Header[] headers = { new BasicHeader("Accept", "application/json"), new BasicHeader("content-type", "application/json") }; ByteArrayEntity ent = new ByteArrayEntity(jsonString.getBytes(), ContentType.create("application/json"));
// Path: doser-dis-core/src/main/java/doser/entitydisambiguation/properties/Properties.java // public final class Properties { // private static Properties instance; // private static final String RESOURCE_NAME = "disambiguation.properties"; // // private static final String RESOURCE_NAME = "./disambiguation.properties"; // // public synchronized static Properties getInstance() { // if (instance == null) { // instance = new Properties(); // } // // return instance; // } // // /** // * Provides easy access to property files (e.g. config.getInt()) // */ // PropertiesConfiguration config; // // private Properties() { // try { // this.config = new PropertiesConfiguration(RESOURCE_NAME); // } catch (final ConfigurationException e) { // Logger.getRootLogger().error("Failed to load properties file: " + RESOURCE_NAME, e); // } // } // // /** // * ArtifactId of the application (from maven pom.xml) // * // * @return artifact id // */ // public String getApplicationArtifactId() { // return this.config.getString("application.artifactId"); // } // // /** // * Name of the application (from maven pom.xml) // * // * @return application name // */ // public String getApplicationName() { // return this.config.getString("application.name"); // } // // /** // * Version of the application (from maven pom.xml) // * // * @return application version // */ // public String getApplicationVersion() { // return this.config.getString("application.version"); // } // // public int getDisambiguationResultSize() { // final String size = this.config.getString("disambiguation.returnSize"); // return Integer.valueOf(size); // } // // /** // * Get location of entity-centric knowledge base // */ // public String getEntityCentricKBWikipedia() { // return this.config.getString("disambiguation.entityCentricKBWikipedia"); // } // // public String getEntityCentricKBBiomed() { // return this.config.getString("disambiguation.entityCentricBiomedCalbC"); // } // // public String getWord2VecService() { // return this.config.getString("disambiguation.Word2VecService"); // } // // public String getWord2VecModel() { // return this.config.getString("word2vecmodel"); // } // // public boolean getCandidateExpansion() { // boolean bool = false; // String s = this.config.getString("candidateExpansion"); // if(s.equalsIgnoreCase("true")) { // bool = true; // } // return bool; // } // } // // Path: doser-dis-core/src/main/java/doser/tools/ServiceQueries.java // public class ServiceQueries { // // public static String httpPostRequest(String uri, AbstractHttpEntity entity, // Header[] header) { // DefaultHttpClient httpclient = new DefaultHttpClient(); // HttpPost httppost = new HttpPost(uri); // httppost.setHeaders(header); // httppost.setEntity(entity); // // HttpResponse response; // StringBuffer buffer = new StringBuffer(); // try { // response = httpclient.execute(httppost); // HttpEntity ent = response.getEntity(); // // buffer.append(EntityUtils.toString(ent)); // httpclient.getConnectionManager().shutdown(); // // } catch (ClientProtocolException e) { // Logger.getRootLogger().error("HTTPClient error", e); // } catch (IOException e) { // Logger.getRootLogger().error("HTTPClient error", e); // } // return buffer.toString(); // } // } // Path: doser-dis-core/src/main/java/doser/word2vec/Word2VecJsonFormat.java import java.io.IOException; import java.util.Set; import org.apache.http.Header; import org.apache.http.entity.ByteArrayEntity; import org.apache.http.entity.ContentType; import org.apache.http.message.BasicHeader; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import doser.entitydisambiguation.properties.Properties; import doser.tools.ServiceQueries; package doser.word2vec; public class Word2VecJsonFormat { private final static Logger logger = LoggerFactory.getLogger(Word2VecJsonFormat.class); private String domain; private Set<String> data; public Set<String> getData() { return data; } public void setData(Set<String> data) { this.data = data; } public String getDomain() { return domain; } public void setDomain(String domain) { this.domain = domain; } public static JSONArray performquery(Object json, String serviceEndpoint) { final ObjectMapper mapper = new ObjectMapper(); String jsonString = null; JSONArray result = null; try { jsonString = mapper.writeValueAsString(json); Header[] headers = { new BasicHeader("Accept", "application/json"), new BasicHeader("content-type", "application/json") }; ByteArrayEntity ent = new ByteArrayEntity(jsonString.getBytes(), ContentType.create("application/json"));
String resStr = ServiceQueries.httpPostRequest(
quhfus/DoSeR-Disambiguation
doser-dis-core/src/main/java/doser/word2vec/Word2VecJsonFormat.java
// Path: doser-dis-core/src/main/java/doser/entitydisambiguation/properties/Properties.java // public final class Properties { // private static Properties instance; // private static final String RESOURCE_NAME = "disambiguation.properties"; // // private static final String RESOURCE_NAME = "./disambiguation.properties"; // // public synchronized static Properties getInstance() { // if (instance == null) { // instance = new Properties(); // } // // return instance; // } // // /** // * Provides easy access to property files (e.g. config.getInt()) // */ // PropertiesConfiguration config; // // private Properties() { // try { // this.config = new PropertiesConfiguration(RESOURCE_NAME); // } catch (final ConfigurationException e) { // Logger.getRootLogger().error("Failed to load properties file: " + RESOURCE_NAME, e); // } // } // // /** // * ArtifactId of the application (from maven pom.xml) // * // * @return artifact id // */ // public String getApplicationArtifactId() { // return this.config.getString("application.artifactId"); // } // // /** // * Name of the application (from maven pom.xml) // * // * @return application name // */ // public String getApplicationName() { // return this.config.getString("application.name"); // } // // /** // * Version of the application (from maven pom.xml) // * // * @return application version // */ // public String getApplicationVersion() { // return this.config.getString("application.version"); // } // // public int getDisambiguationResultSize() { // final String size = this.config.getString("disambiguation.returnSize"); // return Integer.valueOf(size); // } // // /** // * Get location of entity-centric knowledge base // */ // public String getEntityCentricKBWikipedia() { // return this.config.getString("disambiguation.entityCentricKBWikipedia"); // } // // public String getEntityCentricKBBiomed() { // return this.config.getString("disambiguation.entityCentricBiomedCalbC"); // } // // public String getWord2VecService() { // return this.config.getString("disambiguation.Word2VecService"); // } // // public String getWord2VecModel() { // return this.config.getString("word2vecmodel"); // } // // public boolean getCandidateExpansion() { // boolean bool = false; // String s = this.config.getString("candidateExpansion"); // if(s.equalsIgnoreCase("true")) { // bool = true; // } // return bool; // } // } // // Path: doser-dis-core/src/main/java/doser/tools/ServiceQueries.java // public class ServiceQueries { // // public static String httpPostRequest(String uri, AbstractHttpEntity entity, // Header[] header) { // DefaultHttpClient httpclient = new DefaultHttpClient(); // HttpPost httppost = new HttpPost(uri); // httppost.setHeaders(header); // httppost.setEntity(entity); // // HttpResponse response; // StringBuffer buffer = new StringBuffer(); // try { // response = httpclient.execute(httppost); // HttpEntity ent = response.getEntity(); // // buffer.append(EntityUtils.toString(ent)); // httpclient.getConnectionManager().shutdown(); // // } catch (ClientProtocolException e) { // Logger.getRootLogger().error("HTTPClient error", e); // } catch (IOException e) { // Logger.getRootLogger().error("HTTPClient error", e); // } // return buffer.toString(); // } // }
import java.io.IOException; import java.util.Set; import org.apache.http.Header; import org.apache.http.entity.ByteArrayEntity; import org.apache.http.entity.ContentType; import org.apache.http.message.BasicHeader; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import doser.entitydisambiguation.properties.Properties; import doser.tools.ServiceQueries;
package doser.word2vec; public class Word2VecJsonFormat { private final static Logger logger = LoggerFactory.getLogger(Word2VecJsonFormat.class); private String domain; private Set<String> data; public Set<String> getData() { return data; } public void setData(Set<String> data) { this.data = data; } public String getDomain() { return domain; } public void setDomain(String domain) { this.domain = domain; } public static JSONArray performquery(Object json, String serviceEndpoint) { final ObjectMapper mapper = new ObjectMapper(); String jsonString = null; JSONArray result = null; try { jsonString = mapper.writeValueAsString(json); Header[] headers = { new BasicHeader("Accept", "application/json"), new BasicHeader("content-type", "application/json") }; ByteArrayEntity ent = new ByteArrayEntity(jsonString.getBytes(), ContentType.create("application/json")); String resStr = ServiceQueries.httpPostRequest(
// Path: doser-dis-core/src/main/java/doser/entitydisambiguation/properties/Properties.java // public final class Properties { // private static Properties instance; // private static final String RESOURCE_NAME = "disambiguation.properties"; // // private static final String RESOURCE_NAME = "./disambiguation.properties"; // // public synchronized static Properties getInstance() { // if (instance == null) { // instance = new Properties(); // } // // return instance; // } // // /** // * Provides easy access to property files (e.g. config.getInt()) // */ // PropertiesConfiguration config; // // private Properties() { // try { // this.config = new PropertiesConfiguration(RESOURCE_NAME); // } catch (final ConfigurationException e) { // Logger.getRootLogger().error("Failed to load properties file: " + RESOURCE_NAME, e); // } // } // // /** // * ArtifactId of the application (from maven pom.xml) // * // * @return artifact id // */ // public String getApplicationArtifactId() { // return this.config.getString("application.artifactId"); // } // // /** // * Name of the application (from maven pom.xml) // * // * @return application name // */ // public String getApplicationName() { // return this.config.getString("application.name"); // } // // /** // * Version of the application (from maven pom.xml) // * // * @return application version // */ // public String getApplicationVersion() { // return this.config.getString("application.version"); // } // // public int getDisambiguationResultSize() { // final String size = this.config.getString("disambiguation.returnSize"); // return Integer.valueOf(size); // } // // /** // * Get location of entity-centric knowledge base // */ // public String getEntityCentricKBWikipedia() { // return this.config.getString("disambiguation.entityCentricKBWikipedia"); // } // // public String getEntityCentricKBBiomed() { // return this.config.getString("disambiguation.entityCentricBiomedCalbC"); // } // // public String getWord2VecService() { // return this.config.getString("disambiguation.Word2VecService"); // } // // public String getWord2VecModel() { // return this.config.getString("word2vecmodel"); // } // // public boolean getCandidateExpansion() { // boolean bool = false; // String s = this.config.getString("candidateExpansion"); // if(s.equalsIgnoreCase("true")) { // bool = true; // } // return bool; // } // } // // Path: doser-dis-core/src/main/java/doser/tools/ServiceQueries.java // public class ServiceQueries { // // public static String httpPostRequest(String uri, AbstractHttpEntity entity, // Header[] header) { // DefaultHttpClient httpclient = new DefaultHttpClient(); // HttpPost httppost = new HttpPost(uri); // httppost.setHeaders(header); // httppost.setEntity(entity); // // HttpResponse response; // StringBuffer buffer = new StringBuffer(); // try { // response = httpclient.execute(httppost); // HttpEntity ent = response.getEntity(); // // buffer.append(EntityUtils.toString(ent)); // httpclient.getConnectionManager().shutdown(); // // } catch (ClientProtocolException e) { // Logger.getRootLogger().error("HTTPClient error", e); // } catch (IOException e) { // Logger.getRootLogger().error("HTTPClient error", e); // } // return buffer.toString(); // } // } // Path: doser-dis-core/src/main/java/doser/word2vec/Word2VecJsonFormat.java import java.io.IOException; import java.util.Set; import org.apache.http.Header; import org.apache.http.entity.ByteArrayEntity; import org.apache.http.entity.ContentType; import org.apache.http.message.BasicHeader; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import doser.entitydisambiguation.properties.Properties; import doser.tools.ServiceQueries; package doser.word2vec; public class Word2VecJsonFormat { private final static Logger logger = LoggerFactory.getLogger(Word2VecJsonFormat.class); private String domain; private Set<String> data; public Set<String> getData() { return data; } public void setData(Set<String> data) { this.data = data; } public String getDomain() { return domain; } public void setDomain(String domain) { this.domain = domain; } public static JSONArray performquery(Object json, String serviceEndpoint) { final ObjectMapper mapper = new ObjectMapper(); String jsonString = null; JSONArray result = null; try { jsonString = mapper.writeValueAsString(json); Header[] headers = { new BasicHeader("Accept", "application/json"), new BasicHeader("content-type", "application/json") }; ByteArrayEntity ent = new ByteArrayEntity(jsonString.getBytes(), ContentType.create("application/json")); String resStr = ServiceQueries.httpPostRequest(
(Properties.getInstance().getWord2VecService() + serviceEndpoint), ent, headers);
quhfus/DoSeR-Disambiguation
doser-dis-core/src/main/java/doser/entitydisambiguation/backend/DisambiguationTaskSingle.java
// Path: doser-dis-core/src/main/java/doser/entitydisambiguation/dpo/EntityDisambiguationDPO.java // public class EntityDisambiguationDPO { // // private String documentId; // private String context; // private String selectedText; // private String setting; // private String kbversion; // private int startPosition; // // public EntityDisambiguationDPO() { // super(); // } // // public String getContext() { // return this.context; // } // // public String getSelectedText() { // return this.selectedText; // } // // public void setContext(final String context) { // this.context = context; // } // // public void setSelectedText(final String selectedText) { // this.selectedText = selectedText; // } // // public void setSetting(final String setting) { // this.setting = setting; // } // // public String getSetting() { // return setting; // } // // public void setDocumentId(final String documentId) { // this.documentId = documentId; // } // // public String getDocumentId() { // return this.documentId; // } // // public void setInternSetting(final String setting) { // this.setting = setting; // } // // public String getKbversion() { // return kbversion; // } // // public void setKbversion(String kbversion) { // this.kbversion = kbversion; // } // // public int getStartPosition() { // return startPosition; // } // // public void setStartPosition(int startPosition) { // this.startPosition = startPosition; // } // } // // Path: doser-dis-core/src/main/java/doser/entitydisambiguation/knowledgebases/KnowledgeBaseIdentifiers.java // public enum KnowledgeBaseIdentifiers { // Standard, CSTable, Biomed, DocumentCentricDefault; // }
import doser.entitydisambiguation.dpo.EntityDisambiguationDPO; import doser.entitydisambiguation.knowledgebases.KnowledgeBaseIdentifiers;
package doser.entitydisambiguation.backend; public class DisambiguationTaskSingle extends AbstractDisambiguationTask { private EntityDisambiguationDPO entityToDis; public DisambiguationTaskSingle(final EntityDisambiguationDPO entityToDis) { super(); this.entityToDis = entityToDis; this.retrieveDocClasses = false; } public EntityDisambiguationDPO getEntityToDisambiguate() { return this.entityToDis; } public void setSurfaceForm(final EntityDisambiguationDPO surfaceForm) { this.entityToDis = surfaceForm; } /** * Assignment function to determine the used knowledge base * * @param kbversion * @param setting */ @Override public void setKbIdentifier(String kbversion, String setting) { if(setting == null) {
// Path: doser-dis-core/src/main/java/doser/entitydisambiguation/dpo/EntityDisambiguationDPO.java // public class EntityDisambiguationDPO { // // private String documentId; // private String context; // private String selectedText; // private String setting; // private String kbversion; // private int startPosition; // // public EntityDisambiguationDPO() { // super(); // } // // public String getContext() { // return this.context; // } // // public String getSelectedText() { // return this.selectedText; // } // // public void setContext(final String context) { // this.context = context; // } // // public void setSelectedText(final String selectedText) { // this.selectedText = selectedText; // } // // public void setSetting(final String setting) { // this.setting = setting; // } // // public String getSetting() { // return setting; // } // // public void setDocumentId(final String documentId) { // this.documentId = documentId; // } // // public String getDocumentId() { // return this.documentId; // } // // public void setInternSetting(final String setting) { // this.setting = setting; // } // // public String getKbversion() { // return kbversion; // } // // public void setKbversion(String kbversion) { // this.kbversion = kbversion; // } // // public int getStartPosition() { // return startPosition; // } // // public void setStartPosition(int startPosition) { // this.startPosition = startPosition; // } // } // // Path: doser-dis-core/src/main/java/doser/entitydisambiguation/knowledgebases/KnowledgeBaseIdentifiers.java // public enum KnowledgeBaseIdentifiers { // Standard, CSTable, Biomed, DocumentCentricDefault; // } // Path: doser-dis-core/src/main/java/doser/entitydisambiguation/backend/DisambiguationTaskSingle.java import doser.entitydisambiguation.dpo.EntityDisambiguationDPO; import doser.entitydisambiguation.knowledgebases.KnowledgeBaseIdentifiers; package doser.entitydisambiguation.backend; public class DisambiguationTaskSingle extends AbstractDisambiguationTask { private EntityDisambiguationDPO entityToDis; public DisambiguationTaskSingle(final EntityDisambiguationDPO entityToDis) { super(); this.entityToDis = entityToDis; this.retrieveDocClasses = false; } public EntityDisambiguationDPO getEntityToDisambiguate() { return this.entityToDis; } public void setSurfaceForm(final EntityDisambiguationDPO surfaceForm) { this.entityToDis = surfaceForm; } /** * Assignment function to determine the used knowledge base * * @param kbversion * @param setting */ @Override public void setKbIdentifier(String kbversion, String setting) { if(setting == null) {
this.kbIdentifier = KnowledgeBaseIdentifiers.Standard;
quhfus/DoSeR-Disambiguation
doser-dis-core/src/main/java/doser/entitydisambiguation/backend/DisambiguationTaskCollective.java
// Path: doser-dis-core/src/main/java/doser/entitydisambiguation/dpo/EntityDisambiguationDPO.java // public class EntityDisambiguationDPO { // // private String documentId; // private String context; // private String selectedText; // private String setting; // private String kbversion; // private int startPosition; // // public EntityDisambiguationDPO() { // super(); // } // // public String getContext() { // return this.context; // } // // public String getSelectedText() { // return this.selectedText; // } // // public void setContext(final String context) { // this.context = context; // } // // public void setSelectedText(final String selectedText) { // this.selectedText = selectedText; // } // // public void setSetting(final String setting) { // this.setting = setting; // } // // public String getSetting() { // return setting; // } // // public void setDocumentId(final String documentId) { // this.documentId = documentId; // } // // public String getDocumentId() { // return this.documentId; // } // // public void setInternSetting(final String setting) { // this.setting = setting; // } // // public String getKbversion() { // return kbversion; // } // // public void setKbversion(String kbversion) { // this.kbversion = kbversion; // } // // public int getStartPosition() { // return startPosition; // } // // public void setStartPosition(int startPosition) { // this.startPosition = startPosition; // } // } // // Path: doser-dis-core/src/main/java/doser/entitydisambiguation/knowledgebases/KnowledgeBaseIdentifiers.java // public enum KnowledgeBaseIdentifiers { // Standard, CSTable, Biomed, DocumentCentricDefault; // }
import java.util.List; import doser.entitydisambiguation.dpo.EntityDisambiguationDPO; import doser.entitydisambiguation.knowledgebases.KnowledgeBaseIdentifiers;
package doser.entitydisambiguation.backend; public class DisambiguationTaskCollective extends AbstractDisambiguationTask { private List<EntityDisambiguationDPO> entitiesToDis; /* A maintopic e.g. the column identifier in a table */ private String mainTopic; public DisambiguationTaskCollective(final List<EntityDisambiguationDPO> entityToDis, String mainTopic) { super(); this.entitiesToDis = entityToDis; this.mainTopic = mainTopic; } public List<EntityDisambiguationDPO> getEntityToDisambiguate() { return this.entitiesToDis; } public String getMainTopic() { return this.mainTopic; } public void setSurfaceForm(final List<EntityDisambiguationDPO> surfaceForm) { this.entitiesToDis = surfaceForm; } /** * Assignment function to determine the used knowledge base * * @param kbversion * @param setting */ @Override public void setKbIdentifier(String kbversion, String setting) { if(setting == null) {
// Path: doser-dis-core/src/main/java/doser/entitydisambiguation/dpo/EntityDisambiguationDPO.java // public class EntityDisambiguationDPO { // // private String documentId; // private String context; // private String selectedText; // private String setting; // private String kbversion; // private int startPosition; // // public EntityDisambiguationDPO() { // super(); // } // // public String getContext() { // return this.context; // } // // public String getSelectedText() { // return this.selectedText; // } // // public void setContext(final String context) { // this.context = context; // } // // public void setSelectedText(final String selectedText) { // this.selectedText = selectedText; // } // // public void setSetting(final String setting) { // this.setting = setting; // } // // public String getSetting() { // return setting; // } // // public void setDocumentId(final String documentId) { // this.documentId = documentId; // } // // public String getDocumentId() { // return this.documentId; // } // // public void setInternSetting(final String setting) { // this.setting = setting; // } // // public String getKbversion() { // return kbversion; // } // // public void setKbversion(String kbversion) { // this.kbversion = kbversion; // } // // public int getStartPosition() { // return startPosition; // } // // public void setStartPosition(int startPosition) { // this.startPosition = startPosition; // } // } // // Path: doser-dis-core/src/main/java/doser/entitydisambiguation/knowledgebases/KnowledgeBaseIdentifiers.java // public enum KnowledgeBaseIdentifiers { // Standard, CSTable, Biomed, DocumentCentricDefault; // } // Path: doser-dis-core/src/main/java/doser/entitydisambiguation/backend/DisambiguationTaskCollective.java import java.util.List; import doser.entitydisambiguation.dpo.EntityDisambiguationDPO; import doser.entitydisambiguation.knowledgebases.KnowledgeBaseIdentifiers; package doser.entitydisambiguation.backend; public class DisambiguationTaskCollective extends AbstractDisambiguationTask { private List<EntityDisambiguationDPO> entitiesToDis; /* A maintopic e.g. the column identifier in a table */ private String mainTopic; public DisambiguationTaskCollective(final List<EntityDisambiguationDPO> entityToDis, String mainTopic) { super(); this.entitiesToDis = entityToDis; this.mainTopic = mainTopic; } public List<EntityDisambiguationDPO> getEntityToDisambiguate() { return this.entitiesToDis; } public String getMainTopic() { return this.mainTopic; } public void setSurfaceForm(final List<EntityDisambiguationDPO> surfaceForm) { this.entitiesToDis = surfaceForm; } /** * Assignment function to determine the used knowledge base * * @param kbversion * @param setting */ @Override public void setKbIdentifier(String kbversion, String setting) { if(setting == null) {
this.kbIdentifier = KnowledgeBaseIdentifiers.Standard;
quhfus/DoSeR-Disambiguation
doser-dis-core/src/main/java/doser/entitydisambiguation/backend/AbstractDisambiguationTask.java
// Path: doser-dis-core/src/main/java/doser/entitydisambiguation/dpo/Response.java // public class Response { // // private List<DisambiguatedEntity> disEntities; // private String selectedText; // private int documentId; // // public Response() { // super(); // this.disEntities = new LinkedList<DisambiguatedEntity>(); // } // // public List<DisambiguatedEntity> getDisEntities() { // return this.disEntities; // } // // public String getSelectedText() { // return this.selectedText; // } // // public void setDisEntities(final List<DisambiguatedEntity> disEntities) { // this.disEntities = disEntities; // } // // public void setSelectedText(final String selectedText) { // this.selectedText = selectedText; // } // // public int getDocumentId() { // return documentId; // } // // public void setDocumentId(int documentId) { // this.documentId = documentId; // } // } // // Path: doser-dis-core/src/main/java/doser/entitydisambiguation/knowledgebases/AbstractKnowledgeBase.java // public abstract class AbstractKnowledgeBase extends TimerTask { // // private final static Logger logger = LoggerFactory.getLogger(AbstractKnowledgeBase.class); // // private String indexUri; // // private boolean dynamic; // // private SearcherManager manager; // // private IndexSearcher searcher; // // AbstractKnowledgeBase(String uri, boolean dynamic) { // this(uri, dynamic, new DefaultSimilarity()); // } // // AbstractKnowledgeBase(String uri, boolean dynamic, Similarity sim) { // super(); // this.indexUri = uri; // this.dynamic = dynamic; // // File indexDir = new File(indexUri); // Directory dir; // try { // dir = FSDirectory.open(indexDir); // this.manager = new SearcherManager(dir, new SearcherFactory()); // } catch (IOException e) { // logger.error("IOException in "+AbstractKnowledgeBase.class.getName(), e); // } // } // // public String getIndexUri() { // return indexUri; // } // // // public IndexSearcher getSearcher() { // try { // this.searcher = manager.acquire(); // } catch (IOException e) { // logger.error("IOException in "+AbstractKnowledgeBase.class.getName(), e); // } // return this.searcher; // } // // public void release() { // try { // manager.release(searcher); // } catch (IOException e) { // logger.error("IOException in "+AbstractKnowledgeBase.class.getName(), e); // } // } // // /** // * Periodically reopens the Indexreader, if and only if this is an dynamic // * knowledge base. The changed knowledge base will be live within a few moments. // */ // @Override // public void run() { // if (dynamic) { // try { // manager.maybeRefresh(); // } catch (IOException e) { // logger.error("IOException in "+AbstractKnowledgeBase.class.getName(), e); // } // } // } // // public abstract void initialize(); // } // // Path: doser-dis-core/src/main/java/doser/entitydisambiguation/knowledgebases/KnowledgeBaseIdentifiers.java // public enum KnowledgeBaseIdentifiers { // Standard, CSTable, Biomed, DocumentCentricDefault; // }
import java.util.List; import doser.entitydisambiguation.dpo.Response; import doser.entitydisambiguation.knowledgebases.AbstractKnowledgeBase; import doser.entitydisambiguation.knowledgebases.KnowledgeBaseIdentifiers;
package doser.entitydisambiguation.backend; public abstract class AbstractDisambiguationTask { protected int returnNr;
// Path: doser-dis-core/src/main/java/doser/entitydisambiguation/dpo/Response.java // public class Response { // // private List<DisambiguatedEntity> disEntities; // private String selectedText; // private int documentId; // // public Response() { // super(); // this.disEntities = new LinkedList<DisambiguatedEntity>(); // } // // public List<DisambiguatedEntity> getDisEntities() { // return this.disEntities; // } // // public String getSelectedText() { // return this.selectedText; // } // // public void setDisEntities(final List<DisambiguatedEntity> disEntities) { // this.disEntities = disEntities; // } // // public void setSelectedText(final String selectedText) { // this.selectedText = selectedText; // } // // public int getDocumentId() { // return documentId; // } // // public void setDocumentId(int documentId) { // this.documentId = documentId; // } // } // // Path: doser-dis-core/src/main/java/doser/entitydisambiguation/knowledgebases/AbstractKnowledgeBase.java // public abstract class AbstractKnowledgeBase extends TimerTask { // // private final static Logger logger = LoggerFactory.getLogger(AbstractKnowledgeBase.class); // // private String indexUri; // // private boolean dynamic; // // private SearcherManager manager; // // private IndexSearcher searcher; // // AbstractKnowledgeBase(String uri, boolean dynamic) { // this(uri, dynamic, new DefaultSimilarity()); // } // // AbstractKnowledgeBase(String uri, boolean dynamic, Similarity sim) { // super(); // this.indexUri = uri; // this.dynamic = dynamic; // // File indexDir = new File(indexUri); // Directory dir; // try { // dir = FSDirectory.open(indexDir); // this.manager = new SearcherManager(dir, new SearcherFactory()); // } catch (IOException e) { // logger.error("IOException in "+AbstractKnowledgeBase.class.getName(), e); // } // } // // public String getIndexUri() { // return indexUri; // } // // // public IndexSearcher getSearcher() { // try { // this.searcher = manager.acquire(); // } catch (IOException e) { // logger.error("IOException in "+AbstractKnowledgeBase.class.getName(), e); // } // return this.searcher; // } // // public void release() { // try { // manager.release(searcher); // } catch (IOException e) { // logger.error("IOException in "+AbstractKnowledgeBase.class.getName(), e); // } // } // // /** // * Periodically reopens the Indexreader, if and only if this is an dynamic // * knowledge base. The changed knowledge base will be live within a few moments. // */ // @Override // public void run() { // if (dynamic) { // try { // manager.maybeRefresh(); // } catch (IOException e) { // logger.error("IOException in "+AbstractKnowledgeBase.class.getName(), e); // } // } // } // // public abstract void initialize(); // } // // Path: doser-dis-core/src/main/java/doser/entitydisambiguation/knowledgebases/KnowledgeBaseIdentifiers.java // public enum KnowledgeBaseIdentifiers { // Standard, CSTable, Biomed, DocumentCentricDefault; // } // Path: doser-dis-core/src/main/java/doser/entitydisambiguation/backend/AbstractDisambiguationTask.java import java.util.List; import doser.entitydisambiguation.dpo.Response; import doser.entitydisambiguation.knowledgebases.AbstractKnowledgeBase; import doser.entitydisambiguation.knowledgebases.KnowledgeBaseIdentifiers; package doser.entitydisambiguation.backend; public abstract class AbstractDisambiguationTask { protected int returnNr;
protected AbstractKnowledgeBase kb;
quhfus/DoSeR-Disambiguation
doser-dis-core/src/main/java/doser/entitydisambiguation/backend/AbstractDisambiguationTask.java
// Path: doser-dis-core/src/main/java/doser/entitydisambiguation/dpo/Response.java // public class Response { // // private List<DisambiguatedEntity> disEntities; // private String selectedText; // private int documentId; // // public Response() { // super(); // this.disEntities = new LinkedList<DisambiguatedEntity>(); // } // // public List<DisambiguatedEntity> getDisEntities() { // return this.disEntities; // } // // public String getSelectedText() { // return this.selectedText; // } // // public void setDisEntities(final List<DisambiguatedEntity> disEntities) { // this.disEntities = disEntities; // } // // public void setSelectedText(final String selectedText) { // this.selectedText = selectedText; // } // // public int getDocumentId() { // return documentId; // } // // public void setDocumentId(int documentId) { // this.documentId = documentId; // } // } // // Path: doser-dis-core/src/main/java/doser/entitydisambiguation/knowledgebases/AbstractKnowledgeBase.java // public abstract class AbstractKnowledgeBase extends TimerTask { // // private final static Logger logger = LoggerFactory.getLogger(AbstractKnowledgeBase.class); // // private String indexUri; // // private boolean dynamic; // // private SearcherManager manager; // // private IndexSearcher searcher; // // AbstractKnowledgeBase(String uri, boolean dynamic) { // this(uri, dynamic, new DefaultSimilarity()); // } // // AbstractKnowledgeBase(String uri, boolean dynamic, Similarity sim) { // super(); // this.indexUri = uri; // this.dynamic = dynamic; // // File indexDir = new File(indexUri); // Directory dir; // try { // dir = FSDirectory.open(indexDir); // this.manager = new SearcherManager(dir, new SearcherFactory()); // } catch (IOException e) { // logger.error("IOException in "+AbstractKnowledgeBase.class.getName(), e); // } // } // // public String getIndexUri() { // return indexUri; // } // // // public IndexSearcher getSearcher() { // try { // this.searcher = manager.acquire(); // } catch (IOException e) { // logger.error("IOException in "+AbstractKnowledgeBase.class.getName(), e); // } // return this.searcher; // } // // public void release() { // try { // manager.release(searcher); // } catch (IOException e) { // logger.error("IOException in "+AbstractKnowledgeBase.class.getName(), e); // } // } // // /** // * Periodically reopens the Indexreader, if and only if this is an dynamic // * knowledge base. The changed knowledge base will be live within a few moments. // */ // @Override // public void run() { // if (dynamic) { // try { // manager.maybeRefresh(); // } catch (IOException e) { // logger.error("IOException in "+AbstractKnowledgeBase.class.getName(), e); // } // } // } // // public abstract void initialize(); // } // // Path: doser-dis-core/src/main/java/doser/entitydisambiguation/knowledgebases/KnowledgeBaseIdentifiers.java // public enum KnowledgeBaseIdentifiers { // Standard, CSTable, Biomed, DocumentCentricDefault; // }
import java.util.List; import doser.entitydisambiguation.dpo.Response; import doser.entitydisambiguation.knowledgebases.AbstractKnowledgeBase; import doser.entitydisambiguation.knowledgebases.KnowledgeBaseIdentifiers;
package doser.entitydisambiguation.backend; public abstract class AbstractDisambiguationTask { protected int returnNr; protected AbstractKnowledgeBase kb;
// Path: doser-dis-core/src/main/java/doser/entitydisambiguation/dpo/Response.java // public class Response { // // private List<DisambiguatedEntity> disEntities; // private String selectedText; // private int documentId; // // public Response() { // super(); // this.disEntities = new LinkedList<DisambiguatedEntity>(); // } // // public List<DisambiguatedEntity> getDisEntities() { // return this.disEntities; // } // // public String getSelectedText() { // return this.selectedText; // } // // public void setDisEntities(final List<DisambiguatedEntity> disEntities) { // this.disEntities = disEntities; // } // // public void setSelectedText(final String selectedText) { // this.selectedText = selectedText; // } // // public int getDocumentId() { // return documentId; // } // // public void setDocumentId(int documentId) { // this.documentId = documentId; // } // } // // Path: doser-dis-core/src/main/java/doser/entitydisambiguation/knowledgebases/AbstractKnowledgeBase.java // public abstract class AbstractKnowledgeBase extends TimerTask { // // private final static Logger logger = LoggerFactory.getLogger(AbstractKnowledgeBase.class); // // private String indexUri; // // private boolean dynamic; // // private SearcherManager manager; // // private IndexSearcher searcher; // // AbstractKnowledgeBase(String uri, boolean dynamic) { // this(uri, dynamic, new DefaultSimilarity()); // } // // AbstractKnowledgeBase(String uri, boolean dynamic, Similarity sim) { // super(); // this.indexUri = uri; // this.dynamic = dynamic; // // File indexDir = new File(indexUri); // Directory dir; // try { // dir = FSDirectory.open(indexDir); // this.manager = new SearcherManager(dir, new SearcherFactory()); // } catch (IOException e) { // logger.error("IOException in "+AbstractKnowledgeBase.class.getName(), e); // } // } // // public String getIndexUri() { // return indexUri; // } // // // public IndexSearcher getSearcher() { // try { // this.searcher = manager.acquire(); // } catch (IOException e) { // logger.error("IOException in "+AbstractKnowledgeBase.class.getName(), e); // } // return this.searcher; // } // // public void release() { // try { // manager.release(searcher); // } catch (IOException e) { // logger.error("IOException in "+AbstractKnowledgeBase.class.getName(), e); // } // } // // /** // * Periodically reopens the Indexreader, if and only if this is an dynamic // * knowledge base. The changed knowledge base will be live within a few moments. // */ // @Override // public void run() { // if (dynamic) { // try { // manager.maybeRefresh(); // } catch (IOException e) { // logger.error("IOException in "+AbstractKnowledgeBase.class.getName(), e); // } // } // } // // public abstract void initialize(); // } // // Path: doser-dis-core/src/main/java/doser/entitydisambiguation/knowledgebases/KnowledgeBaseIdentifiers.java // public enum KnowledgeBaseIdentifiers { // Standard, CSTable, Biomed, DocumentCentricDefault; // } // Path: doser-dis-core/src/main/java/doser/entitydisambiguation/backend/AbstractDisambiguationTask.java import java.util.List; import doser.entitydisambiguation.dpo.Response; import doser.entitydisambiguation.knowledgebases.AbstractKnowledgeBase; import doser.entitydisambiguation.knowledgebases.KnowledgeBaseIdentifiers; package doser.entitydisambiguation.backend; public abstract class AbstractDisambiguationTask { protected int returnNr; protected AbstractKnowledgeBase kb;
protected KnowledgeBaseIdentifiers kbIdentifier;
quhfus/DoSeR-Disambiguation
doser-dis-core/src/main/java/doser/entitydisambiguation/backend/AbstractDisambiguationTask.java
// Path: doser-dis-core/src/main/java/doser/entitydisambiguation/dpo/Response.java // public class Response { // // private List<DisambiguatedEntity> disEntities; // private String selectedText; // private int documentId; // // public Response() { // super(); // this.disEntities = new LinkedList<DisambiguatedEntity>(); // } // // public List<DisambiguatedEntity> getDisEntities() { // return this.disEntities; // } // // public String getSelectedText() { // return this.selectedText; // } // // public void setDisEntities(final List<DisambiguatedEntity> disEntities) { // this.disEntities = disEntities; // } // // public void setSelectedText(final String selectedText) { // this.selectedText = selectedText; // } // // public int getDocumentId() { // return documentId; // } // // public void setDocumentId(int documentId) { // this.documentId = documentId; // } // } // // Path: doser-dis-core/src/main/java/doser/entitydisambiguation/knowledgebases/AbstractKnowledgeBase.java // public abstract class AbstractKnowledgeBase extends TimerTask { // // private final static Logger logger = LoggerFactory.getLogger(AbstractKnowledgeBase.class); // // private String indexUri; // // private boolean dynamic; // // private SearcherManager manager; // // private IndexSearcher searcher; // // AbstractKnowledgeBase(String uri, boolean dynamic) { // this(uri, dynamic, new DefaultSimilarity()); // } // // AbstractKnowledgeBase(String uri, boolean dynamic, Similarity sim) { // super(); // this.indexUri = uri; // this.dynamic = dynamic; // // File indexDir = new File(indexUri); // Directory dir; // try { // dir = FSDirectory.open(indexDir); // this.manager = new SearcherManager(dir, new SearcherFactory()); // } catch (IOException e) { // logger.error("IOException in "+AbstractKnowledgeBase.class.getName(), e); // } // } // // public String getIndexUri() { // return indexUri; // } // // // public IndexSearcher getSearcher() { // try { // this.searcher = manager.acquire(); // } catch (IOException e) { // logger.error("IOException in "+AbstractKnowledgeBase.class.getName(), e); // } // return this.searcher; // } // // public void release() { // try { // manager.release(searcher); // } catch (IOException e) { // logger.error("IOException in "+AbstractKnowledgeBase.class.getName(), e); // } // } // // /** // * Periodically reopens the Indexreader, if and only if this is an dynamic // * knowledge base. The changed knowledge base will be live within a few moments. // */ // @Override // public void run() { // if (dynamic) { // try { // manager.maybeRefresh(); // } catch (IOException e) { // logger.error("IOException in "+AbstractKnowledgeBase.class.getName(), e); // } // } // } // // public abstract void initialize(); // } // // Path: doser-dis-core/src/main/java/doser/entitydisambiguation/knowledgebases/KnowledgeBaseIdentifiers.java // public enum KnowledgeBaseIdentifiers { // Standard, CSTable, Biomed, DocumentCentricDefault; // }
import java.util.List; import doser.entitydisambiguation.dpo.Response; import doser.entitydisambiguation.knowledgebases.AbstractKnowledgeBase; import doser.entitydisambiguation.knowledgebases.KnowledgeBaseIdentifiers;
package doser.entitydisambiguation.backend; public abstract class AbstractDisambiguationTask { protected int returnNr; protected AbstractKnowledgeBase kb; protected KnowledgeBaseIdentifiers kbIdentifier; protected boolean retrieveDocClasses;
// Path: doser-dis-core/src/main/java/doser/entitydisambiguation/dpo/Response.java // public class Response { // // private List<DisambiguatedEntity> disEntities; // private String selectedText; // private int documentId; // // public Response() { // super(); // this.disEntities = new LinkedList<DisambiguatedEntity>(); // } // // public List<DisambiguatedEntity> getDisEntities() { // return this.disEntities; // } // // public String getSelectedText() { // return this.selectedText; // } // // public void setDisEntities(final List<DisambiguatedEntity> disEntities) { // this.disEntities = disEntities; // } // // public void setSelectedText(final String selectedText) { // this.selectedText = selectedText; // } // // public int getDocumentId() { // return documentId; // } // // public void setDocumentId(int documentId) { // this.documentId = documentId; // } // } // // Path: doser-dis-core/src/main/java/doser/entitydisambiguation/knowledgebases/AbstractKnowledgeBase.java // public abstract class AbstractKnowledgeBase extends TimerTask { // // private final static Logger logger = LoggerFactory.getLogger(AbstractKnowledgeBase.class); // // private String indexUri; // // private boolean dynamic; // // private SearcherManager manager; // // private IndexSearcher searcher; // // AbstractKnowledgeBase(String uri, boolean dynamic) { // this(uri, dynamic, new DefaultSimilarity()); // } // // AbstractKnowledgeBase(String uri, boolean dynamic, Similarity sim) { // super(); // this.indexUri = uri; // this.dynamic = dynamic; // // File indexDir = new File(indexUri); // Directory dir; // try { // dir = FSDirectory.open(indexDir); // this.manager = new SearcherManager(dir, new SearcherFactory()); // } catch (IOException e) { // logger.error("IOException in "+AbstractKnowledgeBase.class.getName(), e); // } // } // // public String getIndexUri() { // return indexUri; // } // // // public IndexSearcher getSearcher() { // try { // this.searcher = manager.acquire(); // } catch (IOException e) { // logger.error("IOException in "+AbstractKnowledgeBase.class.getName(), e); // } // return this.searcher; // } // // public void release() { // try { // manager.release(searcher); // } catch (IOException e) { // logger.error("IOException in "+AbstractKnowledgeBase.class.getName(), e); // } // } // // /** // * Periodically reopens the Indexreader, if and only if this is an dynamic // * knowledge base. The changed knowledge base will be live within a few moments. // */ // @Override // public void run() { // if (dynamic) { // try { // manager.maybeRefresh(); // } catch (IOException e) { // logger.error("IOException in "+AbstractKnowledgeBase.class.getName(), e); // } // } // } // // public abstract void initialize(); // } // // Path: doser-dis-core/src/main/java/doser/entitydisambiguation/knowledgebases/KnowledgeBaseIdentifiers.java // public enum KnowledgeBaseIdentifiers { // Standard, CSTable, Biomed, DocumentCentricDefault; // } // Path: doser-dis-core/src/main/java/doser/entitydisambiguation/backend/AbstractDisambiguationTask.java import java.util.List; import doser.entitydisambiguation.dpo.Response; import doser.entitydisambiguation.knowledgebases.AbstractKnowledgeBase; import doser.entitydisambiguation.knowledgebases.KnowledgeBaseIdentifiers; package doser.entitydisambiguation.backend; public abstract class AbstractDisambiguationTask { protected int returnNr; protected AbstractKnowledgeBase kb; protected KnowledgeBaseIdentifiers kbIdentifier; protected boolean retrieveDocClasses;
protected List<Response> responses;
bingoogolapple/Android-Training
MyMoment/src/com/bingoogol/mymoment/ui/GenericActivity.java
// Path: MyMoment/src/com/bingoogol/mymoment/App.java // public class App extends Application { // private List<Activity> activities; // // @Override // public void onCreate() { // super.onCreate(); // activities = new ArrayList<Activity>(); // } // // public void addActivity(Activity activity) { // activities.add(activity); // } // // public void removeActivity(Activity activity) { // activities.remove(activity); // } // // public void exit() { // for(Activity activity : activities) { // activity.finish(); // } // } // }
import android.app.Activity; import android.os.Bundle; import android.view.View.OnClickListener; import com.bingoogol.mymoment.App;
package com.bingoogol.mymoment.ui; public abstract class GenericActivity extends Activity implements OnClickListener { protected String tag;
// Path: MyMoment/src/com/bingoogol/mymoment/App.java // public class App extends Application { // private List<Activity> activities; // // @Override // public void onCreate() { // super.onCreate(); // activities = new ArrayList<Activity>(); // } // // public void addActivity(Activity activity) { // activities.add(activity); // } // // public void removeActivity(Activity activity) { // activities.remove(activity); // } // // public void exit() { // for(Activity activity : activities) { // activity.finish(); // } // } // } // Path: MyMoment/src/com/bingoogol/mymoment/ui/GenericActivity.java import android.app.Activity; import android.os.Bundle; import android.view.View.OnClickListener; import com.bingoogol.mymoment.App; package com.bingoogol.mymoment.ui; public abstract class GenericActivity extends Activity implements OnClickListener { protected String tag;
protected App app;
bingoogolapple/Android-Training
MyMoment/src/com/bingoogol/mymoment/service/MomentService.java
// Path: MyMoment/src/com/bingoogol/mymoment/domain/Moment.java // public class Moment { // private int id; // private String content; // private String imgPath; // private String publishTime; // // public Moment() { // } // // public Moment(int id, String content, String imgPath, String publishTime) { // this.id = id; // this.content = content; // this.imgPath = imgPath; // this.publishTime = publishTime; // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // // public String getContent() { // return content; // } // // public void setContent(String content) { // this.content = content; // } // // public String getImgPath() { // return imgPath; // } // // public void setImgPath(String imgPath) { // this.imgPath = imgPath; // } // // public String getPublishTime() { // return publishTime; // } // // public void setPublishTime(String publishTime) { // this.publishTime = publishTime; // } // // } // // Path: MyMoment/src/com/bingoogol/mymoment/util/Constants.java // public final class Constants { // private Constants() { // } // // public static final class db { // public static final String DB_NAME = "MyMoment.db"; // public static final int DB_VERSION = 2; // public static final String TABLE_NAME = "Moment"; // public static final String COLUMN_NAME_ID = "_id"; // public static final String COLUMN_NAME_CONTENT = "content"; // public static final String COLUMN_NAME_IMG_PATH = "imgPath"; // public static final String COLUMN_NAME_PUBLISH_TIME = "publishTime"; // } // // public static final class activity { // public static final int GET_FROM_GALLERY = 1; // public static final int GET_FROM_CAMERA = 2; // public static final int GET_FROM_CROP = 3; // } // // public static final class file { // public static final String DIR_ROOT = "MyMoment"; // public static final String DIR_IMAGE = DIR_ROOT + File.separator + "images"; // } // // public static final class tag { // public static final String STORAGE_ERROR = "StorageUtil"; // } // } // // Path: MyMoment/src/com/bingoogol/mymoment/util/DBOpenHelper.java // public class DBOpenHelper extends SQLiteOpenHelper { // // 在SQLiteOpenHelper的子类当中,必须有该构造函数 // public DBOpenHelper(Context context) { // // 必须通过调用父类当中的构造函数,null,采用系统默认游标工厂 // super(context, Constants.db.DB_NAME, null, Constants.db.DB_VERSION); // } // // // 当第一次创建数据库时调用。表格的创建和初始化表格的个数在这里完成。 // @Override // public void onCreate(SQLiteDatabase db) { // StringBuilder sql = new StringBuilder(); // sql.append("create table " + Constants.db.TABLE_NAME + " ("); // sql.append(Constants.db.COLUMN_NAME_ID + " integer primary key autoincrement,"); // sql.append(Constants.db.COLUMN_NAME_CONTENT + " varchar(50) null,"); // sql.append(Constants.db.COLUMN_NAME_IMG_PATH + " varchar(100) null,"); // sql.append(Constants.db.COLUMN_NAME_PUBLISH_TIME + " varchar(16) null"); // sql.append(")"); // db.execSQL(sql.toString()); // } // // // 数据库文件的版本号发生改变的时候调用的,如果目前数据库文件并不存在,这个方法不会被调用 // @Override // public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // } // // }
import java.util.ArrayList; import java.util.List; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import com.bingoogol.mymoment.domain.Moment; import com.bingoogol.mymoment.util.Constants; import com.bingoogol.mymoment.util.DBOpenHelper;
package com.bingoogol.mymoment.service; public class MomentService { private DBOpenHelper dbOpenHelper; public MomentService(Context context) { dbOpenHelper = new DBOpenHelper(context); }
// Path: MyMoment/src/com/bingoogol/mymoment/domain/Moment.java // public class Moment { // private int id; // private String content; // private String imgPath; // private String publishTime; // // public Moment() { // } // // public Moment(int id, String content, String imgPath, String publishTime) { // this.id = id; // this.content = content; // this.imgPath = imgPath; // this.publishTime = publishTime; // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // // public String getContent() { // return content; // } // // public void setContent(String content) { // this.content = content; // } // // public String getImgPath() { // return imgPath; // } // // public void setImgPath(String imgPath) { // this.imgPath = imgPath; // } // // public String getPublishTime() { // return publishTime; // } // // public void setPublishTime(String publishTime) { // this.publishTime = publishTime; // } // // } // // Path: MyMoment/src/com/bingoogol/mymoment/util/Constants.java // public final class Constants { // private Constants() { // } // // public static final class db { // public static final String DB_NAME = "MyMoment.db"; // public static final int DB_VERSION = 2; // public static final String TABLE_NAME = "Moment"; // public static final String COLUMN_NAME_ID = "_id"; // public static final String COLUMN_NAME_CONTENT = "content"; // public static final String COLUMN_NAME_IMG_PATH = "imgPath"; // public static final String COLUMN_NAME_PUBLISH_TIME = "publishTime"; // } // // public static final class activity { // public static final int GET_FROM_GALLERY = 1; // public static final int GET_FROM_CAMERA = 2; // public static final int GET_FROM_CROP = 3; // } // // public static final class file { // public static final String DIR_ROOT = "MyMoment"; // public static final String DIR_IMAGE = DIR_ROOT + File.separator + "images"; // } // // public static final class tag { // public static final String STORAGE_ERROR = "StorageUtil"; // } // } // // Path: MyMoment/src/com/bingoogol/mymoment/util/DBOpenHelper.java // public class DBOpenHelper extends SQLiteOpenHelper { // // 在SQLiteOpenHelper的子类当中,必须有该构造函数 // public DBOpenHelper(Context context) { // // 必须通过调用父类当中的构造函数,null,采用系统默认游标工厂 // super(context, Constants.db.DB_NAME, null, Constants.db.DB_VERSION); // } // // // 当第一次创建数据库时调用。表格的创建和初始化表格的个数在这里完成。 // @Override // public void onCreate(SQLiteDatabase db) { // StringBuilder sql = new StringBuilder(); // sql.append("create table " + Constants.db.TABLE_NAME + " ("); // sql.append(Constants.db.COLUMN_NAME_ID + " integer primary key autoincrement,"); // sql.append(Constants.db.COLUMN_NAME_CONTENT + " varchar(50) null,"); // sql.append(Constants.db.COLUMN_NAME_IMG_PATH + " varchar(100) null,"); // sql.append(Constants.db.COLUMN_NAME_PUBLISH_TIME + " varchar(16) null"); // sql.append(")"); // db.execSQL(sql.toString()); // } // // // 数据库文件的版本号发生改变的时候调用的,如果目前数据库文件并不存在,这个方法不会被调用 // @Override // public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // } // // } // Path: MyMoment/src/com/bingoogol/mymoment/service/MomentService.java import java.util.ArrayList; import java.util.List; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import com.bingoogol.mymoment.domain.Moment; import com.bingoogol.mymoment.util.Constants; import com.bingoogol.mymoment.util.DBOpenHelper; package com.bingoogol.mymoment.service; public class MomentService { private DBOpenHelper dbOpenHelper; public MomentService(Context context) { dbOpenHelper = new DBOpenHelper(context); }
public boolean addMoment(Moment moment) {
bingoogolapple/Android-Training
MyMoment/src/com/bingoogol/mymoment/service/MomentService.java
// Path: MyMoment/src/com/bingoogol/mymoment/domain/Moment.java // public class Moment { // private int id; // private String content; // private String imgPath; // private String publishTime; // // public Moment() { // } // // public Moment(int id, String content, String imgPath, String publishTime) { // this.id = id; // this.content = content; // this.imgPath = imgPath; // this.publishTime = publishTime; // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // // public String getContent() { // return content; // } // // public void setContent(String content) { // this.content = content; // } // // public String getImgPath() { // return imgPath; // } // // public void setImgPath(String imgPath) { // this.imgPath = imgPath; // } // // public String getPublishTime() { // return publishTime; // } // // public void setPublishTime(String publishTime) { // this.publishTime = publishTime; // } // // } // // Path: MyMoment/src/com/bingoogol/mymoment/util/Constants.java // public final class Constants { // private Constants() { // } // // public static final class db { // public static final String DB_NAME = "MyMoment.db"; // public static final int DB_VERSION = 2; // public static final String TABLE_NAME = "Moment"; // public static final String COLUMN_NAME_ID = "_id"; // public static final String COLUMN_NAME_CONTENT = "content"; // public static final String COLUMN_NAME_IMG_PATH = "imgPath"; // public static final String COLUMN_NAME_PUBLISH_TIME = "publishTime"; // } // // public static final class activity { // public static final int GET_FROM_GALLERY = 1; // public static final int GET_FROM_CAMERA = 2; // public static final int GET_FROM_CROP = 3; // } // // public static final class file { // public static final String DIR_ROOT = "MyMoment"; // public static final String DIR_IMAGE = DIR_ROOT + File.separator + "images"; // } // // public static final class tag { // public static final String STORAGE_ERROR = "StorageUtil"; // } // } // // Path: MyMoment/src/com/bingoogol/mymoment/util/DBOpenHelper.java // public class DBOpenHelper extends SQLiteOpenHelper { // // 在SQLiteOpenHelper的子类当中,必须有该构造函数 // public DBOpenHelper(Context context) { // // 必须通过调用父类当中的构造函数,null,采用系统默认游标工厂 // super(context, Constants.db.DB_NAME, null, Constants.db.DB_VERSION); // } // // // 当第一次创建数据库时调用。表格的创建和初始化表格的个数在这里完成。 // @Override // public void onCreate(SQLiteDatabase db) { // StringBuilder sql = new StringBuilder(); // sql.append("create table " + Constants.db.TABLE_NAME + " ("); // sql.append(Constants.db.COLUMN_NAME_ID + " integer primary key autoincrement,"); // sql.append(Constants.db.COLUMN_NAME_CONTENT + " varchar(50) null,"); // sql.append(Constants.db.COLUMN_NAME_IMG_PATH + " varchar(100) null,"); // sql.append(Constants.db.COLUMN_NAME_PUBLISH_TIME + " varchar(16) null"); // sql.append(")"); // db.execSQL(sql.toString()); // } // // // 数据库文件的版本号发生改变的时候调用的,如果目前数据库文件并不存在,这个方法不会被调用 // @Override // public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // } // // }
import java.util.ArrayList; import java.util.List; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import com.bingoogol.mymoment.domain.Moment; import com.bingoogol.mymoment.util.Constants; import com.bingoogol.mymoment.util.DBOpenHelper;
package com.bingoogol.mymoment.service; public class MomentService { private DBOpenHelper dbOpenHelper; public MomentService(Context context) { dbOpenHelper = new DBOpenHelper(context); } public boolean addMoment(Moment moment) { SQLiteDatabase db = null; boolean result = false; try { db = dbOpenHelper.getWritableDatabase(); ContentValues values = new ContentValues();
// Path: MyMoment/src/com/bingoogol/mymoment/domain/Moment.java // public class Moment { // private int id; // private String content; // private String imgPath; // private String publishTime; // // public Moment() { // } // // public Moment(int id, String content, String imgPath, String publishTime) { // this.id = id; // this.content = content; // this.imgPath = imgPath; // this.publishTime = publishTime; // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // // public String getContent() { // return content; // } // // public void setContent(String content) { // this.content = content; // } // // public String getImgPath() { // return imgPath; // } // // public void setImgPath(String imgPath) { // this.imgPath = imgPath; // } // // public String getPublishTime() { // return publishTime; // } // // public void setPublishTime(String publishTime) { // this.publishTime = publishTime; // } // // } // // Path: MyMoment/src/com/bingoogol/mymoment/util/Constants.java // public final class Constants { // private Constants() { // } // // public static final class db { // public static final String DB_NAME = "MyMoment.db"; // public static final int DB_VERSION = 2; // public static final String TABLE_NAME = "Moment"; // public static final String COLUMN_NAME_ID = "_id"; // public static final String COLUMN_NAME_CONTENT = "content"; // public static final String COLUMN_NAME_IMG_PATH = "imgPath"; // public static final String COLUMN_NAME_PUBLISH_TIME = "publishTime"; // } // // public static final class activity { // public static final int GET_FROM_GALLERY = 1; // public static final int GET_FROM_CAMERA = 2; // public static final int GET_FROM_CROP = 3; // } // // public static final class file { // public static final String DIR_ROOT = "MyMoment"; // public static final String DIR_IMAGE = DIR_ROOT + File.separator + "images"; // } // // public static final class tag { // public static final String STORAGE_ERROR = "StorageUtil"; // } // } // // Path: MyMoment/src/com/bingoogol/mymoment/util/DBOpenHelper.java // public class DBOpenHelper extends SQLiteOpenHelper { // // 在SQLiteOpenHelper的子类当中,必须有该构造函数 // public DBOpenHelper(Context context) { // // 必须通过调用父类当中的构造函数,null,采用系统默认游标工厂 // super(context, Constants.db.DB_NAME, null, Constants.db.DB_VERSION); // } // // // 当第一次创建数据库时调用。表格的创建和初始化表格的个数在这里完成。 // @Override // public void onCreate(SQLiteDatabase db) { // StringBuilder sql = new StringBuilder(); // sql.append("create table " + Constants.db.TABLE_NAME + " ("); // sql.append(Constants.db.COLUMN_NAME_ID + " integer primary key autoincrement,"); // sql.append(Constants.db.COLUMN_NAME_CONTENT + " varchar(50) null,"); // sql.append(Constants.db.COLUMN_NAME_IMG_PATH + " varchar(100) null,"); // sql.append(Constants.db.COLUMN_NAME_PUBLISH_TIME + " varchar(16) null"); // sql.append(")"); // db.execSQL(sql.toString()); // } // // // 数据库文件的版本号发生改变的时候调用的,如果目前数据库文件并不存在,这个方法不会被调用 // @Override // public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // } // // } // Path: MyMoment/src/com/bingoogol/mymoment/service/MomentService.java import java.util.ArrayList; import java.util.List; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import com.bingoogol.mymoment.domain.Moment; import com.bingoogol.mymoment.util.Constants; import com.bingoogol.mymoment.util.DBOpenHelper; package com.bingoogol.mymoment.service; public class MomentService { private DBOpenHelper dbOpenHelper; public MomentService(Context context) { dbOpenHelper = new DBOpenHelper(context); } public boolean addMoment(Moment moment) { SQLiteDatabase db = null; boolean result = false; try { db = dbOpenHelper.getWritableDatabase(); ContentValues values = new ContentValues();
values.put(Constants.db.COLUMN_NAME_CONTENT, moment.getContent());
NeoTech-Software/Android-Retainable-Tasks
demo/src/main/java/org/neotech/app/retainabletasksdemo/activity/ProgressTaskHandler.java
// Path: demo/src/main/java/org/neotech/app/retainabletasksdemo/ProgressDialog.java // public class ProgressDialog extends DialogFragment implements DialogInterface.OnClickListener { // // public static ProgressDialog getExistingInstance(FragmentManager fragmentManager, String tag){ // return (ProgressDialog) fragmentManager.findFragmentByTag(tag); // } // // public static ProgressDialog showIfNotShowing(FragmentManager fragmentManager, String tag){ // ProgressDialog fragment = (ProgressDialog) fragmentManager.findFragmentByTag(tag); // // if (fragment == null) { // fragment = new ProgressDialog(); // } else if(fragment.isAdded()){ // return fragment; // } // // fragment.show(fragmentManager, tag); // return fragment; // } // // private TextView progressPercentage; // private TextView progressCount; // private ProgressBar progressBar; // private int progress = 0; // // @NonNull // @Override // public Dialog onCreateDialog(Bundle savedInstanceState) { // final AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); // // @SuppressLint("InflateParams") // final View view = LayoutInflater.from(builder.getContext()).inflate(R.layout.dialog_progress, null, false); // progressPercentage = (TextView) view.findViewById(R.id.progress_percentage); // progressCount = (TextView) view.findViewById(R.id.progress_count); // progressBar = (ProgressBar) view.findViewById(android.R.id.progress); // progressBar.setMax(100); // progressBar.setIndeterminate(false); // // builder.setView(view); // builder.setTitle(R.string.dialog_progress_title); // builder.setPositiveButton(R.string.action_cancel, this); // setCancelable(false); // return builder.create(); // } // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // if(savedInstanceState != null) { // progress = savedInstanceState.getInt("progress"); // } // setProgress(progress); // } // // @Override // public void onSaveInstanceState(Bundle outState) { // super.onSaveInstanceState(outState); // outState.putInt("progress", progress); // } // // @SuppressLint("SetTextI18n") // public void setProgress(int progress){ // if(getDialog() != null) { // progressBar.setProgress(progress); // int percentage = (int) Math.round(((double) progress / (double) progressBar.getMax()) * 100.0); // progressPercentage.setText("" + percentage + "%"); // progressCount.setText(progress + "/" + progressBar.getMax()); // } // this.progress = progress; // } // // @Override // public void onClick(DialogInterface dialog, int which) { // ((OnAlertDialogClickListener) getActivity()).onDialogFragmentClick(this, which); // } // } // // Path: demo/src/main/java/org/neotech/app/retainabletasksdemo/tasks/SimpleTask.java // public class SimpleTask extends Task<Integer, String> { // // public SimpleTask(String tag) { // super(tag); // } // // @Override // protected String doInBackground() { // for(int i = 0; i < 100; i++) { // if(isCancelled()){ // break; // } // SystemClock.sleep(50); // publishProgress(i); // } // return "Result"; // } // // @Override // protected void onPostExecute() { // Log.i("SimpleTask", "SimpleTask.onPostExecute()"); // } // }
import com.google.android.material.snackbar.Snackbar; import org.neotech.app.retainabletasksdemo.ProgressDialog; import org.neotech.app.retainabletasksdemo.R; import org.neotech.app.retainabletasksdemo.tasks.SimpleTask; import org.neotech.library.retainabletasks.TaskAttach; import org.neotech.library.retainabletasks.TaskCancel; import org.neotech.library.retainabletasks.TaskPostExecute; import org.neotech.library.retainabletasks.TaskProgress;
package org.neotech.app.retainabletasksdemo.activity; /** * Created by Rolf Smit on 30-May-17. */ public final class ProgressTaskHandler { private static final String TASK_PROGRESS = "progress-dialog"; private static final String DIALOG_PROGRESS = "progress-dialog";
// Path: demo/src/main/java/org/neotech/app/retainabletasksdemo/ProgressDialog.java // public class ProgressDialog extends DialogFragment implements DialogInterface.OnClickListener { // // public static ProgressDialog getExistingInstance(FragmentManager fragmentManager, String tag){ // return (ProgressDialog) fragmentManager.findFragmentByTag(tag); // } // // public static ProgressDialog showIfNotShowing(FragmentManager fragmentManager, String tag){ // ProgressDialog fragment = (ProgressDialog) fragmentManager.findFragmentByTag(tag); // // if (fragment == null) { // fragment = new ProgressDialog(); // } else if(fragment.isAdded()){ // return fragment; // } // // fragment.show(fragmentManager, tag); // return fragment; // } // // private TextView progressPercentage; // private TextView progressCount; // private ProgressBar progressBar; // private int progress = 0; // // @NonNull // @Override // public Dialog onCreateDialog(Bundle savedInstanceState) { // final AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); // // @SuppressLint("InflateParams") // final View view = LayoutInflater.from(builder.getContext()).inflate(R.layout.dialog_progress, null, false); // progressPercentage = (TextView) view.findViewById(R.id.progress_percentage); // progressCount = (TextView) view.findViewById(R.id.progress_count); // progressBar = (ProgressBar) view.findViewById(android.R.id.progress); // progressBar.setMax(100); // progressBar.setIndeterminate(false); // // builder.setView(view); // builder.setTitle(R.string.dialog_progress_title); // builder.setPositiveButton(R.string.action_cancel, this); // setCancelable(false); // return builder.create(); // } // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // if(savedInstanceState != null) { // progress = savedInstanceState.getInt("progress"); // } // setProgress(progress); // } // // @Override // public void onSaveInstanceState(Bundle outState) { // super.onSaveInstanceState(outState); // outState.putInt("progress", progress); // } // // @SuppressLint("SetTextI18n") // public void setProgress(int progress){ // if(getDialog() != null) { // progressBar.setProgress(progress); // int percentage = (int) Math.round(((double) progress / (double) progressBar.getMax()) * 100.0); // progressPercentage.setText("" + percentage + "%"); // progressCount.setText(progress + "/" + progressBar.getMax()); // } // this.progress = progress; // } // // @Override // public void onClick(DialogInterface dialog, int which) { // ((OnAlertDialogClickListener) getActivity()).onDialogFragmentClick(this, which); // } // } // // Path: demo/src/main/java/org/neotech/app/retainabletasksdemo/tasks/SimpleTask.java // public class SimpleTask extends Task<Integer, String> { // // public SimpleTask(String tag) { // super(tag); // } // // @Override // protected String doInBackground() { // for(int i = 0; i < 100; i++) { // if(isCancelled()){ // break; // } // SystemClock.sleep(50); // publishProgress(i); // } // return "Result"; // } // // @Override // protected void onPostExecute() { // Log.i("SimpleTask", "SimpleTask.onPostExecute()"); // } // } // Path: demo/src/main/java/org/neotech/app/retainabletasksdemo/activity/ProgressTaskHandler.java import com.google.android.material.snackbar.Snackbar; import org.neotech.app.retainabletasksdemo.ProgressDialog; import org.neotech.app.retainabletasksdemo.R; import org.neotech.app.retainabletasksdemo.tasks.SimpleTask; import org.neotech.library.retainabletasks.TaskAttach; import org.neotech.library.retainabletasks.TaskCancel; import org.neotech.library.retainabletasks.TaskPostExecute; import org.neotech.library.retainabletasks.TaskProgress; package org.neotech.app.retainabletasksdemo.activity; /** * Created by Rolf Smit on 30-May-17. */ public final class ProgressTaskHandler { private static final String TASK_PROGRESS = "progress-dialog"; private static final String DIALOG_PROGRESS = "progress-dialog";
private ProgressDialog progressDialog;
NeoTech-Software/Android-Retainable-Tasks
demo/src/main/java/org/neotech/app/retainabletasksdemo/activity/ProgressTaskHandler.java
// Path: demo/src/main/java/org/neotech/app/retainabletasksdemo/ProgressDialog.java // public class ProgressDialog extends DialogFragment implements DialogInterface.OnClickListener { // // public static ProgressDialog getExistingInstance(FragmentManager fragmentManager, String tag){ // return (ProgressDialog) fragmentManager.findFragmentByTag(tag); // } // // public static ProgressDialog showIfNotShowing(FragmentManager fragmentManager, String tag){ // ProgressDialog fragment = (ProgressDialog) fragmentManager.findFragmentByTag(tag); // // if (fragment == null) { // fragment = new ProgressDialog(); // } else if(fragment.isAdded()){ // return fragment; // } // // fragment.show(fragmentManager, tag); // return fragment; // } // // private TextView progressPercentage; // private TextView progressCount; // private ProgressBar progressBar; // private int progress = 0; // // @NonNull // @Override // public Dialog onCreateDialog(Bundle savedInstanceState) { // final AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); // // @SuppressLint("InflateParams") // final View view = LayoutInflater.from(builder.getContext()).inflate(R.layout.dialog_progress, null, false); // progressPercentage = (TextView) view.findViewById(R.id.progress_percentage); // progressCount = (TextView) view.findViewById(R.id.progress_count); // progressBar = (ProgressBar) view.findViewById(android.R.id.progress); // progressBar.setMax(100); // progressBar.setIndeterminate(false); // // builder.setView(view); // builder.setTitle(R.string.dialog_progress_title); // builder.setPositiveButton(R.string.action_cancel, this); // setCancelable(false); // return builder.create(); // } // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // if(savedInstanceState != null) { // progress = savedInstanceState.getInt("progress"); // } // setProgress(progress); // } // // @Override // public void onSaveInstanceState(Bundle outState) { // super.onSaveInstanceState(outState); // outState.putInt("progress", progress); // } // // @SuppressLint("SetTextI18n") // public void setProgress(int progress){ // if(getDialog() != null) { // progressBar.setProgress(progress); // int percentage = (int) Math.round(((double) progress / (double) progressBar.getMax()) * 100.0); // progressPercentage.setText("" + percentage + "%"); // progressCount.setText(progress + "/" + progressBar.getMax()); // } // this.progress = progress; // } // // @Override // public void onClick(DialogInterface dialog, int which) { // ((OnAlertDialogClickListener) getActivity()).onDialogFragmentClick(this, which); // } // } // // Path: demo/src/main/java/org/neotech/app/retainabletasksdemo/tasks/SimpleTask.java // public class SimpleTask extends Task<Integer, String> { // // public SimpleTask(String tag) { // super(tag); // } // // @Override // protected String doInBackground() { // for(int i = 0; i < 100; i++) { // if(isCancelled()){ // break; // } // SystemClock.sleep(50); // publishProgress(i); // } // return "Result"; // } // // @Override // protected void onPostExecute() { // Log.i("SimpleTask", "SimpleTask.onPostExecute()"); // } // }
import com.google.android.material.snackbar.Snackbar; import org.neotech.app.retainabletasksdemo.ProgressDialog; import org.neotech.app.retainabletasksdemo.R; import org.neotech.app.retainabletasksdemo.tasks.SimpleTask; import org.neotech.library.retainabletasks.TaskAttach; import org.neotech.library.retainabletasks.TaskCancel; import org.neotech.library.retainabletasks.TaskPostExecute; import org.neotech.library.retainabletasks.TaskProgress;
package org.neotech.app.retainabletasksdemo.activity; /** * Created by Rolf Smit on 30-May-17. */ public final class ProgressTaskHandler { private static final String TASK_PROGRESS = "progress-dialog"; private static final String DIALOG_PROGRESS = "progress-dialog"; private ProgressDialog progressDialog; private final DemoActivityAnnotations demoActivityAnnotations; public ProgressTaskHandler(DemoActivityAnnotations demoActivityAnnotations){ this.demoActivityAnnotations = demoActivityAnnotations; } public void execute(){ if(!demoActivityAnnotations.getTaskManager().isActive(TASK_PROGRESS)) {
// Path: demo/src/main/java/org/neotech/app/retainabletasksdemo/ProgressDialog.java // public class ProgressDialog extends DialogFragment implements DialogInterface.OnClickListener { // // public static ProgressDialog getExistingInstance(FragmentManager fragmentManager, String tag){ // return (ProgressDialog) fragmentManager.findFragmentByTag(tag); // } // // public static ProgressDialog showIfNotShowing(FragmentManager fragmentManager, String tag){ // ProgressDialog fragment = (ProgressDialog) fragmentManager.findFragmentByTag(tag); // // if (fragment == null) { // fragment = new ProgressDialog(); // } else if(fragment.isAdded()){ // return fragment; // } // // fragment.show(fragmentManager, tag); // return fragment; // } // // private TextView progressPercentage; // private TextView progressCount; // private ProgressBar progressBar; // private int progress = 0; // // @NonNull // @Override // public Dialog onCreateDialog(Bundle savedInstanceState) { // final AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); // // @SuppressLint("InflateParams") // final View view = LayoutInflater.from(builder.getContext()).inflate(R.layout.dialog_progress, null, false); // progressPercentage = (TextView) view.findViewById(R.id.progress_percentage); // progressCount = (TextView) view.findViewById(R.id.progress_count); // progressBar = (ProgressBar) view.findViewById(android.R.id.progress); // progressBar.setMax(100); // progressBar.setIndeterminate(false); // // builder.setView(view); // builder.setTitle(R.string.dialog_progress_title); // builder.setPositiveButton(R.string.action_cancel, this); // setCancelable(false); // return builder.create(); // } // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // if(savedInstanceState != null) { // progress = savedInstanceState.getInt("progress"); // } // setProgress(progress); // } // // @Override // public void onSaveInstanceState(Bundle outState) { // super.onSaveInstanceState(outState); // outState.putInt("progress", progress); // } // // @SuppressLint("SetTextI18n") // public void setProgress(int progress){ // if(getDialog() != null) { // progressBar.setProgress(progress); // int percentage = (int) Math.round(((double) progress / (double) progressBar.getMax()) * 100.0); // progressPercentage.setText("" + percentage + "%"); // progressCount.setText(progress + "/" + progressBar.getMax()); // } // this.progress = progress; // } // // @Override // public void onClick(DialogInterface dialog, int which) { // ((OnAlertDialogClickListener) getActivity()).onDialogFragmentClick(this, which); // } // } // // Path: demo/src/main/java/org/neotech/app/retainabletasksdemo/tasks/SimpleTask.java // public class SimpleTask extends Task<Integer, String> { // // public SimpleTask(String tag) { // super(tag); // } // // @Override // protected String doInBackground() { // for(int i = 0; i < 100; i++) { // if(isCancelled()){ // break; // } // SystemClock.sleep(50); // publishProgress(i); // } // return "Result"; // } // // @Override // protected void onPostExecute() { // Log.i("SimpleTask", "SimpleTask.onPostExecute()"); // } // } // Path: demo/src/main/java/org/neotech/app/retainabletasksdemo/activity/ProgressTaskHandler.java import com.google.android.material.snackbar.Snackbar; import org.neotech.app.retainabletasksdemo.ProgressDialog; import org.neotech.app.retainabletasksdemo.R; import org.neotech.app.retainabletasksdemo.tasks.SimpleTask; import org.neotech.library.retainabletasks.TaskAttach; import org.neotech.library.retainabletasks.TaskCancel; import org.neotech.library.retainabletasks.TaskPostExecute; import org.neotech.library.retainabletasks.TaskProgress; package org.neotech.app.retainabletasksdemo.activity; /** * Created by Rolf Smit on 30-May-17. */ public final class ProgressTaskHandler { private static final String TASK_PROGRESS = "progress-dialog"; private static final String DIALOG_PROGRESS = "progress-dialog"; private ProgressDialog progressDialog; private final DemoActivityAnnotations demoActivityAnnotations; public ProgressTaskHandler(DemoActivityAnnotations demoActivityAnnotations){ this.demoActivityAnnotations = demoActivityAnnotations; } public void execute(){ if(!demoActivityAnnotations.getTaskManager().isActive(TASK_PROGRESS)) {
demoActivityAnnotations.getTaskManager().execute(new SimpleTask(TASK_PROGRESS));