blob_id
stringlengths 40
40
| __id__
int64 225
39,780B
| directory_id
stringlengths 40
40
| path
stringlengths 6
313
| content_id
stringlengths 40
40
| detected_licenses
list | license_type
stringclasses 2
values | repo_name
stringlengths 6
132
| repo_url
stringlengths 25
151
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
70
| visit_date
timestamp[ns] | revision_date
timestamp[ns] | committer_date
timestamp[ns] | github_id
int64 7.28k
689M
⌀ | star_events_count
int64 0
131k
| fork_events_count
int64 0
48k
| gha_license_id
stringclasses 23
values | gha_fork
bool 2
classes | gha_event_created_at
timestamp[ns] | gha_created_at
timestamp[ns] | gha_updated_at
timestamp[ns] | gha_pushed_at
timestamp[ns] | gha_size
int64 0
40.4M
⌀ | gha_stargazers_count
int32 0
112k
⌀ | gha_forks_count
int32 0
39.4k
⌀ | gha_open_issues_count
int32 0
11k
⌀ | gha_language
stringlengths 1
21
⌀ | gha_archived
bool 2
classes | gha_disabled
bool 1
class | content
stringlengths 7
4.37M
| src_encoding
stringlengths 3
16
| language
stringclasses 1
value | length_bytes
int64 7
4.37M
| extension
stringclasses 24
values | filename
stringlengths 4
174
| language_id
stringclasses 1
value | entities
list | contaminating_dataset
stringclasses 0
values | malware_signatures
list | redacted_content
stringlengths 7
4.37M
| redacted_length_bytes
int64 7
4.37M
| alphanum_fraction
float32 0.25
0.94
| alpha_fraction
float32 0.25
0.94
| num_lines
int32 1
84k
| avg_line_length
float32 0.76
99.9
| std_line_length
float32 0
220
| max_line_length
int32 5
998
| is_vendor
bool 2
classes | is_generated
bool 1
class | max_hex_length
int32 0
319
| hex_fraction
float32 0
0.38
| max_unicode_length
int32 0
408
| unicode_fraction
float32 0
0.36
| max_base64_length
int32 0
506
| base64_fraction
float32 0
0.5
| avg_csv_sep_count
float32 0
4
| is_autogen_header
bool 1
class | is_empty_html
bool 1
class | shard
stringclasses 16
values |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4a48f39abdd9c4e3b4ee1385e1eacbbf1dbf614b
| 21,208,548,518,709 |
6e8ade09bbd16d858d82f3aa7eb265f47de5f6a4
|
/src/SpriteTree/LimbNode.java
|
c548683ddcf18a90149b9e203347cf415752f188
|
[] |
no_license
|
hareeshganesan/Vooga
|
https://github.com/hareeshganesan/Vooga
|
6e33cc53fd6e44250ff90b9901b1aba95f2a0f11
|
4a54758c8627ab75454ec8ba3f6ea0660895ea64
|
refs/heads/master
| 2021-01-01T19:42:12.788000 | 2012-04-27T13:37:49 | 2012-04-27T13:37:49 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package SpriteTree;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import com.golden.gamedev.util.ImageUtil;
import com.golden.gamedev.object.Sprite;
public class LimbNode extends Sprite{
private String myName;
private BufferedImage myCurrImage;
private BufferedImage myOrigImage;
private double dx;
private double dy;
private double defaultTheta;
private double mutableTheta;
private LimbNode Parent;
private HashMap<Integer, BufferedImage> myPreGenImgs =new HashMap<Integer, BufferedImage>();
private HashMap<Integer,BufferedImage> myFlippedImgs = new HashMap<Integer,BufferedImage>();
private boolean flipped = false;
private ArrayList<LimbNode> children = new ArrayList<LimbNode>();
//to be implemented
double damageMultiplier;
double damageDealt;
//constructor for root node who doesn't have a parent
public LimbNode(String name, BufferedImage image, double x, double y){
super(image, x, y);
this.myName = name;
this.myOrigImage = image;
}
//constructor for limbs
public LimbNode(String name, LimbNode parent, BufferedImage image,double dx, double dy, int baseTheta){
super(image,parent.getX()+dx, parent.getY()+dy);
this.myName = name;
this.myOrigImage= image;
this.Parent = parent;
this.mutableTheta = baseTheta;
this.defaultTheta = baseTheta;
this.dx = dx;
this.dy = dy;
}
public String getName(){
return this.myName;
}
public void flip(boolean flip){
this.flipped = flip;
for(LimbNode child: this.children){
child.flip(flip);
}
}
public double getTheta(){
return this.mutableTheta;
}
public double getDefaultTheta(){
return this.defaultTheta;
}
public void setTheta(double expTheta){
this.mutableTheta = expTheta;
}
public ArrayList<LimbNode> getChildren(){
return this.children;
}
public void rotate(double dTheta)
{
this.mutableTheta += dTheta;
}
public void addChild(LimbNode child){
children.add(child);
}
public void removeChild(LimbNode child){
children.remove(child);
}
public LimbNode getParent(){
return this.Parent;
}
public Integer roundTheta(double theta){
Integer n = 0;
n = (int) Math.round(theta);
return n;
}
//refactor this code somehow
public void draw(double x, double y, double theta){
this.setX(x);
this.setY(y);
Integer roundedTheta = roundTheta(theta);
if(this.flipped == true){
if(myFlippedImgs.containsKey(roundedTheta)){
this.setImage(myFlippedImgs.get(roundedTheta));
}
else{
this.myCurrImage =GraphicsTest.rotate(this.myOrigImage,theta);
this.myCurrImage = GraphicsTest.horizFlip(this.myCurrImage);
this.setImage(this.myCurrImage);
myFlippedImgs.put(roundTheta(theta), this.myCurrImage);
}
}
else{
if(myPreGenImgs.containsKey(roundedTheta)){
this.setImage(myPreGenImgs.get(roundedTheta));
}
else{
this.myCurrImage =GraphicsTest.rotate(this.myOrigImage,theta);
this.setImage(this.myCurrImage);
myPreGenImgs.put(roundTheta(theta), this.myCurrImage);
}
}
}
public void render(Graphics2D pen,double baseX, double baseY, double baseTheta){
super.render(pen);
double dx =Math.cos(Math.toRadians(baseTheta)) * this.dx- Math.sin(Math.toRadians(baseTheta)) * this.dy;
double dy =Math.sin(Math.toRadians(baseTheta)) * this.dx + Math.cos(Math.toRadians(baseTheta)) * this.dy;
if(this.flipped == true){
dx = -dx;
}
draw((baseX + dx), (baseY + dy),this.mutableTheta+baseTheta);
for(LimbNode limb: this.children){
limb.render(pen, (baseX + dx), (baseY + dy), this.mutableTheta+baseTheta);
}
}
public void update(long elapsedTime){
super.update(elapsedTime);
}
public void print(){
System.out.println(this.Parent);
System.out.println(this.dx);
System.out.println(this.dy);
System.out.println(this.mutableTheta);
}
}
|
UTF-8
|
Java
| 3,963 |
java
|
LimbNode.java
|
Java
|
[] | null |
[] |
package SpriteTree;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import com.golden.gamedev.util.ImageUtil;
import com.golden.gamedev.object.Sprite;
public class LimbNode extends Sprite{
private String myName;
private BufferedImage myCurrImage;
private BufferedImage myOrigImage;
private double dx;
private double dy;
private double defaultTheta;
private double mutableTheta;
private LimbNode Parent;
private HashMap<Integer, BufferedImage> myPreGenImgs =new HashMap<Integer, BufferedImage>();
private HashMap<Integer,BufferedImage> myFlippedImgs = new HashMap<Integer,BufferedImage>();
private boolean flipped = false;
private ArrayList<LimbNode> children = new ArrayList<LimbNode>();
//to be implemented
double damageMultiplier;
double damageDealt;
//constructor for root node who doesn't have a parent
public LimbNode(String name, BufferedImage image, double x, double y){
super(image, x, y);
this.myName = name;
this.myOrigImage = image;
}
//constructor for limbs
public LimbNode(String name, LimbNode parent, BufferedImage image,double dx, double dy, int baseTheta){
super(image,parent.getX()+dx, parent.getY()+dy);
this.myName = name;
this.myOrigImage= image;
this.Parent = parent;
this.mutableTheta = baseTheta;
this.defaultTheta = baseTheta;
this.dx = dx;
this.dy = dy;
}
public String getName(){
return this.myName;
}
public void flip(boolean flip){
this.flipped = flip;
for(LimbNode child: this.children){
child.flip(flip);
}
}
public double getTheta(){
return this.mutableTheta;
}
public double getDefaultTheta(){
return this.defaultTheta;
}
public void setTheta(double expTheta){
this.mutableTheta = expTheta;
}
public ArrayList<LimbNode> getChildren(){
return this.children;
}
public void rotate(double dTheta)
{
this.mutableTheta += dTheta;
}
public void addChild(LimbNode child){
children.add(child);
}
public void removeChild(LimbNode child){
children.remove(child);
}
public LimbNode getParent(){
return this.Parent;
}
public Integer roundTheta(double theta){
Integer n = 0;
n = (int) Math.round(theta);
return n;
}
//refactor this code somehow
public void draw(double x, double y, double theta){
this.setX(x);
this.setY(y);
Integer roundedTheta = roundTheta(theta);
if(this.flipped == true){
if(myFlippedImgs.containsKey(roundedTheta)){
this.setImage(myFlippedImgs.get(roundedTheta));
}
else{
this.myCurrImage =GraphicsTest.rotate(this.myOrigImage,theta);
this.myCurrImage = GraphicsTest.horizFlip(this.myCurrImage);
this.setImage(this.myCurrImage);
myFlippedImgs.put(roundTheta(theta), this.myCurrImage);
}
}
else{
if(myPreGenImgs.containsKey(roundedTheta)){
this.setImage(myPreGenImgs.get(roundedTheta));
}
else{
this.myCurrImage =GraphicsTest.rotate(this.myOrigImage,theta);
this.setImage(this.myCurrImage);
myPreGenImgs.put(roundTheta(theta), this.myCurrImage);
}
}
}
public void render(Graphics2D pen,double baseX, double baseY, double baseTheta){
super.render(pen);
double dx =Math.cos(Math.toRadians(baseTheta)) * this.dx- Math.sin(Math.toRadians(baseTheta)) * this.dy;
double dy =Math.sin(Math.toRadians(baseTheta)) * this.dx + Math.cos(Math.toRadians(baseTheta)) * this.dy;
if(this.flipped == true){
dx = -dx;
}
draw((baseX + dx), (baseY + dy),this.mutableTheta+baseTheta);
for(LimbNode limb: this.children){
limb.render(pen, (baseX + dx), (baseY + dy), this.mutableTheta+baseTheta);
}
}
public void update(long elapsedTime){
super.update(elapsedTime);
}
public void print(){
System.out.println(this.Parent);
System.out.println(this.dx);
System.out.println(this.dy);
System.out.println(this.mutableTheta);
}
}
| 3,963 | 0.712844 | 0.712087 | 183 | 20.655737 | 23.276587 | 107 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.005465 | false | false |
13
|
480957f2b1565a75d9aa56335743878588c90263
| 1,417,339,239,061 |
3545e92e49bccd16ed8e436f52966306e9507c7b
|
/java/src/test/java/search/impl/BinarySearchTest.java
|
e10ab9dea74302e882d597530e6b93dde4091c08
|
[] |
no_license
|
satoshiyamamoto/algorithms-and-data-structure
|
https://github.com/satoshiyamamoto/algorithms-and-data-structure
|
ebdab3e0bfb749c58f1eab04ae3ac45bf16a590d
|
291125958d732bc1c2c5005cf91d670b34da7230
|
refs/heads/master
| 2016-09-07T03:08:07.899000 | 2014-09-24T09:57:27 | 2014-09-24T09:57:27 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package search.impl;
import search.Search;
import search.SearchTestTemplate;
public class BinarySearchTest extends SearchTestTemplate {
@Override
public Search getAlgorithm() {
return Searchs.getBinarySearch();
}
}
|
UTF-8
|
Java
| 229 |
java
|
BinarySearchTest.java
|
Java
|
[] | null |
[] |
package search.impl;
import search.Search;
import search.SearchTestTemplate;
public class BinarySearchTest extends SearchTestTemplate {
@Override
public Search getAlgorithm() {
return Searchs.getBinarySearch();
}
}
| 229 | 0.772926 | 0.772926 | 13 | 16.615385 | 18.036451 | 58 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.307692 | false | false |
13
|
81ce2c850572740bdeed16e3d63e17987363beed
| 30,245,159,748,094 |
b14d2f62b2286b30052814bd4e71aea53fed3324
|
/src/DiscountStrategy/Driver.java
|
72e3bc6b831695b60065ee0b32768ce4cb018a97
|
[] |
no_license
|
DvandenBerge/DiscountStrategy
|
https://github.com/DvandenBerge/DiscountStrategy
|
b232cd5e4a248b2f87adb0a0c32fc0e6167a2d25
|
5fbd491862f05b20aa68b96ba43a6ab4de7112df
|
refs/heads/master
| 2021-01-10T17:10:15.755000 | 2015-10-08T21:18:24 | 2015-10-08T21:18:24 | 43,396,683 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package DiscountStrategy;
import java.io.IOException;
/**
*
* @author dvandenberge
*/
public class Driver {
public static void main(String[] args) throws IOException{
Register register1 = new Register();
register1.beginNewTransaction(2,new Receipt());
register1.scanProductUPC("BC100", 4);
register1.scanProductUPC("BJ111", 2);
register1.scanProductUPC("BM210", 3);
System.out.println(register1.finalizeTransaction());
}
}
|
UTF-8
|
Java
| 522 |
java
|
Driver.java
|
Java
|
[
{
"context": "import java.io.IOException;\r\n\r\n/**\r\n *\r\n * @author dvandenberge\r\n */\r\npublic class Driver {\r\n public static vo",
"end": 92,
"score": 0.9564240574836731,
"start": 80,
"tag": "USERNAME",
"value": "dvandenberge"
}
] | null |
[] |
package DiscountStrategy;
import java.io.IOException;
/**
*
* @author dvandenberge
*/
public class Driver {
public static void main(String[] args) throws IOException{
Register register1 = new Register();
register1.beginNewTransaction(2,new Receipt());
register1.scanProductUPC("BC100", 4);
register1.scanProductUPC("BJ111", 2);
register1.scanProductUPC("BM210", 3);
System.out.println(register1.finalizeTransaction());
}
}
| 522 | 0.624521 | 0.588123 | 20 | 24.1 | 21.637699 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.6 | false | false |
13
|
05b15f06511d64a7aa665e1a5adadab0c5dea795
| 2,576,980,442,341 |
8c53a92d1ba82656e022bf608cdff954ada79ce2
|
/src/main/java/com/oceanleo/blog/domain/Guest.java
|
1ddb38ad347133389fbd840a0f16c0a765e403d7
|
[] |
no_license
|
oceanleo/blog
|
https://github.com/oceanleo/blog
|
2babfee55657a0a83c85acec2cfee91091ef52f4
|
c012ae1aeb9e4ea3f1ebe282c0c73a6b111e08a1
|
refs/heads/master
| 2022-06-23T23:40:29.159000 | 2020-07-13T03:32:49 | 2020-07-13T03:32:49 | 214,333,417 | 0 | 0 | null | false | 2022-06-21T02:01:29 | 2019-10-11T03:15:27 | 2020-07-13T03:32:52 | 2022-06-21T02:01:28 | 17 | 0 | 0 | 2 |
Java
| false | false |
package com.oceanleo.blog.domain;
import java.util.Date;
public class Guest {
public static final String ROOT_SERIAL = "0";
//主键
private Integer id;
//姓名(昵称)
private String name;
//邮箱
private String mail;
//地址
private String address;
//内容
private String content;
//上级id
private String parentId;
//创建时间
private Date createDate;
//序号
private Integer serial;
//回复id
private String replyId;
//是否博主回复
private Boolean admin;
//是否删除
private Boolean deleted;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getMail() {
return mail;
}
public void setMail(String mail) {
this.mail = mail;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public Integer getSerial() {
return serial;
}
public void setSerial(Integer serial) {
this.serial = serial;
}
public String getReplyId() {
return replyId;
}
public void setReplyId(String replyId) {
this.replyId = replyId;
}
public Boolean getAdmin() {
return admin;
}
public void setAdmin(Boolean admin) {
this.admin = admin;
}
public Boolean getDeleted() {
return deleted;
}
public void setDeleted(Boolean deleted) {
this.deleted = deleted;
}
@Override
public String toString() {
return "Guest{" +
"id=" + id +
", name='" + name + '\'' +
", mail='" + mail + '\'' +
", address='" + address + '\'' +
", content='" + content + '\'' +
", parentId='" + parentId + '\'' +
", createDate=" + createDate +
", serial=" + serial +
", replyId='" + replyId + '\'' +
", admin=" + admin +
", deleted=" + deleted +
'}';
}
}
|
UTF-8
|
Java
| 2,770 |
java
|
Guest.java
|
Java
|
[
{
"context": " \"id=\" + id +\n \", name='\" + name + '\\'' +\n \", mail='\" + mail + '\\''",
"end": 2263,
"score": 0.9590513110160828,
"start": 2259,
"tag": "NAME",
"value": "name"
}
] | null |
[] |
package com.oceanleo.blog.domain;
import java.util.Date;
public class Guest {
public static final String ROOT_SERIAL = "0";
//主键
private Integer id;
//姓名(昵称)
private String name;
//邮箱
private String mail;
//地址
private String address;
//内容
private String content;
//上级id
private String parentId;
//创建时间
private Date createDate;
//序号
private Integer serial;
//回复id
private String replyId;
//是否博主回复
private Boolean admin;
//是否删除
private Boolean deleted;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getMail() {
return mail;
}
public void setMail(String mail) {
this.mail = mail;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public Integer getSerial() {
return serial;
}
public void setSerial(Integer serial) {
this.serial = serial;
}
public String getReplyId() {
return replyId;
}
public void setReplyId(String replyId) {
this.replyId = replyId;
}
public Boolean getAdmin() {
return admin;
}
public void setAdmin(Boolean admin) {
this.admin = admin;
}
public Boolean getDeleted() {
return deleted;
}
public void setDeleted(Boolean deleted) {
this.deleted = deleted;
}
@Override
public String toString() {
return "Guest{" +
"id=" + id +
", name='" + name + '\'' +
", mail='" + mail + '\'' +
", address='" + address + '\'' +
", content='" + content + '\'' +
", parentId='" + parentId + '\'' +
", createDate=" + createDate +
", serial=" + serial +
", replyId='" + replyId + '\'' +
", admin=" + admin +
", deleted=" + deleted +
'}';
}
}
| 2,770 | 0.519956 | 0.519586 | 146 | 17.541096 | 15.833088 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.321918 | false | false |
13
|
0fd946c07a3b7d406192cbd1d44d2b5666903b4b
| 9,345,848,855,645 |
36c7d9828c5158370144b61eeb7f56ac8ed50162
|
/src/main/java/scratch/UCERF3/utils/UCERF2_A_FaultMapper.java
|
9b0f35d0ecf48f7607c28dbe360b91dfdc5de392
|
[
"Apache-2.0"
] |
permissive
|
Aditya-Zutshi/opensha
|
https://github.com/Aditya-Zutshi/opensha
|
92f1a5112c855fec37afea27150b4588fd14d077
|
d0e862a62bb3cdd262c4f33742b3a071da6b21b7
|
refs/heads/master
| 2023-08-28T05:00:38.792000 | 2021-10-26T08:13:18 | 2021-10-26T08:13:18 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package scratch.UCERF3.utils;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.opensha.commons.util.ExceptionUtils;
import org.opensha.sha.faultSurface.FaultSection;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import scratch.UCERF3.enumTreeBranches.DeformationModels;
import scratch.UCERF3.enumTreeBranches.FaultModels;
public class UCERF2_A_FaultMapper {
public static boolean wasUCERF2_TypeAFault(int sectionID) {
return getTypeAFaults().contains(sectionID);
}
private static final String DIR = "FaultModels";
private static final String A_FAULT_FILE_NAME = "a_faults.txt";
private static HashSet<Integer> typeAFaults;
private static HashSet<Integer> getTypeAFaults() {
if (typeAFaults == null) {
try {
typeAFaults = new HashSet<Integer>();
BufferedReader br = new BufferedReader(UCERF3_DataUtils.getReader(DIR, A_FAULT_FILE_NAME));
String line = br.readLine();
while (line != null) {
line = line.trim();
if (!line.startsWith("#") && !line.isEmpty()) {
Integer id = Integer.parseInt(line.split("\t")[0]);
typeAFaults.add(id);
}
line = br.readLine();
}
} catch (IOException e) {
typeAFaults = null;
ExceptionUtils.throwAsRuntimeException(e);
}
}
return typeAFaults;
}
private static void writeDataFile(File outputFile, File segFile,
File fm3_1_nameChangeFile, File fm3_2_nameChangeFile) throws IOException {
Map<String, String> fm3_1_changes = loadNameChanges(fm3_1_nameChangeFile);
Map<String, String> fm3_2_changes = loadNameChanges(fm3_2_nameChangeFile);
Map<Integer, String> aFaults = Maps.newHashMap();
List<String> segLines = FileUtils.readLines(segFile);
for (FaultModels fm : FaultModels.values()) {
Map<Integer, FaultSection> sects = fm.fetchFaultSectionsMap();
Map<String, Integer> sectsByName = Maps.newHashMap();
for (FaultSection sect : sects.values())
sectsByName.put(sect.getSectionName().trim(), sect.getSectionId());
for (String line : segLines) {
line = line.trim();
if (line.isEmpty() || line.startsWith("#") || line.startsWith("-"))
continue;
line = line.substring(line.indexOf(":")+1);
String[] names;
if (line.contains(";")) {
names = line.split(";");
} else {
names = new String[1];
names[0] = line;
}
for (String name : names) {
name = name.trim();
if (fm == FaultModels.FM3_1 && fm3_1_changes.containsKey(name))
name = fm3_1_changes.get(name);
if (fm == FaultModels.FM3_2 && fm3_2_changes.containsKey(name))
name = fm3_2_changes.get(name);
Integer sectID = sectsByName.get(name);
if (sectID == null) {
System.out.println("WARNING: sect not found with name: "+name+", FM: "+fm);
int min = Integer.MAX_VALUE;
String closest = null;
for (String matchName : sectsByName.keySet()) {
int dist = StringUtils.getLevenshteinDistance(name, matchName);
if (dist < min) {
min = dist;
closest = matchName;
}
}
System.out.println("Possible match: "+closest);
continue;
}
// Preconditions.checkNotNull(sect, "Sect not found: "+name);
if (!aFaults.containsKey(sectID))
aFaults.put(sectID, name);
}
}
}
FileWriter fw = new FileWriter(outputFile);
fw.write("#ID\tName\n");
List<Integer> sectIDs = Lists.newArrayList(aFaults.keySet());
Collections.sort(sectIDs);
for (Integer sectID : sectIDs) {
String name = aFaults.get(sectID);
fw.write(sectID+"\t"+name+"\n");
}
fw.close();
}
private static Map<String, String> loadNameChanges(File file) throws IOException {
Map<String, String> changes = Maps.newHashMap();
for (String line : FileUtils.readLines(file)) {
String[] names = line.trim().split("\t");
changes.put(names[0].trim(), names[1].trim());
}
return changes;
}
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
File dir = new File("/tmp");
// writeDataFile(new File(new File(UCERF3_DataUtils.DEFAULT_SCRATCH_DATA_DIR.getParentFile(), DIR),
// "a_faults.txt"), new File(dir, "SegmentModels.txt"),
// new File(dir, "FM2to3_1_sectionNameChanges.txt"),
// new File(dir, "FM2to3_2_sectionNameChanges.txt"));
// now test
// for (FaultModels fm : FaultModels.values()) {
// DeformationModels dm = DeformationModels.forFaultModel(fm).get(0);
//
// for (FaultSectionPrefData sect : new DeformationModelFetcher(
// fm, dm, UCERF3_DataUtils.DEFAULT_SCRATCH_DATA_DIR, 0.1).getParentSectionList())
// if (wasUCERF2_TypeAFault(sect.getSectionId()))
// System.out.println("A Fault: "+sect.getSectionId()+". "+sect.getSectionName());
// }
DeformationModelFetcher fetcher = new DeformationModelFetcher(FaultModels.FM2_1, DeformationModels.UCERF2_ALL, null, 0.0);
for (FaultSection sect : fetcher.getParentSectionList()) {
// if (wasUCERF2_TypeAFault(sect.getSectionId()))
// System.out.println("A Fault: "+sect.getSectionId()+". "+sect.getSectionName());
System.out.println(sect.getSectionId()+"\t"+sect.getSectionName()+"\t"+wasUCERF2_TypeAFault(sect.getSectionId()));
}
}
}
|
UTF-8
|
Java
| 5,514 |
java
|
UCERF2_A_FaultMapper.java
|
Java
|
[] | null |
[] |
package scratch.UCERF3.utils;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.opensha.commons.util.ExceptionUtils;
import org.opensha.sha.faultSurface.FaultSection;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import scratch.UCERF3.enumTreeBranches.DeformationModels;
import scratch.UCERF3.enumTreeBranches.FaultModels;
public class UCERF2_A_FaultMapper {
public static boolean wasUCERF2_TypeAFault(int sectionID) {
return getTypeAFaults().contains(sectionID);
}
private static final String DIR = "FaultModels";
private static final String A_FAULT_FILE_NAME = "a_faults.txt";
private static HashSet<Integer> typeAFaults;
private static HashSet<Integer> getTypeAFaults() {
if (typeAFaults == null) {
try {
typeAFaults = new HashSet<Integer>();
BufferedReader br = new BufferedReader(UCERF3_DataUtils.getReader(DIR, A_FAULT_FILE_NAME));
String line = br.readLine();
while (line != null) {
line = line.trim();
if (!line.startsWith("#") && !line.isEmpty()) {
Integer id = Integer.parseInt(line.split("\t")[0]);
typeAFaults.add(id);
}
line = br.readLine();
}
} catch (IOException e) {
typeAFaults = null;
ExceptionUtils.throwAsRuntimeException(e);
}
}
return typeAFaults;
}
private static void writeDataFile(File outputFile, File segFile,
File fm3_1_nameChangeFile, File fm3_2_nameChangeFile) throws IOException {
Map<String, String> fm3_1_changes = loadNameChanges(fm3_1_nameChangeFile);
Map<String, String> fm3_2_changes = loadNameChanges(fm3_2_nameChangeFile);
Map<Integer, String> aFaults = Maps.newHashMap();
List<String> segLines = FileUtils.readLines(segFile);
for (FaultModels fm : FaultModels.values()) {
Map<Integer, FaultSection> sects = fm.fetchFaultSectionsMap();
Map<String, Integer> sectsByName = Maps.newHashMap();
for (FaultSection sect : sects.values())
sectsByName.put(sect.getSectionName().trim(), sect.getSectionId());
for (String line : segLines) {
line = line.trim();
if (line.isEmpty() || line.startsWith("#") || line.startsWith("-"))
continue;
line = line.substring(line.indexOf(":")+1);
String[] names;
if (line.contains(";")) {
names = line.split(";");
} else {
names = new String[1];
names[0] = line;
}
for (String name : names) {
name = name.trim();
if (fm == FaultModels.FM3_1 && fm3_1_changes.containsKey(name))
name = fm3_1_changes.get(name);
if (fm == FaultModels.FM3_2 && fm3_2_changes.containsKey(name))
name = fm3_2_changes.get(name);
Integer sectID = sectsByName.get(name);
if (sectID == null) {
System.out.println("WARNING: sect not found with name: "+name+", FM: "+fm);
int min = Integer.MAX_VALUE;
String closest = null;
for (String matchName : sectsByName.keySet()) {
int dist = StringUtils.getLevenshteinDistance(name, matchName);
if (dist < min) {
min = dist;
closest = matchName;
}
}
System.out.println("Possible match: "+closest);
continue;
}
// Preconditions.checkNotNull(sect, "Sect not found: "+name);
if (!aFaults.containsKey(sectID))
aFaults.put(sectID, name);
}
}
}
FileWriter fw = new FileWriter(outputFile);
fw.write("#ID\tName\n");
List<Integer> sectIDs = Lists.newArrayList(aFaults.keySet());
Collections.sort(sectIDs);
for (Integer sectID : sectIDs) {
String name = aFaults.get(sectID);
fw.write(sectID+"\t"+name+"\n");
}
fw.close();
}
private static Map<String, String> loadNameChanges(File file) throws IOException {
Map<String, String> changes = Maps.newHashMap();
for (String line : FileUtils.readLines(file)) {
String[] names = line.trim().split("\t");
changes.put(names[0].trim(), names[1].trim());
}
return changes;
}
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
File dir = new File("/tmp");
// writeDataFile(new File(new File(UCERF3_DataUtils.DEFAULT_SCRATCH_DATA_DIR.getParentFile(), DIR),
// "a_faults.txt"), new File(dir, "SegmentModels.txt"),
// new File(dir, "FM2to3_1_sectionNameChanges.txt"),
// new File(dir, "FM2to3_2_sectionNameChanges.txt"));
// now test
// for (FaultModels fm : FaultModels.values()) {
// DeformationModels dm = DeformationModels.forFaultModel(fm).get(0);
//
// for (FaultSectionPrefData sect : new DeformationModelFetcher(
// fm, dm, UCERF3_DataUtils.DEFAULT_SCRATCH_DATA_DIR, 0.1).getParentSectionList())
// if (wasUCERF2_TypeAFault(sect.getSectionId()))
// System.out.println("A Fault: "+sect.getSectionId()+". "+sect.getSectionName());
// }
DeformationModelFetcher fetcher = new DeformationModelFetcher(FaultModels.FM2_1, DeformationModels.UCERF2_ALL, null, 0.0);
for (FaultSection sect : fetcher.getParentSectionList()) {
// if (wasUCERF2_TypeAFault(sect.getSectionId()))
// System.out.println("A Fault: "+sect.getSectionId()+". "+sect.getSectionName());
System.out.println(sect.getSectionId()+"\t"+sect.getSectionName()+"\t"+wasUCERF2_TypeAFault(sect.getSectionId()));
}
}
}
| 5,514 | 0.671563 | 0.661407 | 172 | 31.05814 | 26.976025 | 124 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.424419 | false | false |
13
|
dcead6a334e938f92248d2ad73ba478e3ecd3d50
| 2,388,001,853,218 |
ddd400fba24ac198de6571c7faf62dce542d04b4
|
/src/main/java/com/midea/demo/design/facade/FacadeTest.java
|
fc9273a79edd2af512ff44dd3eb857d0bd264fc1
|
[] |
no_license
|
huyi0616/designPartten
|
https://github.com/huyi0616/designPartten
|
1104b76ef31e9e92cc08c3a988d494765b93413f
|
950b718233c1daeaa67bc311f49fb553fda9b7d1
|
refs/heads/master
| 2020-12-24T07:56:22.821000 | 2016-11-10T06:17:44 | 2016-11-10T06:17:44 | 73,352,411 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.midea.demo.design.facade;
public class FacadeTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
Disk disk = new Disk();
Cpu cpu = new Cpu();
Hardware computer = new Computer(cpu,disk);
computer.start();
computer.stop();
}
}
|
UTF-8
|
Java
| 305 |
java
|
FacadeTest.java
|
Java
|
[] | null |
[] |
package com.midea.demo.design.facade;
public class FacadeTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
Disk disk = new Disk();
Cpu cpu = new Cpu();
Hardware computer = new Computer(cpu,disk);
computer.start();
computer.stop();
}
}
| 305 | 0.639344 | 0.639344 | 16 | 17.0625 | 16.087528 | 45 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.4375 | false | false |
13
|
5b3749601a8991c281adc020c1cf1b8eb57c75a8
| 14,516,989,492,651 |
99743ae00b0cd850d4a020c371c332dce27eaef6
|
/projeto_bb/mdc-automacao-integracao-csr/br.com.bb.mdc.testesAutomatizados/src/main/java/br/com/bb/mdc/testesAutomatizadosSteps/AnalisandoMassaChequeStep.java
|
d1e7fddd47e71b85ec910aef9dc6e9b0c3241d34
|
[] |
no_license
|
alexendrios/automacao
|
https://github.com/alexendrios/automacao
|
1b00a167033e766310e14f31d7d2007d415faf33
|
1c5677430990661c42e55606726d7bc37eff2da8
|
refs/heads/master
| 2023-08-14T18:08:01.055000 | 2021-10-02T17:47:20 | 2021-10-02T17:47:20 | 412,864,656 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package br.com.bb.mdc.testesAutomatizadosSteps;
import cucumber.api.PendingException;
import cucumber.api.java.pt.Quando;
public class AnalisandoMassaChequeStep {
@Quando("^acesso o servidor \"([^\"]*)\"$")
public void acessoOServidor(String arg1) throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@Quando("^infomro o arquivo gerado \"([^\"]*)\"$")
public void infomroOArquivoGerado(String arg1) throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@Quando("^busco \"([^\"]*)\", verifico \"([^\"]*)\"$")
public void buscoVerifico(String arg1, String arg2) throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
}
|
UTF-8
|
Java
| 861 |
java
|
AnalisandoMassaChequeStep.java
|
Java
|
[] | null |
[] |
package br.com.bb.mdc.testesAutomatizadosSteps;
import cucumber.api.PendingException;
import cucumber.api.java.pt.Quando;
public class AnalisandoMassaChequeStep {
@Quando("^acesso o servidor \"([^\"]*)\"$")
public void acessoOServidor(String arg1) throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@Quando("^infomro o arquivo gerado \"([^\"]*)\"$")
public void infomroOArquivoGerado(String arg1) throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@Quando("^busco \"([^\"]*)\", verifico \"([^\"]*)\"$")
public void buscoVerifico(String arg1, String arg2) throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
}
| 861 | 0.704994 | 0.700348 | 26 | 32.115383 | 27.46652 | 73 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.923077 | false | false |
13
|
a2689157d08f519c91d0a5ef4aece45ac18233a4
| 19,378,892,464,802 |
cc1b87a0d628d50b0d31fe73f28146baefd82483
|
/AdvPro/src/main/java/com/example/demo/rest/RestValidateController.java
|
523fdc1fd78528c215bc4cd5a5cb5bb7d0a0134b
|
[] |
no_license
|
haiduong07137/duAnRaTruong
|
https://github.com/haiduong07137/duAnRaTruong
|
844227e2a13550770769be5ed73a1c6375ab3833
|
7a9e32baf4acd6d17832ba8c59122c960987b148
|
refs/heads/master
| 2023-01-27T19:21:13.785000 | 2020-12-07T01:55:00 | 2020-12-07T01:55:00 | 319,175,061 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.example.demo.rest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.example.demo.dto.ValidateDto;
import com.example.demo.dto.seachdto.SearchDto;
import com.example.demo.service.ValidateService;
@RestController
@CrossOrigin(origins = { "http://localhost:3001", "http://localhost:3000" })
@RequestMapping(value = "/api/validate")
public class RestValidateController {
@Autowired
ValidateService validateService;
@RequestMapping(value = "/searchValidate", method = RequestMethod.POST)
public ResponseEntity<Page<SearchDto>> searchValidate(@RequestBody SearchDto serSearchDto) {
Page<SearchDto> result = validateService.searchValidate(serSearchDto);
return new ResponseEntity<Page<SearchDto>>(result, HttpStatus.OK);
}
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public ResponseEntity<ValidateDto> getById(@PathVariable Long id) {
ValidateDto validateDto = validateService.findById(id);
return new ResponseEntity<ValidateDto>(validateDto, HttpStatus.OK);
}
@RequestMapping(value = "", method = RequestMethod.POST)
public ResponseEntity<ValidateDto> newValidate(@RequestBody ValidateDto validateDto) {
System.out.println((validateDto != null) + "=ok");
ValidateDto validateDtoNew = validateService.createOrUpdateValidate(validateDto, null);
return new ResponseEntity<ValidateDto>(validateDtoNew, HttpStatus.OK);
// return new ResponseEntity<ValidateDto>(validateDto, HttpStatus.OK);
}
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
public ResponseEntity<ValidateDto> updateValidate(@RequestBody ValidateDto validateDto, @PathVariable Long id) {
ValidateDto validateDtoNew = validateService.createOrUpdateValidate(validateDto, id);
return new ResponseEntity<ValidateDto>(validateDtoNew, HttpStatus.OK);
}
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public void deleteValidate(@PathVariable Long id) {
validateService.deleteById(id);
}
}
|
UTF-8
|
Java
| 2,473 |
java
|
RestValidateController.java
|
Java
|
[] | null |
[] |
package com.example.demo.rest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.example.demo.dto.ValidateDto;
import com.example.demo.dto.seachdto.SearchDto;
import com.example.demo.service.ValidateService;
@RestController
@CrossOrigin(origins = { "http://localhost:3001", "http://localhost:3000" })
@RequestMapping(value = "/api/validate")
public class RestValidateController {
@Autowired
ValidateService validateService;
@RequestMapping(value = "/searchValidate", method = RequestMethod.POST)
public ResponseEntity<Page<SearchDto>> searchValidate(@RequestBody SearchDto serSearchDto) {
Page<SearchDto> result = validateService.searchValidate(serSearchDto);
return new ResponseEntity<Page<SearchDto>>(result, HttpStatus.OK);
}
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public ResponseEntity<ValidateDto> getById(@PathVariable Long id) {
ValidateDto validateDto = validateService.findById(id);
return new ResponseEntity<ValidateDto>(validateDto, HttpStatus.OK);
}
@RequestMapping(value = "", method = RequestMethod.POST)
public ResponseEntity<ValidateDto> newValidate(@RequestBody ValidateDto validateDto) {
System.out.println((validateDto != null) + "=ok");
ValidateDto validateDtoNew = validateService.createOrUpdateValidate(validateDto, null);
return new ResponseEntity<ValidateDto>(validateDtoNew, HttpStatus.OK);
// return new ResponseEntity<ValidateDto>(validateDto, HttpStatus.OK);
}
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
public ResponseEntity<ValidateDto> updateValidate(@RequestBody ValidateDto validateDto, @PathVariable Long id) {
ValidateDto validateDtoNew = validateService.createOrUpdateValidate(validateDto, id);
return new ResponseEntity<ValidateDto>(validateDtoNew, HttpStatus.OK);
}
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public void deleteValidate(@PathVariable Long id) {
validateService.deleteById(id);
}
}
| 2,473 | 0.803882 | 0.800647 | 56 | 43.160713 | 30.908724 | 113 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.410714 | false | false |
13
|
bb100ddad5ce5d8382935fca60446f08b260d074
| 33,715,493,296,545 |
0567d4ea3782a36af50094cc53a54e655b1fa157
|
/chapter6/src/ioexample/FileWriterDemo.java
|
7eb1446643057271b8b8737a6df3d5e1b66f0f3c
|
[] |
no_license
|
Mingmingge/java_work
|
https://github.com/Mingmingge/java_work
|
4e7074007acd188f1a02d7e7fae1e6bdfccd0626
|
0dbfc2f0e440b6f846fceb2fd9652649de68b4d4
|
refs/heads/master
| 2021-01-23T00:48:45.050000 | 2017-06-13T04:08:35 | 2017-06-13T04:08:35 | 92,849,876 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package ioexample;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class FileWriterDemo {
public static void main(String[] args) throws IOException {
// FileWriter fw = new FileWriter("e:\\a.txt");
// fw.write("hello");
// fw.flush();
// fw.write("world");
// fw.close();
FileWriter fw = null;
FileReader fr = null;
try{
fw = new FileWriter("e:\\copy2.java");
fr = new FileReader("e:\\demo1.java");
char[] buf = new char[1024];
int len =0;
while((len=fr.read(buf))!=-1)
{
//System.out.print(new String(buf,0,len));
fw.write(buf,0,len);
fw.flush();
}
}
catch(IOException e)
{
System.out.println(e.toString());
}
finally
{
try{
if(fw!= null)
fw.close();
}
catch(IOException e)
{
System.out.println(e.toString());
}
try{
if(fr!= null)
fr.close();
}
catch(IOException e)
{
System.out.println(e.toString());
}
}
}
}
|
UTF-8
|
Java
| 1,039 |
java
|
FileWriterDemo.java
|
Java
|
[] | null |
[] |
package ioexample;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class FileWriterDemo {
public static void main(String[] args) throws IOException {
// FileWriter fw = new FileWriter("e:\\a.txt");
// fw.write("hello");
// fw.flush();
// fw.write("world");
// fw.close();
FileWriter fw = null;
FileReader fr = null;
try{
fw = new FileWriter("e:\\copy2.java");
fr = new FileReader("e:\\demo1.java");
char[] buf = new char[1024];
int len =0;
while((len=fr.read(buf))!=-1)
{
//System.out.print(new String(buf,0,len));
fw.write(buf,0,len);
fw.flush();
}
}
catch(IOException e)
{
System.out.println(e.toString());
}
finally
{
try{
if(fw!= null)
fw.close();
}
catch(IOException e)
{
System.out.println(e.toString());
}
try{
if(fr!= null)
fr.close();
}
catch(IOException e)
{
System.out.println(e.toString());
}
}
}
}
| 1,039 | 0.549567 | 0.539942 | 56 | 16.553572 | 14.584629 | 60 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.803571 | false | false |
13
|
1059b86e7abf57a6d0b5cdbe7202affdc11c315b
| 17,755,394,846,044 |
67d613f07a5a8d938f4174a57d654099ed9e0394
|
/app/src/main/java/com/teraim/strand/ActivityVallar.java
|
ad1fb1178ef3b46d4dde0b4d3e6e9d55b5aeddeb
|
[
"MIT"
] |
permissive
|
hemip/strand2018
|
https://github.com/hemip/strand2018
|
666cf6025424544617d48ec0d32e522c4662b216
|
66b0e1de5aee735dffecd5bbf281278f2cb259e4
|
refs/heads/master
| 2022-08-21T00:21:20.442000 | 2022-07-13T20:42:11 | 2022-07-13T20:42:11 | 143,611,141 | 0 | 1 | null | false | 2020-05-25T11:07:04 | 2018-08-05T12:31:40 | 2020-05-25T10:58:43 | 2020-05-25T11:07:04 | 21,016 | 0 | 0 | 0 |
Java
| false | false |
package com.teraim.strand;
import java.util.HashMap;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import com.teraim.strand.dataobjekt.Table;
import com.teraim.strand.dataobjekt.TableVallar;
import com.teraim.strand.utils.ImageHandler;
public class ActivityVallar extends M_Activity {
private final Provyta py = Strand.getCurrentProvyta(this);
private TableVallar tv;
private ImageButton pic_drift1;
private ImageButton pic_drift2;
private ImageHandler imgHandler;
//Map name to button
HashMap<String, ImageButton> buttonM = new HashMap<String,ImageButton>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.activity_vallar);
// HorizontalScrollView cp = (HorizontalScrollView)this.findViewById(R.id.contentPane);
LinearLayout cp = (LinearLayout)this.findViewById(R.id.contentPane);
Table myData = py.getVallar();
tv = new TableVallar(this,myData);
tv.setStretchAllColumns(true);
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
tv.setLayoutParams(lp);
cp.addView(tv);
imgHandler = new ImageHandler(this);
buttonM.clear();
pic_drift1 = (ImageButton)this.findViewById(R.id.pic_drift1);
pic_drift2 = (ImageButton)this.findViewById(R.id.pic_drift2);
//Create buttons.
initPic(pic_drift1,"drift1");
initPic(pic_drift2,"drift2");
}
private void initPic(final ImageButton b, final String name) {
buttonM.put(name, b);
imgHandler.drawButton(b,name);
imgHandler.addListener(b,name);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent myI){
if (requestCode == ImageHandler.TAKE_PICTURE){
if (resultCode == Activity.RESULT_OK)
{
Log.d("Strand","picture was taken, result ok");
// String name = myI.getStringExtra(Strand.KEY_PIC_NAME);
String currSaving = imgHandler.getCurrentlySaving();
if (currSaving!=null) {
ImageButton b = buttonM.get(currSaving);
imgHandler.drawButton(b,currSaving);
Log.d("Strand","Drew button!");
} else
Log.e("Strand","Did not find pic with name "+currSaving+" in onActRes in TakePic Activity");
} else {
Log.d("Strand","picture was NOT taken, result NOT ok");
}
}
}
public void onAddRowButtonClicked(View v) {
//Add a row with default driftvallsnummer..
tv.addRow(Integer.toString(py.getDriftVallsC()));
}
}
|
UTF-8
|
Java
| 2,659 |
java
|
ActivityVallar.java
|
Java
|
[] | null |
[] |
package com.teraim.strand;
import java.util.HashMap;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import com.teraim.strand.dataobjekt.Table;
import com.teraim.strand.dataobjekt.TableVallar;
import com.teraim.strand.utils.ImageHandler;
public class ActivityVallar extends M_Activity {
private final Provyta py = Strand.getCurrentProvyta(this);
private TableVallar tv;
private ImageButton pic_drift1;
private ImageButton pic_drift2;
private ImageHandler imgHandler;
//Map name to button
HashMap<String, ImageButton> buttonM = new HashMap<String,ImageButton>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.activity_vallar);
// HorizontalScrollView cp = (HorizontalScrollView)this.findViewById(R.id.contentPane);
LinearLayout cp = (LinearLayout)this.findViewById(R.id.contentPane);
Table myData = py.getVallar();
tv = new TableVallar(this,myData);
tv.setStretchAllColumns(true);
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
tv.setLayoutParams(lp);
cp.addView(tv);
imgHandler = new ImageHandler(this);
buttonM.clear();
pic_drift1 = (ImageButton)this.findViewById(R.id.pic_drift1);
pic_drift2 = (ImageButton)this.findViewById(R.id.pic_drift2);
//Create buttons.
initPic(pic_drift1,"drift1");
initPic(pic_drift2,"drift2");
}
private void initPic(final ImageButton b, final String name) {
buttonM.put(name, b);
imgHandler.drawButton(b,name);
imgHandler.addListener(b,name);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent myI){
if (requestCode == ImageHandler.TAKE_PICTURE){
if (resultCode == Activity.RESULT_OK)
{
Log.d("Strand","picture was taken, result ok");
// String name = myI.getStringExtra(Strand.KEY_PIC_NAME);
String currSaving = imgHandler.getCurrentlySaving();
if (currSaving!=null) {
ImageButton b = buttonM.get(currSaving);
imgHandler.drawButton(b,currSaving);
Log.d("Strand","Drew button!");
} else
Log.e("Strand","Did not find pic with name "+currSaving+" in onActRes in TakePic Activity");
} else {
Log.d("Strand","picture was NOT taken, result NOT ok");
}
}
}
public void onAddRowButtonClicked(View v) {
//Add a row with default driftvallsnummer..
tv.addRow(Integer.toString(py.getDriftVallsC()));
}
}
| 2,659 | 0.735239 | 0.731478 | 95 | 26.989473 | 24.516586 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.28421 | false | false |
13
|
70fda6f7908bf40c96702ad8529316714c2abeb7
| 14,276,471,302,231 |
231b8bfd668b315f5127c365be302ea092f71333
|
/util/src/main/java/br/com/sysdesc/util/classes/CNPJUtil.java
|
f9cdfa49c493436ec3f83a7c880081dc6e595559
|
[] |
no_license
|
leandroZanatta/SysDesc
|
https://github.com/leandroZanatta/SysDesc
|
98142b525a854ea346f285d0c65c584de007b9c2
|
0cb39f594dc92c53ca8f8896c24c48b62675c513
|
refs/heads/master
| 2022-11-17T01:57:28.012000 | 2019-10-13T03:31:15 | 2019-10-13T03:31:15 | 186,448,488 | 0 | 1 | null | false | 2022-11-10T20:48:10 | 2019-05-13T15:36:28 | 2019-10-13T03:32:03 | 2022-11-10T20:48:07 | 528,084 | 0 | 0 | 16 |
Java
| false | false |
package br.com.sysdesc.util.classes;
public class CNPJUtil {
public static Boolean isCNPJValido(String cpf) {
return Boolean.TRUE;
}
}
|
UTF-8
|
Java
| 151 |
java
|
CNPJUtil.java
|
Java
|
[] | null |
[] |
package br.com.sysdesc.util.classes;
public class CNPJUtil {
public static Boolean isCNPJValido(String cpf) {
return Boolean.TRUE;
}
}
| 151 | 0.701987 | 0.701987 | 9 | 14.777778 | 17.478735 | 49 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.666667 | false | false |
13
|
c052972f49f9858d49fc4c507d179a8e411501ea
| 32,590,211,889,926 |
de9f0f6ac99ce53e58a4f0b0dfdfe7c9229e9dcd
|
/src/main/java/com/p2psys/model/BorrowTender.java
|
94c4b1571540afb08ba0db8406152b5bb64ed182
|
[] |
no_license
|
learningtcc/people-to-people-loan-system
|
https://github.com/learningtcc/people-to-people-loan-system
|
591838a40169dc1fb4a4d9860fe538fa2cf5d30f
|
fa56b5f0d4fcd04c8fca246abc05d4483053b02b
|
refs/heads/master
| 2021-03-16T05:07:21.612000 | 2014-10-13T15:08:43 | 2014-10-13T15:08:43 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.p2psys.model;
import java.io.Serializable;
import com.p2psys.domain.Tender;
public class BorrowTender extends Tender implements Serializable {
private static final long serialVersionUID = 2737053575621240588L;
private String username;
//待收时间
private String repay_time;
//待收金额
private String repay_account;
//标名
private String name;
//借款金额
private double borrow_account;
//投标人真实姓名
private String realname;
//投标人身份证号
private String card_id;
// V1.6.6.2 RDPROJECT-353 ljd 2013-10-21 start
//实际还款时间
private String repay_yestime;
public String getRepay_yestime() {
return repay_yestime;
}
public void setRepay_yestime(String repay_yestime) {
this.repay_yestime = repay_yestime;
}
// V1.6.6.2 RDPROJECT-353 ljd 2013-10-21 end
// V1.6.6.2 RDPROJECT-380 lhm 2013-10-21 start
private String award;
/**
* 获取award
*
* @return award
*/
public String getAward() {
return award;
}
/**
* 设置award
*
* @param award 要设置的award
*/
public void setAward(String award) {
this.award = award;
}
// V1.6.6.2 RDPROJECT-380 lhm 2013-10-21 end
public String getRealname() {
return realname;
}
public void setRealname(String realname) {
this.realname = realname;
}
public String getCard_id() {
return card_id;
}
public void setCard_id(String card_id) {
this.card_id = card_id;
}
public double getBorrow_account() {
return borrow_account;
}
public void setBorrow_account(double borrow_account) {
this.borrow_account = borrow_account;
}
public String getRepay_account() {
return repay_account;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void setRepay_account(String repay_account) {
this.repay_account = repay_account;
}
public String getRepay_time() {
return repay_time;
}
public void setRepay_time(String repay_time) {
this.repay_time = repay_time;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
|
UTF-8
|
Java
| 2,259 |
java
|
BorrowTender.java
|
Java
|
[] | null |
[] |
package com.p2psys.model;
import java.io.Serializable;
import com.p2psys.domain.Tender;
public class BorrowTender extends Tender implements Serializable {
private static final long serialVersionUID = 2737053575621240588L;
private String username;
//待收时间
private String repay_time;
//待收金额
private String repay_account;
//标名
private String name;
//借款金额
private double borrow_account;
//投标人真实姓名
private String realname;
//投标人身份证号
private String card_id;
// V1.6.6.2 RDPROJECT-353 ljd 2013-10-21 start
//实际还款时间
private String repay_yestime;
public String getRepay_yestime() {
return repay_yestime;
}
public void setRepay_yestime(String repay_yestime) {
this.repay_yestime = repay_yestime;
}
// V1.6.6.2 RDPROJECT-353 ljd 2013-10-21 end
// V1.6.6.2 RDPROJECT-380 lhm 2013-10-21 start
private String award;
/**
* 获取award
*
* @return award
*/
public String getAward() {
return award;
}
/**
* 设置award
*
* @param award 要设置的award
*/
public void setAward(String award) {
this.award = award;
}
// V1.6.6.2 RDPROJECT-380 lhm 2013-10-21 end
public String getRealname() {
return realname;
}
public void setRealname(String realname) {
this.realname = realname;
}
public String getCard_id() {
return card_id;
}
public void setCard_id(String card_id) {
this.card_id = card_id;
}
public double getBorrow_account() {
return borrow_account;
}
public void setBorrow_account(double borrow_account) {
this.borrow_account = borrow_account;
}
public String getRepay_account() {
return repay_account;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void setRepay_account(String repay_account) {
this.repay_account = repay_account;
}
public String getRepay_time() {
return repay_time;
}
public void setRepay_time(String repay_time) {
this.repay_time = repay_time;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
| 2,259 | 0.664828 | 0.627586 | 115 | 16.913044 | 17.210495 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.208696 | false | false |
13
|
e29e1a31985a6906be0ddc431702306bb5e59953
| 27,118,423,536,027 |
90ef7b55467df73796b970684519c3ff74b7aad5
|
/src/main/java/org/sagebionetworks/web/client/widget/entity/row/EntityRowList.java
|
aa0bfb5408b1cfb2856512ff4537532233c88265
|
[] |
no_license
|
eric-wu/SynapseWebClient
|
https://github.com/eric-wu/SynapseWebClient
|
576d276bee81a7c9aaa2361d64bcbfe0da8a9dd2
|
9ea9e4a8f9826d1e18e879d9f15619a035bb72c0
|
HEAD
| 2016-10-31T20:35:27.578000 | 2013-07-09T22:46:28 | 2013-07-09T22:46:28 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package org.sagebionetworks.web.client.widget.entity.row;
import java.util.List;
/**
* Marker for a row backed by a list.
* @author jmhill
*
* @param <T>
*/
public interface EntityRowList<T> extends EntityRow<List<T>> {
/**
* The type of the list
* @return
*/
Class<? extends T> getListClass();
}
|
UTF-8
|
Java
| 333 |
java
|
EntityRowList.java
|
Java
|
[
{
"context": "\n * Marker for a row backed by a list.\r\n * @author jmhill\r\n *\r\n * @param <T>\r\n */\r\npublic interface EntityR",
"end": 148,
"score": 0.9995784759521484,
"start": 142,
"tag": "USERNAME",
"value": "jmhill"
}
] | null |
[] |
package org.sagebionetworks.web.client.widget.entity.row;
import java.util.List;
/**
* Marker for a row backed by a list.
* @author jmhill
*
* @param <T>
*/
public interface EntityRowList<T> extends EntityRow<List<T>> {
/**
* The type of the list
* @return
*/
Class<? extends T> getListClass();
}
| 333 | 0.624625 | 0.624625 | 19 | 15.526316 | 18.91913 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.421053 | false | false |
13
|
7f43a22730701b5d9df065215199c07094c2426e
| 27,118,423,534,212 |
433ed5cab9f6ce22f48e8316ccfd527dd1901138
|
/src/pipe/gui/Animator.java
|
d9dd83d647e4876485d380c45fa53ebc1d935e0e
|
[] |
no_license
|
ak1007/PipeCoursework
|
https://github.com/ak1007/PipeCoursework
|
e5b2a41a13678d5ab93bd567f29fc025f21b415b
|
e00f334517ba0e003fc4f8b0eeb6d647981f5033
|
refs/heads/master
| 2020-05-19T18:56:21.720000 | 2010-12-14T21:43:12 | 2010-12-14T21:43:12 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package pipe.gui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Iterator;
import javax.swing.JOptionPane;
import javax.swing.Timer;
import pipe.common.dataLayer.Arc;
import pipe.common.dataLayer.DataLayer;
import pipe.common.dataLayer.Place;
import pipe.common.dataLayer.Transition;
/**
* This class is used to process clicks by the user to manually step
* through enabled transitions in the net.
*
* @author unspecified wrote this code
* @author David Patterson fixed a bug with double-firing transitions
* in the doRandomFiring method. I also renamed the fireTransition
* method to recordFiredTransition to better describe what it does.
*
* @author Pere Bonet modified the recordFiredTransition method to
* fix the unexpected behaviour observed during animation playback.
* The method is renamed back to fireTransition.
*
* @author Edwin Chung fixed the bug where users can still step forward to previous
* firing sequence even though it has been reset. The issue where an unexpected behaviour
* will occur when the firing sequence has been altered has been resolved. The problem where
* animation will freeze halfway while stepping back a firing sequence has also been fixed (Feb 2007)
*
* @author Dave Patterson The code now outputs an error message in the status bar
* if there is no transition to be found when picking a random transition to fire. This
* is related to the problem described in bug 1699546.
*/
public class Animator implements Constants{
Timer timer;
int numberSequences;
public static ArrayList firedTransitions;
public static int count= 0;
public Animator(){
firedTransitions = new ArrayList();
timer = new Timer(0, new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if ((getNumberSequences()<1) ||
!CreateGui.getView().animationmode) {
timer.stop();
CreateGui.getApp().setRandomAnimationMode(false);
return;
}
doRandomFiring();
setNumberSequences(getNumberSequences()-1);
}
});
}
/* highlights enabled transitions*/
public void highlightEnabledTransitions(){
/* rewritten by wjk 03/10/2007 */
DataLayer current = CreateGui.currentPNMLData();
current.setEnabledTransitions();
Iterator transitionIterator = current.returnTransitions();
while(transitionIterator.hasNext()){
Transition tempTransition =(Transition) transitionIterator.next();
if(tempTransition.isEnabled(true)==true ){
current.notifyObservers();
tempTransition.repaint();
}
if(tempTransition.isTaggedEnabled(true)==true){
// System.out.println("check");
}
}
}
/* called during animation to unhighlight previously highlighted transitions*/
public void unhighlightDisabledTransitions(){
DataLayer current = CreateGui.currentPNMLData();
current.setEnabledTransitions();
Iterator transitionIterator = current.returnTransitions();
while(transitionIterator.hasNext()){
Transition tempTransition =(Transition) transitionIterator.next();
if(tempTransition.isEnabled(true)==false){
current.notifyObservers();
tempTransition.repaint();
}
/*
if(tempTransition.isTaggedEnabled(false)==false){
current.notifyObservers();
tempTransition.repaint();
}*/
}
}
/* called at end of animation and resets all Transitions to false and unhighlighted*/
public void disableTransitions(){
Iterator transitionIterator = CreateGui.currentPNMLData().returnTransitions();
while(transitionIterator.hasNext()){
Transition tempTransition =(Transition) transitionIterator.next();
tempTransition.setEnabledFalse();
tempTransition.setTaggedEngabledFalse();
CreateGui.currentPNMLData().notifyObservers();
tempTransition.repaint();
}
}
/* stores model at start of animation*/
public void storeModel(){
CreateGui.currentPNMLData().storeState();
}
/*restores model at end of animation and sets all transitions to false and unhighlighted*/
public void restoreModel(){
CreateGui.currentPNMLData().restoreState();
disableTransitions();
}
public void startRandomFiring(){
if(getNumberSequences()>0) {
// stop animation
setNumberSequences(0);
return;
} else try {
String s = JOptionPane.showInputDialog("Enter number of firings to perform", "1");
this.numberSequences=Integer.parseInt(s);
s = JOptionPane.showInputDialog("Enter time delay between firing /ms", "500");
timer.setDelay(Integer.parseInt(s));
timer.start();
} catch (NumberFormatException e) {
CreateGui.getApp().setRandomAnimationMode(false);
}
}
public void stopRandomFiring() {
numberSequences=0;
}
/**
* This method randomly fires one of the
* enabled transitions. It then records the
* information about this by calling the
* recordFiredTransition method.
*
* @author Dave Patterson Apr 29, 2007
* I changed the code to keep the random transition found by the DataLayer.
* If it is not null, I call the fireTransition method, otherwise I put
* out an error message in the status bar.
*
*
* June 20, 2008
* Fixed the bug with double firing and program freezes when there
* is no enabled transition. random firing with tagged token is also integrated
*/
public void doRandomFiring() {
//DataLayer data=CreateGui.currentPNMLData();
// data.setEnabledTransitions();
Transition t=CreateGui.currentPNMLData().fireRandomTransition();
/*do clearStepsForward so that when it revisits original marking place,
* the history starts over
*/
CreateGui.getAnimationHistory().clearStepsForward();
//removeStoredTransitions();
if(t!=null)
{
// determine whether to fire tagged or nontagged token
if(t.isEnabled() && !t.isTaggedTokenEnabled())
this.fireTransition(t);
else if(!t.isEnabled() && t.isTaggedTokenEnabled())
this.fireTaggedTransition(t);
else if(t.isEnabled() && t.isTaggedTokenEnabled())
{
//final double tagged_rate = t.getRateTagged();
//final double untagged_rate = t.getRate();
final double untagged_rate = t.getRate();
double max = 0;
Iterator arcsFrom = t.getConnectToIterator();
while(arcsFrom.hasNext()){
final Arc arc = (Arc)arcsFrom.next();
System.out.println("\n arc source "+arc.getSource().getId());
final Place place = (Place)arc.getSource();
if(place.isTagged())
{
System.out.println("weight tagged arc="+arc.getWeight()
+" current marking="+place.getCurrentMarking());
max = (double)arc.getWeight() / (double)place.getCurrentMarking();
}
System.out.println("\n***"+place.getId()+" max = "+max);
}
final double rateOfTaggedMode = max*untagged_rate;
final double rateOfUntaggedMode = untagged_rate - rateOfTaggedMode;
final double prob_t = rateOfTaggedMode/(rateOfTaggedMode + rateOfUntaggedMode);
final double prob_u = rateOfUntaggedMode /(rateOfTaggedMode + rateOfUntaggedMode);
System.out.println("\n probt = "+prob_t+" probu="+prob_u);
//final double sum = (tagged_rate+untagged_rate);
//final double prob_t = (tagged_rate/sum);
//final double prob_u = untagged_rate/sum;
double random = DataLayer.randomNumber.nextDouble();
System.out.println("\n random ="+ random);
/*
while(random > 1 ){
random/=sum;
System.out.println("\n ="+ random);
}*/
if(random<prob_t)this.fireTaggedTransition(t);
else this.fireTransition(t);
}
}//end if(t!=null)
else
{
CreateGui.getApp().getStatusBar().changeText(
"ERROR: No transition to fire." );
}//end else
}//end method
/*steps back through previously fired transitions*/
public void stepBack(){
if(count>0){
System.out.println("\ncount = "+count+" firedTransitions size = "+this.firedTransitions.size());
Transition lastTransition = (Transition)firedTransitions.get(count-1);
count--;
CreateGui.currentPNMLData().fireTransitionBackwards(lastTransition);
CreateGui.currentPNMLData().setEnabledTransitions();
unhighlightDisabledTransitions();
highlightEnabledTransitions();
}
else return;
}
/* steps forward through previously fired transitions*/
public void stepForward(){
if(count < firedTransitions.size()){
System.out.println("\n****");
for(int i=0;i<firedTransitions.size();i++)
System.out.println( ( (Transition) firedTransitions.get(i)).getId() );
System.out.println("\ncount = "+count+" firedTransitions size = "+this.firedTransitions.size());
Transition nextTransition = (Transition)firedTransitions.get(count);
count++;
System.out.println("\nnextTransition = "+nextTransition.getId());
CreateGui.currentPNMLData().fireTransitionForward(nextTransition);
CreateGui.currentPNMLData().setEnabledTransitions();
unhighlightDisabledTransitions();
highlightEnabledTransitions();
}
return;
}
/* This method keeps track of a fired transition in the
* AnimationHistory object, enables transitions after the
* recent firing, and properly displays the transitions.
*
* @author David Patterson renamed this method and changed
* the AnimationHandler to make it fire the transition before
* calling this method. This prevents double-firing a
* transition.
*
* @author Pere Bonet modified this method so that it now stores transitions
* that has just been fired in an array so that it can be accessed during backwards and
* forwards stepping to fix the unexcepted behaviour observed during animation playback
* The method is renamed back to fireTransition.
*
*
*/
public void fireTransition(Transition transition){
Animator animator = CreateGui.getAnimator();
CreateGui.getAnimationHistory().addHistoryItem(transition.getName());
CreateGui.currentPNMLData().fireTransition(transition);
CreateGui.currentPNMLData().setEnabledTransitions();
animator.highlightEnabledTransitions();
animator.unhighlightDisabledTransitions();
System.out.println("\ncount = "+ count);
if (count == firedTransitions.size()) {
firedTransitions.add(transition);
count++;
} else {
firedTransitions.set(count, transition);
count++;
removeStoredTransitions();
}
//count++;
}
/*
* method to fire tagged token on the enabled taggedTokenTransition
*
*/
public void fireTaggedTransition(Transition transition){
Animator animator = CreateGui.getAnimator();
CreateGui.getAnimationHistory().addHistoryItem(transition.getName()+" fires TAG");
CreateGui.currentPNMLData().fireTaggedTransition(transition);
CreateGui.currentPNMLData().setEnabledTransitions();
animator.highlightEnabledTransitions();
animator.unhighlightDisabledTransitions();
if (count == firedTransitions.size()) {
firedTransitions.add(transition);
count++;
} else {
firedTransitions.set(count, transition);
count++;
removeStoredTransitions();
}
//count++;
}
/*
* modified so that it completely removes all the entries except
* the current one
*/
private void removeStoredTransitions() {
while( firedTransitions.size()>count){
for (int count1 = count ; count1 < firedTransitions.size(); count1++)
firedTransitions.remove(count1);
for(int i=0;i<firedTransitions.size();i++)
System.out.println( ( (Transition) firedTransitions.get(i)).getId() );
}
}
public synchronized int getNumberSequences() {
return numberSequences;
}
public synchronized void setNumberSequences(int numberSequences) {
this.numberSequences = numberSequences;
}
}
|
UTF-8
|
Java
| 12,201 |
java
|
Animator.java
|
Java
|
[
{
"context": " * @author unspecified \twrote this code\n * @author David Patterson fixed a bug with double-firing transitions\n * ",
"end": 547,
"score": 0.9998801946640015,
"start": 532,
"tag": "NAME",
"value": "David Patterson"
},
{
"context": "ion to better describe what it does.\n *\n * @author Pere Bonet modified the recordFiredTransition method to\n * f",
"end": 766,
"score": 0.9998989701271057,
"start": 756,
"tag": "NAME",
"value": "Pere Bonet"
},
{
"context": "is renamed back to fireTransition. \n * \n * @author Edwin Chung fixed the bug where users can still step forward ",
"end": 956,
"score": 0.999893069267273,
"start": 945,
"tag": "NAME",
"value": "Edwin Chung"
},
{
"context": "ce has also been fixed (Feb 2007) \n * \n * @author Dave Patterson The code now outputs an error message in the stat",
"end": 1335,
"score": 0.99986332654953,
"start": 1321,
"tag": "NAME",
"value": "Dave Patterson"
},
{
"context": "d highlightEnabledTransitions(){\n\n\t/* rewritten by wjk 03/10/2007 */\n\t DataLayer current = CreateGui.cu",
"end": 2287,
"score": 0.9995408654212952,
"start": 2284,
"tag": "USERNAME",
"value": "wjk"
},
{
"context": "* recordFiredTransition method.\n * \n * @author Dave Patterson Apr 29, 2007\n * I changed the code to keep the ",
"end": 5176,
"score": 0.999771773815155,
"start": 5162,
"tag": "NAME",
"value": "Dave Patterson"
},
{
"context": "perly displays the transitions.\n * \n * @author David Patterson renamed this method and changed\n * the Animatio",
"end": 9574,
"score": 0.9998443126678467,
"start": 9559,
"tag": "NAME",
"value": "David Patterson"
},
{
"context": "uble-firing a \n * transition.\n * \n * @author Pere Bonet modified this method so that it now stores transi",
"end": 9774,
"score": 0.9998664855957031,
"start": 9764,
"tag": "NAME",
"value": "Pere Bonet"
}
] | null |
[] |
package pipe.gui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Iterator;
import javax.swing.JOptionPane;
import javax.swing.Timer;
import pipe.common.dataLayer.Arc;
import pipe.common.dataLayer.DataLayer;
import pipe.common.dataLayer.Place;
import pipe.common.dataLayer.Transition;
/**
* This class is used to process clicks by the user to manually step
* through enabled transitions in the net.
*
* @author unspecified wrote this code
* @author <NAME> fixed a bug with double-firing transitions
* in the doRandomFiring method. I also renamed the fireTransition
* method to recordFiredTransition to better describe what it does.
*
* @author <NAME> modified the recordFiredTransition method to
* fix the unexpected behaviour observed during animation playback.
* The method is renamed back to fireTransition.
*
* @author <NAME> fixed the bug where users can still step forward to previous
* firing sequence even though it has been reset. The issue where an unexpected behaviour
* will occur when the firing sequence has been altered has been resolved. The problem where
* animation will freeze halfway while stepping back a firing sequence has also been fixed (Feb 2007)
*
* @author <NAME> The code now outputs an error message in the status bar
* if there is no transition to be found when picking a random transition to fire. This
* is related to the problem described in bug 1699546.
*/
public class Animator implements Constants{
Timer timer;
int numberSequences;
public static ArrayList firedTransitions;
public static int count= 0;
public Animator(){
firedTransitions = new ArrayList();
timer = new Timer(0, new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if ((getNumberSequences()<1) ||
!CreateGui.getView().animationmode) {
timer.stop();
CreateGui.getApp().setRandomAnimationMode(false);
return;
}
doRandomFiring();
setNumberSequences(getNumberSequences()-1);
}
});
}
/* highlights enabled transitions*/
public void highlightEnabledTransitions(){
/* rewritten by wjk 03/10/2007 */
DataLayer current = CreateGui.currentPNMLData();
current.setEnabledTransitions();
Iterator transitionIterator = current.returnTransitions();
while(transitionIterator.hasNext()){
Transition tempTransition =(Transition) transitionIterator.next();
if(tempTransition.isEnabled(true)==true ){
current.notifyObservers();
tempTransition.repaint();
}
if(tempTransition.isTaggedEnabled(true)==true){
// System.out.println("check");
}
}
}
/* called during animation to unhighlight previously highlighted transitions*/
public void unhighlightDisabledTransitions(){
DataLayer current = CreateGui.currentPNMLData();
current.setEnabledTransitions();
Iterator transitionIterator = current.returnTransitions();
while(transitionIterator.hasNext()){
Transition tempTransition =(Transition) transitionIterator.next();
if(tempTransition.isEnabled(true)==false){
current.notifyObservers();
tempTransition.repaint();
}
/*
if(tempTransition.isTaggedEnabled(false)==false){
current.notifyObservers();
tempTransition.repaint();
}*/
}
}
/* called at end of animation and resets all Transitions to false and unhighlighted*/
public void disableTransitions(){
Iterator transitionIterator = CreateGui.currentPNMLData().returnTransitions();
while(transitionIterator.hasNext()){
Transition tempTransition =(Transition) transitionIterator.next();
tempTransition.setEnabledFalse();
tempTransition.setTaggedEngabledFalse();
CreateGui.currentPNMLData().notifyObservers();
tempTransition.repaint();
}
}
/* stores model at start of animation*/
public void storeModel(){
CreateGui.currentPNMLData().storeState();
}
/*restores model at end of animation and sets all transitions to false and unhighlighted*/
public void restoreModel(){
CreateGui.currentPNMLData().restoreState();
disableTransitions();
}
public void startRandomFiring(){
if(getNumberSequences()>0) {
// stop animation
setNumberSequences(0);
return;
} else try {
String s = JOptionPane.showInputDialog("Enter number of firings to perform", "1");
this.numberSequences=Integer.parseInt(s);
s = JOptionPane.showInputDialog("Enter time delay between firing /ms", "500");
timer.setDelay(Integer.parseInt(s));
timer.start();
} catch (NumberFormatException e) {
CreateGui.getApp().setRandomAnimationMode(false);
}
}
public void stopRandomFiring() {
numberSequences=0;
}
/**
* This method randomly fires one of the
* enabled transitions. It then records the
* information about this by calling the
* recordFiredTransition method.
*
* @author <NAME> Apr 29, 2007
* I changed the code to keep the random transition found by the DataLayer.
* If it is not null, I call the fireTransition method, otherwise I put
* out an error message in the status bar.
*
*
* June 20, 2008
* Fixed the bug with double firing and program freezes when there
* is no enabled transition. random firing with tagged token is also integrated
*/
public void doRandomFiring() {
//DataLayer data=CreateGui.currentPNMLData();
// data.setEnabledTransitions();
Transition t=CreateGui.currentPNMLData().fireRandomTransition();
/*do clearStepsForward so that when it revisits original marking place,
* the history starts over
*/
CreateGui.getAnimationHistory().clearStepsForward();
//removeStoredTransitions();
if(t!=null)
{
// determine whether to fire tagged or nontagged token
if(t.isEnabled() && !t.isTaggedTokenEnabled())
this.fireTransition(t);
else if(!t.isEnabled() && t.isTaggedTokenEnabled())
this.fireTaggedTransition(t);
else if(t.isEnabled() && t.isTaggedTokenEnabled())
{
//final double tagged_rate = t.getRateTagged();
//final double untagged_rate = t.getRate();
final double untagged_rate = t.getRate();
double max = 0;
Iterator arcsFrom = t.getConnectToIterator();
while(arcsFrom.hasNext()){
final Arc arc = (Arc)arcsFrom.next();
System.out.println("\n arc source "+arc.getSource().getId());
final Place place = (Place)arc.getSource();
if(place.isTagged())
{
System.out.println("weight tagged arc="+arc.getWeight()
+" current marking="+place.getCurrentMarking());
max = (double)arc.getWeight() / (double)place.getCurrentMarking();
}
System.out.println("\n***"+place.getId()+" max = "+max);
}
final double rateOfTaggedMode = max*untagged_rate;
final double rateOfUntaggedMode = untagged_rate - rateOfTaggedMode;
final double prob_t = rateOfTaggedMode/(rateOfTaggedMode + rateOfUntaggedMode);
final double prob_u = rateOfUntaggedMode /(rateOfTaggedMode + rateOfUntaggedMode);
System.out.println("\n probt = "+prob_t+" probu="+prob_u);
//final double sum = (tagged_rate+untagged_rate);
//final double prob_t = (tagged_rate/sum);
//final double prob_u = untagged_rate/sum;
double random = DataLayer.randomNumber.nextDouble();
System.out.println("\n random ="+ random);
/*
while(random > 1 ){
random/=sum;
System.out.println("\n ="+ random);
}*/
if(random<prob_t)this.fireTaggedTransition(t);
else this.fireTransition(t);
}
}//end if(t!=null)
else
{
CreateGui.getApp().getStatusBar().changeText(
"ERROR: No transition to fire." );
}//end else
}//end method
/*steps back through previously fired transitions*/
public void stepBack(){
if(count>0){
System.out.println("\ncount = "+count+" firedTransitions size = "+this.firedTransitions.size());
Transition lastTransition = (Transition)firedTransitions.get(count-1);
count--;
CreateGui.currentPNMLData().fireTransitionBackwards(lastTransition);
CreateGui.currentPNMLData().setEnabledTransitions();
unhighlightDisabledTransitions();
highlightEnabledTransitions();
}
else return;
}
/* steps forward through previously fired transitions*/
public void stepForward(){
if(count < firedTransitions.size()){
System.out.println("\n****");
for(int i=0;i<firedTransitions.size();i++)
System.out.println( ( (Transition) firedTransitions.get(i)).getId() );
System.out.println("\ncount = "+count+" firedTransitions size = "+this.firedTransitions.size());
Transition nextTransition = (Transition)firedTransitions.get(count);
count++;
System.out.println("\nnextTransition = "+nextTransition.getId());
CreateGui.currentPNMLData().fireTransitionForward(nextTransition);
CreateGui.currentPNMLData().setEnabledTransitions();
unhighlightDisabledTransitions();
highlightEnabledTransitions();
}
return;
}
/* This method keeps track of a fired transition in the
* AnimationHistory object, enables transitions after the
* recent firing, and properly displays the transitions.
*
* @author <NAME> renamed this method and changed
* the AnimationHandler to make it fire the transition before
* calling this method. This prevents double-firing a
* transition.
*
* @author <NAME> modified this method so that it now stores transitions
* that has just been fired in an array so that it can be accessed during backwards and
* forwards stepping to fix the unexcepted behaviour observed during animation playback
* The method is renamed back to fireTransition.
*
*
*/
public void fireTransition(Transition transition){
Animator animator = CreateGui.getAnimator();
CreateGui.getAnimationHistory().addHistoryItem(transition.getName());
CreateGui.currentPNMLData().fireTransition(transition);
CreateGui.currentPNMLData().setEnabledTransitions();
animator.highlightEnabledTransitions();
animator.unhighlightDisabledTransitions();
System.out.println("\ncount = "+ count);
if (count == firedTransitions.size()) {
firedTransitions.add(transition);
count++;
} else {
firedTransitions.set(count, transition);
count++;
removeStoredTransitions();
}
//count++;
}
/*
* method to fire tagged token on the enabled taggedTokenTransition
*
*/
public void fireTaggedTransition(Transition transition){
Animator animator = CreateGui.getAnimator();
CreateGui.getAnimationHistory().addHistoryItem(transition.getName()+" fires TAG");
CreateGui.currentPNMLData().fireTaggedTransition(transition);
CreateGui.currentPNMLData().setEnabledTransitions();
animator.highlightEnabledTransitions();
animator.unhighlightDisabledTransitions();
if (count == firedTransitions.size()) {
firedTransitions.add(transition);
count++;
} else {
firedTransitions.set(count, transition);
count++;
removeStoredTransitions();
}
//count++;
}
/*
* modified so that it completely removes all the entries except
* the current one
*/
private void removeStoredTransitions() {
while( firedTransitions.size()>count){
for (int count1 = count ; count1 < firedTransitions.size(); count1++)
firedTransitions.remove(count1);
for(int i=0;i<firedTransitions.size();i++)
System.out.println( ( (Transition) firedTransitions.get(i)).getId() );
}
}
public synchronized int getNumberSequences() {
return numberSequences;
}
public synchronized void setNumberSequences(int numberSequences) {
this.numberSequences = numberSequences;
}
}
| 12,154 | 0.683305 | 0.679043 | 388 | 30.445877 | 26.536198 | 103 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.095361 | false | false |
13
|
a8a4de24cc8a375a98aa2e6817f1dabc0d6e8dee
| 28,372,554,013,831 |
5832134be6eea906cfc2f364dcdd1837634a67ba
|
/trunk/workspace/org.essentialplatform.runtime.shared/src/org/essentialplatform/runtime/shared/domain/IPojo.java
|
294d56beeafc63ac7a22a0a8706c8f2964e4b22d
|
[] |
no_license
|
BackupTheBerlios/rcpviewer-svn
|
https://github.com/BackupTheBerlios/rcpviewer-svn
|
61c0ea77a3c2e3639656338623f61cb02135112c
|
eb63faba1c5e9c812a99df389acf2ec31ec60745
|
refs/heads/master
| 2020-06-04T07:12:21.899000 | 2006-02-28T22:34:19 | 2006-02-28T22:34:19 | 40,805,658 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package org.essentialplatform.runtime.shared.domain;
public interface IPojo {
/**
* Tracks the resolve state and other aspects on behalf of the pojo.
*
* <p>
* Note that transaction state is relevant only on the client and so is
* no longer part of IPojo.
*
* <p>
* Implementation note: previously this method was called <tt>getDomainObject()</tt>.
* It was renamed so that Hibernate would not pick it up as a property. (An
* alternative would have been to use the <tt>@javax.persistence.Transient</tt>
* annotation, however since the field is introduced by an aspect this area is
* still (Dec 2005) somewhat unstable).
*
* TODO: <T>. However, doesn't seem possible to introduce genericised
* members using aspects (PojoAspect).
*/
IDomainObject domainObject();
}
|
UTF-8
|
Java
| 831 |
java
|
IPojo.java
|
Java
|
[] | null |
[] |
package org.essentialplatform.runtime.shared.domain;
public interface IPojo {
/**
* Tracks the resolve state and other aspects on behalf of the pojo.
*
* <p>
* Note that transaction state is relevant only on the client and so is
* no longer part of IPojo.
*
* <p>
* Implementation note: previously this method was called <tt>getDomainObject()</tt>.
* It was renamed so that Hibernate would not pick it up as a property. (An
* alternative would have been to use the <tt>@javax.persistence.Transient</tt>
* annotation, however since the field is introduced by an aspect this area is
* still (Dec 2005) somewhat unstable).
*
* TODO: <T>. However, doesn't seem possible to introduce genericised
* members using aspects (PojoAspect).
*/
IDomainObject domainObject();
}
| 831 | 0.691937 | 0.687124 | 24 | 32.625 | 31.442822 | 86 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.916667 | false | false |
13
|
2281e4498181d3695b30f7260c86b21e5309a34a
| 1,073,741,851,690 |
6c12ec1b36bc9116b0383ca7a19ceae1d3b12308
|
/src/main/java/com/ryft/ingestion/tasks/IngestionTask.java
|
49d6052b3213a7a67d6be13a58e8bef78f3b20f1
|
[] |
no_license
|
getryft/ryft-ingestion-tool
|
https://github.com/getryft/ryft-ingestion-tool
|
a30f7ce4b4fca245976c9678d041a41b74aff0df
|
914747ba5f01f097e7672de2b927bcb25c1612bf
|
refs/heads/master
| 2020-02-12T21:25:11.333000 | 2019-01-14T15:25:13 | 2019-01-14T15:25:13 | 93,732,768 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.ryft.ingestion.tasks;
import com.ryft.ingestion.IngestionApp;
import com.ryft.ingestion.model.config.IngestionContext;
import com.ryft.ingestion.util.AppProperties;
import com.ryft.ingestion.util.TaskFactory;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import jersey.repackaged.com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class IngestionTask implements Runnable {
private final static Logger LOGGER = LoggerFactory.getLogger(IngestionApp.class);
private final ScheduledExecutorService pipelineExecutor;
private final ScheduledExecutorService persistenceExecutor;
private final IngestionContext context;
private final TaskFactory taskFactory;
private final Integer persistPeriod;
private final Integer datacheckPeriod;
public IngestionTask(TaskFactory taskFactory, IngestionContext context) {
this.taskFactory = taskFactory;
this.context = context;
final ThreadFactory threadFactory = new ThreadFactoryBuilder()
.setNameFormat("ingestion-%d")
.setDaemon(false)
.build();
pipelineExecutor = Executors.newScheduledThreadPool(context.getConfig().getDataPipelines().size(), threadFactory);
persistenceExecutor = Executors.newSingleThreadScheduledExecutor(
new ThreadFactoryBuilder().setNameFormat("persistence").build());
persistPeriod = Integer.parseInt(context.getProperty(AppProperties.AppPropertyName.PERSIST_PERIOD_SECONDS));
datacheckPeriod = Integer.parseInt(context.getProperty(AppProperties.AppPropertyName.DATACHECK_PERIOD_SECONDS));
}
public ExecutorService[] getExecutors() {
return new ExecutorService[]{pipelineExecutor, persistenceExecutor};
}
@Override
public void run() {
LOGGER.debug("Start ingestion");
context.getConfig().getDataPipelines().stream()
.map((dataPipeline) -> taskFactory.getFilePipelineTask(context, dataPipeline))
.forEach((pipelineTask) -> pipelineExecutor.scheduleWithFixedDelay(pipelineTask, 0, datacheckPeriod, TimeUnit.SECONDS));
if (context.isStreamIngestionConfigured()) {
context.getConfig().getDataPipelines().stream()
.map((dataPipeline) -> taskFactory.getStreamPipelineTask(context, dataPipeline))
.forEach((pipelineTask) -> pipelineExecutor.scheduleWithFixedDelay(pipelineTask, 0, datacheckPeriod, TimeUnit.SECONDS));
persistenceExecutor.scheduleWithFixedDelay(taskFactory.getPersistStreamStateTask(), 0, persistPeriod, TimeUnit.SECONDS);
}
persistenceExecutor.scheduleWithFixedDelay(taskFactory.getPersistFileStateTask(), 0, persistPeriod, TimeUnit.SECONDS);
}
}
|
UTF-8
|
Java
| 3,000 |
java
|
IngestionTask.java
|
Java
|
[] | null |
[] |
package com.ryft.ingestion.tasks;
import com.ryft.ingestion.IngestionApp;
import com.ryft.ingestion.model.config.IngestionContext;
import com.ryft.ingestion.util.AppProperties;
import com.ryft.ingestion.util.TaskFactory;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import jersey.repackaged.com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class IngestionTask implements Runnable {
private final static Logger LOGGER = LoggerFactory.getLogger(IngestionApp.class);
private final ScheduledExecutorService pipelineExecutor;
private final ScheduledExecutorService persistenceExecutor;
private final IngestionContext context;
private final TaskFactory taskFactory;
private final Integer persistPeriod;
private final Integer datacheckPeriod;
public IngestionTask(TaskFactory taskFactory, IngestionContext context) {
this.taskFactory = taskFactory;
this.context = context;
final ThreadFactory threadFactory = new ThreadFactoryBuilder()
.setNameFormat("ingestion-%d")
.setDaemon(false)
.build();
pipelineExecutor = Executors.newScheduledThreadPool(context.getConfig().getDataPipelines().size(), threadFactory);
persistenceExecutor = Executors.newSingleThreadScheduledExecutor(
new ThreadFactoryBuilder().setNameFormat("persistence").build());
persistPeriod = Integer.parseInt(context.getProperty(AppProperties.AppPropertyName.PERSIST_PERIOD_SECONDS));
datacheckPeriod = Integer.parseInt(context.getProperty(AppProperties.AppPropertyName.DATACHECK_PERIOD_SECONDS));
}
public ExecutorService[] getExecutors() {
return new ExecutorService[]{pipelineExecutor, persistenceExecutor};
}
@Override
public void run() {
LOGGER.debug("Start ingestion");
context.getConfig().getDataPipelines().stream()
.map((dataPipeline) -> taskFactory.getFilePipelineTask(context, dataPipeline))
.forEach((pipelineTask) -> pipelineExecutor.scheduleWithFixedDelay(pipelineTask, 0, datacheckPeriod, TimeUnit.SECONDS));
if (context.isStreamIngestionConfigured()) {
context.getConfig().getDataPipelines().stream()
.map((dataPipeline) -> taskFactory.getStreamPipelineTask(context, dataPipeline))
.forEach((pipelineTask) -> pipelineExecutor.scheduleWithFixedDelay(pipelineTask, 0, datacheckPeriod, TimeUnit.SECONDS));
persistenceExecutor.scheduleWithFixedDelay(taskFactory.getPersistStreamStateTask(), 0, persistPeriod, TimeUnit.SECONDS);
}
persistenceExecutor.scheduleWithFixedDelay(taskFactory.getPersistFileStateTask(), 0, persistPeriod, TimeUnit.SECONDS);
}
}
| 3,000 | 0.747 | 0.745 | 63 | 46.619049 | 38.934795 | 140 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.793651 | false | false |
13
|
4a8795ac4dc65c712a682fe278a048546c0d5389
| 27,565,100,105,756 |
48f93d7e69b3c3423cf2982952ea73acd9cdf3f8
|
/src/main/java/yoonho/demo/reactive/base/masking/MaskingType.java
|
67569a7b5965af34b94004b3949390f6af802654
|
[] |
no_license
|
hosu1014/reactive-webFlux-rediscache
|
https://github.com/hosu1014/reactive-webFlux-rediscache
|
c00417f18a78f917f64355cee00977e73709883e
|
2e5d1906cae248b6feaec664a4aebeec2f44469d
|
refs/heads/master
| 2023-05-05T17:29:51.624000 | 2021-05-26T05:03:45 | 2021-05-26T05:03:45 | 370,580,063 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package yoonho.demo.reactive.base.masking;
public enum MaskingType {
CARD_NO,
ACCOUT_NO
}
|
UTF-8
|
Java
| 94 |
java
|
MaskingType.java
|
Java
|
[] | null |
[] |
package yoonho.demo.reactive.base.masking;
public enum MaskingType {
CARD_NO,
ACCOUT_NO
}
| 94 | 0.755319 | 0.755319 | 6 | 14.666667 | 14.727148 | 42 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.833333 | false | false |
13
|
64c210a9193850f9275d472c19653679a49238e3
| 9,895,604,716,413 |
0d4b1d3ccf7e18ad4b42f8ff7295998483e52eec
|
/JavaCECS277/FileIOCECS277/EarthText.java
|
3a4719729c5724a0f6bf2a61af205b3260e6461b
|
[] |
no_license
|
NikkiNgNguyen/JavaProjects
|
https://github.com/NikkiNgNguyen/JavaProjects
|
38b72811899e5a24ef35240d4d80456e37b380a9
|
2e45f295750572994e0fc4f0d6d882c5c55a869e
|
refs/heads/master
| 2020-05-18T08:39:55.127000 | 2019-05-01T06:17:14 | 2019-05-01T06:17:14 | 184,301,915 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*Audrey Kobayashi
Nikki Nguyen
November 8, 2017
Purpose: creates earth text class that implements advanced cell phone
Inputs: language type, message, and file name
Output: reads and sends text
*/
/**
*class reads and sends text
* @author AudreyKobayashi
* @author NikkiNguyen
*/
import java.io.*;
import java.util.Scanner;
public class EarthText implements AdvancedCellPhone{
LanguageAdapter languageAdapter;
/**
* sends message found on file
* @param languageType
* @param message
* @param fileName
*/
@Override
public void sendMessage(String languageType, char[] message, String fileName) throws InvalidLanguageException {
if(languageType.equalsIgnoreCase("earth")){
try{
PrintWriter write = new PrintWriter(new File(fileName));
write.print(message);
write.close();
}catch(FileNotFoundException fnf){System.out.println("File not found.");}
}else if(languageType.equalsIgnoreCase("vulcan") || languageType.equalsIgnoreCase("ferengi") || languageType.equalsIgnoreCase("klingon")){
languageAdapter = new LanguageAdapter(languageType);
languageAdapter.sendMsg(languageType, message, fileName);
}else{
throw new InvalidLanguageException("Error: unknown language");
}
}
/**
* method reads message found on file
* @param languageType
* @param fileName
*/
@Override
public void readMessage(String languageType, String fileName) throws InvalidLanguageException {
if(languageType.equalsIgnoreCase("Earth")){
try{
Scanner in = new Scanner(new File(fileName));
while(in.hasNextLine()){
System.out.println(in.nextLine());
}
in.close();
}catch(FileNotFoundException fnf){
System.out.println("File not found.");
}
}else if(languageType.equalsIgnoreCase("Vulcan") || languageType.equalsIgnoreCase("Klingon") ||languageType.equalsIgnoreCase("Ferrengi")){
languageAdapter = new LanguageAdapter(languageType);
languageAdapter.readMsg(languageType, fileName);
}else{
throw new InvalidLanguageException("Unknown language");
}
}
/**
* override sendText does nothing
* @param languageType
* @param fileName
*/
@Override
public void sendText(String languageType, String fileName) {
//**do nothing**
}
/**
* override readText does nothing
* @param languageType
* @param fileName
*/
@Override
public void readText(String languageType, String fileName) {
//**do nothing**
}
/**
* override translateText does nothing
* @param languageType
* @param message
* @param fileName
*/
@Override
public void translateText(String languageType, char[] message, String fileName) throws InvalidLanguageException {
//**do nothing**
}
}
|
UTF-8
|
Java
| 2,875 |
java
|
EarthText.java
|
Java
|
[
{
"context": "/*Audrey Kobayashi\n Nikki Nguyen\n November 8, 2017\n Purpose: crea",
"end": 18,
"score": 0.999904453754425,
"start": 2,
"tag": "NAME",
"value": "Audrey Kobayashi"
},
{
"context": "/*Audrey Kobayashi\n Nikki Nguyen\n November 8, 2017\n Purpose: creates earth text ",
"end": 33,
"score": 0.9998893737792969,
"start": 21,
"tag": "NAME",
"value": "Nikki Nguyen"
},
{
"context": "xt\n*/\n\n/**\n *class reads and sends text\n * @author AudreyKobayashi \n * @author NikkiNguyen\n */\nimport java.io.*;\nimp",
"end": 267,
"score": 0.9998508095741272,
"start": 252,
"tag": "NAME",
"value": "AudreyKobayashi"
},
{
"context": " sends text\n * @author AudreyKobayashi \n * @author NikkiNguyen\n */\nimport java.io.*;\nimport java.util.Scanner;\np",
"end": 291,
"score": 0.9980812072753906,
"start": 280,
"tag": "NAME",
"value": "NikkiNguyen"
}
] | null |
[] |
/*<NAME>
<NAME>
November 8, 2017
Purpose: creates earth text class that implements advanced cell phone
Inputs: language type, message, and file name
Output: reads and sends text
*/
/**
*class reads and sends text
* @author AudreyKobayashi
* @author NikkiNguyen
*/
import java.io.*;
import java.util.Scanner;
public class EarthText implements AdvancedCellPhone{
LanguageAdapter languageAdapter;
/**
* sends message found on file
* @param languageType
* @param message
* @param fileName
*/
@Override
public void sendMessage(String languageType, char[] message, String fileName) throws InvalidLanguageException {
if(languageType.equalsIgnoreCase("earth")){
try{
PrintWriter write = new PrintWriter(new File(fileName));
write.print(message);
write.close();
}catch(FileNotFoundException fnf){System.out.println("File not found.");}
}else if(languageType.equalsIgnoreCase("vulcan") || languageType.equalsIgnoreCase("ferengi") || languageType.equalsIgnoreCase("klingon")){
languageAdapter = new LanguageAdapter(languageType);
languageAdapter.sendMsg(languageType, message, fileName);
}else{
throw new InvalidLanguageException("Error: unknown language");
}
}
/**
* method reads message found on file
* @param languageType
* @param fileName
*/
@Override
public void readMessage(String languageType, String fileName) throws InvalidLanguageException {
if(languageType.equalsIgnoreCase("Earth")){
try{
Scanner in = new Scanner(new File(fileName));
while(in.hasNextLine()){
System.out.println(in.nextLine());
}
in.close();
}catch(FileNotFoundException fnf){
System.out.println("File not found.");
}
}else if(languageType.equalsIgnoreCase("Vulcan") || languageType.equalsIgnoreCase("Klingon") ||languageType.equalsIgnoreCase("Ferrengi")){
languageAdapter = new LanguageAdapter(languageType);
languageAdapter.readMsg(languageType, fileName);
}else{
throw new InvalidLanguageException("Unknown language");
}
}
/**
* override sendText does nothing
* @param languageType
* @param fileName
*/
@Override
public void sendText(String languageType, String fileName) {
//**do nothing**
}
/**
* override readText does nothing
* @param languageType
* @param fileName
*/
@Override
public void readText(String languageType, String fileName) {
//**do nothing**
}
/**
* override translateText does nothing
* @param languageType
* @param message
* @param fileName
*/
@Override
public void translateText(String languageType, char[] message, String fileName) throws InvalidLanguageException {
//**do nothing**
}
}
| 2,859 | 0.673043 | 0.671304 | 95 | 29.263159 | 30.634762 | 147 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.242105 | false | false |
13
|
fa69e2a8c06342026bd187859f97c86f4735cdde
| 19,241,453,533,882 |
33bfa7d45c4a8c54c2316b01323a941b758abe78
|
/src/main/java/Airline/repository/TicketRepository.java
|
8855d11a58ff6ab9a530abea9722a95c880ce82e
|
[] |
no_license
|
JakoetTH/Chapter6
|
https://github.com/JakoetTH/Chapter6
|
1b9e4b8814a55d486773c0ed912ded05e232a77f
|
7fa25ff06f161e31be3ab23b14f6d10f0c5f11b5
|
refs/heads/master
| 2020-05-16T13:32:02.239000 | 2015-05-05T07:53:49 | 2015-05-05T07:53:49 | 34,174,378 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package Airline.repository;
import Airline.domain.Ticket;
import org.springframework.data.repository.CrudRepository;
public interface TicketRepository extends CrudRepository<Ticket,String>{
public Ticket findByID(String ID);
}
|
UTF-8
|
Java
| 233 |
java
|
TicketRepository.java
|
Java
|
[] | null |
[] |
package Airline.repository;
import Airline.domain.Ticket;
import org.springframework.data.repository.CrudRepository;
public interface TicketRepository extends CrudRepository<Ticket,String>{
public Ticket findByID(String ID);
}
| 233 | 0.828326 | 0.828326 | 8 | 28.125 | 25.580448 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.625 | false | false |
13
|
d6298376d54a2b0ecdd666903dae2cd99cd1d150
| 19,782,619,428,483 |
5f85e0b9bb0fe18abb874f498c2e34c3db51a590
|
/202004231309 - lyricsound-2 - (Java - Salary Calculation Automation)/01_source-code/05_project/MaasHesaplama/src/Academician.java
|
4794e6ed9744b871b8028479c99f6eb72101b0ec
|
[] |
no_license
|
serdaraltin/Freelance-Works-2020
|
https://github.com/serdaraltin/Freelance-Works-2020
|
8370c68603d309f55f67adc41b74931a844a4e1a
|
7d890a305e764791bf525a170351386eabd957e3
|
refs/heads/master
| 2023-05-31T07:10:42.806000 | 2021-06-20T20:25:27 | 2021-06-20T20:25:27 | 292,573,849 | 5 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
public class Academician extends Personnel {
private double baseSalary = 2600;
private int addCourseFee = 0;
private int overWorkSalary = 0;
public Academician(String name, String surname, String registerNumber, String position, int yearOfStart, int addCourseFee,int overWorkSalary) {
super(name, surname, registerNumber, position, yearOfStart);
this.addCourseFee = addCourseFee;
this.overWorkSalary = overWorkSalary;
}
public double getBaseSalary() {
return baseSalary;
}
public void setBaseSalary(double baseSalary) {
this.baseSalary = baseSalary;
}
public int getAddCourseFee() {
return addCourseFee;
}
public void setAddCourseFee(int addCourseFee) {
this.addCourseFee = addCourseFee;
}
public int getOverWorkSalary() {
this.overWorkSalary *= this.addCourseFee;
return overWorkSalary;
}
public void setOverWorkSalary(int overWorkSalary) {
this.overWorkSalary = overWorkSalary;
}
@Override
public String toString() {
return "Academician{" + "baseSalary=" + baseSalary + ", addCourseFee=" + addCourseFee + ", overWorkSalary=" + overWorkSalary + '}';
}
}
|
UTF-8
|
Java
| 1,242 |
java
|
Academician.java
|
Java
|
[] | null |
[] |
public class Academician extends Personnel {
private double baseSalary = 2600;
private int addCourseFee = 0;
private int overWorkSalary = 0;
public Academician(String name, String surname, String registerNumber, String position, int yearOfStart, int addCourseFee,int overWorkSalary) {
super(name, surname, registerNumber, position, yearOfStart);
this.addCourseFee = addCourseFee;
this.overWorkSalary = overWorkSalary;
}
public double getBaseSalary() {
return baseSalary;
}
public void setBaseSalary(double baseSalary) {
this.baseSalary = baseSalary;
}
public int getAddCourseFee() {
return addCourseFee;
}
public void setAddCourseFee(int addCourseFee) {
this.addCourseFee = addCourseFee;
}
public int getOverWorkSalary() {
this.overWorkSalary *= this.addCourseFee;
return overWorkSalary;
}
public void setOverWorkSalary(int overWorkSalary) {
this.overWorkSalary = overWorkSalary;
}
@Override
public String toString() {
return "Academician{" + "baseSalary=" + baseSalary + ", addCourseFee=" + addCourseFee + ", overWorkSalary=" + overWorkSalary + '}';
}
}
| 1,242 | 0.667472 | 0.662641 | 43 | 27.860466 | 32.149059 | 147 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.604651 | false | false |
13
|
4ba4aeb47b018cb7084c1e56ba0d73ca6aa23700
| 28,613,072,127,273 |
c4c5490ee551ebafb342120b54666e5e8d560474
|
/simulator-samples/sample-bank-service/src/main/java/org/citrusframework/simulator/sample/starter/CalculateStarter.java
|
dae831c62156b332cfa8b05908e91f2c99c8e902
|
[
"Apache-2.0"
] |
permissive
|
citrusframework/citrus-simulator
|
https://github.com/citrusframework/citrus-simulator
|
17d6a8be1c77f1515ef0d83d0a53160ab1268bd7
|
baf1567fdecf5a51e05ee245bd338e42367af243
|
refs/heads/main
| 2023-09-01T14:27:57.825000 | 2023-05-30T17:29:26 | 2023-05-30T17:29:26 | 18,358,222 | 28 | 37 |
Apache-2.0
| false | 2023-09-14T11:57:31 | 2014-04-02T07:33:41 | 2023-09-05T11:09:52 | 2023-09-14T11:57:30 | 7,688 | 39 | 37 | 33 |
Java
| false | false |
/*
* Copyright 2006-2017 the original author or authors.
*
* 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.citrusframework.simulator.sample.starter;
import com.consol.citrus.http.client.HttpClient;
import org.citrusframework.simulator.model.ScenarioParameter;
import org.citrusframework.simulator.model.ScenarioParameterBuilder;
import org.citrusframework.simulator.sample.model.QueryParameter;
import org.citrusframework.simulator.sample.model.Variable;
import org.citrusframework.simulator.scenario.AbstractScenarioStarter;
import org.citrusframework.simulator.scenario.ScenarioRunner;
import org.citrusframework.simulator.scenario.Starter;
import org.citrusframework.simulator.sample.scenario.CalculateIban;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* This starter can be used to test the simulator scenario
* {@link CalculateIban}.
* <br />It does this by sending a HTTP request to the Rest Service Calculate-IBAN. The simulator is configured to
* forward all Calculate-IBAN requests to the CalculateIban scenario which sends back a HTTP response containing the
* calculated IBAN.
*/
@Starter("TestCalculate")
public class CalculateStarter extends AbstractScenarioStarter {
private final HttpClient client;
public CalculateStarter(@Qualifier("simulatorHttpClientEndpoint") HttpClient client) {
this.client = client;
}
@Override
public void run(ScenarioRunner scenario) {
scenario.echo("Sending request to Calculate-IBAN REST Service...");
scenario.http(builder -> builder.client(client)
.send()
.get("/services/rest/bank")
.queryParam(QueryParameter.SORT_CODE, Variable.SORT_CODE.placeholder())
.queryParam(QueryParameter.ACCOUNT_NUMBER, Variable.ACCOUNT.placeholder()));
scenario.echo("Receiving response from Calculate-IBAN REST Service...");
scenario.http(builder -> builder.client(client)
.receive()
.response(HttpStatus.OK)
.contentType(MediaType.APPLICATION_JSON_VALUE));
scenario.echo("Response received from Calculate-IBAN REST Service");
}
@Override
public Collection<ScenarioParameter> getScenarioParameters() {
List<ScenarioParameter> scenarioParameters = new ArrayList<>();
// bank account (text box)
scenarioParameters.add(new ScenarioParameterBuilder()
.name(Variable.ACCOUNT.name())
.label("Bank Account")
.required()
.textbox()
.value("6219653")
.build());
// sort code (text box)
scenarioParameters.add(new ScenarioParameterBuilder()
.name(Variable.SORT_CODE.name())
.label("Sort Code")
.required()
.textbox()
.value("12345670")
.build());
return scenarioParameters;
}
}
|
UTF-8
|
Java
| 3,695 |
java
|
CalculateStarter.java
|
Java
|
[] | null |
[] |
/*
* Copyright 2006-2017 the original author or authors.
*
* 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.citrusframework.simulator.sample.starter;
import com.consol.citrus.http.client.HttpClient;
import org.citrusframework.simulator.model.ScenarioParameter;
import org.citrusframework.simulator.model.ScenarioParameterBuilder;
import org.citrusframework.simulator.sample.model.QueryParameter;
import org.citrusframework.simulator.sample.model.Variable;
import org.citrusframework.simulator.scenario.AbstractScenarioStarter;
import org.citrusframework.simulator.scenario.ScenarioRunner;
import org.citrusframework.simulator.scenario.Starter;
import org.citrusframework.simulator.sample.scenario.CalculateIban;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* This starter can be used to test the simulator scenario
* {@link CalculateIban}.
* <br />It does this by sending a HTTP request to the Rest Service Calculate-IBAN. The simulator is configured to
* forward all Calculate-IBAN requests to the CalculateIban scenario which sends back a HTTP response containing the
* calculated IBAN.
*/
@Starter("TestCalculate")
public class CalculateStarter extends AbstractScenarioStarter {
private final HttpClient client;
public CalculateStarter(@Qualifier("simulatorHttpClientEndpoint") HttpClient client) {
this.client = client;
}
@Override
public void run(ScenarioRunner scenario) {
scenario.echo("Sending request to Calculate-IBAN REST Service...");
scenario.http(builder -> builder.client(client)
.send()
.get("/services/rest/bank")
.queryParam(QueryParameter.SORT_CODE, Variable.SORT_CODE.placeholder())
.queryParam(QueryParameter.ACCOUNT_NUMBER, Variable.ACCOUNT.placeholder()));
scenario.echo("Receiving response from Calculate-IBAN REST Service...");
scenario.http(builder -> builder.client(client)
.receive()
.response(HttpStatus.OK)
.contentType(MediaType.APPLICATION_JSON_VALUE));
scenario.echo("Response received from Calculate-IBAN REST Service");
}
@Override
public Collection<ScenarioParameter> getScenarioParameters() {
List<ScenarioParameter> scenarioParameters = new ArrayList<>();
// bank account (text box)
scenarioParameters.add(new ScenarioParameterBuilder()
.name(Variable.ACCOUNT.name())
.label("Bank Account")
.required()
.textbox()
.value("6219653")
.build());
// sort code (text box)
scenarioParameters.add(new ScenarioParameterBuilder()
.name(Variable.SORT_CODE.name())
.label("Sort Code")
.required()
.textbox()
.value("12345670")
.build());
return scenarioParameters;
}
}
| 3,695 | 0.691746 | 0.684438 | 97 | 37.092785 | 29.393906 | 116 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.350515 | false | false |
13
|
a4f0898ecfe0e1929401be476af5aace1efe0918
| 28,613,072,128,978 |
da80943f298edf2be7e8b8b433dc36506cfde01c
|
/icbms-core/src/main/java/com/icbms/core/socket/handler/TcpMessageHandler.java
|
eb458e86f78e414e1165a9a7ccda0f54695f849b
|
[] |
no_license
|
jaytube/icbms-svs
|
https://github.com/jaytube/icbms-svs
|
f61e41eec0938f36de185523b58c1383494828e1
|
8bc4225b0edc469dbb1e6e34f5f0ac6055ef31c3
|
refs/heads/master
| 2023-01-31T12:18:15.964000 | 2020-12-13T05:18:22 | 2020-12-13T05:18:22 | 318,928,438 | 1 | 2 | null | false | 2020-12-08T06:09:05 | 2020-12-06T01:47:19 | 2020-12-06T06:51:12 | 2020-12-08T06:09:05 | 31 | 1 | 2 | 0 |
Java
| false | false |
package com.icbms.core.socket.handler;
import com.icbms.core.socket.model.TcpMessage;
import org.apache.mina.core.session.IoSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.lang.invoke.MethodHandles;
@Component
public class TcpMessageHandler implements MessageManagerLogicHandler {
private static Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@Resource(type = TcpMessageFacade.class)
private TcpMessageFacade facade;
public void doExec(TcpMessage message, IoSession session) {
handleMsgPack(message, session);
}
public void handleMsgPack(TcpMessage message, IoSession session){
if(facade.getFacadeMap() != null){
MessageManagerLogicHandler handler = (MessageManagerLogicHandler) facade.getFacadeMap().get(message.getCmd());
if(handler != null){
handler.doExec(message, session);
}
}
}
}
|
UTF-8
|
Java
| 968 |
java
|
TcpMessageHandler.java
|
Java
|
[] | null |
[] |
package com.icbms.core.socket.handler;
import com.icbms.core.socket.model.TcpMessage;
import org.apache.mina.core.session.IoSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.lang.invoke.MethodHandles;
@Component
public class TcpMessageHandler implements MessageManagerLogicHandler {
private static Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@Resource(type = TcpMessageFacade.class)
private TcpMessageFacade facade;
public void doExec(TcpMessage message, IoSession session) {
handleMsgPack(message, session);
}
public void handleMsgPack(TcpMessage message, IoSession session){
if(facade.getFacadeMap() != null){
MessageManagerLogicHandler handler = (MessageManagerLogicHandler) facade.getFacadeMap().get(message.getCmd());
if(handler != null){
handler.doExec(message, session);
}
}
}
}
| 968 | 0.788223 | 0.786157 | 32 | 29.25 | 28.754347 | 113 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.40625 | false | false |
13
|
b5bd3c3530d657a00ccf26583ce9ecb5550e86a4
| 20,521,353,784,745 |
ecdc1f0051ba5dc5e56bc379858a83acee3646eb
|
/src/sample/Controller.java
|
5d0c8e1eb6b98c4c166149cbf37a62a0ef922b22
|
[] |
no_license
|
Daval03/Progra-2-NoSQL
|
https://github.com/Daval03/Progra-2-NoSQL
|
7cce1a29deee3614d051a94e66c515ff8c6480da
|
8ec4823a98ac764ec3cdd452fd905671286c350a
|
refs/heads/master
| 2020-05-15T19:21:03.872000 | 2019-04-20T02:21:02 | 2019-04-20T02:21:02 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package sample;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.io.IOException;
import java.util.Hashtable;
public class Controller {
ObjectMapper objectMapper=new ObjectMapper();
public void hola(){
System.out.println("estoy en la funcion");
ObjectNode perro = objectMapper.createObjectNode();
perro.put("hola", 82).put("charanco","tornado");
perro.put("hola", "tornado");
System.out.println(perro);
}
public void table() throws IOException {
Hashtable hashtable= new Hashtable();
hashtable.put("hello", "pico" );
hashtable.put("Paco",85);
hashtable.put("Paco",89);
Hashtable holga = new Hashtable();
holga= (Hashtable) hashtable.clone();
System.out.println(objectMapper.readValue(objectMapper.writeValueAsString(holga),Hashtable.class));
System.out.println(holga);
}
}
|
UTF-8
|
Java
| 1,110 |
java
|
Controller.java
|
Java
|
[] | null |
[] |
package sample;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.io.IOException;
import java.util.Hashtable;
public class Controller {
ObjectMapper objectMapper=new ObjectMapper();
public void hola(){
System.out.println("estoy en la funcion");
ObjectNode perro = objectMapper.createObjectNode();
perro.put("hola", 82).put("charanco","tornado");
perro.put("hola", "tornado");
System.out.println(perro);
}
public void table() throws IOException {
Hashtable hashtable= new Hashtable();
hashtable.put("hello", "pico" );
hashtable.put("Paco",85);
hashtable.put("Paco",89);
Hashtable holga = new Hashtable();
holga= (Hashtable) hashtable.clone();
System.out.println(objectMapper.readValue(objectMapper.writeValueAsString(holga),Hashtable.class));
System.out.println(holga);
}
}
| 1,110 | 0.671171 | 0.665766 | 32 | 32.6875 | 23.692612 | 107 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.875 | false | false |
13
|
707cc609b9fb3f4025b03bc78599b467d18ce265
| 18,485,539,272,043 |
2ef83a19b52bd3a9089a1322ff93eb8da65488f5
|
/ucloud-sdk-java-umem/src/main/java/cn/ucloud/umem/model/CreateUMemSpaceResult.java
|
61b733961752d4d159b759e645c76cfdbb0fb49a
|
[
"Apache-2.0"
] |
permissive
|
liuchangfitcloud/ucloud-sdk-java
|
https://github.com/liuchangfitcloud/ucloud-sdk-java
|
53eb095d180fb459b8ed3f770c087b8441efaa5c
|
ca370c2141527f713feb0c1548d8cc42a8687c2a
|
refs/heads/master
| 2023-01-28T08:59:54.480000 | 2020-09-28T03:51:29 | 2020-09-28T03:51:29 | 315,174,683 | 0 | 0 |
Apache-2.0
| true | 2020-11-23T01:58:12 | 2020-11-23T01:58:12 | 2020-09-28T06:55:36 | 2020-10-13T10:21:46 | 15,849 | 0 | 0 | 0 | null | false | false |
package cn.ucloud.umem.model;
import cn.ucloud.common.pojo.BaseResponseResult;
import com.google.gson.annotations.SerializedName;
/**
* @Description : 创建内存空间 结果类
* @Author : ucloud-sdk-generator
* @Date : 2019-03-15 10:00
**/
public class CreateUMemSpaceResult extends BaseResponseResult {
/**
* 创建内存空间ID列表
*/
@SerializedName("SpaceId")
private String spaceId;
public String getSpaceId() {
return this.spaceId;
}
public void setSpaceId(String spaceId) {
this.spaceId = spaceId;
}
}
|
UTF-8
|
Java
| 581 |
java
|
CreateUMemSpaceResult.java
|
Java
|
[
{
"context": "e;\n\n\n/**\n * @Description : 创建内存空间 结果类\n * @Author : ucloud-sdk-generator\n * @Date : 2019-03-15 10:00\n **/\npublic class Cre",
"end": 199,
"score": 0.9811462759971619,
"start": 179,
"tag": "USERNAME",
"value": "ucloud-sdk-generator"
}
] | null |
[] |
package cn.ucloud.umem.model;
import cn.ucloud.common.pojo.BaseResponseResult;
import com.google.gson.annotations.SerializedName;
/**
* @Description : 创建内存空间 结果类
* @Author : ucloud-sdk-generator
* @Date : 2019-03-15 10:00
**/
public class CreateUMemSpaceResult extends BaseResponseResult {
/**
* 创建内存空间ID列表
*/
@SerializedName("SpaceId")
private String spaceId;
public String getSpaceId() {
return this.spaceId;
}
public void setSpaceId(String spaceId) {
this.spaceId = spaceId;
}
}
| 581 | 0.67276 | 0.650823 | 29 | 17.896551 | 18.31213 | 63 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.206897 | false | false |
13
|
ff8c5035768b00378bd1e7123e1f392e0ea4c247
| 14,190,571,996,700 |
800686c379c3c33d6b9d8893518387ef41bda68d
|
/Ikariam/app/src/main/java/com/thopv/projects/ikariam/home/domain/criterias/MovingTroopsStartAt.java
|
68a1bf0871915f56d9030753298a8d723a0aefc8
|
[] |
no_license
|
thopvna/projects
|
https://github.com/thopvna/projects
|
3f5f517cfc567c9471959fd1c2590877e6672feb
|
f8dacf0c7b516f696e37c7a81b18799f3ac22540
|
refs/heads/master
| 2021-08-28T20:20:01.215000 | 2017-12-13T03:44:37 | 2017-12-13T03:44:37 | 113,744,276 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.thopv.projects.ikariam.home.domain.criterias;
import com.thopv.projects.ikariam.data.source.repositories.Repository;
/**
* Created by thopv on 11/21/2017.
*/
public class MovingTroopsStartAt implements Repository.Criteria {
private long startTime;
public MovingTroopsStartAt(long startTime) {
this.startTime = startTime;
}
public long getStartTime() {
return startTime;
}
}
|
UTF-8
|
Java
| 446 |
java
|
MovingTroopsStartAt.java
|
Java
|
[
{
"context": "rce.repositories.Repository;\r\n\r\n/**\r\n * Created by thopv on 11/21/2017.\r\n */\r\npublic class MovingTroopsSta",
"end": 159,
"score": 0.9996862411499023,
"start": 154,
"tag": "USERNAME",
"value": "thopv"
}
] | null |
[] |
package com.thopv.projects.ikariam.home.domain.criterias;
import com.thopv.projects.ikariam.data.source.repositories.Repository;
/**
* Created by thopv on 11/21/2017.
*/
public class MovingTroopsStartAt implements Repository.Criteria {
private long startTime;
public MovingTroopsStartAt(long startTime) {
this.startTime = startTime;
}
public long getStartTime() {
return startTime;
}
}
| 446 | 0.692825 | 0.674888 | 18 | 22.777779 | 23.766352 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.277778 | false | false |
13
|
cc9dedb53a58f5f1829425507997115417c4f26f
| 26,336,739,501,121 |
0b8cb83ba134835364f8adeaaa7e03922873bf33
|
/src/main/java/com/okcredit/pages/android/verifyMobilePage.java
|
a33f762dbd2f17209edb17eb41d8a111ac6eaf6d
|
[] |
no_license
|
WangPengfei2016/okCredit-android-automation
|
https://github.com/WangPengfei2016/okCredit-android-automation
|
515b1a29252e124e74ac540003c136748919ead1
|
91832198e9a3d9c3b1d61e0b06e83caa583fbfc6
|
refs/heads/master
| 2021-05-17T23:41:12.048000 | 2019-10-03T05:22:13 | 2019-10-03T05:22:13 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.okcredit.pages.android;
import com.okcredit.pages.base.BasePage;
import io.appium.java_client.AppiumDriver;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.CacheLookup;
import org.openqa.selenium.support.FindBy;
import org.testng.Assert;
public class verifyMobilePage extends BasePage {
public verifyMobilePage(AppiumDriver appiumDriver) {
super(appiumDriver);
}
@CacheLookup
@FindBy(xpath = "//android.widget.TextView[@text='Verify mobile']")
private WebElement verifyPageTitle;
@CacheLookup
@FindBy(xpath = "//android.widget.TextView[@text='OTP will be sent for verification']")
private WebElement verifyOTPMessage;
@CacheLookup
@FindBy(id = "mobile")
private WebElement mobileNumber;
@CacheLookup
@FindBy(id = "terms")
private WebElement termAndCondition;
@CacheLookup
@FindBy(id = "next")
private WebElement sendOTP;
public void verifyPageTitle(String title) {
waitVisibilityOf(verifyPageTitle);
Assert.assertEquals(verifyPageTitle.getText(), title);
}
public void verifyOTPMessage(String otpMessage) {
waitVisibilityOf(verifyOTPMessage);
Assert.assertEquals(verifyOTPMessage.getText(), otpMessage);
}
public boolean isTermAndConditionDisplay() {
try {
waitVisibilityOf(termAndCondition);
return true;
} catch (NoSuchElementException e) {
return false;
}
}
public void enterMobileNumber(String mobile) {
waitElementToBeClickable(mobileNumber);
sendKeys(mobileNumber, mobile);
}
public void enterOTP(String OTP) {
waitElementToBeClickable(sendOTP);
sendKeys(sendOTP, OTP);
}
}
|
UTF-8
|
Java
| 1,820 |
java
|
verifyMobilePage.java
|
Java
|
[] | null |
[] |
package com.okcredit.pages.android;
import com.okcredit.pages.base.BasePage;
import io.appium.java_client.AppiumDriver;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.CacheLookup;
import org.openqa.selenium.support.FindBy;
import org.testng.Assert;
public class verifyMobilePage extends BasePage {
public verifyMobilePage(AppiumDriver appiumDriver) {
super(appiumDriver);
}
@CacheLookup
@FindBy(xpath = "//android.widget.TextView[@text='Verify mobile']")
private WebElement verifyPageTitle;
@CacheLookup
@FindBy(xpath = "//android.widget.TextView[@text='OTP will be sent for verification']")
private WebElement verifyOTPMessage;
@CacheLookup
@FindBy(id = "mobile")
private WebElement mobileNumber;
@CacheLookup
@FindBy(id = "terms")
private WebElement termAndCondition;
@CacheLookup
@FindBy(id = "next")
private WebElement sendOTP;
public void verifyPageTitle(String title) {
waitVisibilityOf(verifyPageTitle);
Assert.assertEquals(verifyPageTitle.getText(), title);
}
public void verifyOTPMessage(String otpMessage) {
waitVisibilityOf(verifyOTPMessage);
Assert.assertEquals(verifyOTPMessage.getText(), otpMessage);
}
public boolean isTermAndConditionDisplay() {
try {
waitVisibilityOf(termAndCondition);
return true;
} catch (NoSuchElementException e) {
return false;
}
}
public void enterMobileNumber(String mobile) {
waitElementToBeClickable(mobileNumber);
sendKeys(mobileNumber, mobile);
}
public void enterOTP(String OTP) {
waitElementToBeClickable(sendOTP);
sendKeys(sendOTP, OTP);
}
}
| 1,820 | 0.7 | 0.7 | 63 | 27.888889 | 21.587851 | 91 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.460317 | false | false |
13
|
86ab0d4e6e6c2c04f2c37da08cb95124ebb6a701
| 26,336,739,499,806 |
304dba2b0d9a024e2f78c8b7231493006d19d135
|
/src/org/schmied/questionator/Questionator.java
|
0b20fd7e4f4aa0fcf73772296395effb5242c107
|
[] |
no_license
|
schmied/questionator
|
https://github.com/schmied/questionator
|
c9c5c99cf8c9b021dc38fb47eaecc96256ddb84b
|
d59752e56548df5738a2bf4ea47c7376bdebe8d7
|
refs/heads/master
| 2021-01-24T02:23:31.780000 | 2019-08-10T23:00:27 | 2019-08-10T23:00:27 | 122,846,643 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package org.schmied.questionator;
import java.sql.*;
import java.util.*;
import org.schmied.questionator.importer.Importer;
public class Questionator {
private static final String DB_URL = "jdbc:postgresql://localhost/questionator?user=postgres&password=postgres";
private final Connection connection;
private Questionator() throws Exception {
try {
connection = DriverManager.getConnection(DB_URL);
} catch (final Exception e) {
e.printStackTrace();
close();
throw e;
}
}
private void close() {
try {
if (connection != null && !connection.isClosed())
connection.close();
} catch (final Exception e) {
e.printStackTrace();
}
}
private static Questionator instance() {
try {
return new Questionator();
} catch (final Exception e) {
return null;
}
}
public static final int[] intArray(final Collection<? extends Number> c) {
if (c == null)
return null;
final int[] a = new int[c.size()];
int idx = 0;
for (final Number n : c) {
a[idx] = n.intValue();
idx++;
}
Arrays.sort(a);
return a;
}
public static void main(String[] argv) throws Exception {
final Questionator q = Questionator.instance();
if (q == null)
return;
// Importer.importInsert(q.connection, DUMP_FILE);
Importer.importCopy(q.connection);
q.close();
}
}
/*
SELECT sqrt(i.popularity::float * v.popularity::float) as pop, i.label_en, i.label_de, p.label_en, p.label_de, v.label_en, v.label_de FROM claim_item ci
JOIN item v ON ci.value = v.item_id
JOIN item i ON ci.item_id = i.item_id
JOIN property p ON ci.property_id = p.property_id
ORDER BY pop DESC, i.label_en
LIMIT 100000
SELECT ?subclass ?subclassLabel ?instanceofSubclass ?instanceofSubclassLabel WHERE {
?subclass wdt:P279 wd:Q121998 .
?subclass wdt:P31 wd:Q13406463 .
?subclass wdt:P31 ?instanceofSubclass .
FILTER (?instanceofSubclass != wd:Q13406463) .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
*/
//SELECT ?subclass ?subclassLabel WHERE {
// ?subclass wdt:P279 wd:Q7725634 .
// SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
//}
//SELECT (COUNT(*) AS ?count) WHERE {
// ?item wdt:P31 wd:Q5 .
// SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
//}
//SELECT ?subclass ?subclassLabel (COUNT(?item) AS ?count) WHERE {
// ?subclass wdt:P279 wd:Q7725634 .
// ?item wdt:P31 ?subclass .
// SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
//}
//GROUP BY ?subclass ?subclassLabel
//ORDER BY DESC(?count)
//LIMIT 100
/*
SELECT i.popularity, i.label_en, i.label_de, p.label_en, p.label_de, v.label_en, v.label_de FROM claim_item ci
JOIN item v ON ci.value = v.item_id
JOIN item i ON ci.item_id = i.item_id
JOIN property p ON ci.property_id = p.property_id
ORDER BY popularity DESC, i.label_en
LIMIT 100000
-- property verteilung
SELECT i.popularity, count(*) from item i
JOIN statement_item si ON si.item_id = i.item_id
WHERE si.property_id = 19
GROUP BY i.popularity
ORDER BY i.popularity DESC
LIMIT 10000
-- property auflistung
SELECT i.popularity, i.label_de from item i
JOIN claim_item ci ON ci.item_id = i.item_id
WHERE ci.property_id = 19
ORDER BY i.popularity DESC
LIMIT 10000
*/
// private static final String[] DATATYPES = { "globe-coordinate", "quantity", "string", "time", "wikibase-item" };
/*
final CopyManager copyManager = ((PGConnection) cn).getCopyAPI();
final PushbackReader prItem = new PushbackReader(new StringReader(""), 10000);
final PushbackReader prProperty = new PushbackReader(new StringReader(""), 10000);
final StringBuilder sbItem = new StringBuilder();
final StringBuilder sbProperty = new StringBuilder();
private static final int insert(final String table, final CopyManager cm, final PushbackReader pr, final StringBuilder sb, final int idx,
final int id, final String labelEn, final String labelDe) throws Exception {
sb.append(id).append(",'").append(labelEn.replace("'", "")).append("','").append(labelDe.replace("'", "")).append("'\n");
if (idx > MAX_INSERT_BATCH_COUNT) {
System.out.println(sb.toString());
pr.unread(sb.toString().toCharArray());
cm.copyIn("COPY " + table + " FROM STDIN WITH CSV", pr);
sb.delete(0, sb.length());
return 0;
}
return idx + 1;
}
idxItem = insert("item", copyManager, prItem, sbItem, idxItem, id, labelEn, labelDe);
idxProperty = insert("property", copyManager, prProperty, sbProperty, idxProperty, id, labelEn, labelDe);
prItem.unread(sbItem.toString().toCharArray());
copyManager.copyIn("COPY item FROM STDIN WITH CSV", prItem);
prProperty.unread(sbProperty.toString().toCharArray());
copyManager.copyIn("COPY property FROM STDIN WITH CSV", prProperty);
if (Arrays.binarySearch(DATATYPES, datatype) < 0)
continue;
*/
|
UTF-8
|
Java
| 4,785 |
java
|
Questionator.java
|
Java
|
[
{
"context": "l://localhost/questionator?user=postgres&password=postgres\";\n\n\tprivate final Connection connection;\n\n\tprivat",
"end": 267,
"score": 0.999089777469635,
"start": 259,
"tag": "PASSWORD",
"value": "postgres"
}
] | null |
[] |
package org.schmied.questionator;
import java.sql.*;
import java.util.*;
import org.schmied.questionator.importer.Importer;
public class Questionator {
private static final String DB_URL = "jdbc:postgresql://localhost/questionator?user=postgres&password=<PASSWORD>";
private final Connection connection;
private Questionator() throws Exception {
try {
connection = DriverManager.getConnection(DB_URL);
} catch (final Exception e) {
e.printStackTrace();
close();
throw e;
}
}
private void close() {
try {
if (connection != null && !connection.isClosed())
connection.close();
} catch (final Exception e) {
e.printStackTrace();
}
}
private static Questionator instance() {
try {
return new Questionator();
} catch (final Exception e) {
return null;
}
}
public static final int[] intArray(final Collection<? extends Number> c) {
if (c == null)
return null;
final int[] a = new int[c.size()];
int idx = 0;
for (final Number n : c) {
a[idx] = n.intValue();
idx++;
}
Arrays.sort(a);
return a;
}
public static void main(String[] argv) throws Exception {
final Questionator q = Questionator.instance();
if (q == null)
return;
// Importer.importInsert(q.connection, DUMP_FILE);
Importer.importCopy(q.connection);
q.close();
}
}
/*
SELECT sqrt(i.popularity::float * v.popularity::float) as pop, i.label_en, i.label_de, p.label_en, p.label_de, v.label_en, v.label_de FROM claim_item ci
JOIN item v ON ci.value = v.item_id
JOIN item i ON ci.item_id = i.item_id
JOIN property p ON ci.property_id = p.property_id
ORDER BY pop DESC, i.label_en
LIMIT 100000
SELECT ?subclass ?subclassLabel ?instanceofSubclass ?instanceofSubclassLabel WHERE {
?subclass wdt:P279 wd:Q121998 .
?subclass wdt:P31 wd:Q13406463 .
?subclass wdt:P31 ?instanceofSubclass .
FILTER (?instanceofSubclass != wd:Q13406463) .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
*/
//SELECT ?subclass ?subclassLabel WHERE {
// ?subclass wdt:P279 wd:Q7725634 .
// SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
//}
//SELECT (COUNT(*) AS ?count) WHERE {
// ?item wdt:P31 wd:Q5 .
// SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
//}
//SELECT ?subclass ?subclassLabel (COUNT(?item) AS ?count) WHERE {
// ?subclass wdt:P279 wd:Q7725634 .
// ?item wdt:P31 ?subclass .
// SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
//}
//GROUP BY ?subclass ?subclassLabel
//ORDER BY DESC(?count)
//LIMIT 100
/*
SELECT i.popularity, i.label_en, i.label_de, p.label_en, p.label_de, v.label_en, v.label_de FROM claim_item ci
JOIN item v ON ci.value = v.item_id
JOIN item i ON ci.item_id = i.item_id
JOIN property p ON ci.property_id = p.property_id
ORDER BY popularity DESC, i.label_en
LIMIT 100000
-- property verteilung
SELECT i.popularity, count(*) from item i
JOIN statement_item si ON si.item_id = i.item_id
WHERE si.property_id = 19
GROUP BY i.popularity
ORDER BY i.popularity DESC
LIMIT 10000
-- property auflistung
SELECT i.popularity, i.label_de from item i
JOIN claim_item ci ON ci.item_id = i.item_id
WHERE ci.property_id = 19
ORDER BY i.popularity DESC
LIMIT 10000
*/
// private static final String[] DATATYPES = { "globe-coordinate", "quantity", "string", "time", "wikibase-item" };
/*
final CopyManager copyManager = ((PGConnection) cn).getCopyAPI();
final PushbackReader prItem = new PushbackReader(new StringReader(""), 10000);
final PushbackReader prProperty = new PushbackReader(new StringReader(""), 10000);
final StringBuilder sbItem = new StringBuilder();
final StringBuilder sbProperty = new StringBuilder();
private static final int insert(final String table, final CopyManager cm, final PushbackReader pr, final StringBuilder sb, final int idx,
final int id, final String labelEn, final String labelDe) throws Exception {
sb.append(id).append(",'").append(labelEn.replace("'", "")).append("','").append(labelDe.replace("'", "")).append("'\n");
if (idx > MAX_INSERT_BATCH_COUNT) {
System.out.println(sb.toString());
pr.unread(sb.toString().toCharArray());
cm.copyIn("COPY " + table + " FROM STDIN WITH CSV", pr);
sb.delete(0, sb.length());
return 0;
}
return idx + 1;
}
idxItem = insert("item", copyManager, prItem, sbItem, idxItem, id, labelEn, labelDe);
idxProperty = insert("property", copyManager, prProperty, sbProperty, idxProperty, id, labelEn, labelDe);
prItem.unread(sbItem.toString().toCharArray());
copyManager.copyIn("COPY item FROM STDIN WITH CSV", prItem);
prProperty.unread(sbProperty.toString().toCharArray());
copyManager.copyIn("COPY property FROM STDIN WITH CSV", prProperty);
if (Arrays.binarySearch(DATATYPES, datatype) < 0)
continue;
*/
| 4,787 | 0.701358 | 0.680878 | 166 | 27.825302 | 30.244778 | 152 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.271084 | false | false |
13
|
b3204f54a0f3fd8df88351f4047b6c009fa408bb
| 24,687,472,052,972 |
35f8d40210d53aef9a2aeeaee15e053716ad0caf
|
/EmailContactsWirePractice/src/main/java/com/sg/wirepractice/dao/EmailContactsAuditDao.java
|
539bdc6a29ddb34f65be20b3256ae63813b21df0
|
[] |
no_license
|
Bryan10Butler/sg-bryan-butler-individual-work
|
https://github.com/Bryan10Butler/sg-bryan-butler-individual-work
|
73ac9441c45a2c5c3c0cab249c583594cd921aa9
|
731bfb20f18f6592835cf38b477c43181bd64aa8
|
refs/heads/master
| 2020-03-21T03:00:35.557000 | 2018-06-20T13:04:10 | 2018-06-20T13:04:10 | 138,032,343 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.sg.wirepractice.dao;
public interface EmailContactsAuditDao {
}
|
UTF-8
|
Java
| 77 |
java
|
EmailContactsAuditDao.java
|
Java
|
[] | null |
[] |
package com.sg.wirepractice.dao;
public interface EmailContactsAuditDao {
}
| 77 | 0.818182 | 0.818182 | 4 | 18.25 | 17.977417 | 40 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.25 | false | false |
13
|
05a0c1a54b79c4a91a90f2aa5c38aeb5ed9a07e4
| 33,818,572,502,055 |
f3a9344e25b58f3e45b5d60903e2464c721f9c97
|
/src/SecretChat.java
|
028f0974899cb0cc41e2d51d898b65aa4be2a1c3
|
[] |
no_license
|
Milena-Petrova/Java-exam-preparation-tasks
|
https://github.com/Milena-Petrova/Java-exam-preparation-tasks
|
af57c6e190e96829387984b2bdcd257dd4abd7cc
|
245d769fa81fb59a3be8765c2368a394742be262
|
refs/heads/master
| 2023-03-13T19:11:00.206000 | 2021-03-13T21:52:48 | 2021-03-13T21:52:48 | 347,486,887 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import java.util.Scanner;
public class SecretChat {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String input = scanner.nextLine();
StringBuilder message = new StringBuilder(input);
String command = scanner.nextLine();
while (!command.equals("Reveal")) {
String[] token = command.split(":\\|:");
switch (token[0]) {
case "InsertSpace":
int insertIndex = Integer.parseInt(token[1]);
message = message.insert(insertIndex, " ");
System.out.println(message);
break;
case "Reverse":
String substringReverse = token[1];
if (message.toString().contains(substringReverse)) {
message = new StringBuilder(message.toString().replaceFirst(substringReverse, ""));
for (int i = substringReverse.length()-1; i >= 0; i--) {
message = message.append(substringReverse.charAt(i));
}
System.out.println(message);
} else {
System.out.println("error");
}
break;
case "ChangeAll":
String substr = token[1];
String replacement = token[2];
message = new StringBuilder(message.toString().replaceAll(substr, replacement));
System.out.println(message);
break;
}
command = scanner.nextLine();
}
System.out.printf("You have a new text message: %s", message);
}
}
|
UTF-8
|
Java
| 1,762 |
java
|
SecretChat.java
|
Java
|
[] | null |
[] |
import java.util.Scanner;
public class SecretChat {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String input = scanner.nextLine();
StringBuilder message = new StringBuilder(input);
String command = scanner.nextLine();
while (!command.equals("Reveal")) {
String[] token = command.split(":\\|:");
switch (token[0]) {
case "InsertSpace":
int insertIndex = Integer.parseInt(token[1]);
message = message.insert(insertIndex, " ");
System.out.println(message);
break;
case "Reverse":
String substringReverse = token[1];
if (message.toString().contains(substringReverse)) {
message = new StringBuilder(message.toString().replaceFirst(substringReverse, ""));
for (int i = substringReverse.length()-1; i >= 0; i--) {
message = message.append(substringReverse.charAt(i));
}
System.out.println(message);
} else {
System.out.println("error");
}
break;
case "ChangeAll":
String substr = token[1];
String replacement = token[2];
message = new StringBuilder(message.toString().replaceAll(substr, replacement));
System.out.println(message);
break;
}
command = scanner.nextLine();
}
System.out.printf("You have a new text message: %s", message);
}
}
| 1,762 | 0.485812 | 0.481839 | 42 | 40.952381 | 25.343311 | 107 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.714286 | false | false |
13
|
da478a4f9201768f044be23b6bfea87075fe2143
| 2,843,268,415,140 |
5b6a2c15258e55680d2410cbe0ff548fb4e6e7ad
|
/app/src/main/java/com/huisu/iyoox/adapter/NewErrorExercisesAdapter.java
|
34226615d0207c67ed0aab1d9239b1fd45d35397
|
[] |
no_license
|
mucll/IyooxTask
|
https://github.com/mucll/IyooxTask
|
763772131d0621e8a97df602fd2fe07357516f79
|
4bf912f32896021a36cb11bd34a4f74ea923cc7f
|
refs/heads/master
| 2020-03-23T07:52:17.161000 | 2018-09-10T07:50:15 | 2018-09-10T07:50:15 | 141,294,349 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.huisu.iyoox.adapter;
import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.huisu.iyoox.R;
import com.huisu.iyoox.activity.student.StudentWriteExercisesErrorActivity;
import com.huisu.iyoox.constant.Constant;
import com.huisu.iyoox.entity.SubjectModel;
import com.huisu.iyoox.util.StringUtils;
import com.huisu.iyoox.views.canvasview.CardAdapterHelper;
import java.util.ArrayList;
/**
* Function:
* Date: 2018/9/3
*
* @author dinglai
* @since JDK 1.8
*/
public class NewErrorExercisesAdapter extends RecyclerView.Adapter<NewErrorExercisesAdapter.ViewHodler> {
private Context mContext;
private ArrayList<SubjectModel> models;
private CardAdapterHelper mCardAdapterHelper = new CardAdapterHelper();
public NewErrorExercisesAdapter(Context mContext, ArrayList<SubjectModel> models) {
this.mContext = mContext;
this.models = models;
}
@Override
public ViewHodler onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(mContext).inflate(R.layout.item_new_error_exercises_layout, parent, false);
mCardAdapterHelper.onCreateViewHolder(parent, view);
return new ViewHodler(view);
}
@Override
public void onBindViewHolder(ViewHodler holder, int position) {
mCardAdapterHelper.onBindViewHolder(holder.itemView, position, getItemCount());
final SubjectModel model = models.get(position);
holder.imgView.setImageResource(getSubjectResId(model.getKemu_id()));
if (StringUtils.isPad(mContext)) {
holder.imgView.setScaleType(ImageView.ScaleType.FIT_XY);
} else {
holder.imgView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
}
holder.imgView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, StudentWriteExercisesErrorActivity.class);
intent.putExtra("subjectId", model.getKemu_id());
intent.putExtra("subjectName", model.getKemu_name() + "错题");
mContext.startActivity(intent);
}
});
}
@Override
public int getItemCount() {
return models == null ? 0 : models.size();
}
class ViewHodler extends RecyclerView.ViewHolder {
private ImageView imgView;
public ViewHodler(View itemView) {
super(itemView);
imgView = itemView.findViewById(R.id.imageView);
}
}
private int getSubjectResId(int subjectId) {
switch (subjectId) {
case Constant.SUBJECT_YUWEN:
return R.drawable.ctj_subject_chinese;
case Constant.SUBJECT_SHUXUE:
return R.drawable.ctj_subject_math;
case Constant.SUBJECT_ENGLISH:
return R.drawable.ctj_subject_eng;
case Constant.SUBJECT_WULI:
return R.drawable.ctj_subject_physics;
case Constant.SUBJECT_HUAXUE:
return R.drawable.ctj_subject_chemical;
default:
return R.drawable.ctj_subject_chinese;
}
}
}
|
UTF-8
|
Java
| 3,369 |
java
|
NewErrorExercisesAdapter.java
|
Java
|
[
{
"context": "\n\n/**\n * Function:\n * Date: 2018/9/3\n *\n * @author dinglai\n * @since JDK 1.8\n */\npublic class NewErrorExerci",
"end": 645,
"score": 0.9978682994842529,
"start": 638,
"tag": "USERNAME",
"value": "dinglai"
}
] | null |
[] |
package com.huisu.iyoox.adapter;
import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.huisu.iyoox.R;
import com.huisu.iyoox.activity.student.StudentWriteExercisesErrorActivity;
import com.huisu.iyoox.constant.Constant;
import com.huisu.iyoox.entity.SubjectModel;
import com.huisu.iyoox.util.StringUtils;
import com.huisu.iyoox.views.canvasview.CardAdapterHelper;
import java.util.ArrayList;
/**
* Function:
* Date: 2018/9/3
*
* @author dinglai
* @since JDK 1.8
*/
public class NewErrorExercisesAdapter extends RecyclerView.Adapter<NewErrorExercisesAdapter.ViewHodler> {
private Context mContext;
private ArrayList<SubjectModel> models;
private CardAdapterHelper mCardAdapterHelper = new CardAdapterHelper();
public NewErrorExercisesAdapter(Context mContext, ArrayList<SubjectModel> models) {
this.mContext = mContext;
this.models = models;
}
@Override
public ViewHodler onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(mContext).inflate(R.layout.item_new_error_exercises_layout, parent, false);
mCardAdapterHelper.onCreateViewHolder(parent, view);
return new ViewHodler(view);
}
@Override
public void onBindViewHolder(ViewHodler holder, int position) {
mCardAdapterHelper.onBindViewHolder(holder.itemView, position, getItemCount());
final SubjectModel model = models.get(position);
holder.imgView.setImageResource(getSubjectResId(model.getKemu_id()));
if (StringUtils.isPad(mContext)) {
holder.imgView.setScaleType(ImageView.ScaleType.FIT_XY);
} else {
holder.imgView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
}
holder.imgView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, StudentWriteExercisesErrorActivity.class);
intent.putExtra("subjectId", model.getKemu_id());
intent.putExtra("subjectName", model.getKemu_name() + "错题");
mContext.startActivity(intent);
}
});
}
@Override
public int getItemCount() {
return models == null ? 0 : models.size();
}
class ViewHodler extends RecyclerView.ViewHolder {
private ImageView imgView;
public ViewHodler(View itemView) {
super(itemView);
imgView = itemView.findViewById(R.id.imageView);
}
}
private int getSubjectResId(int subjectId) {
switch (subjectId) {
case Constant.SUBJECT_YUWEN:
return R.drawable.ctj_subject_chinese;
case Constant.SUBJECT_SHUXUE:
return R.drawable.ctj_subject_math;
case Constant.SUBJECT_ENGLISH:
return R.drawable.ctj_subject_eng;
case Constant.SUBJECT_WULI:
return R.drawable.ctj_subject_physics;
case Constant.SUBJECT_HUAXUE:
return R.drawable.ctj_subject_chemical;
default:
return R.drawable.ctj_subject_chinese;
}
}
}
| 3,369 | 0.6737 | 0.670728 | 97 | 33.690723 | 27.391911 | 115 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.556701 | false | false |
13
|
2fc39cd5de8e22d05a1022a2e0d6b51f4d713004
| 10,419,590,675,372 |
38ad586b0c6bcaba8c2157a2fca4a19e7cec5e85
|
/app/src/main/java/com/a1996/ben/pomodoro/View/Tasks.java
|
926cbc96e7919d076fc5c45b505bba50bf35298b
|
[] |
no_license
|
Bmckenzie96/geofencing
|
https://github.com/Bmckenzie96/geofencing
|
42a287c09d43076054fd7a799067219d418e6b53
|
1dfa6dee21a28c30a62202d10c2d1b0fec751fe0
|
refs/heads/master
| 2020-12-25T10:49:32.071000 | 2016-06-24T14:46:11 | 2016-06-24T14:46:11 | 61,891,457 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.a1996.ben.pomodoro.View;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
import com.a1996.ben.pomodoro.R;
import Model.TaskArray;
import Utils.BackendlessHelper;
import Utils.TaskDataSource;
public class Tasks extends AppCompatActivity implements TaskListFragment.TaskAdapterInterface, EditTaskFragment.EditTaskInterface{
TaskListFragment mTaskListFragment;
EditTaskFragment mEditTaskFragment;
BackendlessHelper backendlessHelper = new BackendlessHelper(this);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tasks);
mTaskListFragment = new TaskListFragment();
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.add(R.id.tasksPlaceHolder, mTaskListFragment);
fragmentTransaction.commit();
}
@Override
public void goToContent(int position) {
Bundle args = new Bundle();
args.putString("TITLE", TaskArray.taskArrayList.get(position).getTitle());
args.putString("CONTENT", TaskArray.taskArrayList.get(position).getContent());
args.putInt("INDEX", position);
TaskContentFragment taskContentFragment = new TaskContentFragment();
taskContentFragment.setArguments(args);
getFragmentManager().beginTransaction()
.replace(R.id.tasksPlaceHolder, taskContentFragment)
.addToBackStack("Task View").commit();
}
@Override
public void longItemClick(int position) {
}
@Override
public void goToEdit(int position) {
Bundle args = new Bundle();
args.putString("TITLE", TaskArray.taskArrayList.get(position).getTitle());
args.putString("CONTENT", TaskArray.taskArrayList.get(position).getContent());
args.putInt("INDEX", position);
mEditTaskFragment = new EditTaskFragment();
mEditTaskFragment.setArguments(args);
getFragmentManager().beginTransaction()
.replace(R.id.tasksPlaceHolder, mEditTaskFragment)
.addToBackStack("Task Edit View").commit();
}
@Override
public void delete(int position, TaskAdapter taskAdapter) {
TaskDataSource taskDataSource = new TaskDataSource(this.getApplicationContext());
backendlessHelper.backendlessDelete(TaskArray.taskArrayList.get(position));
taskDataSource.open();
taskDataSource.deleteTask(TaskArray.taskArrayList.get(position));
taskDataSource.close();
TaskArray.removeTask(position);
taskAdapter.notifyDataSetChanged();
}
@Override
public void showEmpty(TextView textView) {
textView.setVisibility(View.VISIBLE);
}
@Override
public void hideEmpty(TextView textView) {
textView.setVisibility(View.INVISIBLE);
}
@Override
public void addTask() {
Intent intent = new Intent(this, AddTask.class);
this.startActivity(intent);
}
@Override
public void doneEdit(String title, String content, final int index) {
TaskArray.taskArrayList.get(index).setTitle(title);
TaskArray.taskArrayList.get(index).setContent(content);
backendlessHelper.backendUpdate(TaskArray.taskArrayList.get(index));
TaskDataSource taskDataSource = new TaskDataSource(Tasks.this.getApplicationContext());
taskDataSource.open();
taskDataSource.updateTask(TaskArray.taskArrayList.get(index));
taskDataSource.close();
getFragmentManager().popBackStack();
}
@Override
public void cancelEdit() {
getFragmentManager().popBackStack();
}
}
|
UTF-8
|
Java
| 3,947 |
java
|
Tasks.java
|
Java
|
[] | null |
[] |
package com.a1996.ben.pomodoro.View;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
import com.a1996.ben.pomodoro.R;
import Model.TaskArray;
import Utils.BackendlessHelper;
import Utils.TaskDataSource;
public class Tasks extends AppCompatActivity implements TaskListFragment.TaskAdapterInterface, EditTaskFragment.EditTaskInterface{
TaskListFragment mTaskListFragment;
EditTaskFragment mEditTaskFragment;
BackendlessHelper backendlessHelper = new BackendlessHelper(this);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tasks);
mTaskListFragment = new TaskListFragment();
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.add(R.id.tasksPlaceHolder, mTaskListFragment);
fragmentTransaction.commit();
}
@Override
public void goToContent(int position) {
Bundle args = new Bundle();
args.putString("TITLE", TaskArray.taskArrayList.get(position).getTitle());
args.putString("CONTENT", TaskArray.taskArrayList.get(position).getContent());
args.putInt("INDEX", position);
TaskContentFragment taskContentFragment = new TaskContentFragment();
taskContentFragment.setArguments(args);
getFragmentManager().beginTransaction()
.replace(R.id.tasksPlaceHolder, taskContentFragment)
.addToBackStack("Task View").commit();
}
@Override
public void longItemClick(int position) {
}
@Override
public void goToEdit(int position) {
Bundle args = new Bundle();
args.putString("TITLE", TaskArray.taskArrayList.get(position).getTitle());
args.putString("CONTENT", TaskArray.taskArrayList.get(position).getContent());
args.putInt("INDEX", position);
mEditTaskFragment = new EditTaskFragment();
mEditTaskFragment.setArguments(args);
getFragmentManager().beginTransaction()
.replace(R.id.tasksPlaceHolder, mEditTaskFragment)
.addToBackStack("Task Edit View").commit();
}
@Override
public void delete(int position, TaskAdapter taskAdapter) {
TaskDataSource taskDataSource = new TaskDataSource(this.getApplicationContext());
backendlessHelper.backendlessDelete(TaskArray.taskArrayList.get(position));
taskDataSource.open();
taskDataSource.deleteTask(TaskArray.taskArrayList.get(position));
taskDataSource.close();
TaskArray.removeTask(position);
taskAdapter.notifyDataSetChanged();
}
@Override
public void showEmpty(TextView textView) {
textView.setVisibility(View.VISIBLE);
}
@Override
public void hideEmpty(TextView textView) {
textView.setVisibility(View.INVISIBLE);
}
@Override
public void addTask() {
Intent intent = new Intent(this, AddTask.class);
this.startActivity(intent);
}
@Override
public void doneEdit(String title, String content, final int index) {
TaskArray.taskArrayList.get(index).setTitle(title);
TaskArray.taskArrayList.get(index).setContent(content);
backendlessHelper.backendUpdate(TaskArray.taskArrayList.get(index));
TaskDataSource taskDataSource = new TaskDataSource(Tasks.this.getApplicationContext());
taskDataSource.open();
taskDataSource.updateTask(TaskArray.taskArrayList.get(index));
taskDataSource.close();
getFragmentManager().popBackStack();
}
@Override
public void cancelEdit() {
getFragmentManager().popBackStack();
}
}
| 3,947 | 0.71092 | 0.70864 | 108 | 35.546295 | 27.992189 | 130 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.648148 | false | false |
13
|
6a47b71b350809b52aa19fc11aaf08da1a9624f3
| 31,774,168,068,384 |
9627af5c4ccbaaaf66e9a21caf3f18ff9b70ac72
|
/todo/src/main/java/com/rk/todo/services/TodoService.java
|
a2a49a50f0ab5fdc314adea182b3df891cb0274e
|
[] |
no_license
|
rk1023/springboot-JWT-demo
|
https://github.com/rk1023/springboot-JWT-demo
|
623425afc257cf37b7b1d19601c41195c66aded0
|
e073363f08900e4840a1318fa672182cb8a98285
|
refs/heads/master
| 2022-12-11T05:48:40.140000 | 2020-08-23T17:16:06 | 2020-08-23T17:16:06 | 289,698,518 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.rk.todo.services;
import java.util.List;
import com.rk.todo.dtos.TodoBasicDetailsDTO;
public interface TodoService {
List<TodoBasicDetailsDTO> getByUserName(String userName);
List<TodoBasicDetailsDTO> deleteTodo(String userName, int todoId);
List<TodoBasicDetailsDTO> addTodo(String userName, TodoBasicDetailsDTO todoDto);
}
|
UTF-8
|
Java
| 347 |
java
|
TodoService.java
|
Java
|
[] | null |
[] |
package com.rk.todo.services;
import java.util.List;
import com.rk.todo.dtos.TodoBasicDetailsDTO;
public interface TodoService {
List<TodoBasicDetailsDTO> getByUserName(String userName);
List<TodoBasicDetailsDTO> deleteTodo(String userName, int todoId);
List<TodoBasicDetailsDTO> addTodo(String userName, TodoBasicDetailsDTO todoDto);
}
| 347 | 0.81268 | 0.81268 | 14 | 23.785715 | 27.589279 | 81 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.857143 | false | false |
13
|
ecbeb1d60b39eda45b62f67b4709e153f13702b4
| 8,967,891,784,022 |
6a0a2c3543d01ce8c5ba649fc61a2c4b07ee0eae
|
/Interpreter/src/parser/Statement.java
|
b3a8756cd1c5120a0ecea64f23a27fe12a35ecbf
|
[] |
no_license
|
ekngen11/DECAF
|
https://github.com/ekngen11/DECAF
|
55dba891ada1681becf69f751cabf174c28a15bc
|
a857289ca061e54013e08503a799696da01a9435
|
refs/heads/master
| 2021-01-22T14:33:05.894000 | 2014-07-10T14:41:12 | 2014-07-10T14:41:12 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package parser;
import java.util.HashMap;
import tokenizer.Token;
import tokenizer.Tokenizer;
public abstract class Statement extends Symbol {
//Statement -> whileStament | ifStatement | PrintStatement
public static Statement getStatement(Tokenizer tokenizer){
if(tokenizer.hasNext(Token.Type.WHILE)){
return new WhileStatement (tokenizer);
}
else if(tokenizer.hasNext(Token.Type.IF)){
return new IfStatement (tokenizer);
}
else if(tokenizer.hasNext(Token.Type.PRINT)){
return new PrintStatement (tokenizer);
}
else if(tokenizer.hasNext(Token.Type.IDENTIFIER)){
return new Assignment (tokenizer);
}
else
return new Block(tokenizer);
}
public abstract void execute(HashMap<String,Object> state);
}
|
UTF-8
|
Java
| 795 |
java
|
Statement.java
|
Java
|
[] | null |
[] |
package parser;
import java.util.HashMap;
import tokenizer.Token;
import tokenizer.Tokenizer;
public abstract class Statement extends Symbol {
//Statement -> whileStament | ifStatement | PrintStatement
public static Statement getStatement(Tokenizer tokenizer){
if(tokenizer.hasNext(Token.Type.WHILE)){
return new WhileStatement (tokenizer);
}
else if(tokenizer.hasNext(Token.Type.IF)){
return new IfStatement (tokenizer);
}
else if(tokenizer.hasNext(Token.Type.PRINT)){
return new PrintStatement (tokenizer);
}
else if(tokenizer.hasNext(Token.Type.IDENTIFIER)){
return new Assignment (tokenizer);
}
else
return new Block(tokenizer);
}
public abstract void execute(HashMap<String,Object> state);
}
| 795 | 0.698113 | 0.698113 | 36 | 20.083334 | 21.281675 | 60 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.75 | false | false |
13
|
2613e5c202815fb19dd1a7cbea8dee9a66973c0e
| 29,549,375,058,775 |
9665862393685079a2ab95a8a167d012a4c5ebde
|
/app/src/main/java/com/keithandthegirl/app/db/model/ShowConstants.java
|
11184f82e66f7bc0a3522e0bfb3f625179e34bff
|
[] |
no_license
|
KeithAndTheGirl/KeithAndTheGirlAndroid
|
https://github.com/KeithAndTheGirl/KeithAndTheGirlAndroid
|
2f03e13ef72f92baf864d380a719e05b2a34b265
|
85e553fb756eb4fbdbb06298046646a9d16d01b0
|
refs/heads/master
| 2016-09-16T02:04:46.142000 | 2015-07-23T02:43:25 | 2015-07-23T02:43:25 | 18,000,295 | 0 | 4 | null | false | 2015-04-25T11:56:53 | 2014-03-22T02:28:05 | 2015-04-15T01:58:51 | 2015-04-15T01:58:49 | 23,169 | 1 | 3 | 8 |
HTML
| null | null |
package com.keithandthegirl.app.db.model;
import android.net.Uri;
import com.keithandthegirl.app.db.KatgProvider;
/**
* Created by dmfrey on 3/19/14.
*/
public class ShowConstants extends AbstractBaseDatabase {
public static final String TABLE_NAME = "show";
public static final Uri CONTENT_URI = Uri.parse( "content://" + KatgProvider.AUTHORITY + "/" + TABLE_NAME );
public static final String CONTENT_TYPE = "vnd.keithandthegirl.cursor.dir/com.keithandthegirl.shows";
public static final String CONTENT_ITEM_TYPE = "vnd.keithandthegirl.cursor.item/com.keithandthegirl.shows";
public static final int ALL = 200;
public static final int SINGLE = 201;
public static final String CREATE_TABLE, DROP_TABLE;
public static final String INSERT_ROW, UPDATE_ROW, DELETE_ROW;
public static final String FIELD_NAME = "name";
public static final String FIELD_NAME_DATA_TYPE = "TEXT";
public static final String FIELD_PREFIX = "prefix";
public static final String FIELD_PREFIX_DATA_TYPE = "TEXT";
public static final String FIELD_VIP = "vip";
public static final String FIELD_VIP_DATA_TYPE = "INTEGER";
public static final String FIELD_SORTORDER = "sortorder";
public static final String FIELD_SORTORDER_DATA_TYPE = "INTEGER";
public static final String FIELD_DESCRIPTION = "description";
public static final String FIELD_DESCRIPTION_DATA_TYPE = "TEXT";
public static final String FIELD_COVERIMAGEURL = "coverimageurl";
public static final String FIELD_COVERIMAGEURL_DATA_TYPE = "TEXT";
public static final String FIELD_COVERIMAGEURL_SQUARED = "coverimageurlsquared";
public static final String FIELD_COVERIMAGEURL_SQUARED_DATA_TYPE = "TEXT";
public static final String FIELD_COVERIMAGEURL_100 = "coverimageurlsquared100";
public static final String FIELD_COVERIMAGEURL_100_DATA_TYPE = "TEXT";
public static final String FIELD_COVERIMAGEURL_200 = "coverimageurlsquared200";
public static final String FIELD_COVERIMAGEURL_200_DATA_TYPE = "TEXT";
public static final String FIELD_FORUMURL = "forumurl";
public static final String FIELD_FORUMURL_DATA_TYPE = "TEXT";
public static final String FIELD_PREVIEWURL = "previewurl";
public static final String FIELD_PREVIEWURL_DATA_TYPE = "TEXT";
public static final String FIELD_EPISODE_COUNT = "episode_count";
public static final String FIELD_EPISODE_COUNT_DATA_TYPE = "INTEGER";
public static final String FIELD_EPISODE_COUNT_MAX = "episode_count_max";
public static final String FIELD_EPISODE_COUNT_MAX_DATA_TYPE = "INTEGER";
public static final String FIELD_EPISODE_COUNT_NEW = "episode_count_new";
public static final String FIELD_EPISODE_COUNT_NEW_DATA_TYPE = "INTEGER";
public static final String[] COLUMN_MAP = { _ID,
FIELD_NAME, FIELD_PREFIX, FIELD_VIP, FIELD_SORTORDER, FIELD_DESCRIPTION, FIELD_COVERIMAGEURL, FIELD_COVERIMAGEURL_SQUARED, FIELD_COVERIMAGEURL_100, FIELD_COVERIMAGEURL_200, FIELD_FORUMURL, FIELD_PREVIEWURL, FIELD_EPISODE_COUNT, FIELD_EPISODE_COUNT_MAX, FIELD_EPISODE_COUNT_NEW,
FIELD_LAST_MODIFIED_DATE
};
static {
StringBuilder createTable = new StringBuilder();
createTable.append( "CREATE TABLE " + TABLE_NAME + " (" );
createTable.append( _ID ).append( " " ).append( FIELD_ID_DATA_TYPE ).append( " " ).append( FIELD_ID_PRIMARY_KEY ).append( ", " );
createTable.append( FIELD_NAME ).append( " " ).append( FIELD_NAME_DATA_TYPE ).append( ", " );
createTable.append( FIELD_PREFIX).append( " " ).append( FIELD_PREFIX_DATA_TYPE ).append( ", " );
createTable.append( FIELD_VIP ).append( " " ).append( FIELD_VIP_DATA_TYPE ).append( ", " );
createTable.append( FIELD_SORTORDER ).append( " " ).append( FIELD_SORTORDER_DATA_TYPE ).append( ", " );
createTable.append( FIELD_DESCRIPTION ).append( " " ).append( FIELD_DESCRIPTION_DATA_TYPE ).append( ", " );
createTable.append( FIELD_COVERIMAGEURL ).append( " " ).append( FIELD_COVERIMAGEURL_DATA_TYPE ).append( ", " );
createTable.append( FIELD_COVERIMAGEURL_SQUARED ).append( " " ).append( FIELD_COVERIMAGEURL_SQUARED_DATA_TYPE ).append( ", " );
createTable.append( FIELD_COVERIMAGEURL_100 ).append( " " ).append( FIELD_COVERIMAGEURL_100_DATA_TYPE ).append( ", " );
createTable.append( FIELD_COVERIMAGEURL_200 ).append( " " ).append( FIELD_COVERIMAGEURL_200_DATA_TYPE ).append( ", " );
createTable.append( FIELD_FORUMURL ).append( " " ).append( FIELD_FORUMURL_DATA_TYPE ).append( ", " );
createTable.append( FIELD_PREVIEWURL ).append( " " ).append( FIELD_PREVIEWURL_DATA_TYPE ).append( ", " );
createTable.append( FIELD_EPISODE_COUNT ).append( " " ).append( FIELD_EPISODE_COUNT_DATA_TYPE ).append( ", " );
createTable.append( FIELD_EPISODE_COUNT_MAX ).append( " " ).append( FIELD_EPISODE_COUNT_MAX_DATA_TYPE ).append( ", " );
createTable.append( FIELD_EPISODE_COUNT_NEW ).append( " " ).append( FIELD_EPISODE_COUNT_NEW_DATA_TYPE ).append( ", " );
createTable.append( FIELD_LAST_MODIFIED_DATE ).append( " " ).append( FIELD_LAST_MODIFIED_DATE_DATA_TYPE );
createTable.append( ");" );
CREATE_TABLE = createTable.toString();
StringBuilder dropTable = new StringBuilder();
dropTable.append( "DROP TABLE IF EXISTS " ).append( TABLE_NAME );
DROP_TABLE = dropTable.toString();
StringBuilder insert = new StringBuilder();
insert.append( "INSERT INTO " ).append( TABLE_NAME ).append( " ( " );
insert.append( _ID ).append( "," );
insert.append( FIELD_NAME ).append( "," );
insert.append( FIELD_PREFIX ).append( "," );
insert.append( FIELD_VIP ).append( "," );
insert.append( FIELD_SORTORDER ).append( "," );
insert.append( FIELD_DESCRIPTION ).append( "," );
insert.append( FIELD_COVERIMAGEURL ).append( "," );
insert.append( FIELD_COVERIMAGEURL_SQUARED ).append( "," );
insert.append( FIELD_COVERIMAGEURL_100 ).append( "," );
insert.append( FIELD_COVERIMAGEURL_200 ).append( "," );
insert.append( FIELD_FORUMURL ).append( "," );
insert.append( FIELD_PREFIX ).append( "," );
insert.append( FIELD_EPISODE_COUNT ).append( "," );
insert.append( FIELD_EPISODE_COUNT_MAX ).append( "," );
insert.append( FIELD_EPISODE_COUNT_NEW ).append( "," );
insert.append( FIELD_LAST_MODIFIED_DATE );
insert.append( " ) " );
insert.append( "VALUES( ?,?,?,?,?,?,?,?,?,?,?,?,?,?,? )" );
INSERT_ROW = insert.toString();
StringBuilder update = new StringBuilder();
update.append( "UPDATE " ).append( TABLE_NAME ).append( " SET " );
update.append( FIELD_NAME ).append( " = ?, " );
update.append( FIELD_PREFIX ).append( " = ?, " );
update.append( FIELD_VIP ).append( " = ?, " );
update.append( FIELD_SORTORDER ).append( " = ?, " );
update.append( FIELD_DESCRIPTION ).append( " = ?, " );
update.append( FIELD_COVERIMAGEURL ).append( " = ?, " );
update.append( FIELD_COVERIMAGEURL_SQUARED ).append( " = ?, " );
update.append( FIELD_COVERIMAGEURL_100 ).append( " = ?, " );
update.append( FIELD_COVERIMAGEURL_200 ).append( " = ?, " );
update.append( FIELD_FORUMURL ).append( " = ?, " );
update.append( FIELD_PREFIX ).append( " = ?, " );
update.append( FIELD_EPISODE_COUNT ).append( " = ?, " );
update.append( FIELD_EPISODE_COUNT_MAX ).append( " = ?, " );
update.append( FIELD_EPISODE_COUNT_NEW ).append( " = ?, " );
update.append( FIELD_LAST_MODIFIED_DATE ).append( " = ? " );
update.append( "WHERE " ).append( _ID ).append( " = ? " );
UPDATE_ROW = update.toString();
StringBuilder delete = new StringBuilder();
delete.append( "DELETE FROM " ).append( TABLE_NAME ).append( " " );
delete.append( "WHERE " ).append( _ID ).append( " = ?" );
DELETE_ROW = delete.toString();
}
}
|
UTF-8
|
Java
| 8,105 |
java
|
ShowConstants.java
|
Java
|
[
{
"context": "andthegirl.app.db.KatgProvider;\n\n/**\n * Created by dmfrey on 3/19/14.\n */\npublic class ShowConstants extend",
"end": 141,
"score": 0.9996576309204102,
"start": 135,
"tag": "USERNAME",
"value": "dmfrey"
}
] | null |
[] |
package com.keithandthegirl.app.db.model;
import android.net.Uri;
import com.keithandthegirl.app.db.KatgProvider;
/**
* Created by dmfrey on 3/19/14.
*/
public class ShowConstants extends AbstractBaseDatabase {
public static final String TABLE_NAME = "show";
public static final Uri CONTENT_URI = Uri.parse( "content://" + KatgProvider.AUTHORITY + "/" + TABLE_NAME );
public static final String CONTENT_TYPE = "vnd.keithandthegirl.cursor.dir/com.keithandthegirl.shows";
public static final String CONTENT_ITEM_TYPE = "vnd.keithandthegirl.cursor.item/com.keithandthegirl.shows";
public static final int ALL = 200;
public static final int SINGLE = 201;
public static final String CREATE_TABLE, DROP_TABLE;
public static final String INSERT_ROW, UPDATE_ROW, DELETE_ROW;
public static final String FIELD_NAME = "name";
public static final String FIELD_NAME_DATA_TYPE = "TEXT";
public static final String FIELD_PREFIX = "prefix";
public static final String FIELD_PREFIX_DATA_TYPE = "TEXT";
public static final String FIELD_VIP = "vip";
public static final String FIELD_VIP_DATA_TYPE = "INTEGER";
public static final String FIELD_SORTORDER = "sortorder";
public static final String FIELD_SORTORDER_DATA_TYPE = "INTEGER";
public static final String FIELD_DESCRIPTION = "description";
public static final String FIELD_DESCRIPTION_DATA_TYPE = "TEXT";
public static final String FIELD_COVERIMAGEURL = "coverimageurl";
public static final String FIELD_COVERIMAGEURL_DATA_TYPE = "TEXT";
public static final String FIELD_COVERIMAGEURL_SQUARED = "coverimageurlsquared";
public static final String FIELD_COVERIMAGEURL_SQUARED_DATA_TYPE = "TEXT";
public static final String FIELD_COVERIMAGEURL_100 = "coverimageurlsquared100";
public static final String FIELD_COVERIMAGEURL_100_DATA_TYPE = "TEXT";
public static final String FIELD_COVERIMAGEURL_200 = "coverimageurlsquared200";
public static final String FIELD_COVERIMAGEURL_200_DATA_TYPE = "TEXT";
public static final String FIELD_FORUMURL = "forumurl";
public static final String FIELD_FORUMURL_DATA_TYPE = "TEXT";
public static final String FIELD_PREVIEWURL = "previewurl";
public static final String FIELD_PREVIEWURL_DATA_TYPE = "TEXT";
public static final String FIELD_EPISODE_COUNT = "episode_count";
public static final String FIELD_EPISODE_COUNT_DATA_TYPE = "INTEGER";
public static final String FIELD_EPISODE_COUNT_MAX = "episode_count_max";
public static final String FIELD_EPISODE_COUNT_MAX_DATA_TYPE = "INTEGER";
public static final String FIELD_EPISODE_COUNT_NEW = "episode_count_new";
public static final String FIELD_EPISODE_COUNT_NEW_DATA_TYPE = "INTEGER";
public static final String[] COLUMN_MAP = { _ID,
FIELD_NAME, FIELD_PREFIX, FIELD_VIP, FIELD_SORTORDER, FIELD_DESCRIPTION, FIELD_COVERIMAGEURL, FIELD_COVERIMAGEURL_SQUARED, FIELD_COVERIMAGEURL_100, FIELD_COVERIMAGEURL_200, FIELD_FORUMURL, FIELD_PREVIEWURL, FIELD_EPISODE_COUNT, FIELD_EPISODE_COUNT_MAX, FIELD_EPISODE_COUNT_NEW,
FIELD_LAST_MODIFIED_DATE
};
static {
StringBuilder createTable = new StringBuilder();
createTable.append( "CREATE TABLE " + TABLE_NAME + " (" );
createTable.append( _ID ).append( " " ).append( FIELD_ID_DATA_TYPE ).append( " " ).append( FIELD_ID_PRIMARY_KEY ).append( ", " );
createTable.append( FIELD_NAME ).append( " " ).append( FIELD_NAME_DATA_TYPE ).append( ", " );
createTable.append( FIELD_PREFIX).append( " " ).append( FIELD_PREFIX_DATA_TYPE ).append( ", " );
createTable.append( FIELD_VIP ).append( " " ).append( FIELD_VIP_DATA_TYPE ).append( ", " );
createTable.append( FIELD_SORTORDER ).append( " " ).append( FIELD_SORTORDER_DATA_TYPE ).append( ", " );
createTable.append( FIELD_DESCRIPTION ).append( " " ).append( FIELD_DESCRIPTION_DATA_TYPE ).append( ", " );
createTable.append( FIELD_COVERIMAGEURL ).append( " " ).append( FIELD_COVERIMAGEURL_DATA_TYPE ).append( ", " );
createTable.append( FIELD_COVERIMAGEURL_SQUARED ).append( " " ).append( FIELD_COVERIMAGEURL_SQUARED_DATA_TYPE ).append( ", " );
createTable.append( FIELD_COVERIMAGEURL_100 ).append( " " ).append( FIELD_COVERIMAGEURL_100_DATA_TYPE ).append( ", " );
createTable.append( FIELD_COVERIMAGEURL_200 ).append( " " ).append( FIELD_COVERIMAGEURL_200_DATA_TYPE ).append( ", " );
createTable.append( FIELD_FORUMURL ).append( " " ).append( FIELD_FORUMURL_DATA_TYPE ).append( ", " );
createTable.append( FIELD_PREVIEWURL ).append( " " ).append( FIELD_PREVIEWURL_DATA_TYPE ).append( ", " );
createTable.append( FIELD_EPISODE_COUNT ).append( " " ).append( FIELD_EPISODE_COUNT_DATA_TYPE ).append( ", " );
createTable.append( FIELD_EPISODE_COUNT_MAX ).append( " " ).append( FIELD_EPISODE_COUNT_MAX_DATA_TYPE ).append( ", " );
createTable.append( FIELD_EPISODE_COUNT_NEW ).append( " " ).append( FIELD_EPISODE_COUNT_NEW_DATA_TYPE ).append( ", " );
createTable.append( FIELD_LAST_MODIFIED_DATE ).append( " " ).append( FIELD_LAST_MODIFIED_DATE_DATA_TYPE );
createTable.append( ");" );
CREATE_TABLE = createTable.toString();
StringBuilder dropTable = new StringBuilder();
dropTable.append( "DROP TABLE IF EXISTS " ).append( TABLE_NAME );
DROP_TABLE = dropTable.toString();
StringBuilder insert = new StringBuilder();
insert.append( "INSERT INTO " ).append( TABLE_NAME ).append( " ( " );
insert.append( _ID ).append( "," );
insert.append( FIELD_NAME ).append( "," );
insert.append( FIELD_PREFIX ).append( "," );
insert.append( FIELD_VIP ).append( "," );
insert.append( FIELD_SORTORDER ).append( "," );
insert.append( FIELD_DESCRIPTION ).append( "," );
insert.append( FIELD_COVERIMAGEURL ).append( "," );
insert.append( FIELD_COVERIMAGEURL_SQUARED ).append( "," );
insert.append( FIELD_COVERIMAGEURL_100 ).append( "," );
insert.append( FIELD_COVERIMAGEURL_200 ).append( "," );
insert.append( FIELD_FORUMURL ).append( "," );
insert.append( FIELD_PREFIX ).append( "," );
insert.append( FIELD_EPISODE_COUNT ).append( "," );
insert.append( FIELD_EPISODE_COUNT_MAX ).append( "," );
insert.append( FIELD_EPISODE_COUNT_NEW ).append( "," );
insert.append( FIELD_LAST_MODIFIED_DATE );
insert.append( " ) " );
insert.append( "VALUES( ?,?,?,?,?,?,?,?,?,?,?,?,?,?,? )" );
INSERT_ROW = insert.toString();
StringBuilder update = new StringBuilder();
update.append( "UPDATE " ).append( TABLE_NAME ).append( " SET " );
update.append( FIELD_NAME ).append( " = ?, " );
update.append( FIELD_PREFIX ).append( " = ?, " );
update.append( FIELD_VIP ).append( " = ?, " );
update.append( FIELD_SORTORDER ).append( " = ?, " );
update.append( FIELD_DESCRIPTION ).append( " = ?, " );
update.append( FIELD_COVERIMAGEURL ).append( " = ?, " );
update.append( FIELD_COVERIMAGEURL_SQUARED ).append( " = ?, " );
update.append( FIELD_COVERIMAGEURL_100 ).append( " = ?, " );
update.append( FIELD_COVERIMAGEURL_200 ).append( " = ?, " );
update.append( FIELD_FORUMURL ).append( " = ?, " );
update.append( FIELD_PREFIX ).append( " = ?, " );
update.append( FIELD_EPISODE_COUNT ).append( " = ?, " );
update.append( FIELD_EPISODE_COUNT_MAX ).append( " = ?, " );
update.append( FIELD_EPISODE_COUNT_NEW ).append( " = ?, " );
update.append( FIELD_LAST_MODIFIED_DATE ).append( " = ? " );
update.append( "WHERE " ).append( _ID ).append( " = ? " );
UPDATE_ROW = update.toString();
StringBuilder delete = new StringBuilder();
delete.append( "DELETE FROM " ).append( TABLE_NAME ).append( " " );
delete.append( "WHERE " ).append( _ID ).append( " = ?" );
DELETE_ROW = delete.toString();
}
}
| 8,105 | 0.645898 | 0.638618 | 155 | 51.290321 | 41.948196 | 289 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.245161 | false | false |
13
|
12d9a38c9dfc45beab3429ff3359c0cdb533b1eb
| 31,344,671,327,387 |
104ade9cffa4910e1d56300ca86ad8d9004e461c
|
/Second_hand_car_backstage/ssm_car_service/src/main/java/com/yzp/service/impl/ProductServiceImpl.java
|
da39c01be37418dd42d6f800a39cd7b53963ac4a
|
[] |
no_license
|
termzf/repositorycar
|
https://github.com/termzf/repositorycar
|
bf5c5535e4f802bcffb98a4ed4c2c064dbc62980
|
d585fb94a0a23028757341e062ffd189b4612d6c
|
refs/heads/master
| 2020-04-18T10:12:55.297000 | 2019-04-17T23:49:46 | 2019-04-17T23:49:46 | 167,460,455 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.yzp.service.impl;
import com.github.pagehelper.PageHelper;
import com.yzp.dao.ProductDao;
import com.yzp.domain.Car;
import com.yzp.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 二手车(产品)实现类
*/
@Service("productService")
public class ProductServiceImpl implements ProductService {
@Autowired
private ProductDao productDao;
/**
* 实现分页,展示所有的二手车
* @return
*/
public List<Car> findAll(int page,int size) {
// PageHelper.startPage(page,size);
return productDao.findAll();
}
/**
* 单车信息
* @param cid
* @return
*/
public Car findOne(String cid) {
return productDao.findOne(cid);
}
/**
* 修改单车几个小信息
* @param car
*/
public void updateOne(Car car) {
productDao.updateCar(car);
}
/**
* 添加详细信息
* @param car
*/
public void insertOne(Car car) {
productDao.insertCar(car);
}
}
|
UTF-8
|
Java
| 1,134 |
java
|
ProductServiceImpl.java
|
Java
|
[] | null |
[] |
package com.yzp.service.impl;
import com.github.pagehelper.PageHelper;
import com.yzp.dao.ProductDao;
import com.yzp.domain.Car;
import com.yzp.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 二手车(产品)实现类
*/
@Service("productService")
public class ProductServiceImpl implements ProductService {
@Autowired
private ProductDao productDao;
/**
* 实现分页,展示所有的二手车
* @return
*/
public List<Car> findAll(int page,int size) {
// PageHelper.startPage(page,size);
return productDao.findAll();
}
/**
* 单车信息
* @param cid
* @return
*/
public Car findOne(String cid) {
return productDao.findOne(cid);
}
/**
* 修改单车几个小信息
* @param car
*/
public void updateOne(Car car) {
productDao.updateCar(car);
}
/**
* 添加详细信息
* @param car
*/
public void insertOne(Car car) {
productDao.insertCar(car);
}
}
| 1,134 | 0.630682 | 0.630682 | 53 | 18.924528 | 16.54023 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.320755 | false | false |
13
|
e5c2573ab643ff5e8b4c9b51cc9c15568bac80f9
| 2,499,670,976,680 |
50d6e2555ee69bede810af77fc682035e1e954c1
|
/app/src/main/java/com/stepin/coronaapp/api/NetworkResponse.java
|
134dbd5b2984c9aaba5ff5c06e06ff6369c28d42
|
[] |
no_license
|
Alexandr720/Android-Corona
|
https://github.com/Alexandr720/Android-Corona
|
a2e3a9dc09f05b50a5ead9ef79df5c74abdababe
|
159182b1040597707b10c92df40c19b36636ed10
|
refs/heads/master
| 2022-12-16T05:49:08.348000 | 2020-09-02T23:00:53 | 2020-09-02T23:00:53 | 292,283,296 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.stepin.coronaapp.api;
import com.stepin.coronaapp.model.ErrorMessage;
public interface NetworkResponse<T> {
void onResponse(T obj, ErrorMessage error);
//void onError(ErrorMessage error);
}
|
UTF-8
|
Java
| 213 |
java
|
NetworkResponse.java
|
Java
|
[] | null |
[] |
package com.stepin.coronaapp.api;
import com.stepin.coronaapp.model.ErrorMessage;
public interface NetworkResponse<T> {
void onResponse(T obj, ErrorMessage error);
//void onError(ErrorMessage error);
}
| 213 | 0.765258 | 0.765258 | 9 | 22.666666 | 20.477631 | 47 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.555556 | false | false |
13
|
7adbd12aac71dcbda0117b0e3942f9f386fb1bd2
| 26,989,574,516,225 |
9833d9da092af7ccac9cd878c16ce5eaf533b3ed
|
/DH2New/src/main/java/com/dhub/dao/RolesDao.java
|
0522dcef6487a2dafc1adcc6ae607aa2a762d596
|
[] |
no_license
|
SamselD/developersH
|
https://github.com/SamselD/developersH
|
3c64d6623ac01877adecc769ac69b28ffe7c24a1
|
e54509876ebb55ba4fae7d2814e0fbd96c630647
|
refs/heads/master
| 2021-01-19T18:36:20.508000 | 2017-04-15T19:28:51 | 2017-04-15T19:28:51 | 88,368,113 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.dhub.dao;
import java.util.List;
import com.dhub.beans.Roles;
public interface RolesDao {
public List<Roles> getAllRoles();
public void createRole(Roles r);
public void updateRole(Roles r);
public void deleteRole(Roles r);
}
|
UTF-8
|
Java
| 244 |
java
|
RolesDao.java
|
Java
|
[] | null |
[] |
package com.dhub.dao;
import java.util.List;
import com.dhub.beans.Roles;
public interface RolesDao {
public List<Roles> getAllRoles();
public void createRole(Roles r);
public void updateRole(Roles r);
public void deleteRole(Roles r);
}
| 244 | 0.758197 | 0.758197 | 12 | 19.333334 | 14.073221 | 34 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.916667 | false | false |
13
|
9586fd34b859389cc05a0293ceab159bb25e9fd9
| 33,517,924,810,643 |
08d3642771ec1f71c404753daa368e4d216ac129
|
/src/com/fenmiao/demo/test/CodeTest03.java
|
a78d297f228cbc0e3452f3e3c3252e18c48e320e
|
[] |
no_license
|
chw-foreverone/TimeDemo1
|
https://github.com/chw-foreverone/TimeDemo1
|
db498159f193e53655ba7d7bc60387e890ce418b
|
ece6f7c892f7f786e62f31457b18f1b7f8e46962
|
refs/heads/master
| 2022-11-24T14:04:59.056000 | 2020-07-31T06:40:11 | 2020-07-31T06:40:11 | 281,299,743 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.fenmiao.demo.test;
import com.fenmiao.demo.entity.User;
import java.util.*;
public class CodeTest03 {
public static void main(String[] args) {
test();
}
public static void test() {
List<User> list = new ArrayList<>();
User user1 = new User("127", 2);
User user2 = new User("126", 4);
User user3 = new User("124", 2);
User user4 = new User("121", 2);
User user5 = new User("123", 5);
User user6 = new User("121", 3);
list.add(user1);
list.add(user2);
list.add(user3);
list.add(user4);
list.add(user5);
list.add(user6);
HashMap<Object, Object> map = new HashMap<>();
list.forEach(a -> {
for (User user : list) {
if (a.getName().equals(user.getName())) {
if (a.getScore() > user.getScore()) {
map.put(a.getName(), a.getScore());
}
}
}
map.computeIfAbsent(a.getName(), k -> a.getScore());
});
System.out.println(map.keySet());
System.out.println(map.values());
}
}
|
UTF-8
|
Java
| 1,181 |
java
|
CodeTest03.java
|
Java
|
[] | null |
[] |
package com.fenmiao.demo.test;
import com.fenmiao.demo.entity.User;
import java.util.*;
public class CodeTest03 {
public static void main(String[] args) {
test();
}
public static void test() {
List<User> list = new ArrayList<>();
User user1 = new User("127", 2);
User user2 = new User("126", 4);
User user3 = new User("124", 2);
User user4 = new User("121", 2);
User user5 = new User("123", 5);
User user6 = new User("121", 3);
list.add(user1);
list.add(user2);
list.add(user3);
list.add(user4);
list.add(user5);
list.add(user6);
HashMap<Object, Object> map = new HashMap<>();
list.forEach(a -> {
for (User user : list) {
if (a.getName().equals(user.getName())) {
if (a.getScore() > user.getScore()) {
map.put(a.getName(), a.getScore());
}
}
}
map.computeIfAbsent(a.getName(), k -> a.getScore());
});
System.out.println(map.keySet());
System.out.println(map.values());
}
}
| 1,181 | 0.489416 | 0.45724 | 44 | 25.84091 | 18.686338 | 64 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.727273 | false | false |
13
|
08364f3cd513c9acab81caabe72dab7258792cba
| 10,273,561,813,711 |
bb97c69c2a65125888179f9535193e05ee32b635
|
/iterators/FibonacciIterator.java
|
b6b30272ad8efb92a939a8937ee8eb3297b1f6d1
|
[] |
no_license
|
cusuh/data-structures-algorithms
|
https://github.com/cusuh/data-structures-algorithms
|
10fb11c804a07c8b173efe26d917224b4fb49a2d
|
09b9cece8e737c8880fe6039122b01b878a5d54f
|
refs/heads/master
| 2016-08-04T12:17:34.043000 | 2015-10-29T01:44:00 | 2015-10-29T01:44:00 | 30,951,332 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import java.util.Iterator;
import java.util.NoSuchElementException;
/**
* This is a class that will allow you to iterate through the first n
* Fibonacci elements
* @author kushagramansingh
*
*/
public class FibonacciIterator implements Iterator<Integer> {
private Integer n;
private Integer current;
private Integer runningValue = 1;
private Integer previousValue = 0;
public FibonacciIterator(Integer n) {
current = 1;
this.n = n;
}
@Override
public boolean hasNext() {
return (current <= n);
}
@Override
public Integer next() {
Integer fib;
if (!this.hasNext()) {
throw new NoSuchElementException();
} else if (current == 1) {
fib = 1;
} else {
fib = previousValue + runningValue;
previousValue = runningValue;
runningValue = fib;
}
current++;
return fib;
}
}
|
UTF-8
|
Java
| 819 |
java
|
FibonacciIterator.java
|
Java
|
[
{
"context": "rough the first n\n * Fibonacci elements\n * @author kushagramansingh\n *\n */\npublic class FibonacciIterator implements ",
"end": 192,
"score": 0.9950048327445984,
"start": 176,
"tag": "USERNAME",
"value": "kushagramansingh"
}
] | null |
[] |
import java.util.Iterator;
import java.util.NoSuchElementException;
/**
* This is a class that will allow you to iterate through the first n
* Fibonacci elements
* @author kushagramansingh
*
*/
public class FibonacciIterator implements Iterator<Integer> {
private Integer n;
private Integer current;
private Integer runningValue = 1;
private Integer previousValue = 0;
public FibonacciIterator(Integer n) {
current = 1;
this.n = n;
}
@Override
public boolean hasNext() {
return (current <= n);
}
@Override
public Integer next() {
Integer fib;
if (!this.hasNext()) {
throw new NoSuchElementException();
} else if (current == 1) {
fib = 1;
} else {
fib = previousValue + runningValue;
previousValue = runningValue;
runningValue = fib;
}
current++;
return fib;
}
}
| 819 | 0.689866 | 0.683761 | 42 | 18.5 | 16.432039 | 69 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.52381 | false | false |
13
|
85a906eb1c6cb9f7ee5cbe4370c6004b8d074451
| 16,226,386,496,993 |
5c80a2290b451323eb378cab2d5c4f632bec2e11
|
/factory/Car.java
|
b0bc9c33dc55689a481ddc57dc1f8b6e6659c80f
|
[] |
no_license
|
heshamsalman/design-patterns
|
https://github.com/heshamsalman/design-patterns
|
85a19da3f8da60956881188e3d878477f723f333
|
2e3cac9d63a6de499aa1f9acaf5be29e66c8ec2e
|
refs/heads/master
| 2021-01-18T20:11:33.365000 | 2015-04-24T05:08:53 | 2015-04-24T05:08:53 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package factory;
/**
* A car is an implementation of automobile.
*
*/
public class Car implements Automobile
{
public void display() {
System.out.println("It is a Toyota Camry.");
}
}
|
UTF-8
|
Java
| 212 |
java
|
Car.java
|
Java
|
[] | null |
[] |
package factory;
/**
* A car is an implementation of automobile.
*
*/
public class Car implements Automobile
{
public void display() {
System.out.println("It is a Toyota Camry.");
}
}
| 212 | 0.617925 | 0.617925 | 13 | 14.461538 | 17.830894 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.153846 | false | false |
13
|
b8f364d63f7799ceda132ba63923fcfd76d844c6
| 9,242,769,663,283 |
6ea524bf8ce2eb951797d293572bbbd94afe51ae
|
/app/src/main/java/com/de/dmdk/MembershipEntryActivity.java
|
f78741e010f7e9314c3a900b2c6777fa5d246b33
|
[] |
no_license
|
VijayDePrabu/DMDK
|
https://github.com/VijayDePrabu/DMDK
|
5871fc09c63ccedc16158e761c7ab44aa9c2eced
|
f4203a7210285aab7503a83ab6a1569d166c278c
|
refs/heads/master
| 2021-01-11T02:46:06.588000 | 2016-11-14T02:40:12 | 2016-11-14T02:40:12 | 70,928,915 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.de.dmdk;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.pdf.PdfDocument;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Environment;
import android.print.PrintAttributes;
import android.print.PrintDocumentAdapter;
import android.print.PrintJob;
import android.print.PrintManager;
import com.de.dmdk.view.InstantAutoCompleteTextView;
import android.print.PrinterInfo;
import android.print.pdf.PrintedPdfDocument;
import android.support.v4.print.PrintHelper;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.text.InputType;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.graphics.pdf.PdfDocument.*;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.commonsware.cwac.cam2.CameraActivity;
import com.commonsware.cwac.cam2.Facing;
import com.commonsware.cwac.cam2.ZoomStyle;
import com.de.dmdk.languagehelper.LocaleHelper;
import com.de.dmdk.membership.MemberDatum;
import com.de.dmdk.permissions.MarshMallowPermission;
import com.de.dmdk.printhelper.PdfDocumentAdapter;
import com.de.dmdk.printhelper.PrintJobMonitorService;
import com.de.dmdk.printhelper.USBAdapter;
import com.google.android.gms.appindexing.Action;
import com.google.android.gms.appindexing.AppIndex;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.Query;
import com.google.firebase.database.ValueEventListener;
import com.hp.mss.hpprint.activity.PrintPluginManagerActivity;
import com.hp.mss.hpprint.model.ImagePrintItem;
import com.hp.mss.hpprint.model.PrintItem;
import com.hp.mss.hpprint.model.PrintJobData;
import com.hp.mss.hpprint.model.asset.ImageAsset;
import com.hp.mss.hpprint.util.PrintUtil;
import com.pixplicity.easyprefs.library.Prefs;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Locale;
import java.util.regex.Pattern;
import static com.de.dmdk.R.id.autoCompleteTVTownCity;
import static com.de.dmdk.R.id.editTVoterId;
import static com.de.dmdk.R.id.idCardLayout;
public class MembershipEntryActivity extends BaseActivity implements View.OnClickListener,TextWatcher{
private boolean isFormEditable;
private View idCardView;
private LinearLayout mLinearLayout;
private PrintManager mgr = null;
private ImageView imageVPhoto, imageVPhotoPrint;
private File file;
private Bitmap memberBitmap ;
/* Input Fields of ID Card*/
private Spinner spinGender;
private InstantAutoCompleteTextView autoCompleteTVEntryFormPanchayat;
private InstantAutoCompleteTextView autoCompleteTVTownCity;
private InstantAutoCompleteTextView autoCompleteTVDistrict;
private int purpose;
PanchayatDetailsAdapter adapter ;
/**
* ATTENTION: This was auto-generated to implement the App Indexing API.
* See https://g.co/AppIndexing/AndroidStudio for more information.
*/
private GoogleApiClient client;
/* Firebase elements */
/* Fire Database */
private DatabaseReference databaseRootReference = FirebaseDatabase.getInstance().getReference();
private DatabaseReference databaseMemberDataReference = FirebaseDatabase.getInstance().getReference("member_data");
private RelativeLayout few;
private EditText editTPhone;
private EditText editTName;
private EditText editTDOB;
private EditText editTHusband;
private EditText editTVoterId;
private EditText editTWard;
private EditText editTMembershipId;
private EditText editTDate;
private InstantAutoCompleteTextView editTMLA;
private InstantAutoCompleteTextView editTMP;
private Button btnPreview;
private boolean isBackMenuAvailable, isPrintMenuAvailable, isClearMenuAvailable;
private int idCardRId;
private Menu menu;
private PanchayatDetails selectedPanchayat;
private MpMlaDistrict selectedMpMlaDistrict;
private String tempDOB;
private boolean isPushMemberData;
private DatabaseReference updateMemberRef;
@Override
protected void onCreate(Bundle savedInstanceState) {
LocaleHelper.setLocale(this,"ta");
super.onCreate(savedInstanceState);
getIntentCheck();
setContentView(R.layout.activity_new_membership_entry);
initView();
setUpListeners();
if(purpose == DMDKConstants.PURPOSE_UPDATE_RECORDS) {
showDialogs("Update Member Record","Enter the MemberID");
}else if(purpose == DMDKConstants.PURPOSE_PRINT) {
showDialogs("Print","Enter the MemberID");
}
mgr = (PrintManager) getSystemService(PRINT_SERVICE);
client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
/* get all mp, mla,district data*/
databaseRootReference.child("mp_mla_district").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
System.out.println("VIJAY "+snapshot.getValue()); //prints "Do you have data? You'll love Firebase."
Log.e("Count " ,""+snapshot.getChildrenCount());
ArrayList<String> mp = new ArrayList<String>();
ArrayList<String> mla = new ArrayList<String>();
/*
ArrayList<String> mpmlaDistrict = new ArrayList<String>();
*/
final ArrayList<MpMlaDistrict> mpMlaDistrictDetailFull = new ArrayList<MpMlaDistrict>();
for (DataSnapshot single : snapshot.getChildren()) {
MpMlaDistrict mpMlaDistrictDetails= single.getValue(MpMlaDistrict.class);
Log.e("village_panchayat_name" ,""+mpMlaDistrictDetails.getMp_tamil());
if(!TextUtils.isEmpty(mpMlaDistrictDetails.getMp())) {
mp.add(mpMlaDistrictDetails.getMp());
}
mla.add(mpMlaDistrictDetails.getMla());
/*
mpmlaDistrict.add(mpMlaDistrictDetails.getDistrictTamil());
*/
mpMlaDistrictDetailFull.add(mpMlaDistrictDetails);
}
/*PanchayatDetailsAdapter adapter =
new PanchayatDetailsAdapter(MembershipEntryActivity.this, R.layout.list_row, panchayatDetail);*/
ArrayAdapter<String> adapter =
new ArrayAdapter<String>(MembershipEntryActivity.this, R.layout.list_row,R.id.txtTitle, mp);
editTMP.setAdapter(adapter);
editTMP.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
String selected = (String) arg0.getAdapter().getItem(arg2);
for(MpMlaDistrict mpMlaDistrict:mpMlaDistrictDetailFull)
{
if(selected.equalsIgnoreCase(mpMlaDistrict.getMp())){
/*Toast.makeText(MembershipEntryActivity.this,
"Clicked " + arg2 + " name: " + panchayat.getVillage_panchayat_name_tamil(),
Toast.LENGTH_SHORT).show();*/
selectedMpMlaDistrict = mpMlaDistrict;
editTMP.setText(mpMlaDistrict.getMp_tamil());
autoCompleteTVDistrict.setText(mpMlaDistrict.getDistrict_tamil());
// autoCompleteTVTownCity.setText(mpMlaDistrict.getDistrict_name());
}
}
}
});
/*editTMP.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
*//*if((TextUtils.isEmpty(s.toString()) || (null==selectedMpMlaDistrict)) || (!s.toString().equalsIgnoreCase(selectedMpMlaDistrict.getDistrict()))){
selectedMpMlaDistrict = null;
autoCompleteTVDistrict.setText("");
}*//*
}
});*/
/* mla */
ArrayAdapter<String> adaptereditTMLA =
new ArrayAdapter<String>(MembershipEntryActivity.this, R.layout.list_row,R.id.txtTitle, mla);
editTMLA.setAdapter(adaptereditTMLA);
editTMLA.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
String selected = (String) arg0.getAdapter().getItem(arg2);
for(MpMlaDistrict mpMlaDistrict:mpMlaDistrictDetailFull)
{
if(selected.equalsIgnoreCase(mpMlaDistrict.getMla())){
/*Toast.makeText(MembershipEntryActivity.this,
"Clicked " + arg2 + " name: " + panchayat.getVillage_panchayat_name_tamil(),
Toast.LENGTH_SHORT).show();*/
selectedMpMlaDistrict = mpMlaDistrict;
editTMLA.setText(mpMlaDistrict.getMla_tamil());
autoCompleteTVDistrict.setText(mpMlaDistrict.getDistrict_tamil());
// autoCompleteTVTownCity.setText(mpMlaDistrict.getDistrict_name());
}
}
}
});
/* editTMP.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
*//* if((TextUtils.isEmpty(s.toString()) || (null==selectedMpMlaDistrict)) || (!s.toString().equalsIgnoreCase(selectedMpMlaDistrict.getDistrict()))){
selectedMpMlaDistrict = null;
autoCompleteTVDistrict.setText("");
}*//*
}
});*/
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
/* get all panchayat data*/
databaseRootReference.child("autocomplete").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
System.out.println("VIJAY "+snapshot.getValue()); //prints "Do you have data? You'll love Firebase."
Log.e("Count " ,""+snapshot.getChildrenCount());
ArrayList<String> panchayatName = new ArrayList<String>();
ArrayList<String> panchayatDistrict = new ArrayList<String>();
final ArrayList<PanchayatDetails> panchayatDetailFull = new ArrayList<PanchayatDetails>();
for (DataSnapshot single : snapshot.getChildren()) {
PanchayatDetails panchayatDetails= single.getValue(PanchayatDetails.class);
Log.e("village_panchayat_name" ,""+panchayatDetails.getVillage_panchayat_name_tamil());
panchayatName.add(panchayatDetails.getVillage_panchayat_name());
panchayatDetailFull.add(panchayatDetails);
}
/*PanchayatDetailsAdapter adapter =
new PanchayatDetailsAdapter(MembershipEntryActivity.this, R.layout.list_row, panchayatDetail);*/
ArrayAdapter<String> adapter =
new ArrayAdapter<String>(MembershipEntryActivity.this, R.layout.list_row,R.id.txtTitle, panchayatName);
autoCompleteTVEntryFormPanchayat.setAdapter(adapter);
autoCompleteTVEntryFormPanchayat.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
String selected = (String) arg0.getAdapter().getItem(arg2);
for(PanchayatDetails panchayat:panchayatDetailFull)
{
if(selected.equalsIgnoreCase(panchayat.getVillage_panchayat_name())){
/*Toast.makeText(MembershipEntryActivity.this,
"Clicked " + arg2 + " name: " + panchayat.getVillage_panchayat_name_tamil(),
Toast.LENGTH_SHORT).show();*/
selectedPanchayat = panchayat;
autoCompleteTVEntryFormPanchayat.setText(panchayat.getVillage_panchayat_name_tamil());
autoCompleteTVDistrict.setText(panchayat.getDistrict_name_tamil());
autoCompleteTVTownCity.setText(panchayat.getDistrict_name_tamil());
}
}
}
});
autoCompleteTVEntryFormPanchayat.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
if((TextUtils.isEmpty(s.toString()) || (null==selectedPanchayat)) || (!s.toString().equalsIgnoreCase(selectedPanchayat.getVillage_panchayat_name()))){
selectedPanchayat = null;
autoCompleteTVDistrict.setText("");
autoCompleteTVTownCity.setText("");
}
}
});
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
/* Auto complete*/
/* databaseRootReference.child("0").orderByChild("village_panchayat_name").*//*startAt("Na").limitToFirst(6).*//*addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
PanchayatDetails panchayatDetails= dataSnapshot.getValue(PanchayatDetails.class);
Log.e("village_panchayat_name" ,""+panchayatDetails.getVillage_panchayat_name());
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});*/
}
private void getIntentCheck() {
Intent intent = getIntent();
purpose = intent.getIntExtra(DMDKConstants.PURPOSE,DMDKConstants.PURPOSE_NEW_REGISTER);
}
private void setUpListeners() {
imageVPhoto.setOnClickListener(this);
autoCompleteTVEntryFormPanchayat.addTextChangedListener(this);
String[] genderArray= getResources().getStringArray(R.array.genderArray);
ArrayAdapter<String> genderAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, genderArray);
genderAdapter.setDropDownViewResource(R.layout.spinner_dropdown);
spinGender.setAdapter(genderAdapter);
editTPhone.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if(!hasFocus) {
if(TextUtils.isEmpty(editTPhone.getText().toString()) && (!isValidMobile(editTPhone.getText().toString()))){
showAlertDialog("Enter valid phone number");
}
}
}
});
editTDOB.setOnClickListener(this);
editTPhone.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
editTDOB.setText("");
}
});
editTDOB.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
if((!TextUtils.isEmpty(editTPhone.getText().toString().trim()) && (!TextUtils.isEmpty(s.toString()))) && (!s.toString().equalsIgnoreCase(tempDOB))){
tempDOB= s.toString();
if((purpose == DMDKConstants.PURPOSE_NEW_REGISTER)) {
verifyPhoneDOB();
}
}
}
});
btnPreview.setOnClickListener(this);
}
private boolean isValidMobile(String phone2)
{
boolean check=false;
if(!Pattern.matches("[a-zA-Z]+", phone2))
{
if(phone2.length() < 6 || phone2.length() > 13)
{
check = false;
editTPhone.setError(editTPhone.getText());
}
else
{
check = true;
}
}
else
{
check=false;
}
return check;
}
private void verifyPhoneDOB() {
Query queryRef = databaseMemberDataReference.orderByChild("phone").equalTo(editTPhone.getText().toString().trim())/*.orderByChild("dob")*/;
queryRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if(dataSnapshot.getValue() != null){
for(DataSnapshot childDataSnapshot:dataSnapshot.getChildren()){
MemberDatum memberDatum= childDataSnapshot.getValue(MemberDatum.class);
if(memberDatum.getDob().equalsIgnoreCase(editTDOB.getText().toString().trim())){
// Toast.makeText(getApplicationContext(),memberDatum.getName()+" Member already found!!!",Toast.LENGTH_SHORT).show();
showAlertDialog("Member "+memberDatum.getName()+" already found!!!");
btnPreview.setEnabled(false);
isPushMemberData = false;
return;
}else{
// Toast.makeText(getApplicationContext(),"Phone number already used!!",Toast.LENGTH_SHORT).show();
if(isClearMenuAvailable) {
showAlertDialog("Phone number already used!!");
btnPreview.setEnabled(false);
}
isPushMemberData = false;
return;
}
}
}else{
// Toast.makeText(getApplicationContext(),"New Memeber ID created!!",Toast.LENGTH_SHORT).show();
if(isClearMenuAvailable) {
editTMembershipId.setText(""+getLastMemberID()+1);
}
isPushMemberData = true;
btnPreview.setEnabled(true);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
private void initView() {
mLinearLayout = (LinearLayout) findViewById(R.id.linearLayout_focus);
imageVPhoto = (ImageView) findViewById(R.id.imageVPhoto);
spinGender = (Spinner)findViewById(R.id.gender);
autoCompleteTVEntryFormPanchayat = (InstantAutoCompleteTextView)findViewById(R.id.autoCompleteTVPanchayat);
autoCompleteTVTownCity = (InstantAutoCompleteTextView)findViewById(R.id.autoCompleteTVTownCity);
autoCompleteTVDistrict = (InstantAutoCompleteTextView)findViewById(R.id.autoCompleteTVDistrict);
// dotLoader = (DotLoader) findViewById(R.id.dotLoader);
few = (RelativeLayout)findViewById( R.id.few );
editTPhone = (EditText)findViewById( R.id.editTPhone );
editTName = (EditText)findViewById( R.id.editTName );
editTDOB = (EditText)findViewById( R.id.editTDOB );
editTHusband = (EditText)findViewById( R.id.editTHusband );
editTVoterId = (EditText)findViewById( R.id.editTVoterId );
editTWard = (EditText)findViewById( R.id.editTWard );
editTMembershipId = (EditText)findViewById( R.id.editTMembershipId );
editTDate = (EditText)findViewById( R.id.editTDate );
editTMLA = (InstantAutoCompleteTextView)findViewById( R.id.editTMLA );
editTMP = (InstantAutoCompleteTextView)findViewById( R.id.editTMP );
btnPreview = (Button) findViewById(R.id.btnPreview);
isBackMenuAvailable= false;
isPrintMenuAvailable= false;
isClearMenuAvailable = true;
invalidateOptionsMenu();
Calendar c = Calendar.getInstance();
int mYear = c.get(Calendar.YEAR);
int mMonth = c.get(Calendar.MONTH);
int mDay = c.get(Calendar.DAY_OF_MONTH);
editTDate.setText(new StringBuilder()
.append(mDay).append("/")
// Month is 0 based so add 1
.append(mMonth + 1).append("/")
.append(mYear).append(" "));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
new MenuInflater(this).inflate(R.menu.membershipform_menu, menu);
this.menu= menu;
return super.onCreateOptionsMenu(menu);
}
RelativeLayout idCard;
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.back:
View currentFocusedView = getCurrentFocus();
if (currentFocusedView != null) currentFocusedView.clearFocus();
if (mLinearLayout != null) {
mLinearLayout.requestFocus();
}
idCardView = (View) findViewById(idCardLayout);
idCardView.setVisibility(View.VISIBLE);
RelativeLayout layout=(RelativeLayout)findViewById(R.id.few);
layout.removeView(idCard);
isPrintMenuAvailable= false;
isBackMenuAvailable = false;
isClearMenuAvailable = true;
invalidateOptionsMenu();
return true;
case R.id.action_print:
if(idCard!=null) {
Bitmap bitmap = Bitmap.createBitmap(convertDpToPx(332), convertDpToPx(472),
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
/* temporrily remove icons borders and secretart signature for printing*/
View printPartView= idCard;
printPartView.setBackgroundResource(R.drawable.print_part_border);
printPartView.findViewById(R.id.imageVFlagIcon).setVisibility(View.INVISIBLE);
printPartView.findViewById(R.id.imageVSymbolIcon).setVisibility(View.INVISIBLE);
printPartView.findViewById(R.id.textVGeneralSecretary).setVisibility(View.INVISIBLE);
printPartView.draw(canvas);
/* back to how it is was before sending printing part*/
idCard.setBackgroundResource(R.drawable.id_card_border);
idCard.setPadding(convertDpToPx(32), convertDpToPx(16),convertDpToPx(32), 0);
idCard.findViewById(R.id.imageVFlagIcon).setVisibility(View.VISIBLE);
idCard.findViewById(R.id.imageVSymbolIcon).setVisibility(View.VISIBLE);
idCard.findViewById(R.id.textVGeneralSecretary).setVisibility(View.VISIBLE);
PrintHelper help = new PrintHelper(this);
help.setScaleMode(PrintHelper.SCALE_MODE_FIT);
help.printBitmap("IDCard", bitmap);
// old code
/*PrintHelper help = new PrintHelper(this);
help.setScaleMode(PrintHelper.SCALE_MODE_FIT);
help.printBitmap("IDCard", bitmap);*/
// github library
/* ImageAsset */
/* ImageAsset bitmapAsset = new ImageAsset(this, bitmap, ImageAsset.MeasurementUnits.INCHES, 3.46f,4.92f);
*//* PrintItem *//*
// PrintItem printItemDefault = new ImagePrintItem(PrintItem.ScaleType.CENTER, bitmapAsset);
PrintItem printItemB7 = new ImagePrintItem(PrintAttributes.MediaSize.ISO_B7, PrintItem.ScaleType.FIT, bitmapAsset);
*//*PrintJobData*//*
PrintJobData printJobData = new PrintJobData(this, printItemB7);
printJobData.setJobName("Example");
PrintAttributes printAttributes = new PrintAttributes.Builder()
.setMediaSize(printItemB7.getMediaSize())
.build();
printJobData.setPrintDialogOptions(printAttributes);
PrintUtil.setPrintJobData(printJobData);
if(Build.VERSION.SDK_INT >= 19) {
Intent intent = new Intent(this, PrintPluginManagerActivity.class);
startActivity(intent);
}*/
/*Print*/
/*PrintUtil.print(this);*/
// posifix code
/*USBAdapter usbAdapter = new USBAdapter();
usbAdapter.printBitmap(this,bitmap);*/
}
return true;
case R.id.clear_form:
ViewGroup group = (ViewGroup)findViewById(idCardLayout);
for (int i = 0, count = group.getChildCount(); i < count; ++i) {
View view = group.getChildAt(i);
if (view instanceof EditText) {
((EditText)view).setText("");
}
}
imageVPhoto.setImageDrawable(getResources().getDrawable(android.R.drawable.ic_menu_camera));
return true;
/*case R.id.action_options:
return true;
*/
case R.id.action_about:
if(idCard!=null) {
Bitmap bitmap = Bitmap.createBitmap(convertDpToPx(332), convertDpToPx(472),
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
idCard.draw(canvas);
/* ImageAsset */
ImageAsset bitmapAsset = new ImageAsset(this, bitmap, ImageAsset.MeasurementUnits.INCHES, 3.46f,4.92f);
// PrintItem printItemDefault = new ImagePrintItem(PrintItem.ScaleType.CENTER, bitmapAsset);
PrintItem printItemB7 = new ImagePrintItem(PrintAttributes.MediaSize.ISO_B7, PrintItem.ScaleType.FIT, bitmapAsset);
PrintJobData printJobData = new PrintJobData(this, printItemB7);
printJobData.setJobName("Example");
PrintAttributes printAttributes = new PrintAttributes.Builder()
.setMediaSize(printItemB7.getMediaSize())
.build();
printJobData.setPrintDialogOptions(printAttributes);
PrintUtil.setPrintJobData(printJobData);
if(Build.VERSION.SDK_INT >= 19) {
Intent intent = new Intent(this, PrintPluginManagerActivity.class);
startActivity(intent);
}
/*Print*/
// PrintUtil.print(this);
}
/*Toast.makeText(this,"This is a demo app, work in progress!",Toast.LENGTH_SHORT).show();*/
return true;
default:
// If we got here, the user's action was not recognized.
// Invoke the superclass to handle it.
return super.onOptionsItemSelected(item);
}
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
MenuItem itemPrint = menu.findItem(R.id.action_print);
MenuItem itemBack = menu.findItem(R.id.back);
MenuItem itemClear = menu.findItem(R.id.clear_form);
enablePrintMenu(itemPrint,isPrintMenuAvailable);
enableMenu(itemBack,isBackMenuAvailable);
enableMenu(itemClear,isClearMenuAvailable);
return true;
}
/* enable menu and change alpha value */
private void enablePrintMenu(MenuItem item,boolean isMenuAvailable) {
if (isMenuAvailable) {
item.setEnabled(true);
item.getIcon().setAlpha(255);
} else {
// disabled
item.setEnabled(false);
item.getIcon().setAlpha(130);
}
}
/* enable menu and change visibility */
private void enableMenu(MenuItem item,boolean isMenuAvailable) {
if (isMenuAvailable) {
item.setEnabled(true);
item.setVisible(true);
} else {
// disabled
item.setEnabled(false);
item.setVisible(false);
}
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.imageVPhoto:
takePhoto();
break;
case R.id.editTDOB:
showStartDateDialog();
break;
case R.id.btnPreview:
if ((purpose == DMDKConstants.PURPOSE_NEW_REGISTER)) {
verifyPhoneDOB();
}
if (selectedPanchayat == null) {
showAlertDialog("Panchayat/Town/City/District details manually typed. Tamil Translation not available!");
}
// show uneditable preview
if (isAllFieldsFilled()) {
// activate print menu and back menu
isPrintMenuAvailable = true;
isBackMenuAvailable = true;
isClearMenuAvailable = false;
invalidateOptionsMenu();
setLocale("ta");
// storing to database
if (isPushMemberData) {
if (purpose == DMDKConstants.PURPOSE_UPDATE_RECORDS) {
storingToDatabase(true);
return;
} else if (purpose == DMDKConstants.PURPOSE_NEW_REGISTER) {
{
storingToDatabase(false);
}
}
// end of storing to database
idCardView = (View) findViewById(idCardLayout);
idCardView.setVisibility(View.GONE);
RelativeLayout layout = (RelativeLayout) findViewById(R.id.few);
idCard = getIDCard();
idCardRId = View.generateViewId();
idCard.setId(idCardRId);
layout.addView(idCard);
imageVPhotoPrint.setImageDrawable(imageVPhoto.getDrawable());
// clearing any focus
View currentFocusedView = getCurrentFocus();
if (currentFocusedView != null) currentFocusedView.clearFocus();
if (mLinearLayout != null) {
mLinearLayout.requestFocus();
}
hideKeyboard(this);
} else {
showAlertDialog("Some fields are missing!");
}
}
break;
}
}
private void storingToDatabase(boolean isUpdate) {
MemberDatum memberDatum = new MemberDatum();
memberDatum.setPhone(editTPhone.getText().toString());
memberDatum.setDob(editTDOB.getText().toString());
memberDatum.setMembershipId(editTMembershipId.getText().toString());
memberDatum.setName(editTName.getText().toString());
memberDatum.setHusbandName(editTHusband.getText().toString());
String[] genderArray= getResources().getStringArray(R.array.genderArray);
if(spinGender.getSelectedItemPosition()>0) {
memberDatum.setGender(genderArray[spinGender.getSelectedItemPosition()]);
}else{
memberDatum.setGender("---");
}
memberDatum.setVoterId(editTVoterId.getText().toString());
if(selectedMpMlaDistrict!=null) {
memberDatum.setMp(selectedMpMlaDistrict.getMp_tamil());
memberDatum.setMla(selectedMpMlaDistrict.getMla_tamil());
}
else{
memberDatum.setMp(editTMP.getText().toString());
memberDatum.setMla(editTMLA.getText().toString());
}
if(selectedPanchayat!=null) {
memberDatum.setPanchayat(selectedPanchayat.getVillage_panchayat_name_tamil());
}
else{
memberDatum.setPanchayat(autoCompleteTVEntryFormPanchayat.getText().toString().trim());
}
if(selectedPanchayat!=null) {
memberDatum.setTownCity(selectedPanchayat.getDistrict_name_tamil());
}
else{
memberDatum.setTownCity(autoCompleteTVTownCity.getText().toString().trim());
}
if(selectedPanchayat!=null) {
memberDatum.setDistrict(selectedPanchayat.getDistrict_name_tamil());
}
else{
memberDatum.setDistrict(autoCompleteTVTownCity.getText().toString().trim());
}
memberDatum.setWard(editTWard.getText().toString());
memberDatum.setDoj(editTDate.getText().toString());
if(isUpdate && updateMemberRef!=null){
updateMemberRef.removeValue();
}
databaseMemberDataReference.push().setValue(memberDatum);
}
private boolean isAllFieldsFilled() {
ViewGroup group = (ViewGroup)findViewById(idCardLayout);
for (int i = 0, count = group.getChildCount(); i < count; ++i) {
View view = group.getChildAt(i);
if (view instanceof EditText) {
if(TextUtils.isEmpty(((EditText)view).getText().toString().trim())){
return false;
}
}
}
return true;
}
public void printPDF(View view) {
PrintManager printManager = (PrintManager) getSystemService(PRINT_SERVICE);
PrintAttributes.Builder builder = new PrintAttributes.Builder();
builder.setMediaSize( PrintAttributes.MediaSize.ISO_B7);
printManager.print("print_any_view_job_name", new ViewPrintAdapter(this,
view), builder.build());
}
@TargetApi(19)
private void generatePdf() {
int widthPostScript = (int) 3.56 * 72;
int heighPostScript = (int) 4.94 * 72;
PrintAttributes.Builder builder = new PrintAttributes.Builder();
builder.setColorMode(PrintAttributes.COLOR_MODE_COLOR);
builder.setMediaSize(PrintAttributes.MediaSize.ISO_B7);// or ISO_B7
builder.setMinMargins(PrintAttributes.Margins.NO_MARGINS);
/*
builder.setResolution(PrintAttributes.Resolution.ISO_B7);
*/
PrintedPdfDocument document = new PrintedPdfDocument(this, builder.build());
Page page = document.startPage(1);
idCardView = (View) findViewById(idCardLayout);
View content = idCardView;
Canvas canvas = page.getCanvas();
float scaleWidth = (float)332.16/(float)content.getWidth();
float scaleHeight = (float)472.32/(float)content.getHeight();
canvas.scale(scaleWidth, scaleHeight);
content.draw(canvas);
document.finishPage(page);
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
//handle case of no SDCARD present
} else {
String dir = Environment.getExternalStorageDirectory() + File.separator + "myDirectory";
//create folder
File folder = new File(dir); //folder name
folder.mkdirs();
//create file
String pdfName = "idcard_pdf"
/*+ sdf.format(Calendar.getInstance().getTime()) */ + ".pdf";
try {
File outputFile = new File(dir, pdfName);
Prefs.putString(DMDKConstants.IDCARD_PDF_PATH, outputFile.getPath());
/*
File file = new File(getExternalFilesDir(null).getAbsolutePath(), "document22.pdf");
*/
document.writeTo(new FileOutputStream(outputFile));
} catch (IOException e) {
Log.e("cannot generate pdf", e.toString());
}
}
document.close();
}
private boolean generateIDCardPDF() {
// Toast.makeText(this,"Printing the ID card",Toast.LENGTH_SHORT).show();
// create a new document
PdfDocument document = new PdfDocument();
int widthPostScript = (int) 3 * 72;
int heighPostScript = (int) 4 * 72;
// crate a page description
PageInfo pageInfo = new PageInfo.Builder(widthPostScript, heighPostScript, 1).create();
// start a page
Page page = document.startPage(pageInfo);
idCardView = (View) findViewById(idCardLayout);
Canvas canvas = page.getCanvas();
Resources res = getResources();
DisplayMetrics dm = res.getDisplayMetrics();
float scaleWidth = (float)widthPostScript/(float)(idCardView.getMeasuredWidth()*72/dm.xdpi);
float scaleHeight = (float)heighPostScript/(float)(idCardView.getMeasuredHeight()*72/dm.xdpi);
canvas.scale(scaleWidth, scaleHeight);
idCardView.draw(canvas);
// finish the page
document.finishPage(page);
// add more pages
// write the document content
// document.writeTo(getOutputStream());
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
//handle case of no SDCARD present
} else {
String dir = Environment.getExternalStorageDirectory() + File.separator + "myDirectory";
//create folder
File folder = new File(dir); //folder name
folder.mkdirs();
//create file
String pdfName = "idcard_pdf"
/*+ sdf.format(Calendar.getInstance().getTime()) */ + ".pdf";
File outputFile = new File(dir, pdfName);
Prefs.putString(DMDKConstants.IDCARD_PDF_PATH, outputFile.getPath());
try {
outputFile.createNewFile();
OutputStream out = new FileOutputStream(outputFile);
document.writeTo(out);
// close the document
document.close();
out.close();
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
return true;
}
private PrintJob print(String name, PrintDocumentAdapter adapter,
PrintAttributes attrs) {
startService(new Intent(this, PrintJobMonitorService.class));
return (mgr.print(name, adapter, attrs));
}
private void takePhoto() {
MarshMallowPermission marshMallowPermission = new MarshMallowPermission(this);
if (!marshMallowPermission.checkPermissionForCamera()) {
marshMallowPermission.requestPermissionForCamera();
}else {
if (!marshMallowPermission.checkPermissionForExternalStorage()) {
marshMallowPermission.requestPermissionForExternalStorage();
} else {
file = new File(Environment.getExternalStorageDirectory()
+ File.separator + "/test.jpg"/*getFilesDir(), "member_photo.jpg"*/);
try {
if (file.exists()) {
file.delete();
}
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
Intent i = new CameraActivity.IntentBuilder(this)
.skipConfirm()
.facing(Facing.BACK)
.to(Uri.fromFile(file))
.zoomStyle(ZoomStyle.SEEKBAR)
.updateMediaStore()
.build();
startActivityForResult(i, DMDKConstants.REQUEST_PICTURE);
}
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
if (requestCode == DMDKConstants.REQUEST_PICTURE) {
if (resultCode == RESULT_OK) {
memberBitmap = (Bitmap) data.getParcelableExtra("data");
if(memberBitmap != null) {
imageVPhoto.setImageBitmap(memberBitmap);
}else{
// app flow this way always as we provide target file location in intentbuilder
setPic(imageVPhoto);
}
} else {
imageVPhoto.setImageDrawable(getResources().getDrawable(android.R.drawable.ic_menu_camera));
}
}
}
private void setPic(ImageView mImageView) {
// Get the dimensions of the View
int targetW = mImageView.getWidth();
int targetH = mImageView.getHeight();
// Get the dimensions of the bitmap
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
bmOptions.inJustDecodeBounds = true;
BitmapFactory.decodeFile(file.getPath(), bmOptions);
int photoW = bmOptions.outWidth;
int photoH = bmOptions.outHeight;
// Determine how much to scale down the image
int scaleFactor = Math.min(photoW/targetW, photoH/targetH);
// Decode the image file into a Bitmap sized to fill the View
bmOptions.inJustDecodeBounds = false;
bmOptions.inSampleSize = scaleFactor;
bmOptions.inPurgeable = true;
Bitmap bitmap = BitmapFactory.decodeFile(file.getPath(), bmOptions);
mImageView.setImageBitmap(bitmap);
}
public void setLocale(String lang) {
Locale myLocale = new Locale(lang);
Resources res = getResources();
DisplayMetrics dm = res.getDisplayMetrics();
Configuration conf = res.getConfiguration();
conf.locale = myLocale;
res.updateConfiguration(conf, dm);
// MembershipEntryActivity.this.recreate();
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
}
@Override
public void onStart() {
super.onStart();
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
client.connect();
Action viewAction = Action.newAction(
Action.TYPE_VIEW, // TODO: choose an action type.
"IDCardPreview Page", // TODO: Define a title for the content shown.
// TODO: If you have web page content that matches this app activity's content,
// make sure this auto-generated web page URL is correct.
// Otherwise, set the URL to null.
Uri.parse("http://host/path"),
// TODO: Make sure this auto-generated app URL is correct.
Uri.parse("android-app://com.de.dmdk/http/host/path")
);
AppIndex.AppIndexApi.start(client, viewAction);
}
@Override
public void onStop() {
super.onStop();
LocaleHelper.setLocale(this,"en");
}
private class PDFGeneration extends AsyncTask<String, Integer, Boolean> {
@Override
protected Boolean doInBackground(String... params) {
return generateIDCardPDF();
}
@Override
protected void onPostExecute(Boolean result) {
// dotLoader.setVisibility(View.GONE);
if(result) {
print("TEST IDCARD PDF",
new PdfDocumentAdapter(getApplicationContext()),
new PrintAttributes.Builder().build());
}
}
@Override
protected void onPreExecute() {
// dotLoader.setVisibility(View.VISIBLE);
}
@Override
protected void onProgressUpdate(Integer... values) {
}
}
/* @Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
}*/
private RelativeLayout getIDCard(){
RelativeLayout idCardLayout = new RelativeLayout(this);
idCardLayout.setId(R.id.idCardLayout);
idCardLayout.setBackgroundResource(R.drawable.id_card_border);
idCardLayout.setPadding(convertDpToPx(32), convertDpToPx(16),convertDpToPx(32), 0);
RelativeLayout.LayoutParams layout_506 = new RelativeLayout.LayoutParams(convertDpToPx(332),convertDpToPx(472));
layout_506.addRule(RelativeLayout.CENTER_IN_PARENT);
idCardLayout.setLayoutParams(layout_506);
ImageView imageVFlagIcon = new ImageView(this);
imageVFlagIcon.setId(R.id.imageVFlagIcon);
imageVFlagIcon.setImageResource(R.drawable.idcard_logo_flag);
RelativeLayout.LayoutParams layout_621 = new RelativeLayout.LayoutParams(convertDpToPx(50),convertDpToPx(50));
layout_621.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
layout_621.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
layout_621.width = convertDpToPx(50);
layout_621.height = convertDpToPx(50);
imageVFlagIcon.setLayoutParams(layout_621);
idCardLayout.addView(imageVFlagIcon);
ImageView imageVSymbolIcon = new ImageView(this);
imageVSymbolIcon.setId(R.id.imageVSymbolIcon);
imageVSymbolIcon.setImageResource(R.drawable.idcard_logo_symbol);
RelativeLayout.LayoutParams layout_565 = new RelativeLayout.LayoutParams(convertDpToPx(50),convertDpToPx(50));
layout_565.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
layout_565.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
layout_565.width = convertDpToPx(50);
layout_565.height = convertDpToPx(50);
imageVSymbolIcon.setLayoutParams(layout_565);
idCardLayout.addView(imageVSymbolIcon);
TextView textVName = new TextView(this);
textVName.setId(R.id.textVName);
textVName.setText(getResources().getString(R.string.name));
textVName.setTextColor(getResources().getColor(R.color.colorFont));
textVName.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_391 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_391.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_391.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_391.addRule(RelativeLayout.BELOW, R.id.imageVFlagIcon);
textVName.setLayoutParams(layout_391);
idCardLayout.addView(textVName);
EditText editTNamePrint = new EditText(this);
editTNamePrint.setId(R.id.editTName);
editTNamePrint.setEms(20);
editTNamePrint.setRawInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
editTNamePrint.setLines(1);
editTNamePrint.setText(editTName.getText().toString().trim());
setEditTextEditable(editTNamePrint, false);
editTNamePrint.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_447 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_447.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_447.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_447.addRule(RelativeLayout.RIGHT_OF, R.id.textVName);
layout_447.addRule(RelativeLayout.ALIGN_BASELINE, R.id.textVName);
editTNamePrint.setLayoutParams(layout_447);
idCardLayout.addView(editTNamePrint);
TextView textVAge = new TextView(this);
textVAge.setId(R.id.textVAge);
textVAge.setText(getResources().getString(R.string.dob));
textVAge.setTextColor(getResources().getColor(R.color.colorFont));
textVAge.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_131 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_131.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_131.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_131.addRule(RelativeLayout.BELOW, R.id.textVName);
layout_131.addRule(RelativeLayout.ALIGN_LEFT, R.id.textVName);
layout_131.rightMargin = convertDpToPx(8);
layout_131.topMargin = convertDpToPx(15);
textVAge.setLayoutParams(layout_131);
idCardLayout.addView(textVAge);
EditText editTAgePrint = new EditText(this);
editTAgePrint.setId(R.id.editTAge);
editTAgePrint.setEms(6);
editTAgePrint.setText(editTDOB.getText().toString().trim());
setEditTextEditable(editTAgePrint, false);
editTAgePrint.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
editTAgePrint.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
RelativeLayout.LayoutParams layout_192 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_192.addRule(RelativeLayout.RIGHT_OF, R.id.textVAge);
layout_192.addRule(RelativeLayout.ALIGN_BASELINE, R.id.textVAge);
layout_192.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_192.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_192.rightMargin = convertDpToPx(8);
editTAgePrint.setLayoutParams(layout_192);
idCardLayout.addView(editTAgePrint);
TextView textVGender = new TextView(this);
textVGender.setId(R.id.textVGender);
textVGender.setText(getResources().getString(R.string.gender));
textVGender.setTextColor(getResources().getColor(R.color.colorFont));
textVGender.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_297 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_297.addRule(RelativeLayout.RIGHT_OF, R.id.editTAge);
layout_297.addRule(RelativeLayout.ALIGN_BASELINE, R.id.editTAge);
layout_297.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_297.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_297.rightMargin = convertDpToPx(8);
textVGender.setLayoutParams(layout_297);
idCardLayout.addView(textVGender);
EditText editGender = new EditText(this);
editGender.setId(R.id.spinGender);
editTNamePrint.setEms(4);
editGender.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
String[] genderArray= getResources().getStringArray(R.array.genderArray);
if(spinGender.getSelectedItemPosition()>0) {
editGender.setText(genderArray[spinGender.getSelectedItemPosition()]);
}else{
editGender.setText("-");
}
setEditTextEditable(editGender, false);
RelativeLayout.LayoutParams layout_803 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_803.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_803.addRule(RelativeLayout.RIGHT_OF, R.id.textVGender);
layout_803.addRule(RelativeLayout.ALIGN_BASELINE, R.id.textVGender);
layout_803.rightMargin = convertDpToPx(8);
editGender.setLayoutParams(layout_803);
idCardLayout.addView(editGender);
TextView textVHusband = new TextView(this);
textVHusband.setId(R.id.textVHusband);
textVHusband.setText(getResources().getString(R.string.husband_name));
textVHusband.setTextColor(getResources().getColor(R.color.colorFont));
textVHusband.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_19 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_19.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_19.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_19.addRule(RelativeLayout.BELOW, R.id.textVAge);
layout_19.addRule(RelativeLayout.ALIGN_LEFT, R.id.textVAge);
layout_19.rightMargin = convertDpToPx(8);
layout_19.topMargin = convertDpToPx(15);
textVHusband.setLayoutParams(layout_19);
idCardLayout.addView(textVHusband);
EditText editTHusbandPrint = new EditText(this);
editTHusbandPrint.setId(R.id.editTHusband);
editTHusbandPrint.setEms(20);
editTHusbandPrint.setText(editTHusband.getText().toString().trim());
setEditTextEditable(editTHusbandPrint, false);
editTHusbandPrint.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
editTHusbandPrint.setRawInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
RelativeLayout.LayoutParams layout_752 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_752.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_752.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_752.addRule(RelativeLayout.RIGHT_OF, R.id.textVHusband);
layout_752.addRule(RelativeLayout.BELOW, R.id.spinGender);
layout_752.addRule(RelativeLayout.ALIGN_BASELINE, R.id.textVHusband);
layout_752.rightMargin = convertDpToPx(8);
editTHusbandPrint.setLayoutParams(layout_752);
idCardLayout.addView(editTHusbandPrint);
TextView textVVoterId = new TextView(this);
textVVoterId.setId(R.id.textVVoterId);
textVVoterId.setText(getResources().getString(R.string.voter_id));
textVVoterId.setTextColor(getResources().getColor(R.color.colorFont));
textVVoterId.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_760 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_760.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_760.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_760.addRule(RelativeLayout.BELOW, R.id.textVHusband);
layout_760.addRule(RelativeLayout.ALIGN_LEFT, R.id.textVHusband);
layout_760.rightMargin = convertDpToPx(8);
layout_760.topMargin = convertDpToPx(15);
textVVoterId.setLayoutParams(layout_760);
idCardLayout.addView(textVVoterId);
EditText editTVoterIdPrint = new EditText(this);
editTVoterIdPrint.setId(R.id.editTVoterId);
editTVoterIdPrint.setEms(20);
editTVoterIdPrint.setText(editTVoterId.getText().toString().trim());
setEditTextEditable(editTVoterIdPrint, false);
editTVoterIdPrint.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
editTVoterIdPrint.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
RelativeLayout.LayoutParams layout_357 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_357.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_357.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_357.addRule(RelativeLayout.RIGHT_OF, R.id.textVVoterId);
layout_357.addRule(RelativeLayout.ALIGN_BASELINE, R.id.textVVoterId);
layout_357.rightMargin = convertDpToPx(8);
editTVoterIdPrint.setLayoutParams(layout_357);
idCardLayout.addView(editTVoterIdPrint);
TextView textVWard = new TextView(this);
textVWard.setId(R.id.textVWard);
textVWard.setText(getResources().getString(R.string.ward));
textVWard.setTextColor(getResources().getColor(R.color.colorFont));
textVWard.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_61 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_61.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_61.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_61.addRule(RelativeLayout.BELOW, R.id.textVVoterId);
layout_61.addRule(RelativeLayout.ALIGN_LEFT, R.id.textVVoterId);
layout_61.rightMargin = convertDpToPx(8);
layout_61.topMargin = convertDpToPx(15);
textVWard.setLayoutParams(layout_61);
idCardLayout.addView(textVWard);
EditText editTWardPrint = new EditText(this);
editTWardPrint.setId(R.id.editTWard);
editTWardPrint.setEms(20);
editTWardPrint.setText(editTWard.getText().toString().trim());
setEditTextEditable(editTWardPrint, false);
editTWardPrint.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
editTWardPrint.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
RelativeLayout.LayoutParams layout_611 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_611.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_611.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_611.addRule(RelativeLayout.RIGHT_OF, R.id.textVWard);
layout_611.addRule(RelativeLayout.ALIGN_BASELINE, R.id.textVWard);
layout_611.rightMargin = convertDpToPx(8);
editTWardPrint.setLayoutParams(layout_611);
idCardLayout.addView(editTWardPrint);
TextView textVPanchayat = new TextView(this);
textVPanchayat.setId(R.id.textVPanchayat);
textVPanchayat.setText(getResources().getString(R.string.panchayat));
textVPanchayat.setTextColor(getResources().getColor(R.color.colorFont));
textVPanchayat.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_695 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_695.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_695.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_695.addRule(RelativeLayout.BELOW, R.id.textVWard);
layout_695.addRule(RelativeLayout.ALIGN_LEFT, R.id.textVWard);
layout_695.rightMargin = convertDpToPx(8);
layout_695.topMargin = convertDpToPx(15);
textVPanchayat.setLayoutParams(layout_695);
idCardLayout.addView(textVPanchayat);
InstantAutoCompleteTextView autoCompleteTVPanchayatPrint = new InstantAutoCompleteTextView(this);
autoCompleteTVPanchayatPrint.setId(R.id.autoCompleteTVPanchayatPrint);
autoCompleteTVPanchayatPrint.setEms(12);
if(selectedPanchayat!=null) {
autoCompleteTVPanchayatPrint.setText(selectedPanchayat.getVillage_panchayat_name_tamil());
}
else{
autoCompleteTVPanchayatPrint.setText(autoCompleteTVEntryFormPanchayat.getText().toString().trim());
}
setEditTextEditable(autoCompleteTVPanchayatPrint, false);
autoCompleteTVPanchayatPrint.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_80 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_80.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_80.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_80.addRule(RelativeLayout.RIGHT_OF, R.id.textVPanchayat);
layout_80.addRule(RelativeLayout.ALIGN_BASELINE, R.id.textVPanchayat);
layout_80.rightMargin = convertDpToPx(8);
autoCompleteTVPanchayatPrint.setLayoutParams(layout_80);
idCardLayout.addView(autoCompleteTVPanchayatPrint);
TextView textVTownCity = new TextView(this);
textVTownCity.setId(R.id.textVTownCity);
textVTownCity.setText(getResources().getString(R.string.town_city));
textVTownCity.setTextColor(getResources().getColor(R.color.colorFont));
textVTownCity.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_528 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_528.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_528.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_528.addRule(RelativeLayout.BELOW, R.id.textVPanchayat);
layout_528.addRule(RelativeLayout.ALIGN_LEFT, R.id.textVPanchayat);
layout_528.rightMargin = convertDpToPx(8);
layout_528.topMargin = convertDpToPx(15);
textVTownCity.setLayoutParams(layout_528);
idCardLayout.addView(textVTownCity);
InstantAutoCompleteTextView autoCompleteTVTownCityPrint = new InstantAutoCompleteTextView(this);
autoCompleteTVTownCityPrint.setId(R.id.autoCompleteTVTownCityPrint);
autoCompleteTVTownCityPrint.setEms(8);
if(selectedPanchayat!=null) {
autoCompleteTVTownCityPrint.setText(selectedPanchayat.getDistrict_name_tamil());
}
else{
autoCompleteTVTownCityPrint.setText(autoCompleteTVTownCity.getText().toString().trim());
}
autoCompleteTVTownCityPrint.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
setEditTextEditable(autoCompleteTVTownCityPrint, false);
RelativeLayout.LayoutParams layout_656 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_656.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_656.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_656.addRule(RelativeLayout.RIGHT_OF, R.id.textVTownCity);
layout_656.addRule(RelativeLayout.ALIGN_BASELINE, R.id.textVTownCity);
layout_656.rightMargin = convertDpToPx(8);
autoCompleteTVTownCityPrint.setLayoutParams(layout_656);
idCardLayout.addView(autoCompleteTVTownCityPrint);
TextView textVDistrict = new TextView(this);
textVDistrict.setId(R.id.textVDistrict);
textVDistrict.setText(getResources().getString(R.string.district));
textVDistrict.setTextColor(getResources().getColor(R.color.colorFont));
textVDistrict.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_45 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_45.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_45.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_45.addRule(RelativeLayout.BELOW, R.id.textVTownCity);
layout_45.addRule(RelativeLayout.ALIGN_LEFT, R.id.textVTownCity);
layout_45.rightMargin = convertDpToPx(8);
layout_45.topMargin = convertDpToPx(15);
textVDistrict.setLayoutParams(layout_45);
idCardLayout.addView(textVDistrict);
InstantAutoCompleteTextView autoCompleteTVDistrictPrint = new InstantAutoCompleteTextView(this);
autoCompleteTVDistrictPrint.setId(R.id.autoCompleteTVDistrictPrint);
autoCompleteTVDistrictPrint.setEms(8);
if(selectedPanchayat!=null) {
autoCompleteTVDistrictPrint.setText(selectedPanchayat.getDistrict_name_tamil());
}
else{
autoCompleteTVDistrictPrint.setText(autoCompleteTVDistrict.getText().toString().trim());
}
autoCompleteTVDistrictPrint.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
setEditTextEditable(autoCompleteTVDistrictPrint, false);
RelativeLayout.LayoutParams layout_147 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_147.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_147.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_147.addRule(RelativeLayout.RIGHT_OF, R.id.textVDistrict);
layout_147.addRule(RelativeLayout.ALIGN_BASELINE, R.id.textVDistrict);
layout_147.rightMargin = convertDpToPx(8);
autoCompleteTVDistrictPrint.setLayoutParams(layout_147);
idCardLayout.addView(autoCompleteTVDistrictPrint);
TextView textVMembershipId = new TextView(this);
textVMembershipId.setId(R.id.textVMembershipId);
textVMembershipId.setText(getResources().getString(R.string.membership_id));
textVMembershipId.setTextColor(getResources().getColor(R.color.colorFont));
textVMembershipId.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_961 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_961.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_961.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_961.addRule(RelativeLayout.BELOW, R.id.textVDistrict);
layout_961.addRule(RelativeLayout.ALIGN_LEFT, R.id.textVDistrict);
layout_961.rightMargin = convertDpToPx(8);
layout_961.topMargin = convertDpToPx(15);
layout_961.bottomMargin = convertDpToPx(10);
textVMembershipId.setLayoutParams(layout_961);
idCardLayout.addView(textVMembershipId);
EditText editTMembershipIdPrint = new EditText(this);
editTMembershipIdPrint.setId(R.id.editTMembershipIdPrint);
editTMembershipIdPrint.setEms(5);
editTMembershipIdPrint.setText(editTMembershipId.getText().toString().trim());
setEditTextEditable(editTMembershipIdPrint, false);
editTMembershipIdPrint.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
editTMembershipIdPrint.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
RelativeLayout.LayoutParams layout_302 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_302.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_302.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_302.addRule(RelativeLayout.RIGHT_OF, R.id.textVMembershipId);
layout_302.addRule(RelativeLayout.ALIGN_BASELINE, R.id.textVMembershipId);
layout_302.rightMargin = convertDpToPx(8);
editTMembershipIdPrint.setLayoutParams(layout_302);
idCardLayout.addView(editTMembershipIdPrint);
TextView textVdate = new TextView(this);
textVdate.setId(R.id.textVdate);
textVdate.setText(getResources().getString(R.string.date));
textVdate.setTextColor(getResources().getColor(R.color.colorFont));
textVdate.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_70 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_70.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_70.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_70.addRule(RelativeLayout.RIGHT_OF, R.id.editTMembershipIdPrint);
layout_70.addRule(RelativeLayout.ALIGN_BASELINE, R.id.editTMembershipIdPrint);
layout_70.rightMargin = convertDpToPx(8);
layout_70.topMargin = convertDpToPx(15);
textVdate.setLayoutParams(layout_70);
idCardLayout.addView(textVdate);
EditText editTDatePrint = new EditText(this);
editTDatePrint.setId(R.id.editTDatingPrint);
editTDatePrint.setText(editTDate.getText().toString().trim());
setEditTextEditable(editTDatePrint, false);
editTDatePrint.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
editTDatePrint.setEms(7);
RelativeLayout.LayoutParams layout_112 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_112.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_112.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_112.addRule(RelativeLayout.RIGHT_OF, R.id.textVdate);
layout_112.addRule(RelativeLayout.ALIGN_BASELINE, R.id.textVdate);
editTDatePrint.setLayoutParams(layout_112);
idCardLayout.addView(editTDatePrint);
imageVPhotoPrint = new ImageView(this);
imageVPhotoPrint.setId(R.id.imageVPhoto);
RelativeLayout.LayoutParams layout_63 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_63.addRule(RelativeLayout.ALIGN_LEFT, R.id.textVMembershipId);
layout_63.addRule(RelativeLayout.BELOW, R.id.textVMembershipId);
layout_63.width = convertDpToPx(70);
layout_63.height = convertDpToPx(80);
layout_63.bottomMargin = convertDpToPx(18);
imageVPhotoPrint.setLayoutParams(layout_63);
idCardLayout.addView(imageVPhotoPrint);
TextView textVGeneralSecretary = new TextView(this);
textVGeneralSecretary.setId(R.id.textVGeneralSecretary);
textVGeneralSecretary.setText(getResources().getString(R.string.general_secretary));
textVGeneralSecretary.setTextColor(getResources().getColor(R.color.colorFont));
textVGeneralSecretary.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_452 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_452.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_452.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_452.bottomMargin = convertDpToPx(18);
layout_452.setMarginEnd(convertDpToPx(36));
layout_452.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
layout_452.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
textVGeneralSecretary.setLayoutParams(layout_452);
idCardLayout.addView(textVGeneralSecretary);
return idCardLayout;
}
private int convertDpToPx(int dp){
return (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, getResources().getDisplayMetrics());
}
private void setEditTextEditable(EditText editText,boolean yes){
if (!yes) { // disable editing password
editText.setFocusable(false);
editText.setFocusableInTouchMode(false); // user touches widget on phone with touch screen
editText.setClickable(false); // user navigates with wheel and selects widget
} else { // enable editing of password
editText.setFocusable(true);
editText.setFocusableInTouchMode(true);
editText.setClickable(true);
}
}
public void showStartDateDialog(){
Calendar c = Calendar.getInstance();
int mYear = c.get(Calendar.YEAR);
int mMonth = c.get(Calendar.MONTH);
int mDay = c.get(Calendar.DAY_OF_MONTH);
System.out.println("the selected " + mDay);
DatePickerDialog dialog = new DatePickerDialog(this,android.R.style.Theme_Holo_Dialog,
new mDateSetListener(), mYear, mMonth, mDay);
dialog.show();
}
/* public void showAlertDialog(String message){
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle(getString(R.string.app_name));
alertDialog.setMessage(message);
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alertDialog.show();
}*/
class mDateSetListener implements DatePickerDialog.OnDateSetListener {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
// TODO Auto-generated method stub
// getCalender();
int mYear = year;
int mMonth = monthOfYear;
int mDay = dayOfMonth;
editTDOB.setText(new StringBuilder()
.append(mDay).append("/")
// Month is 0 based so add 1
.append(mMonth + 1).append("/")
.append(mYear).append(" "));
System.out.println(editTDOB.getText().toString());
}
}
@Override
public void onBackPressed() {
if(isBackMenuAvailable){
setLocale("en");
MenuItem menuBack = menu.findItem(R.id.back);
onOptionsItemSelected(menuBack);
}else {
super.onBackPressed();
}
}
public static void hideKeyboard(Activity activity) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
//Find the currently focused view, so we can grab the correct window token from it.
View view = activity.getCurrentFocus();
//If no view currently has focus, create a new one, just so we can grab a window token from it
if (view == null) {
view = new View(activity);
}
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
/* void printTemplateSample()
{
Printer myPrinter = new Printer();
PrinterInfo myPrinterInfo = new PrinterInfo();
try{
// Retrieve printer informations
myPrinterInfo = myPrinter.getPrinterInfo();
// Set printer informations
myPrinterInfo.printerModel = PrinterInfo.Model.PJ_663;
myPrinterInfo.port=PrinterInfo.Port.BLUETOOTH;
myPrinterInfo.printMode=PrinterInfo.PrintMode.ORIGINAL;
myPrinterInfo.paperSize = PrinterInfo.PaperSize.A4;
myPrinter.setPrinterInfo(myPrinterInfo);
// Start creating P-touch Template command print data
myPrinter.startPTTPrint(1, null);
// Replace text
myPrinter.replaceText("abcde");
myPrinter.replaceText("12345");
// Trasmit P-touch Template command print data
myPrinter.flushPTTPrint();
}catch(Exception e){
}
}*/
private void showDialogs(String title,String message){
LayoutInflater linf = LayoutInflater.from(this);
final View inflator = linf.inflate(R.layout.search_dialog, null);
AlertDialog.Builder alert = new AlertDialog.Builder(this,R.style.DialogTheme);
alert.setTitle(title);
/*alert.setMessage(message);*/
alert.setView(inflator);
final EditText et1 = (EditText) inflator.findViewById(R.id.editTSearchMemberId);
alert.setPositiveButton("ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton)
{
if(!TextUtils.isEmpty(et1.getText())) {
String formatted = et1.getText().toString().trim();
if (formatted.length()==1) {
formatted = String.format("%02d", Integer.parseInt(et1.getText().toString().trim()));
}
searchMember(formatted);
}else{
showAlertDialog("Please enter memberid");
}
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.cancel();
finish();
}
});
if(!(isFinishing()))
alert.show();
}
/* Search member */
private void searchMember(final String memberID) {
showProgress("");
Query queryRef = databaseMemberDataReference.orderByChild("membershipId").equalTo(memberID)/*.orderByChild("dob")*/;
queryRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if(updateMemberRef!=null){
showAlertDialogWithClickListener("Member " + " updated!!!", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialogInterface, int i) {
finish();
}
},new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialogInterface, int i) {
finish();
}
});
}
if(dataSnapshot.getValue() != null){
dismissProgress();
for(DataSnapshot childDataSnapshot:dataSnapshot.getChildren()){
MemberDatum memberDatum= childDataSnapshot.getValue(MemberDatum.class);
if(memberDatum.getMembershipId().equalsIgnoreCase(memberID)){
// Toast.makeText(getApplicationContext(),memberDatum.getName()+" Member already found!!!",Toast.LENGTH_SHORT).show();
showAlertDialog("Member " + memberDatum.getName() + " found!!!");
if(purpose == DMDKConstants.PURPOSE_UPDATE_RECORDS) {
btnPreview.setText("Update");
}else if(purpose == DMDKConstants.PURPOSE_PRINT){
btnPreview.setText("Print");
}
btnPreview.setEnabled(true);
fillData(memberDatum);
updateMemberRef= childDataSnapshot.getRef();
isPushMemberData = true;
return;
}else{
// Toast.makeText(getApplicationContext(),"Phone number already used!!",Toast.LENGTH_SHORT).show();
if(isClearMenuAvailable) {
showAlertDialog("Member "+memberID+" not found!!!");
if(purpose == DMDKConstants.PURPOSE_UPDATE_RECORDS) {
btnPreview.setText("Update");
}else if(purpose == DMDKConstants.PURPOSE_PRINT){
btnPreview.setText("Print");
} btnPreview.setEnabled(false);
}
isPushMemberData = false;
if(purpose == DMDKConstants.PURPOSE_UPDATE_RECORDS) {
showDialogs("Update Member Record","Enter the MemberID");
}else if(purpose == DMDKConstants.PURPOSE_PRINT) {
showDialogs("Print","Enter the MemberID");
}
return;
}
}
}else{
dismissProgress();
if(isClearMenuAvailable) {
showAlertDialog("Member "+memberID+" not found!!!");
if(purpose == DMDKConstants.PURPOSE_UPDATE_RECORDS) {
btnPreview.setText("Update");
}else if(purpose == DMDKConstants.PURPOSE_PRINT){
btnPreview.setText("Print");
} btnPreview.setEnabled(false);
}
isPushMemberData = false;
if(purpose == DMDKConstants.PURPOSE_UPDATE_RECORDS) {
showDialogs("Update Member Record","Enter the MemberID");
}else if(purpose == DMDKConstants.PURPOSE_PRINT) {
showDialogs("Print","Enter the MemberID");
}
return;
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
dismissProgress();
}
});
}
private void fillData(MemberDatum memberDatum) {
editTPhone.setText(memberDatum.getPhone());
editTDOB.setText(memberDatum.getDob());
editTMembershipId.setText(memberDatum.getMembershipId());
editTName.setText(memberDatum.getName());
editTHusband.setText(memberDatum.getHusbandName());
editTVoterId.setText(memberDatum.getVoterId());
editTMP.setText(memberDatum.getMp());
editTMLA.setText(memberDatum.getMla());
autoCompleteTVDistrict.setText(memberDatum.getDistrict());
autoCompleteTVEntryFormPanchayat.setText(memberDatum.getPanchayat());
autoCompleteTVTownCity.setText(memberDatum.getTownCity());
editTDate.setText(memberDatum.getDoj());
}
int lastMemberId;
private int getLastMemberID() {
showProgress("");
Query queryRef = databaseMemberDataReference.orderByChild("membershipId").limitToLast(1)/*.orderByChild("dob")*/;
queryRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if(dataSnapshot.getValue() != null){
dismissProgress();
for(DataSnapshot childDataSnapshot:dataSnapshot.getChildren()){
MemberDatum memberDatum= childDataSnapshot.getValue(MemberDatum.class);
lastMemberId= Integer.parseInt(memberDatum.getMembershipId().trim());
}
}else{
dismissProgress();
return;
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
dismissProgress();
}
});
return lastMemberId;
}
}
|
UTF-8
|
Java
| 86,422 |
java
|
MembershipEntryActivity.java
|
Java
|
[] | null |
[] |
package com.de.dmdk;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.pdf.PdfDocument;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Environment;
import android.print.PrintAttributes;
import android.print.PrintDocumentAdapter;
import android.print.PrintJob;
import android.print.PrintManager;
import com.de.dmdk.view.InstantAutoCompleteTextView;
import android.print.PrinterInfo;
import android.print.pdf.PrintedPdfDocument;
import android.support.v4.print.PrintHelper;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.text.InputType;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.graphics.pdf.PdfDocument.*;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.commonsware.cwac.cam2.CameraActivity;
import com.commonsware.cwac.cam2.Facing;
import com.commonsware.cwac.cam2.ZoomStyle;
import com.de.dmdk.languagehelper.LocaleHelper;
import com.de.dmdk.membership.MemberDatum;
import com.de.dmdk.permissions.MarshMallowPermission;
import com.de.dmdk.printhelper.PdfDocumentAdapter;
import com.de.dmdk.printhelper.PrintJobMonitorService;
import com.de.dmdk.printhelper.USBAdapter;
import com.google.android.gms.appindexing.Action;
import com.google.android.gms.appindexing.AppIndex;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.Query;
import com.google.firebase.database.ValueEventListener;
import com.hp.mss.hpprint.activity.PrintPluginManagerActivity;
import com.hp.mss.hpprint.model.ImagePrintItem;
import com.hp.mss.hpprint.model.PrintItem;
import com.hp.mss.hpprint.model.PrintJobData;
import com.hp.mss.hpprint.model.asset.ImageAsset;
import com.hp.mss.hpprint.util.PrintUtil;
import com.pixplicity.easyprefs.library.Prefs;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Locale;
import java.util.regex.Pattern;
import static com.de.dmdk.R.id.autoCompleteTVTownCity;
import static com.de.dmdk.R.id.editTVoterId;
import static com.de.dmdk.R.id.idCardLayout;
public class MembershipEntryActivity extends BaseActivity implements View.OnClickListener,TextWatcher{
private boolean isFormEditable;
private View idCardView;
private LinearLayout mLinearLayout;
private PrintManager mgr = null;
private ImageView imageVPhoto, imageVPhotoPrint;
private File file;
private Bitmap memberBitmap ;
/* Input Fields of ID Card*/
private Spinner spinGender;
private InstantAutoCompleteTextView autoCompleteTVEntryFormPanchayat;
private InstantAutoCompleteTextView autoCompleteTVTownCity;
private InstantAutoCompleteTextView autoCompleteTVDistrict;
private int purpose;
PanchayatDetailsAdapter adapter ;
/**
* ATTENTION: This was auto-generated to implement the App Indexing API.
* See https://g.co/AppIndexing/AndroidStudio for more information.
*/
private GoogleApiClient client;
/* Firebase elements */
/* Fire Database */
private DatabaseReference databaseRootReference = FirebaseDatabase.getInstance().getReference();
private DatabaseReference databaseMemberDataReference = FirebaseDatabase.getInstance().getReference("member_data");
private RelativeLayout few;
private EditText editTPhone;
private EditText editTName;
private EditText editTDOB;
private EditText editTHusband;
private EditText editTVoterId;
private EditText editTWard;
private EditText editTMembershipId;
private EditText editTDate;
private InstantAutoCompleteTextView editTMLA;
private InstantAutoCompleteTextView editTMP;
private Button btnPreview;
private boolean isBackMenuAvailable, isPrintMenuAvailable, isClearMenuAvailable;
private int idCardRId;
private Menu menu;
private PanchayatDetails selectedPanchayat;
private MpMlaDistrict selectedMpMlaDistrict;
private String tempDOB;
private boolean isPushMemberData;
private DatabaseReference updateMemberRef;
@Override
protected void onCreate(Bundle savedInstanceState) {
LocaleHelper.setLocale(this,"ta");
super.onCreate(savedInstanceState);
getIntentCheck();
setContentView(R.layout.activity_new_membership_entry);
initView();
setUpListeners();
if(purpose == DMDKConstants.PURPOSE_UPDATE_RECORDS) {
showDialogs("Update Member Record","Enter the MemberID");
}else if(purpose == DMDKConstants.PURPOSE_PRINT) {
showDialogs("Print","Enter the MemberID");
}
mgr = (PrintManager) getSystemService(PRINT_SERVICE);
client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
/* get all mp, mla,district data*/
databaseRootReference.child("mp_mla_district").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
System.out.println("VIJAY "+snapshot.getValue()); //prints "Do you have data? You'll love Firebase."
Log.e("Count " ,""+snapshot.getChildrenCount());
ArrayList<String> mp = new ArrayList<String>();
ArrayList<String> mla = new ArrayList<String>();
/*
ArrayList<String> mpmlaDistrict = new ArrayList<String>();
*/
final ArrayList<MpMlaDistrict> mpMlaDistrictDetailFull = new ArrayList<MpMlaDistrict>();
for (DataSnapshot single : snapshot.getChildren()) {
MpMlaDistrict mpMlaDistrictDetails= single.getValue(MpMlaDistrict.class);
Log.e("village_panchayat_name" ,""+mpMlaDistrictDetails.getMp_tamil());
if(!TextUtils.isEmpty(mpMlaDistrictDetails.getMp())) {
mp.add(mpMlaDistrictDetails.getMp());
}
mla.add(mpMlaDistrictDetails.getMla());
/*
mpmlaDistrict.add(mpMlaDistrictDetails.getDistrictTamil());
*/
mpMlaDistrictDetailFull.add(mpMlaDistrictDetails);
}
/*PanchayatDetailsAdapter adapter =
new PanchayatDetailsAdapter(MembershipEntryActivity.this, R.layout.list_row, panchayatDetail);*/
ArrayAdapter<String> adapter =
new ArrayAdapter<String>(MembershipEntryActivity.this, R.layout.list_row,R.id.txtTitle, mp);
editTMP.setAdapter(adapter);
editTMP.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
String selected = (String) arg0.getAdapter().getItem(arg2);
for(MpMlaDistrict mpMlaDistrict:mpMlaDistrictDetailFull)
{
if(selected.equalsIgnoreCase(mpMlaDistrict.getMp())){
/*Toast.makeText(MembershipEntryActivity.this,
"Clicked " + arg2 + " name: " + panchayat.getVillage_panchayat_name_tamil(),
Toast.LENGTH_SHORT).show();*/
selectedMpMlaDistrict = mpMlaDistrict;
editTMP.setText(mpMlaDistrict.getMp_tamil());
autoCompleteTVDistrict.setText(mpMlaDistrict.getDistrict_tamil());
// autoCompleteTVTownCity.setText(mpMlaDistrict.getDistrict_name());
}
}
}
});
/*editTMP.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
*//*if((TextUtils.isEmpty(s.toString()) || (null==selectedMpMlaDistrict)) || (!s.toString().equalsIgnoreCase(selectedMpMlaDistrict.getDistrict()))){
selectedMpMlaDistrict = null;
autoCompleteTVDistrict.setText("");
}*//*
}
});*/
/* mla */
ArrayAdapter<String> adaptereditTMLA =
new ArrayAdapter<String>(MembershipEntryActivity.this, R.layout.list_row,R.id.txtTitle, mla);
editTMLA.setAdapter(adaptereditTMLA);
editTMLA.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
String selected = (String) arg0.getAdapter().getItem(arg2);
for(MpMlaDistrict mpMlaDistrict:mpMlaDistrictDetailFull)
{
if(selected.equalsIgnoreCase(mpMlaDistrict.getMla())){
/*Toast.makeText(MembershipEntryActivity.this,
"Clicked " + arg2 + " name: " + panchayat.getVillage_panchayat_name_tamil(),
Toast.LENGTH_SHORT).show();*/
selectedMpMlaDistrict = mpMlaDistrict;
editTMLA.setText(mpMlaDistrict.getMla_tamil());
autoCompleteTVDistrict.setText(mpMlaDistrict.getDistrict_tamil());
// autoCompleteTVTownCity.setText(mpMlaDistrict.getDistrict_name());
}
}
}
});
/* editTMP.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
*//* if((TextUtils.isEmpty(s.toString()) || (null==selectedMpMlaDistrict)) || (!s.toString().equalsIgnoreCase(selectedMpMlaDistrict.getDistrict()))){
selectedMpMlaDistrict = null;
autoCompleteTVDistrict.setText("");
}*//*
}
});*/
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
/* get all panchayat data*/
databaseRootReference.child("autocomplete").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
System.out.println("VIJAY "+snapshot.getValue()); //prints "Do you have data? You'll love Firebase."
Log.e("Count " ,""+snapshot.getChildrenCount());
ArrayList<String> panchayatName = new ArrayList<String>();
ArrayList<String> panchayatDistrict = new ArrayList<String>();
final ArrayList<PanchayatDetails> panchayatDetailFull = new ArrayList<PanchayatDetails>();
for (DataSnapshot single : snapshot.getChildren()) {
PanchayatDetails panchayatDetails= single.getValue(PanchayatDetails.class);
Log.e("village_panchayat_name" ,""+panchayatDetails.getVillage_panchayat_name_tamil());
panchayatName.add(panchayatDetails.getVillage_panchayat_name());
panchayatDetailFull.add(panchayatDetails);
}
/*PanchayatDetailsAdapter adapter =
new PanchayatDetailsAdapter(MembershipEntryActivity.this, R.layout.list_row, panchayatDetail);*/
ArrayAdapter<String> adapter =
new ArrayAdapter<String>(MembershipEntryActivity.this, R.layout.list_row,R.id.txtTitle, panchayatName);
autoCompleteTVEntryFormPanchayat.setAdapter(adapter);
autoCompleteTVEntryFormPanchayat.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
String selected = (String) arg0.getAdapter().getItem(arg2);
for(PanchayatDetails panchayat:panchayatDetailFull)
{
if(selected.equalsIgnoreCase(panchayat.getVillage_panchayat_name())){
/*Toast.makeText(MembershipEntryActivity.this,
"Clicked " + arg2 + " name: " + panchayat.getVillage_panchayat_name_tamil(),
Toast.LENGTH_SHORT).show();*/
selectedPanchayat = panchayat;
autoCompleteTVEntryFormPanchayat.setText(panchayat.getVillage_panchayat_name_tamil());
autoCompleteTVDistrict.setText(panchayat.getDistrict_name_tamil());
autoCompleteTVTownCity.setText(panchayat.getDistrict_name_tamil());
}
}
}
});
autoCompleteTVEntryFormPanchayat.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
if((TextUtils.isEmpty(s.toString()) || (null==selectedPanchayat)) || (!s.toString().equalsIgnoreCase(selectedPanchayat.getVillage_panchayat_name()))){
selectedPanchayat = null;
autoCompleteTVDistrict.setText("");
autoCompleteTVTownCity.setText("");
}
}
});
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
/* Auto complete*/
/* databaseRootReference.child("0").orderByChild("village_panchayat_name").*//*startAt("Na").limitToFirst(6).*//*addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
PanchayatDetails panchayatDetails= dataSnapshot.getValue(PanchayatDetails.class);
Log.e("village_panchayat_name" ,""+panchayatDetails.getVillage_panchayat_name());
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});*/
}
private void getIntentCheck() {
Intent intent = getIntent();
purpose = intent.getIntExtra(DMDKConstants.PURPOSE,DMDKConstants.PURPOSE_NEW_REGISTER);
}
private void setUpListeners() {
imageVPhoto.setOnClickListener(this);
autoCompleteTVEntryFormPanchayat.addTextChangedListener(this);
String[] genderArray= getResources().getStringArray(R.array.genderArray);
ArrayAdapter<String> genderAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, genderArray);
genderAdapter.setDropDownViewResource(R.layout.spinner_dropdown);
spinGender.setAdapter(genderAdapter);
editTPhone.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if(!hasFocus) {
if(TextUtils.isEmpty(editTPhone.getText().toString()) && (!isValidMobile(editTPhone.getText().toString()))){
showAlertDialog("Enter valid phone number");
}
}
}
});
editTDOB.setOnClickListener(this);
editTPhone.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
editTDOB.setText("");
}
});
editTDOB.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
if((!TextUtils.isEmpty(editTPhone.getText().toString().trim()) && (!TextUtils.isEmpty(s.toString()))) && (!s.toString().equalsIgnoreCase(tempDOB))){
tempDOB= s.toString();
if((purpose == DMDKConstants.PURPOSE_NEW_REGISTER)) {
verifyPhoneDOB();
}
}
}
});
btnPreview.setOnClickListener(this);
}
private boolean isValidMobile(String phone2)
{
boolean check=false;
if(!Pattern.matches("[a-zA-Z]+", phone2))
{
if(phone2.length() < 6 || phone2.length() > 13)
{
check = false;
editTPhone.setError(editTPhone.getText());
}
else
{
check = true;
}
}
else
{
check=false;
}
return check;
}
private void verifyPhoneDOB() {
Query queryRef = databaseMemberDataReference.orderByChild("phone").equalTo(editTPhone.getText().toString().trim())/*.orderByChild("dob")*/;
queryRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if(dataSnapshot.getValue() != null){
for(DataSnapshot childDataSnapshot:dataSnapshot.getChildren()){
MemberDatum memberDatum= childDataSnapshot.getValue(MemberDatum.class);
if(memberDatum.getDob().equalsIgnoreCase(editTDOB.getText().toString().trim())){
// Toast.makeText(getApplicationContext(),memberDatum.getName()+" Member already found!!!",Toast.LENGTH_SHORT).show();
showAlertDialog("Member "+memberDatum.getName()+" already found!!!");
btnPreview.setEnabled(false);
isPushMemberData = false;
return;
}else{
// Toast.makeText(getApplicationContext(),"Phone number already used!!",Toast.LENGTH_SHORT).show();
if(isClearMenuAvailable) {
showAlertDialog("Phone number already used!!");
btnPreview.setEnabled(false);
}
isPushMemberData = false;
return;
}
}
}else{
// Toast.makeText(getApplicationContext(),"New Memeber ID created!!",Toast.LENGTH_SHORT).show();
if(isClearMenuAvailable) {
editTMembershipId.setText(""+getLastMemberID()+1);
}
isPushMemberData = true;
btnPreview.setEnabled(true);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
private void initView() {
mLinearLayout = (LinearLayout) findViewById(R.id.linearLayout_focus);
imageVPhoto = (ImageView) findViewById(R.id.imageVPhoto);
spinGender = (Spinner)findViewById(R.id.gender);
autoCompleteTVEntryFormPanchayat = (InstantAutoCompleteTextView)findViewById(R.id.autoCompleteTVPanchayat);
autoCompleteTVTownCity = (InstantAutoCompleteTextView)findViewById(R.id.autoCompleteTVTownCity);
autoCompleteTVDistrict = (InstantAutoCompleteTextView)findViewById(R.id.autoCompleteTVDistrict);
// dotLoader = (DotLoader) findViewById(R.id.dotLoader);
few = (RelativeLayout)findViewById( R.id.few );
editTPhone = (EditText)findViewById( R.id.editTPhone );
editTName = (EditText)findViewById( R.id.editTName );
editTDOB = (EditText)findViewById( R.id.editTDOB );
editTHusband = (EditText)findViewById( R.id.editTHusband );
editTVoterId = (EditText)findViewById( R.id.editTVoterId );
editTWard = (EditText)findViewById( R.id.editTWard );
editTMembershipId = (EditText)findViewById( R.id.editTMembershipId );
editTDate = (EditText)findViewById( R.id.editTDate );
editTMLA = (InstantAutoCompleteTextView)findViewById( R.id.editTMLA );
editTMP = (InstantAutoCompleteTextView)findViewById( R.id.editTMP );
btnPreview = (Button) findViewById(R.id.btnPreview);
isBackMenuAvailable= false;
isPrintMenuAvailable= false;
isClearMenuAvailable = true;
invalidateOptionsMenu();
Calendar c = Calendar.getInstance();
int mYear = c.get(Calendar.YEAR);
int mMonth = c.get(Calendar.MONTH);
int mDay = c.get(Calendar.DAY_OF_MONTH);
editTDate.setText(new StringBuilder()
.append(mDay).append("/")
// Month is 0 based so add 1
.append(mMonth + 1).append("/")
.append(mYear).append(" "));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
new MenuInflater(this).inflate(R.menu.membershipform_menu, menu);
this.menu= menu;
return super.onCreateOptionsMenu(menu);
}
RelativeLayout idCard;
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.back:
View currentFocusedView = getCurrentFocus();
if (currentFocusedView != null) currentFocusedView.clearFocus();
if (mLinearLayout != null) {
mLinearLayout.requestFocus();
}
idCardView = (View) findViewById(idCardLayout);
idCardView.setVisibility(View.VISIBLE);
RelativeLayout layout=(RelativeLayout)findViewById(R.id.few);
layout.removeView(idCard);
isPrintMenuAvailable= false;
isBackMenuAvailable = false;
isClearMenuAvailable = true;
invalidateOptionsMenu();
return true;
case R.id.action_print:
if(idCard!=null) {
Bitmap bitmap = Bitmap.createBitmap(convertDpToPx(332), convertDpToPx(472),
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
/* temporrily remove icons borders and secretart signature for printing*/
View printPartView= idCard;
printPartView.setBackgroundResource(R.drawable.print_part_border);
printPartView.findViewById(R.id.imageVFlagIcon).setVisibility(View.INVISIBLE);
printPartView.findViewById(R.id.imageVSymbolIcon).setVisibility(View.INVISIBLE);
printPartView.findViewById(R.id.textVGeneralSecretary).setVisibility(View.INVISIBLE);
printPartView.draw(canvas);
/* back to how it is was before sending printing part*/
idCard.setBackgroundResource(R.drawable.id_card_border);
idCard.setPadding(convertDpToPx(32), convertDpToPx(16),convertDpToPx(32), 0);
idCard.findViewById(R.id.imageVFlagIcon).setVisibility(View.VISIBLE);
idCard.findViewById(R.id.imageVSymbolIcon).setVisibility(View.VISIBLE);
idCard.findViewById(R.id.textVGeneralSecretary).setVisibility(View.VISIBLE);
PrintHelper help = new PrintHelper(this);
help.setScaleMode(PrintHelper.SCALE_MODE_FIT);
help.printBitmap("IDCard", bitmap);
// old code
/*PrintHelper help = new PrintHelper(this);
help.setScaleMode(PrintHelper.SCALE_MODE_FIT);
help.printBitmap("IDCard", bitmap);*/
// github library
/* ImageAsset */
/* ImageAsset bitmapAsset = new ImageAsset(this, bitmap, ImageAsset.MeasurementUnits.INCHES, 3.46f,4.92f);
*//* PrintItem *//*
// PrintItem printItemDefault = new ImagePrintItem(PrintItem.ScaleType.CENTER, bitmapAsset);
PrintItem printItemB7 = new ImagePrintItem(PrintAttributes.MediaSize.ISO_B7, PrintItem.ScaleType.FIT, bitmapAsset);
*//*PrintJobData*//*
PrintJobData printJobData = new PrintJobData(this, printItemB7);
printJobData.setJobName("Example");
PrintAttributes printAttributes = new PrintAttributes.Builder()
.setMediaSize(printItemB7.getMediaSize())
.build();
printJobData.setPrintDialogOptions(printAttributes);
PrintUtil.setPrintJobData(printJobData);
if(Build.VERSION.SDK_INT >= 19) {
Intent intent = new Intent(this, PrintPluginManagerActivity.class);
startActivity(intent);
}*/
/*Print*/
/*PrintUtil.print(this);*/
// posifix code
/*USBAdapter usbAdapter = new USBAdapter();
usbAdapter.printBitmap(this,bitmap);*/
}
return true;
case R.id.clear_form:
ViewGroup group = (ViewGroup)findViewById(idCardLayout);
for (int i = 0, count = group.getChildCount(); i < count; ++i) {
View view = group.getChildAt(i);
if (view instanceof EditText) {
((EditText)view).setText("");
}
}
imageVPhoto.setImageDrawable(getResources().getDrawable(android.R.drawable.ic_menu_camera));
return true;
/*case R.id.action_options:
return true;
*/
case R.id.action_about:
if(idCard!=null) {
Bitmap bitmap = Bitmap.createBitmap(convertDpToPx(332), convertDpToPx(472),
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
idCard.draw(canvas);
/* ImageAsset */
ImageAsset bitmapAsset = new ImageAsset(this, bitmap, ImageAsset.MeasurementUnits.INCHES, 3.46f,4.92f);
// PrintItem printItemDefault = new ImagePrintItem(PrintItem.ScaleType.CENTER, bitmapAsset);
PrintItem printItemB7 = new ImagePrintItem(PrintAttributes.MediaSize.ISO_B7, PrintItem.ScaleType.FIT, bitmapAsset);
PrintJobData printJobData = new PrintJobData(this, printItemB7);
printJobData.setJobName("Example");
PrintAttributes printAttributes = new PrintAttributes.Builder()
.setMediaSize(printItemB7.getMediaSize())
.build();
printJobData.setPrintDialogOptions(printAttributes);
PrintUtil.setPrintJobData(printJobData);
if(Build.VERSION.SDK_INT >= 19) {
Intent intent = new Intent(this, PrintPluginManagerActivity.class);
startActivity(intent);
}
/*Print*/
// PrintUtil.print(this);
}
/*Toast.makeText(this,"This is a demo app, work in progress!",Toast.LENGTH_SHORT).show();*/
return true;
default:
// If we got here, the user's action was not recognized.
// Invoke the superclass to handle it.
return super.onOptionsItemSelected(item);
}
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
MenuItem itemPrint = menu.findItem(R.id.action_print);
MenuItem itemBack = menu.findItem(R.id.back);
MenuItem itemClear = menu.findItem(R.id.clear_form);
enablePrintMenu(itemPrint,isPrintMenuAvailable);
enableMenu(itemBack,isBackMenuAvailable);
enableMenu(itemClear,isClearMenuAvailable);
return true;
}
/* enable menu and change alpha value */
private void enablePrintMenu(MenuItem item,boolean isMenuAvailable) {
if (isMenuAvailable) {
item.setEnabled(true);
item.getIcon().setAlpha(255);
} else {
// disabled
item.setEnabled(false);
item.getIcon().setAlpha(130);
}
}
/* enable menu and change visibility */
private void enableMenu(MenuItem item,boolean isMenuAvailable) {
if (isMenuAvailable) {
item.setEnabled(true);
item.setVisible(true);
} else {
// disabled
item.setEnabled(false);
item.setVisible(false);
}
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.imageVPhoto:
takePhoto();
break;
case R.id.editTDOB:
showStartDateDialog();
break;
case R.id.btnPreview:
if ((purpose == DMDKConstants.PURPOSE_NEW_REGISTER)) {
verifyPhoneDOB();
}
if (selectedPanchayat == null) {
showAlertDialog("Panchayat/Town/City/District details manually typed. Tamil Translation not available!");
}
// show uneditable preview
if (isAllFieldsFilled()) {
// activate print menu and back menu
isPrintMenuAvailable = true;
isBackMenuAvailable = true;
isClearMenuAvailable = false;
invalidateOptionsMenu();
setLocale("ta");
// storing to database
if (isPushMemberData) {
if (purpose == DMDKConstants.PURPOSE_UPDATE_RECORDS) {
storingToDatabase(true);
return;
} else if (purpose == DMDKConstants.PURPOSE_NEW_REGISTER) {
{
storingToDatabase(false);
}
}
// end of storing to database
idCardView = (View) findViewById(idCardLayout);
idCardView.setVisibility(View.GONE);
RelativeLayout layout = (RelativeLayout) findViewById(R.id.few);
idCard = getIDCard();
idCardRId = View.generateViewId();
idCard.setId(idCardRId);
layout.addView(idCard);
imageVPhotoPrint.setImageDrawable(imageVPhoto.getDrawable());
// clearing any focus
View currentFocusedView = getCurrentFocus();
if (currentFocusedView != null) currentFocusedView.clearFocus();
if (mLinearLayout != null) {
mLinearLayout.requestFocus();
}
hideKeyboard(this);
} else {
showAlertDialog("Some fields are missing!");
}
}
break;
}
}
private void storingToDatabase(boolean isUpdate) {
MemberDatum memberDatum = new MemberDatum();
memberDatum.setPhone(editTPhone.getText().toString());
memberDatum.setDob(editTDOB.getText().toString());
memberDatum.setMembershipId(editTMembershipId.getText().toString());
memberDatum.setName(editTName.getText().toString());
memberDatum.setHusbandName(editTHusband.getText().toString());
String[] genderArray= getResources().getStringArray(R.array.genderArray);
if(spinGender.getSelectedItemPosition()>0) {
memberDatum.setGender(genderArray[spinGender.getSelectedItemPosition()]);
}else{
memberDatum.setGender("---");
}
memberDatum.setVoterId(editTVoterId.getText().toString());
if(selectedMpMlaDistrict!=null) {
memberDatum.setMp(selectedMpMlaDistrict.getMp_tamil());
memberDatum.setMla(selectedMpMlaDistrict.getMla_tamil());
}
else{
memberDatum.setMp(editTMP.getText().toString());
memberDatum.setMla(editTMLA.getText().toString());
}
if(selectedPanchayat!=null) {
memberDatum.setPanchayat(selectedPanchayat.getVillage_panchayat_name_tamil());
}
else{
memberDatum.setPanchayat(autoCompleteTVEntryFormPanchayat.getText().toString().trim());
}
if(selectedPanchayat!=null) {
memberDatum.setTownCity(selectedPanchayat.getDistrict_name_tamil());
}
else{
memberDatum.setTownCity(autoCompleteTVTownCity.getText().toString().trim());
}
if(selectedPanchayat!=null) {
memberDatum.setDistrict(selectedPanchayat.getDistrict_name_tamil());
}
else{
memberDatum.setDistrict(autoCompleteTVTownCity.getText().toString().trim());
}
memberDatum.setWard(editTWard.getText().toString());
memberDatum.setDoj(editTDate.getText().toString());
if(isUpdate && updateMemberRef!=null){
updateMemberRef.removeValue();
}
databaseMemberDataReference.push().setValue(memberDatum);
}
private boolean isAllFieldsFilled() {
ViewGroup group = (ViewGroup)findViewById(idCardLayout);
for (int i = 0, count = group.getChildCount(); i < count; ++i) {
View view = group.getChildAt(i);
if (view instanceof EditText) {
if(TextUtils.isEmpty(((EditText)view).getText().toString().trim())){
return false;
}
}
}
return true;
}
public void printPDF(View view) {
PrintManager printManager = (PrintManager) getSystemService(PRINT_SERVICE);
PrintAttributes.Builder builder = new PrintAttributes.Builder();
builder.setMediaSize( PrintAttributes.MediaSize.ISO_B7);
printManager.print("print_any_view_job_name", new ViewPrintAdapter(this,
view), builder.build());
}
@TargetApi(19)
private void generatePdf() {
int widthPostScript = (int) 3.56 * 72;
int heighPostScript = (int) 4.94 * 72;
PrintAttributes.Builder builder = new PrintAttributes.Builder();
builder.setColorMode(PrintAttributes.COLOR_MODE_COLOR);
builder.setMediaSize(PrintAttributes.MediaSize.ISO_B7);// or ISO_B7
builder.setMinMargins(PrintAttributes.Margins.NO_MARGINS);
/*
builder.setResolution(PrintAttributes.Resolution.ISO_B7);
*/
PrintedPdfDocument document = new PrintedPdfDocument(this, builder.build());
Page page = document.startPage(1);
idCardView = (View) findViewById(idCardLayout);
View content = idCardView;
Canvas canvas = page.getCanvas();
float scaleWidth = (float)332.16/(float)content.getWidth();
float scaleHeight = (float)472.32/(float)content.getHeight();
canvas.scale(scaleWidth, scaleHeight);
content.draw(canvas);
document.finishPage(page);
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
//handle case of no SDCARD present
} else {
String dir = Environment.getExternalStorageDirectory() + File.separator + "myDirectory";
//create folder
File folder = new File(dir); //folder name
folder.mkdirs();
//create file
String pdfName = "idcard_pdf"
/*+ sdf.format(Calendar.getInstance().getTime()) */ + ".pdf";
try {
File outputFile = new File(dir, pdfName);
Prefs.putString(DMDKConstants.IDCARD_PDF_PATH, outputFile.getPath());
/*
File file = new File(getExternalFilesDir(null).getAbsolutePath(), "document22.pdf");
*/
document.writeTo(new FileOutputStream(outputFile));
} catch (IOException e) {
Log.e("cannot generate pdf", e.toString());
}
}
document.close();
}
private boolean generateIDCardPDF() {
// Toast.makeText(this,"Printing the ID card",Toast.LENGTH_SHORT).show();
// create a new document
PdfDocument document = new PdfDocument();
int widthPostScript = (int) 3 * 72;
int heighPostScript = (int) 4 * 72;
// crate a page description
PageInfo pageInfo = new PageInfo.Builder(widthPostScript, heighPostScript, 1).create();
// start a page
Page page = document.startPage(pageInfo);
idCardView = (View) findViewById(idCardLayout);
Canvas canvas = page.getCanvas();
Resources res = getResources();
DisplayMetrics dm = res.getDisplayMetrics();
float scaleWidth = (float)widthPostScript/(float)(idCardView.getMeasuredWidth()*72/dm.xdpi);
float scaleHeight = (float)heighPostScript/(float)(idCardView.getMeasuredHeight()*72/dm.xdpi);
canvas.scale(scaleWidth, scaleHeight);
idCardView.draw(canvas);
// finish the page
document.finishPage(page);
// add more pages
// write the document content
// document.writeTo(getOutputStream());
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
//handle case of no SDCARD present
} else {
String dir = Environment.getExternalStorageDirectory() + File.separator + "myDirectory";
//create folder
File folder = new File(dir); //folder name
folder.mkdirs();
//create file
String pdfName = "idcard_pdf"
/*+ sdf.format(Calendar.getInstance().getTime()) */ + ".pdf";
File outputFile = new File(dir, pdfName);
Prefs.putString(DMDKConstants.IDCARD_PDF_PATH, outputFile.getPath());
try {
outputFile.createNewFile();
OutputStream out = new FileOutputStream(outputFile);
document.writeTo(out);
// close the document
document.close();
out.close();
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
return true;
}
private PrintJob print(String name, PrintDocumentAdapter adapter,
PrintAttributes attrs) {
startService(new Intent(this, PrintJobMonitorService.class));
return (mgr.print(name, adapter, attrs));
}
private void takePhoto() {
MarshMallowPermission marshMallowPermission = new MarshMallowPermission(this);
if (!marshMallowPermission.checkPermissionForCamera()) {
marshMallowPermission.requestPermissionForCamera();
}else {
if (!marshMallowPermission.checkPermissionForExternalStorage()) {
marshMallowPermission.requestPermissionForExternalStorage();
} else {
file = new File(Environment.getExternalStorageDirectory()
+ File.separator + "/test.jpg"/*getFilesDir(), "member_photo.jpg"*/);
try {
if (file.exists()) {
file.delete();
}
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
Intent i = new CameraActivity.IntentBuilder(this)
.skipConfirm()
.facing(Facing.BACK)
.to(Uri.fromFile(file))
.zoomStyle(ZoomStyle.SEEKBAR)
.updateMediaStore()
.build();
startActivityForResult(i, DMDKConstants.REQUEST_PICTURE);
}
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
if (requestCode == DMDKConstants.REQUEST_PICTURE) {
if (resultCode == RESULT_OK) {
memberBitmap = (Bitmap) data.getParcelableExtra("data");
if(memberBitmap != null) {
imageVPhoto.setImageBitmap(memberBitmap);
}else{
// app flow this way always as we provide target file location in intentbuilder
setPic(imageVPhoto);
}
} else {
imageVPhoto.setImageDrawable(getResources().getDrawable(android.R.drawable.ic_menu_camera));
}
}
}
private void setPic(ImageView mImageView) {
// Get the dimensions of the View
int targetW = mImageView.getWidth();
int targetH = mImageView.getHeight();
// Get the dimensions of the bitmap
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
bmOptions.inJustDecodeBounds = true;
BitmapFactory.decodeFile(file.getPath(), bmOptions);
int photoW = bmOptions.outWidth;
int photoH = bmOptions.outHeight;
// Determine how much to scale down the image
int scaleFactor = Math.min(photoW/targetW, photoH/targetH);
// Decode the image file into a Bitmap sized to fill the View
bmOptions.inJustDecodeBounds = false;
bmOptions.inSampleSize = scaleFactor;
bmOptions.inPurgeable = true;
Bitmap bitmap = BitmapFactory.decodeFile(file.getPath(), bmOptions);
mImageView.setImageBitmap(bitmap);
}
public void setLocale(String lang) {
Locale myLocale = new Locale(lang);
Resources res = getResources();
DisplayMetrics dm = res.getDisplayMetrics();
Configuration conf = res.getConfiguration();
conf.locale = myLocale;
res.updateConfiguration(conf, dm);
// MembershipEntryActivity.this.recreate();
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
}
@Override
public void onStart() {
super.onStart();
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
client.connect();
Action viewAction = Action.newAction(
Action.TYPE_VIEW, // TODO: choose an action type.
"IDCardPreview Page", // TODO: Define a title for the content shown.
// TODO: If you have web page content that matches this app activity's content,
// make sure this auto-generated web page URL is correct.
// Otherwise, set the URL to null.
Uri.parse("http://host/path"),
// TODO: Make sure this auto-generated app URL is correct.
Uri.parse("android-app://com.de.dmdk/http/host/path")
);
AppIndex.AppIndexApi.start(client, viewAction);
}
@Override
public void onStop() {
super.onStop();
LocaleHelper.setLocale(this,"en");
}
private class PDFGeneration extends AsyncTask<String, Integer, Boolean> {
@Override
protected Boolean doInBackground(String... params) {
return generateIDCardPDF();
}
@Override
protected void onPostExecute(Boolean result) {
// dotLoader.setVisibility(View.GONE);
if(result) {
print("TEST IDCARD PDF",
new PdfDocumentAdapter(getApplicationContext()),
new PrintAttributes.Builder().build());
}
}
@Override
protected void onPreExecute() {
// dotLoader.setVisibility(View.VISIBLE);
}
@Override
protected void onProgressUpdate(Integer... values) {
}
}
/* @Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
}*/
private RelativeLayout getIDCard(){
RelativeLayout idCardLayout = new RelativeLayout(this);
idCardLayout.setId(R.id.idCardLayout);
idCardLayout.setBackgroundResource(R.drawable.id_card_border);
idCardLayout.setPadding(convertDpToPx(32), convertDpToPx(16),convertDpToPx(32), 0);
RelativeLayout.LayoutParams layout_506 = new RelativeLayout.LayoutParams(convertDpToPx(332),convertDpToPx(472));
layout_506.addRule(RelativeLayout.CENTER_IN_PARENT);
idCardLayout.setLayoutParams(layout_506);
ImageView imageVFlagIcon = new ImageView(this);
imageVFlagIcon.setId(R.id.imageVFlagIcon);
imageVFlagIcon.setImageResource(R.drawable.idcard_logo_flag);
RelativeLayout.LayoutParams layout_621 = new RelativeLayout.LayoutParams(convertDpToPx(50),convertDpToPx(50));
layout_621.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
layout_621.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
layout_621.width = convertDpToPx(50);
layout_621.height = convertDpToPx(50);
imageVFlagIcon.setLayoutParams(layout_621);
idCardLayout.addView(imageVFlagIcon);
ImageView imageVSymbolIcon = new ImageView(this);
imageVSymbolIcon.setId(R.id.imageVSymbolIcon);
imageVSymbolIcon.setImageResource(R.drawable.idcard_logo_symbol);
RelativeLayout.LayoutParams layout_565 = new RelativeLayout.LayoutParams(convertDpToPx(50),convertDpToPx(50));
layout_565.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
layout_565.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
layout_565.width = convertDpToPx(50);
layout_565.height = convertDpToPx(50);
imageVSymbolIcon.setLayoutParams(layout_565);
idCardLayout.addView(imageVSymbolIcon);
TextView textVName = new TextView(this);
textVName.setId(R.id.textVName);
textVName.setText(getResources().getString(R.string.name));
textVName.setTextColor(getResources().getColor(R.color.colorFont));
textVName.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_391 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_391.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_391.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_391.addRule(RelativeLayout.BELOW, R.id.imageVFlagIcon);
textVName.setLayoutParams(layout_391);
idCardLayout.addView(textVName);
EditText editTNamePrint = new EditText(this);
editTNamePrint.setId(R.id.editTName);
editTNamePrint.setEms(20);
editTNamePrint.setRawInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
editTNamePrint.setLines(1);
editTNamePrint.setText(editTName.getText().toString().trim());
setEditTextEditable(editTNamePrint, false);
editTNamePrint.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_447 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_447.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_447.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_447.addRule(RelativeLayout.RIGHT_OF, R.id.textVName);
layout_447.addRule(RelativeLayout.ALIGN_BASELINE, R.id.textVName);
editTNamePrint.setLayoutParams(layout_447);
idCardLayout.addView(editTNamePrint);
TextView textVAge = new TextView(this);
textVAge.setId(R.id.textVAge);
textVAge.setText(getResources().getString(R.string.dob));
textVAge.setTextColor(getResources().getColor(R.color.colorFont));
textVAge.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_131 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_131.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_131.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_131.addRule(RelativeLayout.BELOW, R.id.textVName);
layout_131.addRule(RelativeLayout.ALIGN_LEFT, R.id.textVName);
layout_131.rightMargin = convertDpToPx(8);
layout_131.topMargin = convertDpToPx(15);
textVAge.setLayoutParams(layout_131);
idCardLayout.addView(textVAge);
EditText editTAgePrint = new EditText(this);
editTAgePrint.setId(R.id.editTAge);
editTAgePrint.setEms(6);
editTAgePrint.setText(editTDOB.getText().toString().trim());
setEditTextEditable(editTAgePrint, false);
editTAgePrint.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
editTAgePrint.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
RelativeLayout.LayoutParams layout_192 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_192.addRule(RelativeLayout.RIGHT_OF, R.id.textVAge);
layout_192.addRule(RelativeLayout.ALIGN_BASELINE, R.id.textVAge);
layout_192.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_192.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_192.rightMargin = convertDpToPx(8);
editTAgePrint.setLayoutParams(layout_192);
idCardLayout.addView(editTAgePrint);
TextView textVGender = new TextView(this);
textVGender.setId(R.id.textVGender);
textVGender.setText(getResources().getString(R.string.gender));
textVGender.setTextColor(getResources().getColor(R.color.colorFont));
textVGender.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_297 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_297.addRule(RelativeLayout.RIGHT_OF, R.id.editTAge);
layout_297.addRule(RelativeLayout.ALIGN_BASELINE, R.id.editTAge);
layout_297.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_297.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_297.rightMargin = convertDpToPx(8);
textVGender.setLayoutParams(layout_297);
idCardLayout.addView(textVGender);
EditText editGender = new EditText(this);
editGender.setId(R.id.spinGender);
editTNamePrint.setEms(4);
editGender.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
String[] genderArray= getResources().getStringArray(R.array.genderArray);
if(spinGender.getSelectedItemPosition()>0) {
editGender.setText(genderArray[spinGender.getSelectedItemPosition()]);
}else{
editGender.setText("-");
}
setEditTextEditable(editGender, false);
RelativeLayout.LayoutParams layout_803 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_803.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_803.addRule(RelativeLayout.RIGHT_OF, R.id.textVGender);
layout_803.addRule(RelativeLayout.ALIGN_BASELINE, R.id.textVGender);
layout_803.rightMargin = convertDpToPx(8);
editGender.setLayoutParams(layout_803);
idCardLayout.addView(editGender);
TextView textVHusband = new TextView(this);
textVHusband.setId(R.id.textVHusband);
textVHusband.setText(getResources().getString(R.string.husband_name));
textVHusband.setTextColor(getResources().getColor(R.color.colorFont));
textVHusband.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_19 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_19.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_19.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_19.addRule(RelativeLayout.BELOW, R.id.textVAge);
layout_19.addRule(RelativeLayout.ALIGN_LEFT, R.id.textVAge);
layout_19.rightMargin = convertDpToPx(8);
layout_19.topMargin = convertDpToPx(15);
textVHusband.setLayoutParams(layout_19);
idCardLayout.addView(textVHusband);
EditText editTHusbandPrint = new EditText(this);
editTHusbandPrint.setId(R.id.editTHusband);
editTHusbandPrint.setEms(20);
editTHusbandPrint.setText(editTHusband.getText().toString().trim());
setEditTextEditable(editTHusbandPrint, false);
editTHusbandPrint.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
editTHusbandPrint.setRawInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
RelativeLayout.LayoutParams layout_752 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_752.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_752.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_752.addRule(RelativeLayout.RIGHT_OF, R.id.textVHusband);
layout_752.addRule(RelativeLayout.BELOW, R.id.spinGender);
layout_752.addRule(RelativeLayout.ALIGN_BASELINE, R.id.textVHusband);
layout_752.rightMargin = convertDpToPx(8);
editTHusbandPrint.setLayoutParams(layout_752);
idCardLayout.addView(editTHusbandPrint);
TextView textVVoterId = new TextView(this);
textVVoterId.setId(R.id.textVVoterId);
textVVoterId.setText(getResources().getString(R.string.voter_id));
textVVoterId.setTextColor(getResources().getColor(R.color.colorFont));
textVVoterId.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_760 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_760.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_760.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_760.addRule(RelativeLayout.BELOW, R.id.textVHusband);
layout_760.addRule(RelativeLayout.ALIGN_LEFT, R.id.textVHusband);
layout_760.rightMargin = convertDpToPx(8);
layout_760.topMargin = convertDpToPx(15);
textVVoterId.setLayoutParams(layout_760);
idCardLayout.addView(textVVoterId);
EditText editTVoterIdPrint = new EditText(this);
editTVoterIdPrint.setId(R.id.editTVoterId);
editTVoterIdPrint.setEms(20);
editTVoterIdPrint.setText(editTVoterId.getText().toString().trim());
setEditTextEditable(editTVoterIdPrint, false);
editTVoterIdPrint.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
editTVoterIdPrint.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
RelativeLayout.LayoutParams layout_357 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_357.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_357.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_357.addRule(RelativeLayout.RIGHT_OF, R.id.textVVoterId);
layout_357.addRule(RelativeLayout.ALIGN_BASELINE, R.id.textVVoterId);
layout_357.rightMargin = convertDpToPx(8);
editTVoterIdPrint.setLayoutParams(layout_357);
idCardLayout.addView(editTVoterIdPrint);
TextView textVWard = new TextView(this);
textVWard.setId(R.id.textVWard);
textVWard.setText(getResources().getString(R.string.ward));
textVWard.setTextColor(getResources().getColor(R.color.colorFont));
textVWard.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_61 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_61.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_61.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_61.addRule(RelativeLayout.BELOW, R.id.textVVoterId);
layout_61.addRule(RelativeLayout.ALIGN_LEFT, R.id.textVVoterId);
layout_61.rightMargin = convertDpToPx(8);
layout_61.topMargin = convertDpToPx(15);
textVWard.setLayoutParams(layout_61);
idCardLayout.addView(textVWard);
EditText editTWardPrint = new EditText(this);
editTWardPrint.setId(R.id.editTWard);
editTWardPrint.setEms(20);
editTWardPrint.setText(editTWard.getText().toString().trim());
setEditTextEditable(editTWardPrint, false);
editTWardPrint.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
editTWardPrint.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
RelativeLayout.LayoutParams layout_611 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_611.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_611.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_611.addRule(RelativeLayout.RIGHT_OF, R.id.textVWard);
layout_611.addRule(RelativeLayout.ALIGN_BASELINE, R.id.textVWard);
layout_611.rightMargin = convertDpToPx(8);
editTWardPrint.setLayoutParams(layout_611);
idCardLayout.addView(editTWardPrint);
TextView textVPanchayat = new TextView(this);
textVPanchayat.setId(R.id.textVPanchayat);
textVPanchayat.setText(getResources().getString(R.string.panchayat));
textVPanchayat.setTextColor(getResources().getColor(R.color.colorFont));
textVPanchayat.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_695 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_695.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_695.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_695.addRule(RelativeLayout.BELOW, R.id.textVWard);
layout_695.addRule(RelativeLayout.ALIGN_LEFT, R.id.textVWard);
layout_695.rightMargin = convertDpToPx(8);
layout_695.topMargin = convertDpToPx(15);
textVPanchayat.setLayoutParams(layout_695);
idCardLayout.addView(textVPanchayat);
InstantAutoCompleteTextView autoCompleteTVPanchayatPrint = new InstantAutoCompleteTextView(this);
autoCompleteTVPanchayatPrint.setId(R.id.autoCompleteTVPanchayatPrint);
autoCompleteTVPanchayatPrint.setEms(12);
if(selectedPanchayat!=null) {
autoCompleteTVPanchayatPrint.setText(selectedPanchayat.getVillage_panchayat_name_tamil());
}
else{
autoCompleteTVPanchayatPrint.setText(autoCompleteTVEntryFormPanchayat.getText().toString().trim());
}
setEditTextEditable(autoCompleteTVPanchayatPrint, false);
autoCompleteTVPanchayatPrint.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_80 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_80.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_80.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_80.addRule(RelativeLayout.RIGHT_OF, R.id.textVPanchayat);
layout_80.addRule(RelativeLayout.ALIGN_BASELINE, R.id.textVPanchayat);
layout_80.rightMargin = convertDpToPx(8);
autoCompleteTVPanchayatPrint.setLayoutParams(layout_80);
idCardLayout.addView(autoCompleteTVPanchayatPrint);
TextView textVTownCity = new TextView(this);
textVTownCity.setId(R.id.textVTownCity);
textVTownCity.setText(getResources().getString(R.string.town_city));
textVTownCity.setTextColor(getResources().getColor(R.color.colorFont));
textVTownCity.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_528 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_528.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_528.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_528.addRule(RelativeLayout.BELOW, R.id.textVPanchayat);
layout_528.addRule(RelativeLayout.ALIGN_LEFT, R.id.textVPanchayat);
layout_528.rightMargin = convertDpToPx(8);
layout_528.topMargin = convertDpToPx(15);
textVTownCity.setLayoutParams(layout_528);
idCardLayout.addView(textVTownCity);
InstantAutoCompleteTextView autoCompleteTVTownCityPrint = new InstantAutoCompleteTextView(this);
autoCompleteTVTownCityPrint.setId(R.id.autoCompleteTVTownCityPrint);
autoCompleteTVTownCityPrint.setEms(8);
if(selectedPanchayat!=null) {
autoCompleteTVTownCityPrint.setText(selectedPanchayat.getDistrict_name_tamil());
}
else{
autoCompleteTVTownCityPrint.setText(autoCompleteTVTownCity.getText().toString().trim());
}
autoCompleteTVTownCityPrint.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
setEditTextEditable(autoCompleteTVTownCityPrint, false);
RelativeLayout.LayoutParams layout_656 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_656.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_656.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_656.addRule(RelativeLayout.RIGHT_OF, R.id.textVTownCity);
layout_656.addRule(RelativeLayout.ALIGN_BASELINE, R.id.textVTownCity);
layout_656.rightMargin = convertDpToPx(8);
autoCompleteTVTownCityPrint.setLayoutParams(layout_656);
idCardLayout.addView(autoCompleteTVTownCityPrint);
TextView textVDistrict = new TextView(this);
textVDistrict.setId(R.id.textVDistrict);
textVDistrict.setText(getResources().getString(R.string.district));
textVDistrict.setTextColor(getResources().getColor(R.color.colorFont));
textVDistrict.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_45 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_45.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_45.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_45.addRule(RelativeLayout.BELOW, R.id.textVTownCity);
layout_45.addRule(RelativeLayout.ALIGN_LEFT, R.id.textVTownCity);
layout_45.rightMargin = convertDpToPx(8);
layout_45.topMargin = convertDpToPx(15);
textVDistrict.setLayoutParams(layout_45);
idCardLayout.addView(textVDistrict);
InstantAutoCompleteTextView autoCompleteTVDistrictPrint = new InstantAutoCompleteTextView(this);
autoCompleteTVDistrictPrint.setId(R.id.autoCompleteTVDistrictPrint);
autoCompleteTVDistrictPrint.setEms(8);
if(selectedPanchayat!=null) {
autoCompleteTVDistrictPrint.setText(selectedPanchayat.getDistrict_name_tamil());
}
else{
autoCompleteTVDistrictPrint.setText(autoCompleteTVDistrict.getText().toString().trim());
}
autoCompleteTVDistrictPrint.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
setEditTextEditable(autoCompleteTVDistrictPrint, false);
RelativeLayout.LayoutParams layout_147 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_147.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_147.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_147.addRule(RelativeLayout.RIGHT_OF, R.id.textVDistrict);
layout_147.addRule(RelativeLayout.ALIGN_BASELINE, R.id.textVDistrict);
layout_147.rightMargin = convertDpToPx(8);
autoCompleteTVDistrictPrint.setLayoutParams(layout_147);
idCardLayout.addView(autoCompleteTVDistrictPrint);
TextView textVMembershipId = new TextView(this);
textVMembershipId.setId(R.id.textVMembershipId);
textVMembershipId.setText(getResources().getString(R.string.membership_id));
textVMembershipId.setTextColor(getResources().getColor(R.color.colorFont));
textVMembershipId.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_961 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_961.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_961.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_961.addRule(RelativeLayout.BELOW, R.id.textVDistrict);
layout_961.addRule(RelativeLayout.ALIGN_LEFT, R.id.textVDistrict);
layout_961.rightMargin = convertDpToPx(8);
layout_961.topMargin = convertDpToPx(15);
layout_961.bottomMargin = convertDpToPx(10);
textVMembershipId.setLayoutParams(layout_961);
idCardLayout.addView(textVMembershipId);
EditText editTMembershipIdPrint = new EditText(this);
editTMembershipIdPrint.setId(R.id.editTMembershipIdPrint);
editTMembershipIdPrint.setEms(5);
editTMembershipIdPrint.setText(editTMembershipId.getText().toString().trim());
setEditTextEditable(editTMembershipIdPrint, false);
editTMembershipIdPrint.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
editTMembershipIdPrint.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
RelativeLayout.LayoutParams layout_302 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_302.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_302.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_302.addRule(RelativeLayout.RIGHT_OF, R.id.textVMembershipId);
layout_302.addRule(RelativeLayout.ALIGN_BASELINE, R.id.textVMembershipId);
layout_302.rightMargin = convertDpToPx(8);
editTMembershipIdPrint.setLayoutParams(layout_302);
idCardLayout.addView(editTMembershipIdPrint);
TextView textVdate = new TextView(this);
textVdate.setId(R.id.textVdate);
textVdate.setText(getResources().getString(R.string.date));
textVdate.setTextColor(getResources().getColor(R.color.colorFont));
textVdate.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_70 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_70.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_70.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_70.addRule(RelativeLayout.RIGHT_OF, R.id.editTMembershipIdPrint);
layout_70.addRule(RelativeLayout.ALIGN_BASELINE, R.id.editTMembershipIdPrint);
layout_70.rightMargin = convertDpToPx(8);
layout_70.topMargin = convertDpToPx(15);
textVdate.setLayoutParams(layout_70);
idCardLayout.addView(textVdate);
EditText editTDatePrint = new EditText(this);
editTDatePrint.setId(R.id.editTDatingPrint);
editTDatePrint.setText(editTDate.getText().toString().trim());
setEditTextEditable(editTDatePrint, false);
editTDatePrint.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
editTDatePrint.setEms(7);
RelativeLayout.LayoutParams layout_112 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_112.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_112.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_112.addRule(RelativeLayout.RIGHT_OF, R.id.textVdate);
layout_112.addRule(RelativeLayout.ALIGN_BASELINE, R.id.textVdate);
editTDatePrint.setLayoutParams(layout_112);
idCardLayout.addView(editTDatePrint);
imageVPhotoPrint = new ImageView(this);
imageVPhotoPrint.setId(R.id.imageVPhoto);
RelativeLayout.LayoutParams layout_63 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_63.addRule(RelativeLayout.ALIGN_LEFT, R.id.textVMembershipId);
layout_63.addRule(RelativeLayout.BELOW, R.id.textVMembershipId);
layout_63.width = convertDpToPx(70);
layout_63.height = convertDpToPx(80);
layout_63.bottomMargin = convertDpToPx(18);
imageVPhotoPrint.setLayoutParams(layout_63);
idCardLayout.addView(imageVPhotoPrint);
TextView textVGeneralSecretary = new TextView(this);
textVGeneralSecretary.setId(R.id.textVGeneralSecretary);
textVGeneralSecretary.setText(getResources().getString(R.string.general_secretary));
textVGeneralSecretary.setTextColor(getResources().getColor(R.color.colorFont));
textVGeneralSecretary.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
RelativeLayout.LayoutParams layout_452 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layout_452.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_452.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
layout_452.bottomMargin = convertDpToPx(18);
layout_452.setMarginEnd(convertDpToPx(36));
layout_452.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
layout_452.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
textVGeneralSecretary.setLayoutParams(layout_452);
idCardLayout.addView(textVGeneralSecretary);
return idCardLayout;
}
private int convertDpToPx(int dp){
return (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, getResources().getDisplayMetrics());
}
private void setEditTextEditable(EditText editText,boolean yes){
if (!yes) { // disable editing password
editText.setFocusable(false);
editText.setFocusableInTouchMode(false); // user touches widget on phone with touch screen
editText.setClickable(false); // user navigates with wheel and selects widget
} else { // enable editing of password
editText.setFocusable(true);
editText.setFocusableInTouchMode(true);
editText.setClickable(true);
}
}
public void showStartDateDialog(){
Calendar c = Calendar.getInstance();
int mYear = c.get(Calendar.YEAR);
int mMonth = c.get(Calendar.MONTH);
int mDay = c.get(Calendar.DAY_OF_MONTH);
System.out.println("the selected " + mDay);
DatePickerDialog dialog = new DatePickerDialog(this,android.R.style.Theme_Holo_Dialog,
new mDateSetListener(), mYear, mMonth, mDay);
dialog.show();
}
/* public void showAlertDialog(String message){
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle(getString(R.string.app_name));
alertDialog.setMessage(message);
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alertDialog.show();
}*/
class mDateSetListener implements DatePickerDialog.OnDateSetListener {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
// TODO Auto-generated method stub
// getCalender();
int mYear = year;
int mMonth = monthOfYear;
int mDay = dayOfMonth;
editTDOB.setText(new StringBuilder()
.append(mDay).append("/")
// Month is 0 based so add 1
.append(mMonth + 1).append("/")
.append(mYear).append(" "));
System.out.println(editTDOB.getText().toString());
}
}
@Override
public void onBackPressed() {
if(isBackMenuAvailable){
setLocale("en");
MenuItem menuBack = menu.findItem(R.id.back);
onOptionsItemSelected(menuBack);
}else {
super.onBackPressed();
}
}
public static void hideKeyboard(Activity activity) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
//Find the currently focused view, so we can grab the correct window token from it.
View view = activity.getCurrentFocus();
//If no view currently has focus, create a new one, just so we can grab a window token from it
if (view == null) {
view = new View(activity);
}
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
/* void printTemplateSample()
{
Printer myPrinter = new Printer();
PrinterInfo myPrinterInfo = new PrinterInfo();
try{
// Retrieve printer informations
myPrinterInfo = myPrinter.getPrinterInfo();
// Set printer informations
myPrinterInfo.printerModel = PrinterInfo.Model.PJ_663;
myPrinterInfo.port=PrinterInfo.Port.BLUETOOTH;
myPrinterInfo.printMode=PrinterInfo.PrintMode.ORIGINAL;
myPrinterInfo.paperSize = PrinterInfo.PaperSize.A4;
myPrinter.setPrinterInfo(myPrinterInfo);
// Start creating P-touch Template command print data
myPrinter.startPTTPrint(1, null);
// Replace text
myPrinter.replaceText("abcde");
myPrinter.replaceText("12345");
// Trasmit P-touch Template command print data
myPrinter.flushPTTPrint();
}catch(Exception e){
}
}*/
private void showDialogs(String title,String message){
LayoutInflater linf = LayoutInflater.from(this);
final View inflator = linf.inflate(R.layout.search_dialog, null);
AlertDialog.Builder alert = new AlertDialog.Builder(this,R.style.DialogTheme);
alert.setTitle(title);
/*alert.setMessage(message);*/
alert.setView(inflator);
final EditText et1 = (EditText) inflator.findViewById(R.id.editTSearchMemberId);
alert.setPositiveButton("ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton)
{
if(!TextUtils.isEmpty(et1.getText())) {
String formatted = et1.getText().toString().trim();
if (formatted.length()==1) {
formatted = String.format("%02d", Integer.parseInt(et1.getText().toString().trim()));
}
searchMember(formatted);
}else{
showAlertDialog("Please enter memberid");
}
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.cancel();
finish();
}
});
if(!(isFinishing()))
alert.show();
}
/* Search member */
private void searchMember(final String memberID) {
showProgress("");
Query queryRef = databaseMemberDataReference.orderByChild("membershipId").equalTo(memberID)/*.orderByChild("dob")*/;
queryRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if(updateMemberRef!=null){
showAlertDialogWithClickListener("Member " + " updated!!!", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialogInterface, int i) {
finish();
}
},new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialogInterface, int i) {
finish();
}
});
}
if(dataSnapshot.getValue() != null){
dismissProgress();
for(DataSnapshot childDataSnapshot:dataSnapshot.getChildren()){
MemberDatum memberDatum= childDataSnapshot.getValue(MemberDatum.class);
if(memberDatum.getMembershipId().equalsIgnoreCase(memberID)){
// Toast.makeText(getApplicationContext(),memberDatum.getName()+" Member already found!!!",Toast.LENGTH_SHORT).show();
showAlertDialog("Member " + memberDatum.getName() + " found!!!");
if(purpose == DMDKConstants.PURPOSE_UPDATE_RECORDS) {
btnPreview.setText("Update");
}else if(purpose == DMDKConstants.PURPOSE_PRINT){
btnPreview.setText("Print");
}
btnPreview.setEnabled(true);
fillData(memberDatum);
updateMemberRef= childDataSnapshot.getRef();
isPushMemberData = true;
return;
}else{
// Toast.makeText(getApplicationContext(),"Phone number already used!!",Toast.LENGTH_SHORT).show();
if(isClearMenuAvailable) {
showAlertDialog("Member "+memberID+" not found!!!");
if(purpose == DMDKConstants.PURPOSE_UPDATE_RECORDS) {
btnPreview.setText("Update");
}else if(purpose == DMDKConstants.PURPOSE_PRINT){
btnPreview.setText("Print");
} btnPreview.setEnabled(false);
}
isPushMemberData = false;
if(purpose == DMDKConstants.PURPOSE_UPDATE_RECORDS) {
showDialogs("Update Member Record","Enter the MemberID");
}else if(purpose == DMDKConstants.PURPOSE_PRINT) {
showDialogs("Print","Enter the MemberID");
}
return;
}
}
}else{
dismissProgress();
if(isClearMenuAvailable) {
showAlertDialog("Member "+memberID+" not found!!!");
if(purpose == DMDKConstants.PURPOSE_UPDATE_RECORDS) {
btnPreview.setText("Update");
}else if(purpose == DMDKConstants.PURPOSE_PRINT){
btnPreview.setText("Print");
} btnPreview.setEnabled(false);
}
isPushMemberData = false;
if(purpose == DMDKConstants.PURPOSE_UPDATE_RECORDS) {
showDialogs("Update Member Record","Enter the MemberID");
}else if(purpose == DMDKConstants.PURPOSE_PRINT) {
showDialogs("Print","Enter the MemberID");
}
return;
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
dismissProgress();
}
});
}
private void fillData(MemberDatum memberDatum) {
editTPhone.setText(memberDatum.getPhone());
editTDOB.setText(memberDatum.getDob());
editTMembershipId.setText(memberDatum.getMembershipId());
editTName.setText(memberDatum.getName());
editTHusband.setText(memberDatum.getHusbandName());
editTVoterId.setText(memberDatum.getVoterId());
editTMP.setText(memberDatum.getMp());
editTMLA.setText(memberDatum.getMla());
autoCompleteTVDistrict.setText(memberDatum.getDistrict());
autoCompleteTVEntryFormPanchayat.setText(memberDatum.getPanchayat());
autoCompleteTVTownCity.setText(memberDatum.getTownCity());
editTDate.setText(memberDatum.getDoj());
}
int lastMemberId;
private int getLastMemberID() {
showProgress("");
Query queryRef = databaseMemberDataReference.orderByChild("membershipId").limitToLast(1)/*.orderByChild("dob")*/;
queryRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if(dataSnapshot.getValue() != null){
dismissProgress();
for(DataSnapshot childDataSnapshot:dataSnapshot.getChildren()){
MemberDatum memberDatum= childDataSnapshot.getValue(MemberDatum.class);
lastMemberId= Integer.parseInt(memberDatum.getMembershipId().trim());
}
}else{
dismissProgress();
return;
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
dismissProgress();
}
});
return lastMemberId;
}
}
| 86,422 | 0.623823 | 0.614253 | 1,966 | 42.95829 | 34.168949 | 181 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.688708 | false | false |
13
|
c9cab7226b543025d15edb0ecef4eb08ab7dc4ff
| 21,749,714,418,440 |
2bdc54629d9dec9ad519ac5f0bf5cbccefaabfb7
|
/src/main/java/com/finedu/springboot/repository/MemberRepository.java
|
ddff1a9860906319683ca9a8f63676153f424959
|
[] |
no_license
|
simhw/Springboot-Fintech
|
https://github.com/simhw/Springboot-Fintech
|
adf700c12725fb258b5bbcef4de6b4ddfcb6ea7d
|
25d8f3ed0520ac75107fcf6bfccc0d1f7d0e3034
|
refs/heads/master
| 2023-06-30T14:50:36.173000 | 2021-08-07T04:27:25 | 2021-08-07T04:27:25 | 393,544,491 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.finedu.springboot.repository;
import com.finedu.springboot.model.Member;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
// Bean으로 설정
@Repository
public interface MemberRepository extends PagingAndSortingRepository<Member, Long> {
}
|
UTF-8
|
Java
| 327 |
java
|
MemberRepository.java
|
Java
|
[] | null |
[] |
package com.finedu.springboot.repository;
import com.finedu.springboot.model.Member;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
// Bean으로 설정
@Repository
public interface MemberRepository extends PagingAndSortingRepository<Member, Long> {
}
| 327 | 0.852665 | 0.852665 | 9 | 34.444443 | 28.655468 | 84 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.555556 | false | false |
13
|
9e9e2967279c50b3ee3b1c5c809a72898a26ee62
| 11,373,073,407,813 |
62f053922c520456b6a8ec41c1ec481b0e1c4c1c
|
/src/test/java/fxreload/ADOCTest.java
|
9bc814667fa9ef59d6afd0558fbed08c0289a5af
|
[
"Apache-2.0"
] |
permissive
|
krizzdewizz/fxreload
|
https://github.com/krizzdewizz/fxreload
|
6148be0a4b35656f85b77a04d6ccf7e03c98856e
|
cce973eb49951d0759e961ac5efec87f1bd8a4c7
|
refs/heads/master
| 2021-01-10T07:57:56.854000 | 2015-11-30T12:24:03 | 2015-11-30T12:24:03 | 47,084,107 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package fxreload;
import java.util.Collections;
import org.asciidoctor.Asciidoctor;
import org.junit.Test;
public class ADOCTest {
@Test
public void test() throws Exception {
final Asciidoctor asciiDoc = Asciidoctor.Factory.create();
String html = asciiDoc.convert(IndexHtml.convertStreamToString(getClass().getResourceAsStream("README.md")), Collections.emptyMap());
System.out.println(html);
// Files.write(Paths.get(System.getProperty("user.dir"),
// "src_test/fxreload/readme.html"), html.getBytes("UTF-8"));
}
}
|
UTF-8
|
Java
| 534 |
java
|
ADOCTest.java
|
Java
|
[] | null |
[] |
package fxreload;
import java.util.Collections;
import org.asciidoctor.Asciidoctor;
import org.junit.Test;
public class ADOCTest {
@Test
public void test() throws Exception {
final Asciidoctor asciiDoc = Asciidoctor.Factory.create();
String html = asciiDoc.convert(IndexHtml.convertStreamToString(getClass().getResourceAsStream("README.md")), Collections.emptyMap());
System.out.println(html);
// Files.write(Paths.get(System.getProperty("user.dir"),
// "src_test/fxreload/readme.html"), html.getBytes("UTF-8"));
}
}
| 534 | 0.750936 | 0.749064 | 18 | 28.666666 | 33.28997 | 135 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.333333 | false | false |
13
|
b471541d3974414eec1cd865a2e02f58ef97ee7c
| 19,292,993,104,014 |
c5099c97fef1121cd124b020ea6208865a7dc8aa
|
/Demo/src/main/java/silence/com/cn/a310application/qqanalyst/QQSimulateBusiness.java
|
aa5d400aa9ec2afd5539916995952b8ae6b552d3
|
[
"Apache-2.0"
] |
permissive
|
nexthacker/AutoInteraction-Library
|
https://github.com/nexthacker/AutoInteraction-Library
|
a1cdf29009575fcf82eccbcac323fdc6d4e8030f
|
b27c7e26e4a65c1c7edbea8524e0be845ef68660
|
refs/heads/master
| 2020-04-04T23:25:37.564000 | 2017-07-04T08:46:15 | 2017-07-04T08:46:15 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package silence.com.cn.a310application.qqanalyst;
import android.content.ClipboardManager;
import android.content.Context;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import silence.com.cn.a310application.appanalyst.AnalystBusiness;
import silence.com.cn.a310application.appanalyst.AnalystServiceHandler;
import silence.com.cn.a310application.appanalyst.GpsMocker;
import silence.com.cn.a310application.appanalyst.Log;
import silence.com.cn.a310application.appanalyst.MyException;
import silence.com.cn.a310application.appanalyst.ToastDuration;
import silence.com.cn.a310application.appanalyst.UiTree;
public class QQSimulateBusiness extends AnalystBusiness {
public static final int RECONNECT_SERVER_DELAY = 5 * 1000;
public static final int SUBMIT_WXPERSON_TIMEOUT = 10 * 1000;
public static final int LOCATING_TIMEOUT = 10 * 1000;
private static final java.lang.String TAG = "QQSimulateBusiness";
private final Handler mMainHandler = new Handler();
// private final DiskFiles mDiskFiles;
private Thread mNewGpsThread[] = new Thread[]{null};
// private WxTask mWxTask;
private ClipboardManager.OnPrimaryClipChangedListener mPrimaryClipChangedListener;
public QQSimulateBusiness(@NonNull AnalystServiceHandler serviceHandler) throws MyException {
super(serviceHandler);
// mDiskFiles = new DiskFiles(new File(Environment.getExternalStorageDirectory(), "tencent" + File.separator +
// "MicroMsg" + File.separator + "WeiXin"));
}
@Override
public void handleUiEvent(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
Log.i("QQSimulateBusiness.handleUiEvent # keepingAlive=" + (keepingAlive ? "true" : "false"));
FormPage formPage = FormPage.valueOf(uiTree.getFoundFormPage());
if (null == formPage) {
return;
}
switch (formPage) {
case QQ_MainActivity_Message:
handle_QQMainActivity_Message(uiTree, keepingAlive);
break;
}
}
private void handle_QQMainActivity_Message(UiTree uiTree, boolean keepingAlive) {
try {
uiTree.getNode("动态").click();
Log.d("点击了动态页面==============");
} catch (MyException e) {
e.printStackTrace();
}
}
public Context getContext() {
return getServiceHandler().getContext();
}
public GpsMocker getGpsMocker() {
return getServiceHandler().getGpsMocker();
}
private void readyClipboard(ClipboardManager.OnPrimaryClipChangedListener listener) {
ClipboardManager clipboardManager = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
if (null != mPrimaryClipChangedListener) {
clipboardManager.removePrimaryClipChangedListener(mPrimaryClipChangedListener);
}
mPrimaryClipChangedListener = listener;
clipboardManager.addPrimaryClipChangedListener(mPrimaryClipChangedListener);
}
private void releaseClipboard() {
ClipboardManager clipboardManager = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
clipboardManager.removePrimaryClipChangedListener(mPrimaryClipChangedListener);
mPrimaryClipChangedListener = null;
}
public void requireBack(@NonNull UiTree uiTree) {
try {
uiTree.getNode("返回").click();
} catch (MyException e) {
getServiceHandler().requireBack();
}
}
private void submitGlobalException(final String message) {
// final Config config = new Config();
// config.load(getContext());
/* new Thread(new Runnable() {
@Override
public void run() {
String url = "http://" + config.getAppServerUrl() + Url.SubmitGlobalException;
try {
Connection connection = Jsoup.connect(url);
connection.ignoreContentType(true); connection.data("content", message);
connection.data("pointId", "");
connection.data("type", "1");
connection.post();
} catch (Exception e) {
Log.e(new MyException("提交异常信息失败", new MyException("连接URL: " + url, e)));
}
}
}).start();*/
}
private void submitTaskException(final int taskId, final String message) {
/* final Config config = new Config();
config.load(getContext());
new Thread(new Runnable() {
@Override
public void run() {
String url = "http://" + config.getAppServerUrl() + Url.SubmitTaskException;
try {
Connection connection = Jsoup.connect(url);
connection.ignoreContentType(true);
connection.data("content", message);
connection.data("pointId", "" + taskId);
connection.data("type", "2");
connection.post();
} catch (Exception e) {
Log.e(new MyException("提交异常信息失败", new MyException("连接URL: " + url, e)));
}
}
}).start();*/
}
private void submitException(@Nullable Integer taskId, final String message) {
if (null == taskId) {
submitGlobalException(message);
} else {
submitTaskException(taskId, message);
}
}
private void handle_LauncherUI_Login(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
Log.e("界面异常 - 当前为登录界面", getContext(), ToastDuration.LENGTH_LONG);
submitGlobalException("当前为登录界面,需要人工登录");
}
/*private void handle_LauncherUI_Main(@NonNull final UiTree uiTree, final boolean keepingAlive) throws MyException {
if (!getGpsMocker().isWorking()) {
synchronized (mNewGpsThread) {
if (null == mNewGpsThread[0]) {
mNewGpsThread[0] = new Thread(new Runnable() {
@Override
public void run() {
final int id;
final int areaId;
final Gps mockGps;
final WxScope wxScope;
try {
if (Macro.RealGps || !Macro.Network) {
mockGps = Macro.MockGps;
id = 0;
areaId = 0;
// wxScope = WxScope.forPersonCount(10);
} else {
try {
JSONObject jsonObject;
String url = null;
try {
Config config = new Config();
config.load(getContext());
url = "http://" + config.getAppServerUrl() + Url.GetTask + config
.getAppAreaConfig();
Connection connection = Jsoup.connect(url);
connection.ignoreContentType(true);
Document document = connection.get();
SilenceLog.e(document.toString());
jsonObject = new JSONObject(document.body().text());
} catch (Exception e) {
throw new MyException("连接服务器失败", new MyException("连接URL: " + url, e));
}
String gpsText;
int amount;
long intervalTime;//秒
String type;
try {
JSONArray jsonArray = jsonObject.getJSONArray("data");
JSONObject itemObject = jsonArray.getJSONObject(0);
id = itemObject.getInt("id");
areaId = itemObject.getInt("area_id");
gpsText = itemObject.getString("position");
amount = itemObject.getInt("amount");
intervalTime = itemObject.getLong("interval_time");
type = itemObject.getString("type");
} catch (Exception e) {
throw new MyException("解析服务器数据异常", new MyException("连接URL: " + url, e));
}
try {
String[] texts = gpsText.split(":");
mockGps = new Gps(Float.parseFloat(texts[2]), Float.parseFloat(texts[1]));
} catch (Exception e) {
throw new MyException("解析服务器GPS数据异常", new MyException("连接URL: " + url, e));
}
if ("amount".equals(type)) {
wxScope = WxScope.forPersonCount(amount);
} else if ("interval_time".equals(type)) {
wxScope = WxScope.forTaskTime(intervalTime * 1000);
} else {
throw new MyException("解析服务器工作方式异常", new MyException("连接URL: " + url));
}
} catch (Exception e) {
Log.e(e, getContext(), ToastDuration.LENGTH_SHORT);
mMainHandler.postDelayed(new Runnable() {
@Override
public void run() {
getServiceHandler().requirePost();
}
}, RECONNECT_SERVER_DELAY);
return;
}
}
} finally {
synchronized (mNewGpsThread) {
mNewGpsThread[0] = null;
}
}
mMainHandler.post(new Runnable() {
@Override
public void run() {
getGpsMocker().start(getContext(), mockGps);
mWxTask = new WxTask(id, areaId, wxScope);
getServiceHandler().requirePost();
}
});
}
});
mNewGpsThread[0].start();
}
}
} else {
uiTree.getNode("发现").click();
uiTree.getNode("附近的人").click();
}
}*/
/* private void handle_LoginHistoryUI(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
//TODO Zhukun 自动登录
final Config config = new Config();
config.load(getContext());
uiTree.getNode("输入密码").setEditText(QQApplication.getContext(), "");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
uiTree.getNode("输入密码").setEditText(QQApplication.getContext(), config.getWeChatPwd());
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
uiTree.getNode("登录").click();
submitGlobalException("输入密码" + config.getWeChatPwd());
Log.e("输入密码" + config.getWeChatPwd(), getContext(), ToastDuration.LENGTH_LONG);
}*/
/**
* 帐号或密码错误,请重新填写
*
* @param uiTree uiTree
* @param keepingAlive keepingAlive
* @throws MyException
*/
/* private void handle_LoginErro_1(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
uiTree.getNode("确定").click();
Log.e("帐号或密码错误,请重新填写");
}*/
/**
* 密码错误,找回或重置密码?
*
* @param uiTree uiTree
* @param keepingAlive keepingAlive
* @throws MyException
*/
/* private void handle_LoginErro_2(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
uiTree.getNode("取消").click();
Log.e("密码错误,找回或重置密码?");
}*/
/* private void handle_NearbyFriendsIntroUI(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (!getGpsMocker().isWorking()) {
requireBack(uiTree);
return;
}
uiTree.getNode("开始查看").click();
}*/
/* private void handle_NearbyFriendShowSayHiUI(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (!getGpsMocker().isWorking()) {
requireBack(uiTree);
return;
}
uiTree.getNode("开始查看").click();
}*/
/* private void handle_BaseP_0(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (!getGpsMocker().isWorking()) {
requireBack(uiTree);
return;
}
if (null == mWxTask) {
getGpsMocker().stop();
requireBack(uiTree);
return;
}
if (mWxTask.mLocatingStartTime <= 0) {
//第一次进入该页面
mWxTask.mLocatingStartTime = System.currentTimeMillis();
return;
}
if (System.currentTimeMillis() >= mWxTask.mLocatingStartTime + LOCATING_TIMEOUT) {
mWxTask.mLocatingStartTime = 0;
submitTaskException(mWxTask.getId(), "定位超时");
requireBack(uiTree);
return;
}
}*/
/*
private void handle_BaseH_0(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
uiTree.getNode("下次不提示").click();
uiTree.getNode("确定").click();
}
*/
/* private void handle_BaseH_1(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
uiTree.getNode("确定").click();
}
*/
/* private void handle_BaseH_2(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
Log.e("定位异常", getContext(), ToastDuration.LENGTH_LONG);
submitException(null == mWxTask ? null : mWxTask.getId(), "定位失败");
getGpsMocker().stop();
requireBack(uiTree);
}*/
/* private void handle_BaseH_3(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
uiTree.getNode("确定").click();
}*/
/* private void handle_BaseH_4(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
uiTree.getNode("确定").click();
}*/
/* private void handle_BaseH_5(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
uiTree.getNode("关闭").click();
}*/
private void handle_BaseH_6(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
uiTree.getNode("取消").click();
}
private void handle_BaseH_7(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
uiTree.getNode("取消").click();
}
private void handle_BaseH_8(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
uiTree.getNode("取消").click();
}
private void handle_BaseH_9(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
uiTree.getNode("确定").click();
}
/* private void handle_NearbyFriendsUI(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (!getGpsMocker().isWorking()) {
requireBack(uiTree);
return;
}
if (null == mWxTask) {
getGpsMocker().stop();
requireBack(uiTree);
return;
}
if (null == mWxTask.person()) {
uiTree.getNode("更多").click();
return;
}
UiNode listNode = uiTree.getNode("列表");
if (mWxTask.mPersonIndex >= listNode.getChildCount()) {
//需要翻页
int count = listNode.getChildCount();
if (count > 0) {
UiNode lastItemNode = listNode.getChild(count - 1);
WxPersonTemp personTemp = new WxPersonTemp();
try {
UiNode node = lastItemNode.getChild(0).getChild(1).getChild(0).getChild(0);
personTemp.mNickname = StringUtil.toNullable(node.getText());
} catch (NullPointerException e) {
//忽略异常
}
try {
UiNode node = lastItemNode.getChild(0).getChild(1).getChild(0).getChild(1);
personTemp.mSex = StringUtil.toNullable(node.getDescription());
} catch (NullPointerException e) {
//忽略异常
}
try {
UiNode node = lastItemNode.getChild(0).getChild(1).getChild(1).getChild(0);
personTemp.mDistance = StringUtil.toNullable(node.getText());
} catch (NullPointerException e) {
//忽略异常
}
try {
UiNode node = lastItemNode.getChild(0).getChild(2).getChild(0);
personTemp.mIdiograph = StringUtil.toNullable(node.getText());
} catch (NullPointerException e) {
//忽略异常
}
if (null != mWxTask.mPersonTemp) {
if (personTemp.equals(mWxTask.mPersonTemp)) {
Log.i("遍历结束", getContext(), ToastDuration.LENGTH_SHORT);
getGpsMocker().stop();
getServiceHandler().requirePost();
return;
}
}
mWxTask.mPersonTemp = personTemp;
} else {
mWxTask.mPersonTemp = null;
}
mWxTask.mPersonIndex = 0;
listNode.scrollForward();
getServiceHandler().requirePost();
} else {
UiNode itemNode = listNode.getChild(mWxTask.mPersonIndex);
if (0 == mWxTask.mPersonIndex) {
if (0 == itemNode.getChildCount()) {
//首页第一个为空,跳过
mWxTask.mPersonIndex++;
handle_NearbyFriendsUI(uiTree, keepingAlive);
return;
} else {
Rect listViewBounds = new Rect();
listNode.getBoundsInScreen(listViewBounds);
Rect itemBounds = new Rect();
itemNode.getBoundsInScreen(itemBounds);
if (itemBounds.top < listViewBounds.top) {
//第一个为上一页已访问的,跳过
mWxTask.mPersonIndex++;
handle_NearbyFriendsUI(uiTree, keepingAlive);
return;
}
}
}
mWxTask.mPersonIndex++;
try {
mWxTask.personNew();
} catch (WxTask.TaskEndException e) {
Log.i("当前任务结束", getContext(), ToastDuration.LENGTH_SHORT);
getGpsMocker().stop();
requireBack(uiTree);
return;
} catch (MyException e) {
Log.e(new MyException("获取下个Person异常", e), getContext(), ToastDuration.LENGTH_SHORT);
getGpsMocker().stop();
requireBack(uiTree);
return;
}
itemNode.click();
}
}
*/
private void handle_NearbyFriendsUI_Nobody(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (getGpsMocker().isWorking()) {
Log.e("没有附近的人", getContext(), ToastDuration.LENGTH_LONG);
getGpsMocker().stop();
}
requireBack(uiTree);
}
/* private void handle_NearbyFriendsUI_NoLocation(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (getGpsMocker().isWorking()) {
Log.e("不能获取位置", getContext(), ToastDuration.LENGTH_LONG);
submitException(null == mWxTask ? null : mWxTask.getId(), "不能获取位置");
getGpsMocker().stop();
}
requireBack(uiTree);
}*/
/* private void handle_NearbyFriendsUIMenu(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null != mWxTask && null == mWxTask.person()) {
mWxTask.personReset();
uiTree.getNode("清除位置并退出").click();
} else {
requireBack(uiTree);
}
}*/
/*private void handle_ContactInfoUI(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
switch (mWxTask.person().step()) {
case PersonInfo:
handle_ContactInfoUI_CasePersonInfo(uiTree, keepingAlive);
break;
case PersonImage:
handle_ContactInfoUI_CasePersonImage(uiTree, keepingAlive);
break;
case Messages:
handle_ContactInfoUI_CaseMessages(uiTree, keepingAlive);
break;
case Finish:
case Finished:
handle_ContactInfoUI_CaseFinish(uiTree, keepingAlive);
break;
default:
Log.e("QQSimulateBusiness.handle_ContactInfoUI # 错误步骤(" + mWxTask.person().step().name() + "),返回",
getContext(), ToastDuration.LENGTH_SHORT);
requireBack(uiTree);
break;
}
}*/
/*private void handle_ContactInfoUI_CasePersonInfo(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
if (WxPerson.Step.PersonInfo != mWxTask.person().step()) {
requireBack(uiTree);
return;
}
String nickname = StringUtil.toNb(uiTree.getNode("昵称").getText());
if (null != nickname) {
// 昵称总是会多一个空格,这里去掉
if (nickname.endsWith(" ")) {
nickname = nickname.substring(0, nickname.length() - 1);
}
}
mWxTask.person().setNickname(nickname);
String sex = StringUtil.toNb(uiTree.getNode("性别").getDescription());
mWxTask.person().setSex(sex);
String location = StringUtil.toNb(uiTree.getNode("位置").getText());
mWxTask.person().setLocation(location);
UiNode listNode = uiTree.getNode("列表");
for (int i = 2; i < listNode.getChildCount(); i++) {
try {
UiNode itemNode = listNode.getChild(i);
UiNode labelNode = itemNode.getChild(0).getChild(0).getChild(0).getChild(0);
String label = StringUtil.toEb(labelNode.getText());
if (label.equals("地区")) {
UiNode valueNode = itemNode.getChild(0).getChild(0).getChild(1).getChild(0).getChild(0);
mWxTask.person().setRegion(StringUtil.toNb(valueNode.getText()));
} else if (label.equals("个性签名")) {
UiNode valueNode = itemNode.getChild(0).getChild(0).getChild(1).getChild(0).getChild(0);
mWxTask.person().setIdiograph(StringUtil.toNb(valueNode.getText()));
}
} catch (NullPointerException e) {
//继续遍历
}
}
mWxTask.person().nextStep(WxPerson.Step.PersonImage);
handle_ContactInfoUI_CasePersonImage(uiTree, keepingAlive);
}*/
/*private void handle_ContactInfoUI_CasePersonImage(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
if (WxPerson.Step.PersonImage != mWxTask.person().step()) {
requireBack(uiTree);
return;
}
uiTree.getNode("头像").click();
}*/
/*private void handle_ContactInfoUIImage(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
switch (mWxTask.person().step()) {
case PersonImage: {
UiNode node = uiTree.getNode("图片");
Rect bounds = new Rect();
node.getBoundsInScreen(bounds);
mWxTask.person().nextStep(WxPerson.Step.PersonImageSaving);
mWxTask.person().mImageSaveCount = 0;
getServiceHandler().requireMockLongClick(new PointXY(bounds.centerX(), bounds.centerY()));
getServiceHandler().requirePost();
}
break;
case PersonImageSaving:
if (mWxTask.person().mImageSaveCount > 3) {
Log.e("获取头像失败", getContext(), ToastDuration.LENGTH_SHORT);
mWxTask.person().nextStep(WxPerson.Step.PersonImageSaved);
mWxTask.person().nextStep();
requireBack(uiTree);
} else {
mWxTask.person().mImageSaveCount++;
getServiceHandler().requirePost();
}
break;
case PersonImageSaved:
mWxTask.person().setPersonImage(mDiskFiles.nextFreshFileName());
mWxTask.person().nextStep();
requireBack(uiTree);
break;
default:
Log.e("QQSimulateBusiness.handle_ContactInfoUIImage # 错误步骤(" + mWxTask.person().step().name() + "),返回",
getContext(), ToastDuration.LENGTH_SHORT);
requireBack(uiTree);
break;
}
}*/
/*private void handle_BaseK_ImageSaving(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
if (WxPerson.Step.PersonImageSaving != mWxTask.person().step()) {
requireBack(uiTree);
return;
}
mDiskFiles.scanFiles();
mWxTask.person().nextStep(WxPerson.Step.PersonImageSaved);
uiTree.getNode("保存到手机").click();
}*/
/* private void handle_ContactInfoUI_CaseMessages(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
if (WxPerson.Step.Messages != mWxTask.person().step()) {
requireBack(uiTree);
return;
}
UiNode listNode = uiTree.getNode("列表");
UiNode photosNode = null;
for (int i = 2; i < listNode.getChildCount(); i++) {
try {
UiNode itemNode = listNode.getChild(i);
String description = StringUtil.toEb(itemNode.getDescription());
if (description.startsWith("个人相册")) {
photosNode = itemNode;
break;
}
} catch (Exception e) {
//继续遍历
}
}
if (null == photosNode) {
mWxTask.person().nextStep(WxPerson.Step.Finish);
handle_ContactInfoUI_CaseFinish(uiTree, keepingAlive);
} else {
photosNode.click();
}
}*/
/*private void handle_ContactInfoUI_CaseFinish(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
switch (mWxTask.person().step()) {
case Finish: {
if (null != mWxTask.person().mFinishTime) {
//判断超时
if (System.currentTimeMillis() >= mWxTask.person().mFinishTime + SUBMIT_WXPERSON_TIMEOUT) {
mWxTask.person().nextStep(WxPerson.Step.Finished);
getServiceHandler().requirePost();
}
} else {
final WxPerson wxPerson = mWxTask.person();
wxPerson.mFinishTime = System.currentTimeMillis();
final Config config = new Config();
config.load(getContext());
new Thread(new Runnable() {
@Override
public void run() {
try {
wxPerson.submit(getContext(), config);
Log.i("提交完成");
} catch (MyException e) {
Log.e(e, getContext(), ToastDuration.LENGTH_SHORT);
}
mMainHandler.post(new Runnable() {
@Override
public void run() {
wxPerson.deleteImageFiles();
wxPerson.nextStep(WxPerson.Step.Finished);
getServiceHandler().requirePost();
}
});
}
}).start();
}
}
break;
case Finished:
requireBack(uiTree);
break;
default:
Log.e("QQSimulateBusiness.handle_ContactInfoUI_CaseFinish # 错误步骤(" + mWxTask.person().step().name() + ")" +
",返回", getContext(), ToastDuration.LENGTH_SHORT);
requireBack(uiTree);
break;
}
}*/
/*private void handle_SnsUserUI(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
if (WxPerson.Step.Messages != mWxTask.person().step()) {
requireBack(uiTree);
return;
}
UiNode listNode = uiTree.getNode("列表");
List<WxMessage> wxMessages = mWxTask.person().getMessages();
String md = null;
for (int i = 1; i < listNode.getChildCount(); i++) {
if (i - 1 >= wxMessages.size()) {
wxMessages.add(null);
}
WxMessage wxMessage = wxMessages.get(i - 1);
UiNode itemNode = listNode.getChild(i);
try {
UiNode dateMdNode = itemNode.getChild(2).getChild(0).getChild(0).getChild(0);
UiNode dateDNode = dateMdNode.getChild(0);
if (StringUtil.compareNb(dateDNode.getClassName(), "android.widget.TextView")) {
String d = StringUtil.toEb(dateDNode.getText());
md = DateUtil.toMd(d, null);
if (null == md) {
UiNode dateMNode = dateMdNode.getChild(1);
String m = StringUtil.toEb(dateMNode.getText());
md = m + d;
}
}
} catch (NullPointerException e) {
//忽略异常
}
if (null == wxMessage) {
try {
if (StringUtil.compareNb(itemNode.getChild(0).getChild(0).getChild(1).getText(), "非朋友最多显示十张照片")) {
//结束
break;
}
} catch (NullPointerException e) {
//忽略异常
}
try {
UiNode node = itemNode;
if (StringUtil.compareNb("android.widget.LinearLayout", node.getClassName()) && 1 == node
.getChildCount()) {
node = itemNode.getChild(0);
if (StringUtil.compareNb("android.widget.LinearLayout", node.getClassName()) && 1 == node
.getChildCount()) {
node = node.getChild(0);
if (StringUtil.compareNb("android.widget.LinearLayout", node.getClassName()) && 1 == node
.getChildCount()) {
node = node.getChild(0);
if (StringUtil.compareNb("android.widget.ImageView", node.getClassName()) && 0 ==
node.getChildCount()) {
//结束行
break;
}
}
}
}
} catch (NullPointerException e) {
//忽略异常
}
//由于可点的位置在itemNode内部,所以使用最后一个子节点来判断
UiNode childNode = null;
for (int n = 0; n < itemNode.getChildCount(); n++) {
UiNode node = null;
try {
node = itemNode.getChild(n).getChild(0);
} catch (NullPointerException e) {
//忽略异常
}
try {
node = itemNode.getChild(n).getChild(1);
} catch (NullPointerException e) {
//忽略异常
}
if (null != node) {
childNode = node;
}
}
if (null == childNode) {
//异常,结束
break;
}
//点击进入具体的消息页面
Rect listBounds = new Rect();
listNode.getBoundsInScreen(listBounds);
Rect childBounds = new Rect();
childNode.getBoundsInScreen(childBounds);
if (childBounds.top >= listBounds.bottom) {
//该项已经在显示界面之外,由于目前没有滚屏机制,所以忽略之后的item
break;
}
PointXY point = new PointXY(childBounds.centerX(), childBounds.centerY());
if (point.mY >= listBounds.bottom) {
point.mY = listBounds.bottom - 1;
}
getServiceHandler().requireMockClick(point);
return;
} else {
wxMessage.setDateMd(md);
}
}
//遍历结束
if (!wxMessages.isEmpty()) {
//去掉最后一条,最后一条为结束图标
if (null == wxMessages.get(wxMessages.size() - 1)) {
wxMessages.remove(wxMessages.size() - 1);
}
}
mWxTask.person().nextStep(WxPerson.Step.Finish);
requireBack(uiTree);
}
*/
/*private void handle_SnsGalleryUI(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
switch (mWxTask.person().step()) {
case Messages: {
List<WxMessage> wxMessages = mWxTask.person().getMessages();
if (wxMessages.isEmpty()) {
requireBack(uiTree);
return;
}
WxMessage wxMessage = new WxMessage();
wxMessage.mGalleryPageIndex = 0;
wxMessage.mGalleryNoTitleClickCount = 0;
try {
wxMessage.setDescription(StringUtil.toNb(uiTree.getNode("描述").getText()));
} catch (MyException e) {
//忽略异常
}
wxMessage.setDateYmdhm(DateUtil.toYmdhm(StringUtil.toNb(uiTree.getNode("时间").getText())));
wxMessages.set(wxMessages.size() - 1, wxMessage);
mWxTask.person().nextStep(WxPerson.Step.MessageImageReading);
handle_SnsGalleryUI(uiTree, keepingAlive);
}
break;
case MessageImageReading: {
uiTree.getNode("更多").click();
}
break;
case MessageImageOneReadEnd: {
List<WxMessage> wxMessages = mWxTask.person().getMessages();
if (wxMessages.isEmpty()) {
requireBack(uiTree);
return;
}
WxMessage wxMessage = wxMessages.get(wxMessages.size() - 1);
if (null == wxMessage) {
requireBack(uiTree);
return;
}
wxMessage.getImages().add(mDiskFiles.nextFreshFileName());
UiNode pagingNode = null;
try {
pagingNode = uiTree.getNode("分页");
} catch (MyException e) {
//忽略异常
}
if (null != pagingNode) {
wxMessage.mGalleryPageIndex++;
String text = StringUtil.toEb(pagingNode.getText());
String separator = " / ";
int off = text.indexOf(separator);
int page = Integer.parseInt(text.substring(0, off));
if (page != wxMessage.mGalleryPageIndex) {
Log.e("当前页码不匹配,返回", getContext(), ToastDuration.LENGTH_SHORT);
mWxTask.person().nextStep(WxPerson.Step.Messages);
requireBack(uiTree);
}
int count = Integer.parseInt(text.substring(off + separator.length()));
if (page < count) {
UiNode galleryNode = uiTree.getNode("照片墙");
Rect bounds = new Rect();
galleryNode.getBoundsInScreen(bounds);
if (Math.abs(bounds.right - bounds.left) <= 2) {
throw new MyException("照片墙控件大小异常");
}
wxMessage.mGalleryNoTitleClickCount = 0;
mWxTask.person().nextStep(WxPerson.Step.MessageImageReading);
getServiceHandler().requireMockMove(new PointXY2XY(new PointXY(bounds.right - 1, bounds
.centerY()), new PointXY(bounds.left + 1, bounds.centerY())));
return;
} else {
mWxTask.person().nextStep(WxPerson.Step.Messages);
requireBack(uiTree);
}
} else {
mWxTask.person().nextStep(WxPerson.Step.Messages);
requireBack(uiTree);
}
}
break;
default:
Log.e("QQSimulateBusiness.handle_SnsGalleryUI # 错误步骤(" + mWxTask.person().step().name() + "),返回", getContext
(), ToastDuration.LENGTH_SHORT);
requireBack(uiTree);
break;
}
}*/
/*private void handle_SnsGalleryUI_NoTitle(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
if (WxPerson.Step.MessageImageReading != mWxTask.person().step()) {
requireBack(uiTree);
return;
}
List<WxMessage> wxMessages = mWxTask.person().getMessages();
if (wxMessages.isEmpty()) {
requireBack(uiTree);
return;
}
WxMessage wxMessage = wxMessages.get(wxMessages.size() - 1);
if (null == wxMessage) {
requireBack(uiTree);
return;
}
if (wxMessage.mGalleryNoTitleClickCount >= 5) {
//点击多次无反应,则当前页面为“图片获取中”状态
requireBack(uiTree);
return;
}
wxMessage.mGalleryNoTitleClickCount++;
UiNode node = uiTree.getNode("照片墙");
Rect bounds = new Rect();
node.getBoundsInScreen(bounds);
getServiceHandler().requireMockClick(new PointXY(bounds.centerX(), bounds.centerY()));
getServiceHandler().requirePost();
}
private void handle_SnsGalleryUIMenu(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
if (WxPerson.Step.MessageImageReading != mWxTask.person().step()) {
requireBack(uiTree);
return;
}
mWxTask.person().nextStep(WxPerson.Step.MessageImageOneReadEnd);
mDiskFiles.scanFiles();
try {
uiTree.getNode("保存到手机").click();
} catch (MyException e) {
//当前为视频或其他
requireBack(uiTree);
}
}*/
/* private void handle_SnsCommentDetailUI(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
switch (mWxTask.person().step()) {
case Messages: {
List<WxMessage> wxMessages = mWxTask.person().getMessages();
if (wxMessages.isEmpty()) {
requireBack(uiTree);
return;
}
final WxMessage wxMessage = new WxMessage();
try {
wxMessage.setTitle(StringUtil.toNb(uiTree.getNode("标题").getText()));
} catch (MyException e) {
//忽略异常
}
try {
wxMessage.setDescription(StringUtil.toNb(uiTree.getNode("描述").getText()));
} catch (MyException e) {
//忽略异常
}
try {
wxMessage.setSource(StringUtil.toNb(uiTree.getNode("源").getText()));
} catch (MyException e) {
//忽略异常
}
try {
wxMessage.setRegion(StringUtil.toNb(uiTree.getNode("地区").getText()));
} catch (MyException e) {
//忽略异常
}
try {
wxMessage.setDateYmdhm(DateUtil.toYmdhm(StringUtil.toNb(uiTree.getNode("时间").getText())));
} catch (MyException e) {
//忽略异常
}
try {
wxMessage.setTail(StringUtil.toNb(uiTree.getNode("尾注").getText()));
} catch (MyException e) {
//忽略异常
}
if (Macro.Debug) {
String text = "获取消息内容:";
text += "\n日期:" + wxMessage.getDateYmdhm();
text += "\n描述:" + wxMessage.getDescription();
text += "\n标题:" + wxMessage.getTitle();
text += "\n源:" + wxMessage.getSource();
text += "\n尾注:" + wxMessage.getTail();
text += "\n地区位置:" + wxMessage.getRegion();
Log.i(text);
}
wxMessages.set(wxMessages.size() - 1, wxMessage);
UiNode enterNode = null;
try {
enterNode = uiTree.getNode("进入");
} catch (MyException e) {
//忽略异常
}
if (null != enterNode) {
mWxTask.person().nextStep(WxPerson.Step.MessageWebReading);
readyClipboard(new ClipboardManager.OnPrimaryClipChangedListener() {
@Override
public void onPrimaryClipChanged() {
ClipboardManager clipboardManager = (ClipboardManager) getContext().getSystemService
(Context.CLIPBOARD_SERVICE);
try {
wxMessage.setUrl(StringUtil.toNb(clipboardManager.getPrimaryClip().getItemAt(0)
.getText()));
if (Macro.Debug) {
Log.i("获取URL:" + wxMessage.getUrl());
}
} catch (Exception e) {
//忽略异常
}
releaseClipboard();
}
});
Rect bounds = new Rect();
enterNode.getBoundsInScreen(bounds);
getServiceHandler().requireMockClick(new PointXY(bounds.centerX(), bounds.centerY()));
getServiceHandler().requirePost();
} else {
requireBack(uiTree);
}
}
break;
case MessageWebReading: {
List<WxMessage> wxMessages = mWxTask.person().getMessages();
if (wxMessages.isEmpty()) {
requireBack(uiTree);
return;
}
WxMessage wxMessage = wxMessages.get(wxMessages.size() - 1);
if (null == wxMessage) {
requireBack(uiTree);
return;
}
if (wxMessage.mWebReadingCount > 3) {
Log.e("获取URL失败", getContext(), ToastDuration.LENGTH_SHORT);
mWxTask.person().nextStep(WxPerson.Step.Messages);
requireBack(uiTree);
} else {
wxMessage.mWebReadingCount++;
}
}
break;
case MessageWebReadEnd: {
releaseClipboard();
mWxTask.person().nextStep(WxPerson.Step.Messages);
requireBack(uiTree);
}
break;
default:
Log.e("QQSimulateBusiness.handle_SnsCommentDetailUI # 错误步骤(" + mWxTask.person().step().name() + "),返回",
getContext(), ToastDuration.LENGTH_SHORT);
requireBack(uiTree);
break;
}
}*/
/*private void handle_WebViewUI(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
switch (mWxTask.person().step()) {
case MessageWebReading:
try {
uiTree.getNode("更多").click();
} catch (MyException e) {
mWxTask.person().nextStep(WxPerson.Step.MessageWebReadEnd);
requireBack(uiTree);
}
break;
case MessageWebReadEnd:
requireBack(uiTree);
break;
default:
Log.e("QQSimulateBusiness.handle_WebViewUI # 错误步骤(" + mWxTask.person().step().name() + "),返回", getContext(),
ToastDuration.LENGTH_SHORT);
requireBack(uiTree);
break;
}
}
*/
/*private void handle_WebViewUIMenu_Normal(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
if (WxPerson.Step.MessageWebReading != mWxTask.person().step()) {
requireBack(uiTree);
return;
}
mWxTask.person().nextStep(WxPerson.Step.MessageWebReadEnd);
uiTree.getNode("复制链接").click();
}*/
/*private void handle_WebViewUIMenu_Other(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
if (WxPerson.Step.MessageWebReading != mWxTask.person().step()) {
requireBack(uiTree);
return;
}
mWxTask.person().nextStep(WxPerson.Step.MessageWebReadEnd);
requireBack(uiTree);
}*/
}
|
UTF-8
|
Java
| 50,381 |
java
|
QQSimulateBusiness.java
|
Java
|
[] | null |
[] |
package silence.com.cn.a310application.qqanalyst;
import android.content.ClipboardManager;
import android.content.Context;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import silence.com.cn.a310application.appanalyst.AnalystBusiness;
import silence.com.cn.a310application.appanalyst.AnalystServiceHandler;
import silence.com.cn.a310application.appanalyst.GpsMocker;
import silence.com.cn.a310application.appanalyst.Log;
import silence.com.cn.a310application.appanalyst.MyException;
import silence.com.cn.a310application.appanalyst.ToastDuration;
import silence.com.cn.a310application.appanalyst.UiTree;
public class QQSimulateBusiness extends AnalystBusiness {
public static final int RECONNECT_SERVER_DELAY = 5 * 1000;
public static final int SUBMIT_WXPERSON_TIMEOUT = 10 * 1000;
public static final int LOCATING_TIMEOUT = 10 * 1000;
private static final java.lang.String TAG = "QQSimulateBusiness";
private final Handler mMainHandler = new Handler();
// private final DiskFiles mDiskFiles;
private Thread mNewGpsThread[] = new Thread[]{null};
// private WxTask mWxTask;
private ClipboardManager.OnPrimaryClipChangedListener mPrimaryClipChangedListener;
public QQSimulateBusiness(@NonNull AnalystServiceHandler serviceHandler) throws MyException {
super(serviceHandler);
// mDiskFiles = new DiskFiles(new File(Environment.getExternalStorageDirectory(), "tencent" + File.separator +
// "MicroMsg" + File.separator + "WeiXin"));
}
@Override
public void handleUiEvent(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
Log.i("QQSimulateBusiness.handleUiEvent # keepingAlive=" + (keepingAlive ? "true" : "false"));
FormPage formPage = FormPage.valueOf(uiTree.getFoundFormPage());
if (null == formPage) {
return;
}
switch (formPage) {
case QQ_MainActivity_Message:
handle_QQMainActivity_Message(uiTree, keepingAlive);
break;
}
}
private void handle_QQMainActivity_Message(UiTree uiTree, boolean keepingAlive) {
try {
uiTree.getNode("动态").click();
Log.d("点击了动态页面==============");
} catch (MyException e) {
e.printStackTrace();
}
}
public Context getContext() {
return getServiceHandler().getContext();
}
public GpsMocker getGpsMocker() {
return getServiceHandler().getGpsMocker();
}
private void readyClipboard(ClipboardManager.OnPrimaryClipChangedListener listener) {
ClipboardManager clipboardManager = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
if (null != mPrimaryClipChangedListener) {
clipboardManager.removePrimaryClipChangedListener(mPrimaryClipChangedListener);
}
mPrimaryClipChangedListener = listener;
clipboardManager.addPrimaryClipChangedListener(mPrimaryClipChangedListener);
}
private void releaseClipboard() {
ClipboardManager clipboardManager = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
clipboardManager.removePrimaryClipChangedListener(mPrimaryClipChangedListener);
mPrimaryClipChangedListener = null;
}
public void requireBack(@NonNull UiTree uiTree) {
try {
uiTree.getNode("返回").click();
} catch (MyException e) {
getServiceHandler().requireBack();
}
}
private void submitGlobalException(final String message) {
// final Config config = new Config();
// config.load(getContext());
/* new Thread(new Runnable() {
@Override
public void run() {
String url = "http://" + config.getAppServerUrl() + Url.SubmitGlobalException;
try {
Connection connection = Jsoup.connect(url);
connection.ignoreContentType(true); connection.data("content", message);
connection.data("pointId", "");
connection.data("type", "1");
connection.post();
} catch (Exception e) {
Log.e(new MyException("提交异常信息失败", new MyException("连接URL: " + url, e)));
}
}
}).start();*/
}
private void submitTaskException(final int taskId, final String message) {
/* final Config config = new Config();
config.load(getContext());
new Thread(new Runnable() {
@Override
public void run() {
String url = "http://" + config.getAppServerUrl() + Url.SubmitTaskException;
try {
Connection connection = Jsoup.connect(url);
connection.ignoreContentType(true);
connection.data("content", message);
connection.data("pointId", "" + taskId);
connection.data("type", "2");
connection.post();
} catch (Exception e) {
Log.e(new MyException("提交异常信息失败", new MyException("连接URL: " + url, e)));
}
}
}).start();*/
}
private void submitException(@Nullable Integer taskId, final String message) {
if (null == taskId) {
submitGlobalException(message);
} else {
submitTaskException(taskId, message);
}
}
private void handle_LauncherUI_Login(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
Log.e("界面异常 - 当前为登录界面", getContext(), ToastDuration.LENGTH_LONG);
submitGlobalException("当前为登录界面,需要人工登录");
}
/*private void handle_LauncherUI_Main(@NonNull final UiTree uiTree, final boolean keepingAlive) throws MyException {
if (!getGpsMocker().isWorking()) {
synchronized (mNewGpsThread) {
if (null == mNewGpsThread[0]) {
mNewGpsThread[0] = new Thread(new Runnable() {
@Override
public void run() {
final int id;
final int areaId;
final Gps mockGps;
final WxScope wxScope;
try {
if (Macro.RealGps || !Macro.Network) {
mockGps = Macro.MockGps;
id = 0;
areaId = 0;
// wxScope = WxScope.forPersonCount(10);
} else {
try {
JSONObject jsonObject;
String url = null;
try {
Config config = new Config();
config.load(getContext());
url = "http://" + config.getAppServerUrl() + Url.GetTask + config
.getAppAreaConfig();
Connection connection = Jsoup.connect(url);
connection.ignoreContentType(true);
Document document = connection.get();
SilenceLog.e(document.toString());
jsonObject = new JSONObject(document.body().text());
} catch (Exception e) {
throw new MyException("连接服务器失败", new MyException("连接URL: " + url, e));
}
String gpsText;
int amount;
long intervalTime;//秒
String type;
try {
JSONArray jsonArray = jsonObject.getJSONArray("data");
JSONObject itemObject = jsonArray.getJSONObject(0);
id = itemObject.getInt("id");
areaId = itemObject.getInt("area_id");
gpsText = itemObject.getString("position");
amount = itemObject.getInt("amount");
intervalTime = itemObject.getLong("interval_time");
type = itemObject.getString("type");
} catch (Exception e) {
throw new MyException("解析服务器数据异常", new MyException("连接URL: " + url, e));
}
try {
String[] texts = gpsText.split(":");
mockGps = new Gps(Float.parseFloat(texts[2]), Float.parseFloat(texts[1]));
} catch (Exception e) {
throw new MyException("解析服务器GPS数据异常", new MyException("连接URL: " + url, e));
}
if ("amount".equals(type)) {
wxScope = WxScope.forPersonCount(amount);
} else if ("interval_time".equals(type)) {
wxScope = WxScope.forTaskTime(intervalTime * 1000);
} else {
throw new MyException("解析服务器工作方式异常", new MyException("连接URL: " + url));
}
} catch (Exception e) {
Log.e(e, getContext(), ToastDuration.LENGTH_SHORT);
mMainHandler.postDelayed(new Runnable() {
@Override
public void run() {
getServiceHandler().requirePost();
}
}, RECONNECT_SERVER_DELAY);
return;
}
}
} finally {
synchronized (mNewGpsThread) {
mNewGpsThread[0] = null;
}
}
mMainHandler.post(new Runnable() {
@Override
public void run() {
getGpsMocker().start(getContext(), mockGps);
mWxTask = new WxTask(id, areaId, wxScope);
getServiceHandler().requirePost();
}
});
}
});
mNewGpsThread[0].start();
}
}
} else {
uiTree.getNode("发现").click();
uiTree.getNode("附近的人").click();
}
}*/
/* private void handle_LoginHistoryUI(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
//TODO Zhukun 自动登录
final Config config = new Config();
config.load(getContext());
uiTree.getNode("输入密码").setEditText(QQApplication.getContext(), "");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
uiTree.getNode("输入密码").setEditText(QQApplication.getContext(), config.getWeChatPwd());
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
uiTree.getNode("登录").click();
submitGlobalException("输入密码" + config.getWeChatPwd());
Log.e("输入密码" + config.getWeChatPwd(), getContext(), ToastDuration.LENGTH_LONG);
}*/
/**
* 帐号或密码错误,请重新填写
*
* @param uiTree uiTree
* @param keepingAlive keepingAlive
* @throws MyException
*/
/* private void handle_LoginErro_1(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
uiTree.getNode("确定").click();
Log.e("帐号或密码错误,请重新填写");
}*/
/**
* 密码错误,找回或重置密码?
*
* @param uiTree uiTree
* @param keepingAlive keepingAlive
* @throws MyException
*/
/* private void handle_LoginErro_2(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
uiTree.getNode("取消").click();
Log.e("密码错误,找回或重置密码?");
}*/
/* private void handle_NearbyFriendsIntroUI(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (!getGpsMocker().isWorking()) {
requireBack(uiTree);
return;
}
uiTree.getNode("开始查看").click();
}*/
/* private void handle_NearbyFriendShowSayHiUI(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (!getGpsMocker().isWorking()) {
requireBack(uiTree);
return;
}
uiTree.getNode("开始查看").click();
}*/
/* private void handle_BaseP_0(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (!getGpsMocker().isWorking()) {
requireBack(uiTree);
return;
}
if (null == mWxTask) {
getGpsMocker().stop();
requireBack(uiTree);
return;
}
if (mWxTask.mLocatingStartTime <= 0) {
//第一次进入该页面
mWxTask.mLocatingStartTime = System.currentTimeMillis();
return;
}
if (System.currentTimeMillis() >= mWxTask.mLocatingStartTime + LOCATING_TIMEOUT) {
mWxTask.mLocatingStartTime = 0;
submitTaskException(mWxTask.getId(), "定位超时");
requireBack(uiTree);
return;
}
}*/
/*
private void handle_BaseH_0(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
uiTree.getNode("下次不提示").click();
uiTree.getNode("确定").click();
}
*/
/* private void handle_BaseH_1(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
uiTree.getNode("确定").click();
}
*/
/* private void handle_BaseH_2(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
Log.e("定位异常", getContext(), ToastDuration.LENGTH_LONG);
submitException(null == mWxTask ? null : mWxTask.getId(), "定位失败");
getGpsMocker().stop();
requireBack(uiTree);
}*/
/* private void handle_BaseH_3(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
uiTree.getNode("确定").click();
}*/
/* private void handle_BaseH_4(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
uiTree.getNode("确定").click();
}*/
/* private void handle_BaseH_5(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
uiTree.getNode("关闭").click();
}*/
private void handle_BaseH_6(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
uiTree.getNode("取消").click();
}
private void handle_BaseH_7(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
uiTree.getNode("取消").click();
}
private void handle_BaseH_8(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
uiTree.getNode("取消").click();
}
private void handle_BaseH_9(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
uiTree.getNode("确定").click();
}
/* private void handle_NearbyFriendsUI(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (!getGpsMocker().isWorking()) {
requireBack(uiTree);
return;
}
if (null == mWxTask) {
getGpsMocker().stop();
requireBack(uiTree);
return;
}
if (null == mWxTask.person()) {
uiTree.getNode("更多").click();
return;
}
UiNode listNode = uiTree.getNode("列表");
if (mWxTask.mPersonIndex >= listNode.getChildCount()) {
//需要翻页
int count = listNode.getChildCount();
if (count > 0) {
UiNode lastItemNode = listNode.getChild(count - 1);
WxPersonTemp personTemp = new WxPersonTemp();
try {
UiNode node = lastItemNode.getChild(0).getChild(1).getChild(0).getChild(0);
personTemp.mNickname = StringUtil.toNullable(node.getText());
} catch (NullPointerException e) {
//忽略异常
}
try {
UiNode node = lastItemNode.getChild(0).getChild(1).getChild(0).getChild(1);
personTemp.mSex = StringUtil.toNullable(node.getDescription());
} catch (NullPointerException e) {
//忽略异常
}
try {
UiNode node = lastItemNode.getChild(0).getChild(1).getChild(1).getChild(0);
personTemp.mDistance = StringUtil.toNullable(node.getText());
} catch (NullPointerException e) {
//忽略异常
}
try {
UiNode node = lastItemNode.getChild(0).getChild(2).getChild(0);
personTemp.mIdiograph = StringUtil.toNullable(node.getText());
} catch (NullPointerException e) {
//忽略异常
}
if (null != mWxTask.mPersonTemp) {
if (personTemp.equals(mWxTask.mPersonTemp)) {
Log.i("遍历结束", getContext(), ToastDuration.LENGTH_SHORT);
getGpsMocker().stop();
getServiceHandler().requirePost();
return;
}
}
mWxTask.mPersonTemp = personTemp;
} else {
mWxTask.mPersonTemp = null;
}
mWxTask.mPersonIndex = 0;
listNode.scrollForward();
getServiceHandler().requirePost();
} else {
UiNode itemNode = listNode.getChild(mWxTask.mPersonIndex);
if (0 == mWxTask.mPersonIndex) {
if (0 == itemNode.getChildCount()) {
//首页第一个为空,跳过
mWxTask.mPersonIndex++;
handle_NearbyFriendsUI(uiTree, keepingAlive);
return;
} else {
Rect listViewBounds = new Rect();
listNode.getBoundsInScreen(listViewBounds);
Rect itemBounds = new Rect();
itemNode.getBoundsInScreen(itemBounds);
if (itemBounds.top < listViewBounds.top) {
//第一个为上一页已访问的,跳过
mWxTask.mPersonIndex++;
handle_NearbyFriendsUI(uiTree, keepingAlive);
return;
}
}
}
mWxTask.mPersonIndex++;
try {
mWxTask.personNew();
} catch (WxTask.TaskEndException e) {
Log.i("当前任务结束", getContext(), ToastDuration.LENGTH_SHORT);
getGpsMocker().stop();
requireBack(uiTree);
return;
} catch (MyException e) {
Log.e(new MyException("获取下个Person异常", e), getContext(), ToastDuration.LENGTH_SHORT);
getGpsMocker().stop();
requireBack(uiTree);
return;
}
itemNode.click();
}
}
*/
private void handle_NearbyFriendsUI_Nobody(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (getGpsMocker().isWorking()) {
Log.e("没有附近的人", getContext(), ToastDuration.LENGTH_LONG);
getGpsMocker().stop();
}
requireBack(uiTree);
}
/* private void handle_NearbyFriendsUI_NoLocation(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (getGpsMocker().isWorking()) {
Log.e("不能获取位置", getContext(), ToastDuration.LENGTH_LONG);
submitException(null == mWxTask ? null : mWxTask.getId(), "不能获取位置");
getGpsMocker().stop();
}
requireBack(uiTree);
}*/
/* private void handle_NearbyFriendsUIMenu(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null != mWxTask && null == mWxTask.person()) {
mWxTask.personReset();
uiTree.getNode("清除位置并退出").click();
} else {
requireBack(uiTree);
}
}*/
/*private void handle_ContactInfoUI(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
switch (mWxTask.person().step()) {
case PersonInfo:
handle_ContactInfoUI_CasePersonInfo(uiTree, keepingAlive);
break;
case PersonImage:
handle_ContactInfoUI_CasePersonImage(uiTree, keepingAlive);
break;
case Messages:
handle_ContactInfoUI_CaseMessages(uiTree, keepingAlive);
break;
case Finish:
case Finished:
handle_ContactInfoUI_CaseFinish(uiTree, keepingAlive);
break;
default:
Log.e("QQSimulateBusiness.handle_ContactInfoUI # 错误步骤(" + mWxTask.person().step().name() + "),返回",
getContext(), ToastDuration.LENGTH_SHORT);
requireBack(uiTree);
break;
}
}*/
/*private void handle_ContactInfoUI_CasePersonInfo(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
if (WxPerson.Step.PersonInfo != mWxTask.person().step()) {
requireBack(uiTree);
return;
}
String nickname = StringUtil.toNb(uiTree.getNode("昵称").getText());
if (null != nickname) {
// 昵称总是会多一个空格,这里去掉
if (nickname.endsWith(" ")) {
nickname = nickname.substring(0, nickname.length() - 1);
}
}
mWxTask.person().setNickname(nickname);
String sex = StringUtil.toNb(uiTree.getNode("性别").getDescription());
mWxTask.person().setSex(sex);
String location = StringUtil.toNb(uiTree.getNode("位置").getText());
mWxTask.person().setLocation(location);
UiNode listNode = uiTree.getNode("列表");
for (int i = 2; i < listNode.getChildCount(); i++) {
try {
UiNode itemNode = listNode.getChild(i);
UiNode labelNode = itemNode.getChild(0).getChild(0).getChild(0).getChild(0);
String label = StringUtil.toEb(labelNode.getText());
if (label.equals("地区")) {
UiNode valueNode = itemNode.getChild(0).getChild(0).getChild(1).getChild(0).getChild(0);
mWxTask.person().setRegion(StringUtil.toNb(valueNode.getText()));
} else if (label.equals("个性签名")) {
UiNode valueNode = itemNode.getChild(0).getChild(0).getChild(1).getChild(0).getChild(0);
mWxTask.person().setIdiograph(StringUtil.toNb(valueNode.getText()));
}
} catch (NullPointerException e) {
//继续遍历
}
}
mWxTask.person().nextStep(WxPerson.Step.PersonImage);
handle_ContactInfoUI_CasePersonImage(uiTree, keepingAlive);
}*/
/*private void handle_ContactInfoUI_CasePersonImage(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
if (WxPerson.Step.PersonImage != mWxTask.person().step()) {
requireBack(uiTree);
return;
}
uiTree.getNode("头像").click();
}*/
/*private void handle_ContactInfoUIImage(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
switch (mWxTask.person().step()) {
case PersonImage: {
UiNode node = uiTree.getNode("图片");
Rect bounds = new Rect();
node.getBoundsInScreen(bounds);
mWxTask.person().nextStep(WxPerson.Step.PersonImageSaving);
mWxTask.person().mImageSaveCount = 0;
getServiceHandler().requireMockLongClick(new PointXY(bounds.centerX(), bounds.centerY()));
getServiceHandler().requirePost();
}
break;
case PersonImageSaving:
if (mWxTask.person().mImageSaveCount > 3) {
Log.e("获取头像失败", getContext(), ToastDuration.LENGTH_SHORT);
mWxTask.person().nextStep(WxPerson.Step.PersonImageSaved);
mWxTask.person().nextStep();
requireBack(uiTree);
} else {
mWxTask.person().mImageSaveCount++;
getServiceHandler().requirePost();
}
break;
case PersonImageSaved:
mWxTask.person().setPersonImage(mDiskFiles.nextFreshFileName());
mWxTask.person().nextStep();
requireBack(uiTree);
break;
default:
Log.e("QQSimulateBusiness.handle_ContactInfoUIImage # 错误步骤(" + mWxTask.person().step().name() + "),返回",
getContext(), ToastDuration.LENGTH_SHORT);
requireBack(uiTree);
break;
}
}*/
/*private void handle_BaseK_ImageSaving(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
if (WxPerson.Step.PersonImageSaving != mWxTask.person().step()) {
requireBack(uiTree);
return;
}
mDiskFiles.scanFiles();
mWxTask.person().nextStep(WxPerson.Step.PersonImageSaved);
uiTree.getNode("保存到手机").click();
}*/
/* private void handle_ContactInfoUI_CaseMessages(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
if (WxPerson.Step.Messages != mWxTask.person().step()) {
requireBack(uiTree);
return;
}
UiNode listNode = uiTree.getNode("列表");
UiNode photosNode = null;
for (int i = 2; i < listNode.getChildCount(); i++) {
try {
UiNode itemNode = listNode.getChild(i);
String description = StringUtil.toEb(itemNode.getDescription());
if (description.startsWith("个人相册")) {
photosNode = itemNode;
break;
}
} catch (Exception e) {
//继续遍历
}
}
if (null == photosNode) {
mWxTask.person().nextStep(WxPerson.Step.Finish);
handle_ContactInfoUI_CaseFinish(uiTree, keepingAlive);
} else {
photosNode.click();
}
}*/
/*private void handle_ContactInfoUI_CaseFinish(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
switch (mWxTask.person().step()) {
case Finish: {
if (null != mWxTask.person().mFinishTime) {
//判断超时
if (System.currentTimeMillis() >= mWxTask.person().mFinishTime + SUBMIT_WXPERSON_TIMEOUT) {
mWxTask.person().nextStep(WxPerson.Step.Finished);
getServiceHandler().requirePost();
}
} else {
final WxPerson wxPerson = mWxTask.person();
wxPerson.mFinishTime = System.currentTimeMillis();
final Config config = new Config();
config.load(getContext());
new Thread(new Runnable() {
@Override
public void run() {
try {
wxPerson.submit(getContext(), config);
Log.i("提交完成");
} catch (MyException e) {
Log.e(e, getContext(), ToastDuration.LENGTH_SHORT);
}
mMainHandler.post(new Runnable() {
@Override
public void run() {
wxPerson.deleteImageFiles();
wxPerson.nextStep(WxPerson.Step.Finished);
getServiceHandler().requirePost();
}
});
}
}).start();
}
}
break;
case Finished:
requireBack(uiTree);
break;
default:
Log.e("QQSimulateBusiness.handle_ContactInfoUI_CaseFinish # 错误步骤(" + mWxTask.person().step().name() + ")" +
",返回", getContext(), ToastDuration.LENGTH_SHORT);
requireBack(uiTree);
break;
}
}*/
/*private void handle_SnsUserUI(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
if (WxPerson.Step.Messages != mWxTask.person().step()) {
requireBack(uiTree);
return;
}
UiNode listNode = uiTree.getNode("列表");
List<WxMessage> wxMessages = mWxTask.person().getMessages();
String md = null;
for (int i = 1; i < listNode.getChildCount(); i++) {
if (i - 1 >= wxMessages.size()) {
wxMessages.add(null);
}
WxMessage wxMessage = wxMessages.get(i - 1);
UiNode itemNode = listNode.getChild(i);
try {
UiNode dateMdNode = itemNode.getChild(2).getChild(0).getChild(0).getChild(0);
UiNode dateDNode = dateMdNode.getChild(0);
if (StringUtil.compareNb(dateDNode.getClassName(), "android.widget.TextView")) {
String d = StringUtil.toEb(dateDNode.getText());
md = DateUtil.toMd(d, null);
if (null == md) {
UiNode dateMNode = dateMdNode.getChild(1);
String m = StringUtil.toEb(dateMNode.getText());
md = m + d;
}
}
} catch (NullPointerException e) {
//忽略异常
}
if (null == wxMessage) {
try {
if (StringUtil.compareNb(itemNode.getChild(0).getChild(0).getChild(1).getText(), "非朋友最多显示十张照片")) {
//结束
break;
}
} catch (NullPointerException e) {
//忽略异常
}
try {
UiNode node = itemNode;
if (StringUtil.compareNb("android.widget.LinearLayout", node.getClassName()) && 1 == node
.getChildCount()) {
node = itemNode.getChild(0);
if (StringUtil.compareNb("android.widget.LinearLayout", node.getClassName()) && 1 == node
.getChildCount()) {
node = node.getChild(0);
if (StringUtil.compareNb("android.widget.LinearLayout", node.getClassName()) && 1 == node
.getChildCount()) {
node = node.getChild(0);
if (StringUtil.compareNb("android.widget.ImageView", node.getClassName()) && 0 ==
node.getChildCount()) {
//结束行
break;
}
}
}
}
} catch (NullPointerException e) {
//忽略异常
}
//由于可点的位置在itemNode内部,所以使用最后一个子节点来判断
UiNode childNode = null;
for (int n = 0; n < itemNode.getChildCount(); n++) {
UiNode node = null;
try {
node = itemNode.getChild(n).getChild(0);
} catch (NullPointerException e) {
//忽略异常
}
try {
node = itemNode.getChild(n).getChild(1);
} catch (NullPointerException e) {
//忽略异常
}
if (null != node) {
childNode = node;
}
}
if (null == childNode) {
//异常,结束
break;
}
//点击进入具体的消息页面
Rect listBounds = new Rect();
listNode.getBoundsInScreen(listBounds);
Rect childBounds = new Rect();
childNode.getBoundsInScreen(childBounds);
if (childBounds.top >= listBounds.bottom) {
//该项已经在显示界面之外,由于目前没有滚屏机制,所以忽略之后的item
break;
}
PointXY point = new PointXY(childBounds.centerX(), childBounds.centerY());
if (point.mY >= listBounds.bottom) {
point.mY = listBounds.bottom - 1;
}
getServiceHandler().requireMockClick(point);
return;
} else {
wxMessage.setDateMd(md);
}
}
//遍历结束
if (!wxMessages.isEmpty()) {
//去掉最后一条,最后一条为结束图标
if (null == wxMessages.get(wxMessages.size() - 1)) {
wxMessages.remove(wxMessages.size() - 1);
}
}
mWxTask.person().nextStep(WxPerson.Step.Finish);
requireBack(uiTree);
}
*/
/*private void handle_SnsGalleryUI(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
switch (mWxTask.person().step()) {
case Messages: {
List<WxMessage> wxMessages = mWxTask.person().getMessages();
if (wxMessages.isEmpty()) {
requireBack(uiTree);
return;
}
WxMessage wxMessage = new WxMessage();
wxMessage.mGalleryPageIndex = 0;
wxMessage.mGalleryNoTitleClickCount = 0;
try {
wxMessage.setDescription(StringUtil.toNb(uiTree.getNode("描述").getText()));
} catch (MyException e) {
//忽略异常
}
wxMessage.setDateYmdhm(DateUtil.toYmdhm(StringUtil.toNb(uiTree.getNode("时间").getText())));
wxMessages.set(wxMessages.size() - 1, wxMessage);
mWxTask.person().nextStep(WxPerson.Step.MessageImageReading);
handle_SnsGalleryUI(uiTree, keepingAlive);
}
break;
case MessageImageReading: {
uiTree.getNode("更多").click();
}
break;
case MessageImageOneReadEnd: {
List<WxMessage> wxMessages = mWxTask.person().getMessages();
if (wxMessages.isEmpty()) {
requireBack(uiTree);
return;
}
WxMessage wxMessage = wxMessages.get(wxMessages.size() - 1);
if (null == wxMessage) {
requireBack(uiTree);
return;
}
wxMessage.getImages().add(mDiskFiles.nextFreshFileName());
UiNode pagingNode = null;
try {
pagingNode = uiTree.getNode("分页");
} catch (MyException e) {
//忽略异常
}
if (null != pagingNode) {
wxMessage.mGalleryPageIndex++;
String text = StringUtil.toEb(pagingNode.getText());
String separator = " / ";
int off = text.indexOf(separator);
int page = Integer.parseInt(text.substring(0, off));
if (page != wxMessage.mGalleryPageIndex) {
Log.e("当前页码不匹配,返回", getContext(), ToastDuration.LENGTH_SHORT);
mWxTask.person().nextStep(WxPerson.Step.Messages);
requireBack(uiTree);
}
int count = Integer.parseInt(text.substring(off + separator.length()));
if (page < count) {
UiNode galleryNode = uiTree.getNode("照片墙");
Rect bounds = new Rect();
galleryNode.getBoundsInScreen(bounds);
if (Math.abs(bounds.right - bounds.left) <= 2) {
throw new MyException("照片墙控件大小异常");
}
wxMessage.mGalleryNoTitleClickCount = 0;
mWxTask.person().nextStep(WxPerson.Step.MessageImageReading);
getServiceHandler().requireMockMove(new PointXY2XY(new PointXY(bounds.right - 1, bounds
.centerY()), new PointXY(bounds.left + 1, bounds.centerY())));
return;
} else {
mWxTask.person().nextStep(WxPerson.Step.Messages);
requireBack(uiTree);
}
} else {
mWxTask.person().nextStep(WxPerson.Step.Messages);
requireBack(uiTree);
}
}
break;
default:
Log.e("QQSimulateBusiness.handle_SnsGalleryUI # 错误步骤(" + mWxTask.person().step().name() + "),返回", getContext
(), ToastDuration.LENGTH_SHORT);
requireBack(uiTree);
break;
}
}*/
/*private void handle_SnsGalleryUI_NoTitle(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
if (WxPerson.Step.MessageImageReading != mWxTask.person().step()) {
requireBack(uiTree);
return;
}
List<WxMessage> wxMessages = mWxTask.person().getMessages();
if (wxMessages.isEmpty()) {
requireBack(uiTree);
return;
}
WxMessage wxMessage = wxMessages.get(wxMessages.size() - 1);
if (null == wxMessage) {
requireBack(uiTree);
return;
}
if (wxMessage.mGalleryNoTitleClickCount >= 5) {
//点击多次无反应,则当前页面为“图片获取中”状态
requireBack(uiTree);
return;
}
wxMessage.mGalleryNoTitleClickCount++;
UiNode node = uiTree.getNode("照片墙");
Rect bounds = new Rect();
node.getBoundsInScreen(bounds);
getServiceHandler().requireMockClick(new PointXY(bounds.centerX(), bounds.centerY()));
getServiceHandler().requirePost();
}
private void handle_SnsGalleryUIMenu(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
if (WxPerson.Step.MessageImageReading != mWxTask.person().step()) {
requireBack(uiTree);
return;
}
mWxTask.person().nextStep(WxPerson.Step.MessageImageOneReadEnd);
mDiskFiles.scanFiles();
try {
uiTree.getNode("保存到手机").click();
} catch (MyException e) {
//当前为视频或其他
requireBack(uiTree);
}
}*/
/* private void handle_SnsCommentDetailUI(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
switch (mWxTask.person().step()) {
case Messages: {
List<WxMessage> wxMessages = mWxTask.person().getMessages();
if (wxMessages.isEmpty()) {
requireBack(uiTree);
return;
}
final WxMessage wxMessage = new WxMessage();
try {
wxMessage.setTitle(StringUtil.toNb(uiTree.getNode("标题").getText()));
} catch (MyException e) {
//忽略异常
}
try {
wxMessage.setDescription(StringUtil.toNb(uiTree.getNode("描述").getText()));
} catch (MyException e) {
//忽略异常
}
try {
wxMessage.setSource(StringUtil.toNb(uiTree.getNode("源").getText()));
} catch (MyException e) {
//忽略异常
}
try {
wxMessage.setRegion(StringUtil.toNb(uiTree.getNode("地区").getText()));
} catch (MyException e) {
//忽略异常
}
try {
wxMessage.setDateYmdhm(DateUtil.toYmdhm(StringUtil.toNb(uiTree.getNode("时间").getText())));
} catch (MyException e) {
//忽略异常
}
try {
wxMessage.setTail(StringUtil.toNb(uiTree.getNode("尾注").getText()));
} catch (MyException e) {
//忽略异常
}
if (Macro.Debug) {
String text = "获取消息内容:";
text += "\n日期:" + wxMessage.getDateYmdhm();
text += "\n描述:" + wxMessage.getDescription();
text += "\n标题:" + wxMessage.getTitle();
text += "\n源:" + wxMessage.getSource();
text += "\n尾注:" + wxMessage.getTail();
text += "\n地区位置:" + wxMessage.getRegion();
Log.i(text);
}
wxMessages.set(wxMessages.size() - 1, wxMessage);
UiNode enterNode = null;
try {
enterNode = uiTree.getNode("进入");
} catch (MyException e) {
//忽略异常
}
if (null != enterNode) {
mWxTask.person().nextStep(WxPerson.Step.MessageWebReading);
readyClipboard(new ClipboardManager.OnPrimaryClipChangedListener() {
@Override
public void onPrimaryClipChanged() {
ClipboardManager clipboardManager = (ClipboardManager) getContext().getSystemService
(Context.CLIPBOARD_SERVICE);
try {
wxMessage.setUrl(StringUtil.toNb(clipboardManager.getPrimaryClip().getItemAt(0)
.getText()));
if (Macro.Debug) {
Log.i("获取URL:" + wxMessage.getUrl());
}
} catch (Exception e) {
//忽略异常
}
releaseClipboard();
}
});
Rect bounds = new Rect();
enterNode.getBoundsInScreen(bounds);
getServiceHandler().requireMockClick(new PointXY(bounds.centerX(), bounds.centerY()));
getServiceHandler().requirePost();
} else {
requireBack(uiTree);
}
}
break;
case MessageWebReading: {
List<WxMessage> wxMessages = mWxTask.person().getMessages();
if (wxMessages.isEmpty()) {
requireBack(uiTree);
return;
}
WxMessage wxMessage = wxMessages.get(wxMessages.size() - 1);
if (null == wxMessage) {
requireBack(uiTree);
return;
}
if (wxMessage.mWebReadingCount > 3) {
Log.e("获取URL失败", getContext(), ToastDuration.LENGTH_SHORT);
mWxTask.person().nextStep(WxPerson.Step.Messages);
requireBack(uiTree);
} else {
wxMessage.mWebReadingCount++;
}
}
break;
case MessageWebReadEnd: {
releaseClipboard();
mWxTask.person().nextStep(WxPerson.Step.Messages);
requireBack(uiTree);
}
break;
default:
Log.e("QQSimulateBusiness.handle_SnsCommentDetailUI # 错误步骤(" + mWxTask.person().step().name() + "),返回",
getContext(), ToastDuration.LENGTH_SHORT);
requireBack(uiTree);
break;
}
}*/
/*private void handle_WebViewUI(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
switch (mWxTask.person().step()) {
case MessageWebReading:
try {
uiTree.getNode("更多").click();
} catch (MyException e) {
mWxTask.person().nextStep(WxPerson.Step.MessageWebReadEnd);
requireBack(uiTree);
}
break;
case MessageWebReadEnd:
requireBack(uiTree);
break;
default:
Log.e("QQSimulateBusiness.handle_WebViewUI # 错误步骤(" + mWxTask.person().step().name() + "),返回", getContext(),
ToastDuration.LENGTH_SHORT);
requireBack(uiTree);
break;
}
}
*/
/*private void handle_WebViewUIMenu_Normal(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
if (WxPerson.Step.MessageWebReading != mWxTask.person().step()) {
requireBack(uiTree);
return;
}
mWxTask.person().nextStep(WxPerson.Step.MessageWebReadEnd);
uiTree.getNode("复制链接").click();
}*/
/*private void handle_WebViewUIMenu_Other(@NonNull UiTree uiTree, boolean keepingAlive) throws MyException {
if (null == mWxTask || null == mWxTask.person()) {
requireBack(uiTree);
return;
}
if (WxPerson.Step.MessageWebReading != mWxTask.person().step()) {
requireBack(uiTree);
return;
}
mWxTask.person().nextStep(WxPerson.Step.MessageWebReadEnd);
requireBack(uiTree);
}*/
}
| 50,381 | 0.489384 | 0.486073 | 1,144 | 41.775349 | 29.070255 | 124 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.61451 | false | false |
13
|
9e7b1e81ea0adb1cd7c9bb7b291be8c67aa34446
| 6,794,638,265,977 |
466b50f1ad2b24a029697719425e599005e6e98c
|
/app/src/main/java/com/example/hzy/lovenum/Activityname1.java
|
08aa30a68402c4b7749ecda14a7fc85e6f4d0c50
|
[] |
no_license
|
huozuyue/zs
|
https://github.com/huozuyue/zs
|
edac830b45e3f9e176c4077fa15d8b9363344466
|
8da035d2ea6ba093f6e3f226fe7160f4e93b58cc
|
refs/heads/master
| 2020-03-19T15:43:37.372000 | 2018-07-18T08:26:51 | 2018-07-18T08:26:51 | 136,633,054 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.example.hzy.lovenum;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
import android.widget.TextView;
import com.amap.api.maps.AMap;
import com.amap.api.maps.MapView;
public class Activityname1 extends AppCompatActivity {
private TextView mTextMessage;
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
= new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.navigation_home:
mTextMessage.setText(R.string.title_home);
return true;
case R.id.navigation_dashboard:
mTextMessage.setText(R.string.title_dashboard);
return true;
case R.id.navigation_notifications:
mTextMessage.setText(R.string.title_notifications);
return true;
}
return false;
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_activityname1);
mTextMessage = (TextView) findViewById(R.id.message);
BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
MapView mapView = (MapView) findViewById(R.id.map);//找到地图控件
//在activity执行onCreate时执行mMapView.onCreate(savedInstanceState),创建地图
mapView.onCreate(savedInstanceState);
AMap aMap = mapView.getMap();//初始化地图控制器对象
}
}
|
UTF-8
|
Java
| 1,968 |
java
|
Activityname1.java
|
Java
|
[] | null |
[] |
package com.example.hzy.lovenum;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
import android.widget.TextView;
import com.amap.api.maps.AMap;
import com.amap.api.maps.MapView;
public class Activityname1 extends AppCompatActivity {
private TextView mTextMessage;
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
= new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.navigation_home:
mTextMessage.setText(R.string.title_home);
return true;
case R.id.navigation_dashboard:
mTextMessage.setText(R.string.title_dashboard);
return true;
case R.id.navigation_notifications:
mTextMessage.setText(R.string.title_notifications);
return true;
}
return false;
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_activityname1);
mTextMessage = (TextView) findViewById(R.id.message);
BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
MapView mapView = (MapView) findViewById(R.id.map);//找到地图控件
//在activity执行onCreate时执行mMapView.onCreate(savedInstanceState),创建地图
mapView.onCreate(savedInstanceState);
AMap aMap = mapView.getMap();//初始化地图控制器对象
}
}
| 1,968 | 0.685475 | 0.683908 | 61 | 30.377048 | 28.447342 | 99 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.42623 | false | false |
13
|
97ba0c8c6bf59dae82bc194910324602a99ddf97
| 28,166,395,564,870 |
107163a4b835b98fd77fc88d83e0e168abc9dd70
|
/app/src/main/java/com/mejrabsoft/myapplication/Adapter/adapter.java
|
be1228bc953cbc5a73c9895386229865f77bc0cd
|
[] |
no_license
|
TahirIqbal95/my-application
|
https://github.com/TahirIqbal95/my-application
|
abcd37a9e7e3de86d5c1d764cb339ee3d515fa3e
|
3b9cbca6bacc6ea42173828fb36f9d3ffa91f7b4
|
refs/heads/master
| 2022-11-30T05:35:32.692000 | 2020-08-04T14:07:04 | 2020-08-04T14:07:04 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.mejrabsoft.myapplication.Adapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.mejrabsoft.myapplication.Model.GetCategory;
import com.mejrabsoft.myapplication.R;
import java.util.List;
public class adapter extends RecyclerView.Adapter<adapter.MyviewHolder> {
List<GetCategory.MainCategory> list;
public adapter(List<GetCategory.MainCategory> list) {
this.list = list;
}
@NonNull
@Override
public MyviewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout,parent,false);
return new MyviewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull MyviewHolder holder, int position) {
holder.name.setText(list.get(position).categories.name);
}
@Override
public int getItemCount() {
return list.size();
}
public class MyviewHolder extends RecyclerView.ViewHolder {
TextView name;
public MyviewHolder(@NonNull View itemView) {
super(itemView);
name = itemView.findViewById(R.id.name);
}
}
}
|
UTF-8
|
Java
| 1,339 |
java
|
adapter.java
|
Java
|
[] | null |
[] |
package com.mejrabsoft.myapplication.Adapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.mejrabsoft.myapplication.Model.GetCategory;
import com.mejrabsoft.myapplication.R;
import java.util.List;
public class adapter extends RecyclerView.Adapter<adapter.MyviewHolder> {
List<GetCategory.MainCategory> list;
public adapter(List<GetCategory.MainCategory> list) {
this.list = list;
}
@NonNull
@Override
public MyviewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout,parent,false);
return new MyviewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull MyviewHolder holder, int position) {
holder.name.setText(list.get(position).categories.name);
}
@Override
public int getItemCount() {
return list.size();
}
public class MyviewHolder extends RecyclerView.ViewHolder {
TextView name;
public MyviewHolder(@NonNull View itemView) {
super(itemView);
name = itemView.findViewById(R.id.name);
}
}
}
| 1,339 | 0.713219 | 0.713219 | 54 | 23.796297 | 25.95536 | 99 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.425926 | false | false |
13
|
bf1622cdd16690362a35dfd7d55022e31c3aec9c
| 22,634,477,667,618 |
c7f82294a3e2fe4ce7c6f2f1061a8107672493b0
|
/src/interpreter/SymbolTable.java
|
046b1e856f9c6bf52c645be2a0e568b36a0e69d5
|
[] |
no_license
|
ksantosh95/Lua-Interpreter
|
https://github.com/ksantosh95/Lua-Interpreter
|
f9475b47b530eea8c1b94545ed4c15fa79754ec1
|
3a791b0a80ce2a78e821ef5ffeee2cf2b6f2e6d2
|
refs/heads/master
| 2023-02-11T12:12:05.617000 | 2021-01-07T20:17:17 | 2021-01-07T20:17:17 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package interpreter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import luaCompiler.AST.Name;
import luaCompiler.AST.Stat;
import luaCompiler.AST.StatLabel;
import interpreter.LuaTable.IllegalTableKeyException;
public class SymbolTable {
@SuppressWarnings("serial")
public class IllegalTableKeyException extends RuntimeException {
}
static final int DEFAULT_ARRAY_SIZE = 32;
Map<Integer,ArrayList<StatLabel>> map ;
public SymbolTable(){
map = new HashMap<>();
}
public void put(StatLabel key, Integer val) {
ArrayList<StatLabel> s= new ArrayList<>();
if (key instanceof StatLabel) {
ArrayList<StatLabel> m = map.get(val);
if(m==null)
{s.add(key);}
else
{
s=m;
s.add(key);
}
map.put(val,s);
}
}
public void display()
{
Set<Integer> statset = map.keySet();
for (Integer s:statset)
{
System.out.println("\nKEY= "+s+" VALUE="+map.get(s));
}
}
public StatLabel get(Name nm,int ind )
{
ArrayList<StatLabel> slist= new ArrayList<>();
while(ind>=0)
{
ArrayList<StatLabel> m = map.get(ind);
if(m ==null)
{
return null;
}
else
{
slist=m;
for(StatLabel s:slist )
{
if((nm.name).equals((s.label).name))
{
return s;
}
}
}
ind--;
}
return null;
}
public Boolean StatExists(Name nm, int ind)
{
ArrayList<StatLabel> slist= new ArrayList<>();
while(ind>=0)
{
ArrayList<StatLabel> m = map.get(ind);
if(m ==null)
{
return null;
}
else
{
slist = m;
for(StatLabel s:slist )
{
if((nm.name).equals((s.label).name))
{
return true;
}
}
ind=ind-1;
}
}
return false;
}
}
|
UTF-8
|
Java
| 1,793 |
java
|
SymbolTable.java
|
Java
|
[] | null |
[] |
package interpreter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import luaCompiler.AST.Name;
import luaCompiler.AST.Stat;
import luaCompiler.AST.StatLabel;
import interpreter.LuaTable.IllegalTableKeyException;
public class SymbolTable {
@SuppressWarnings("serial")
public class IllegalTableKeyException extends RuntimeException {
}
static final int DEFAULT_ARRAY_SIZE = 32;
Map<Integer,ArrayList<StatLabel>> map ;
public SymbolTable(){
map = new HashMap<>();
}
public void put(StatLabel key, Integer val) {
ArrayList<StatLabel> s= new ArrayList<>();
if (key instanceof StatLabel) {
ArrayList<StatLabel> m = map.get(val);
if(m==null)
{s.add(key);}
else
{
s=m;
s.add(key);
}
map.put(val,s);
}
}
public void display()
{
Set<Integer> statset = map.keySet();
for (Integer s:statset)
{
System.out.println("\nKEY= "+s+" VALUE="+map.get(s));
}
}
public StatLabel get(Name nm,int ind )
{
ArrayList<StatLabel> slist= new ArrayList<>();
while(ind>=0)
{
ArrayList<StatLabel> m = map.get(ind);
if(m ==null)
{
return null;
}
else
{
slist=m;
for(StatLabel s:slist )
{
if((nm.name).equals((s.label).name))
{
return s;
}
}
}
ind--;
}
return null;
}
public Boolean StatExists(Name nm, int ind)
{
ArrayList<StatLabel> slist= new ArrayList<>();
while(ind>=0)
{
ArrayList<StatLabel> m = map.get(ind);
if(m ==null)
{
return null;
}
else
{
slist = m;
for(StatLabel s:slist )
{
if((nm.name).equals((s.label).name))
{
return true;
}
}
ind=ind-1;
}
}
return false;
}
}
| 1,793 | 0.6029 | 0.600112 | 122 | 13.696721 | 15.481819 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.221312 | false | false |
13
|
7ffd2c4ebf22e13d557c4389b0f0395fcd37019c
| 23,321,672,434,480 |
01110b3c72be0cfd9322146e1fd51195aa02d625
|
/app/src/main/java/com/sloths/speedy/shortsounds/view/ShortSoundsApplication.java
|
92c4bc9963231d91c28304018c40c77a5bbeac0a
|
[] |
no_license
|
nharlow89/ShortSounds
|
https://github.com/nharlow89/ShortSounds
|
610cc59ce1ef63fdb26dd08c71d9dd56886689d5
|
230008f0bea25730f51c913136c39cf165791d45
|
refs/heads/master
| 2021-01-20T11:13:58.809000 | 2015-06-05T00:21:05 | 2015-06-05T00:21:05 | 33,558,049 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.sloths.speedy.shortsounds.view;
import android.app.Application;
import android.content.Context;
import android.view.Gravity;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
/**
* ShortSoundsApplication allows other classes to get the overall
* Application Context
*/
public class ShortSoundsApplication extends Application {
private static Context context;
/**
* Sets up the ShortSounds application when the app is created
*/
@Override
public void onCreate(){
super.onCreate();
ShortSoundsApplication.context = getApplicationContext();
}
/**
* Returns the overall Application context.
* @return The overall application Context
*/
public static Context getAppContext() {
return ShortSoundsApplication.context;
}
/**
* shows toast
* @param text The String text associated with the toast
*/
public void showToast(String text) {
Toast toast = Toast.makeText(this, text, Toast.LENGTH_SHORT);
LinearLayout layout =(LinearLayout)toast.getView();
TextView textView = ((TextView)layout.getChildAt(0));
textView.setTextSize(20);
textView.setGravity(Gravity.CENTER);
toast.show();
}
}
|
UTF-8
|
Java
| 1,299 |
java
|
ShortSoundsApplication.java
|
Java
|
[] | null |
[] |
package com.sloths.speedy.shortsounds.view;
import android.app.Application;
import android.content.Context;
import android.view.Gravity;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
/**
* ShortSoundsApplication allows other classes to get the overall
* Application Context
*/
public class ShortSoundsApplication extends Application {
private static Context context;
/**
* Sets up the ShortSounds application when the app is created
*/
@Override
public void onCreate(){
super.onCreate();
ShortSoundsApplication.context = getApplicationContext();
}
/**
* Returns the overall Application context.
* @return The overall application Context
*/
public static Context getAppContext() {
return ShortSoundsApplication.context;
}
/**
* shows toast
* @param text The String text associated with the toast
*/
public void showToast(String text) {
Toast toast = Toast.makeText(this, text, Toast.LENGTH_SHORT);
LinearLayout layout =(LinearLayout)toast.getView();
TextView textView = ((TextView)layout.getChildAt(0));
textView.setTextSize(20);
textView.setGravity(Gravity.CENTER);
toast.show();
}
}
| 1,299 | 0.690531 | 0.688222 | 46 | 27.23913 | 22.023886 | 69 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.413043 | false | false |
13
|
48365327286fb7767ed1019ccff11cebd0103f12
| 34,016,140,999,915 |
8f2e3aba246eebc3fb935356c097b6e167c4c503
|
/src/main/java/com/synectiks/cms/graphql/types/State/AbstractStateInput.java
|
420bdb0c3f6d5cc53dab16f9f42ead2fd428ce01
|
[] |
no_license
|
xformation/cms-backend
|
https://github.com/xformation/cms-backend
|
b2b685b1a0c39e8e25f5e9d7e64c43f932c8e9f9
|
390545fdbab0d0c7bd9a123d1d4f132fbc4a7289
|
refs/heads/master
| 2022-12-15T12:12:39.350000 | 2020-06-11T06:17:47 | 2020-06-11T06:17:47 | 163,104,143 | 2 | 3 | null | false | 2022-12-10T00:50:26 | 2018-12-25T18:35:26 | 2020-06-11T06:17:58 | 2022-12-10T00:50:26 | 18,323 | 1 | 3 | 37 |
Java
| false | false |
package com.synectiks.cms.graphql.types.State;
import java.util.Objects;
public class AbstractStateInput {
private Long id;
private String stateName;
private String divisionType;
private String stateCode;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getStateName() {
return stateName;
}
public void setStateName(String stateName) {
this.stateName = stateName;
}
public String getDivisionType() {
return divisionType;
}
public void setDivisionType(String divisionType) {
this.divisionType = divisionType;
}
public String getStateCode() {
return stateCode;
}
public void setStateCode(String stateCode) {
this.stateCode = stateCode;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AbstractStateInput that = (AbstractStateInput) o;
return Objects.equals(id, that.id) &&
Objects.equals(stateName, that.stateName) &&
Objects.equals(divisionType, that.divisionType) &&
Objects.equals(stateCode, that.stateCode);
}
@Override
public int hashCode() {
return Objects.hash(id, stateName, divisionType, stateCode);
}
@Override
public String toString() {
return "AbstractStateInput{" +
"id=" + id +
", stateName='" + stateName + '\'' +
", divisionType='" + divisionType + '\'' +
", stateCode='" + stateCode + '\'' +
'}';
}
}
|
UTF-8
|
Java
| 1,683 |
java
|
AbstractStateInput.java
|
Java
|
[] | null |
[] |
package com.synectiks.cms.graphql.types.State;
import java.util.Objects;
public class AbstractStateInput {
private Long id;
private String stateName;
private String divisionType;
private String stateCode;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getStateName() {
return stateName;
}
public void setStateName(String stateName) {
this.stateName = stateName;
}
public String getDivisionType() {
return divisionType;
}
public void setDivisionType(String divisionType) {
this.divisionType = divisionType;
}
public String getStateCode() {
return stateCode;
}
public void setStateCode(String stateCode) {
this.stateCode = stateCode;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AbstractStateInput that = (AbstractStateInput) o;
return Objects.equals(id, that.id) &&
Objects.equals(stateName, that.stateName) &&
Objects.equals(divisionType, that.divisionType) &&
Objects.equals(stateCode, that.stateCode);
}
@Override
public int hashCode() {
return Objects.hash(id, stateName, divisionType, stateCode);
}
@Override
public String toString() {
return "AbstractStateInput{" +
"id=" + id +
", stateName='" + stateName + '\'' +
", divisionType='" + divisionType + '\'' +
", stateCode='" + stateCode + '\'' +
'}';
}
}
| 1,683 | 0.588235 | 0.588235 | 68 | 23.735294 | 20.06139 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.470588 | false | false |
13
|
f7e909d26c603743aa73e44ce14caa1e3921aa83
| 2,396,591,775,743 |
a6fb064b0d286886ad59c7f3d5b4f0036a8c3ccc
|
/report/src/main/java/report/service/imps/SelectFieldsService.java
|
7241e5e51314e6dcb1d73d88b3df630319d0e8f5
|
[] |
no_license
|
xiongshaogang/supersion
|
https://github.com/xiongshaogang/supersion
|
8496407ccf5b298bc50a27af19d858cc57f6999b
|
c88f803924b21e4993076f22ab16a210ac4a32a2
|
refs/heads/master
| 2021-01-19T17:36:37.251000 | 2016-12-14T06:44:52 | 2016-12-14T06:44:52 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package report.service.imps;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.ServletActionContext;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import report.dto.ItemInfo;
import extend.dto.ReportModel_Field;
import extend.dto.ReportModel_Table;
import extend.dto.Suit;
import framework.helper.FrameworkFactory;
import framework.interfaces.IParamObjectResultExecute;
import framework.interfaces.RequestManager;
import framework.services.imps.BaseObjectDaoResultService;
import framework.show.ShowContext;
public class SelectFieldsService extends BaseObjectDaoResultService{
@Override
public void initSuccessResult() throws Exception {
HttpServletResponse response = ServletActionContext.getResponse();
response.setCharacterEncoding("UTF-8");
String AutoTableId = RequestManager.getReportCheckParam().get("AutoTableID");
if(AutoTableId == null) {
String suitID = RequestManager.getReportCheckParam().get("SuitID");
String tmpName = RequestManager.getReportCheckParam().get("TmpName");
DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Class.forName("report.dto.ItemInfo"));
if(suitID != null && !"".equals(suitID) ) {
// RequestManager.setId(AutoTableId);
IParamObjectResultExecute singleObjectFindByIdDao = (IParamObjectResultExecute)FrameworkFactory.CreateBean("singleObjectFindByIdDao");
Suit suit = (Suit)singleObjectFindByIdDao.paramObjectResultExecute(new Object[]{"extend.dto.Suit", suitID, null});
detachedCriteria.add(Restrictions.eq("suit", suit));
detachedCriteria.addOrder(Order.asc("strItemCode"));
}
IParamObjectResultExecute dao = (IParamObjectResultExecute)FrameworkFactory.CreateBean("singleObjectFindByCriteriaDao");
List<ItemInfo> objectListItemInfo = (List<ItemInfo>)dao.paramObjectResultExecute(new Object[]{detachedCriteria, null});
StringBuffer ItemInfos = new StringBuffer();
for(ItemInfo info : objectListItemInfo) {
String filterItem = ShowContext.getInstance().getShowEntityMap().get("sysParam").get("filterBindItem");
if(filterItem != null && filterItem.equals("true")
&& !info.getStrItemCode().startsWith(tmpName)) continue;
ItemInfos.append(info.getStrItemCode());
ItemInfos.append(",");
ItemInfos.append(info.getStrItemName());
ItemInfos.append(";");
}
if(ItemInfos==null){
ItemInfos.append("");
}
response.getWriter().write(ItemInfos.toString());
}
else {
DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Class.forName("extend.dto.ReportModel_Field"));
if(!"".equals(AutoTableId)) {
// RequestManager.setId(AutoTableId);
IParamObjectResultExecute singleObjectFindByIdDao = (IParamObjectResultExecute)FrameworkFactory.CreateBean("singleObjectFindByIdDao");
ReportModel_Table table = (ReportModel_Table)singleObjectFindByIdDao.paramObjectResultExecute(new Object[]{"extend.dto.ReportModel_Table",AutoTableId,null});
detachedCriteria.add(Restrictions.eq("reportModel_Table", table));
detachedCriteria.addOrder(Order.asc("nSeq"));
}
IParamObjectResultExecute dao = (IParamObjectResultExecute)FrameworkFactory.CreateBean("singleObjectFindByCriteriaDao");
List<ReportModel_Field> objectListField = (List<ReportModel_Field>)dao.paramObjectResultExecute(new Object[]{detachedCriteria,null});
StringBuffer fields = new StringBuffer();
for(ReportModel_Field code : objectListField) {
fields.append(code.getStrChinaName());
fields.append(",");
fields.append(code.getStrFieldName());
fields.append(",");
fields.append(code.getAutoFieldID());
fields.append(",");
fields.append(code.getReportModel_Table().getAutoTableID());
fields.append(";");
}
if(fields==null){
fields.append("");
}
response.getWriter().write(fields.toString());
}
}
}
|
UTF-8
|
Java
| 4,067 |
java
|
SelectFieldsService.java
|
Java
|
[] | null |
[] |
package report.service.imps;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.ServletActionContext;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import report.dto.ItemInfo;
import extend.dto.ReportModel_Field;
import extend.dto.ReportModel_Table;
import extend.dto.Suit;
import framework.helper.FrameworkFactory;
import framework.interfaces.IParamObjectResultExecute;
import framework.interfaces.RequestManager;
import framework.services.imps.BaseObjectDaoResultService;
import framework.show.ShowContext;
public class SelectFieldsService extends BaseObjectDaoResultService{
@Override
public void initSuccessResult() throws Exception {
HttpServletResponse response = ServletActionContext.getResponse();
response.setCharacterEncoding("UTF-8");
String AutoTableId = RequestManager.getReportCheckParam().get("AutoTableID");
if(AutoTableId == null) {
String suitID = RequestManager.getReportCheckParam().get("SuitID");
String tmpName = RequestManager.getReportCheckParam().get("TmpName");
DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Class.forName("report.dto.ItemInfo"));
if(suitID != null && !"".equals(suitID) ) {
// RequestManager.setId(AutoTableId);
IParamObjectResultExecute singleObjectFindByIdDao = (IParamObjectResultExecute)FrameworkFactory.CreateBean("singleObjectFindByIdDao");
Suit suit = (Suit)singleObjectFindByIdDao.paramObjectResultExecute(new Object[]{"extend.dto.Suit", suitID, null});
detachedCriteria.add(Restrictions.eq("suit", suit));
detachedCriteria.addOrder(Order.asc("strItemCode"));
}
IParamObjectResultExecute dao = (IParamObjectResultExecute)FrameworkFactory.CreateBean("singleObjectFindByCriteriaDao");
List<ItemInfo> objectListItemInfo = (List<ItemInfo>)dao.paramObjectResultExecute(new Object[]{detachedCriteria, null});
StringBuffer ItemInfos = new StringBuffer();
for(ItemInfo info : objectListItemInfo) {
String filterItem = ShowContext.getInstance().getShowEntityMap().get("sysParam").get("filterBindItem");
if(filterItem != null && filterItem.equals("true")
&& !info.getStrItemCode().startsWith(tmpName)) continue;
ItemInfos.append(info.getStrItemCode());
ItemInfos.append(",");
ItemInfos.append(info.getStrItemName());
ItemInfos.append(";");
}
if(ItemInfos==null){
ItemInfos.append("");
}
response.getWriter().write(ItemInfos.toString());
}
else {
DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Class.forName("extend.dto.ReportModel_Field"));
if(!"".equals(AutoTableId)) {
// RequestManager.setId(AutoTableId);
IParamObjectResultExecute singleObjectFindByIdDao = (IParamObjectResultExecute)FrameworkFactory.CreateBean("singleObjectFindByIdDao");
ReportModel_Table table = (ReportModel_Table)singleObjectFindByIdDao.paramObjectResultExecute(new Object[]{"extend.dto.ReportModel_Table",AutoTableId,null});
detachedCriteria.add(Restrictions.eq("reportModel_Table", table));
detachedCriteria.addOrder(Order.asc("nSeq"));
}
IParamObjectResultExecute dao = (IParamObjectResultExecute)FrameworkFactory.CreateBean("singleObjectFindByCriteriaDao");
List<ReportModel_Field> objectListField = (List<ReportModel_Field>)dao.paramObjectResultExecute(new Object[]{detachedCriteria,null});
StringBuffer fields = new StringBuffer();
for(ReportModel_Field code : objectListField) {
fields.append(code.getStrChinaName());
fields.append(",");
fields.append(code.getStrFieldName());
fields.append(",");
fields.append(code.getAutoFieldID());
fields.append(",");
fields.append(code.getReportModel_Table().getAutoTableID());
fields.append(";");
}
if(fields==null){
fields.append("");
}
response.getWriter().write(fields.toString());
}
}
}
| 4,067 | 0.740841 | 0.740349 | 94 | 41.265957 | 37.755421 | 161 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.159575 | false | false |
13
|
ffa79e1b1b260c031325354821a0490bc79873bd
| 30,554,397,397,475 |
cb73c53feacd4a9b6af1c91cf911eeb1ae4f7f81
|
/src/Grid.java
|
b383dbe148f756ca88e2773ea82780ae9a77b61c
|
[] |
no_license
|
terfan/tictactoe
|
https://github.com/terfan/tictactoe
|
5a083a93bbf10d845249114939ef601b7ec169fc
|
c350396ffc3ff1f1fad5fe7388509cd3c37afbcc
|
refs/heads/master
| 2021-01-23T06:34:09.081000 | 2013-01-20T05:51:56 | 2013-01-20T05:51:56 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
public class Grid {
Square[][] squares = new Square[3][3];
boolean won;
public Grid() {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
squares[i][j] = new Square();
squares[i][j].value = 0;
}
}
this.won = false;
}
public boolean isWon() {
return checkHoriz() || checkVert() || checkDiag1() || checkDiag2();
}
public boolean checkHoriz() {
if (squares[0][0].value != 0 && squares[0][0].value == squares[0][1].value && squares[0][1].value == squares[0][2].value) {
return true;
}
if (squares[1][0].value != 0 && squares[1][0].value == squares[1][1].value && squares[1][1].value == squares[1][2].value) {
return true;
}
if (squares[2][0].value != 0 && squares[2][0].value == squares[2][1].value && squares[2][1].value == squares[2][2].value) {
return true;
}
return false;
}
public boolean checkVert() {
if (squares[0][0].value != 0 && squares[0][0].value == squares[1][0].value && squares[1][0].value == squares[2][0].value || squares[0][1].value != 0
&& squares[0][1].value == squares[1][1].value && squares[1][1].value == squares[2][1].value || squares[0][2].value != 0
&& squares[0][2].value == squares[1][2].value && squares[1][2].value == squares[2][2].value) {
return true;
}
return false;
}
public boolean checkDiag1() {
if (squares[0][0].value != 0 && squares[0][0].value == squares[1][1].value && squares[1][1].value == squares[2][2].value) {
return true;
}
return false;
}
public boolean checkDiag2() {
if (squares[0][2].value != 0 && squares[0][2].value == squares[1][1].value && squares[1][1].value == squares[2][0].value) {
return true;
}
return false;
}
}
|
UTF-8
|
Java
| 1,965 |
java
|
Grid.java
|
Java
|
[] | null |
[] |
public class Grid {
Square[][] squares = new Square[3][3];
boolean won;
public Grid() {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
squares[i][j] = new Square();
squares[i][j].value = 0;
}
}
this.won = false;
}
public boolean isWon() {
return checkHoriz() || checkVert() || checkDiag1() || checkDiag2();
}
public boolean checkHoriz() {
if (squares[0][0].value != 0 && squares[0][0].value == squares[0][1].value && squares[0][1].value == squares[0][2].value) {
return true;
}
if (squares[1][0].value != 0 && squares[1][0].value == squares[1][1].value && squares[1][1].value == squares[1][2].value) {
return true;
}
if (squares[2][0].value != 0 && squares[2][0].value == squares[2][1].value && squares[2][1].value == squares[2][2].value) {
return true;
}
return false;
}
public boolean checkVert() {
if (squares[0][0].value != 0 && squares[0][0].value == squares[1][0].value && squares[1][0].value == squares[2][0].value || squares[0][1].value != 0
&& squares[0][1].value == squares[1][1].value && squares[1][1].value == squares[2][1].value || squares[0][2].value != 0
&& squares[0][2].value == squares[1][2].value && squares[1][2].value == squares[2][2].value) {
return true;
}
return false;
}
public boolean checkDiag1() {
if (squares[0][0].value != 0 && squares[0][0].value == squares[1][1].value && squares[1][1].value == squares[2][2].value) {
return true;
}
return false;
}
public boolean checkDiag2() {
if (squares[0][2].value != 0 && squares[0][2].value == squares[1][1].value && squares[1][1].value == squares[2][0].value) {
return true;
}
return false;
}
}
| 1,965 | 0.490585 | 0.440204 | 56 | 34.089287 | 42.728077 | 156 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.535714 | false | false |
13
|
c1b80b4faf45ea73f289e409a621a4968941e7e2
| 2,233,383,050,012 |
7137ca86cc36dc9534484ba36dc47e0af33cbc1b
|
/vmware/ngc/NGC-Plugin/src/main/java/org/opensds/vmware/ngc/util/ObjectIdUtil.java
|
7556b4c2a1185349769f4829d4fabbcdfc64c479
|
[
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
littlehotcx/nbp
|
https://github.com/littlehotcx/nbp
|
2bed485e5f338de6a58b7834ebc17bfa48f22f3d
|
a65eb1d5d6c9eaeb22dfd8cab17b941a9873f3b3
|
refs/heads/master
| 2021-12-02T09:49:27.058000 | 2021-06-29T11:26:31 | 2021-06-29T11:26:31 | 199,649,454 | 3 | 1 |
Apache-2.0
| true | 2019-08-07T01:45:39 | 2019-07-30T12:41:46 | 2019-07-30T13:48:01 | 2019-08-07T01:45:38 | 112,877 | 1 | 1 | 0 |
Go
| false | false |
// Copyright 2019 The OpenSDS Authors.
//
// 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.opensds.vmware.ngc.util;
/**
* ObjectId encoding/decoding
*/
public class ObjectIdUtil {
// Forward slash must be encoded in URLs
private static final String FORWARD_SLASH = "/";
// Single encoding
private static final String FORWARD_SLASH_ENCODED1 = "%2F";
// Double encoding
private static final String FORWARD_SLASH_ENCODED2 = "%252F";
public static String encodeObjectId(String objectId) {
return objectId == null ? null : objectId.replace(FORWARD_SLASH, FORWARD_SLASH_ENCODED2);
}
/**
* Decode the given objectId when passed as a path variable in a Spring controller
* (Spring already performs 1 level of decoding)
*
* @param objectId Encoded id
* @return The decoded object id
*/
public static String decodePathVariable(String objectId) {
return objectId == null ? null : objectId.replace(FORWARD_SLASH_ENCODED1, FORWARD_SLASH);
}
/**
* Decode the given objectId when passed as a URL parameter, i.e. reverse the
* double encoding done by encodeObjectId.
*
* @param objectId Encoded id
* @return The decoded object id
*/
public static String decodeParameter(String objectId) {
return objectId == null ? null : objectId.replace(FORWARD_SLASH_ENCODED2, FORWARD_SLASH);
}
}
|
UTF-8
|
Java
| 1,933 |
java
|
ObjectIdUtil.java
|
Java
|
[] | null |
[] |
// Copyright 2019 The OpenSDS Authors.
//
// 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.opensds.vmware.ngc.util;
/**
* ObjectId encoding/decoding
*/
public class ObjectIdUtil {
// Forward slash must be encoded in URLs
private static final String FORWARD_SLASH = "/";
// Single encoding
private static final String FORWARD_SLASH_ENCODED1 = "%2F";
// Double encoding
private static final String FORWARD_SLASH_ENCODED2 = "%252F";
public static String encodeObjectId(String objectId) {
return objectId == null ? null : objectId.replace(FORWARD_SLASH, FORWARD_SLASH_ENCODED2);
}
/**
* Decode the given objectId when passed as a path variable in a Spring controller
* (Spring already performs 1 level of decoding)
*
* @param objectId Encoded id
* @return The decoded object id
*/
public static String decodePathVariable(String objectId) {
return objectId == null ? null : objectId.replace(FORWARD_SLASH_ENCODED1, FORWARD_SLASH);
}
/**
* Decode the given objectId when passed as a URL parameter, i.e. reverse the
* double encoding done by encodeObjectId.
*
* @param objectId Encoded id
* @return The decoded object id
*/
public static String decodeParameter(String objectId) {
return objectId == null ? null : objectId.replace(FORWARD_SLASH_ENCODED2, FORWARD_SLASH);
}
}
| 1,933 | 0.698396 | 0.689084 | 54 | 34.796295 | 30.991863 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.296296 | false | false |
13
|
aed03831249146b7216436a6f19f2a17762a15f0
| 33,947,421,524,863 |
60d2f287a7e3f9afac3b9769dfeaac31b0777102
|
/app/src/main/java/com/mylocumchoice/MyLocumChoicePharmacy/view/bookings/activities/SearchActivity.java
|
78dcc4dc92ac060bbc5f8905350b031cafc1aefe
|
[] |
no_license
|
om79/MLC
|
https://github.com/om79/MLC
|
018a64f5c44a280db0d83e0556c2d80fa092fbed
|
556b44fb4ce2c1ecff1a1bcf7cca8f76c886e4a0
|
refs/heads/master
| 2020-04-06T13:43:34.530000 | 2018-11-12T15:57:03 | 2018-11-12T15:57:03 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.mylocumchoice.MyLocumChoicePharmacy.view.bookings.activities;
import android.Manifest;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.LocationManager;
import android.os.Bundle;
import android.provider.Settings;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.PendingResult;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.location.places.AutocompleteFilter;
import com.google.android.gms.location.places.Place;
import com.google.android.gms.location.places.PlaceBuffer;
import com.google.android.gms.location.places.PlaceLikelihood;
import com.google.android.gms.location.places.PlaceLikelihoodBuffer;
import com.google.android.gms.location.places.Places;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.mylocumchoice.MyLocumChoicePharmacy.R;
import com.mylocumchoice.MyLocumChoicePharmacy.view.base.AppActivity;
import com.mylocumchoice.MyLocumChoicePharmacy.view.bookings.adapters.PlaceAutoCompleteAdapter;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
public class SearchActivity extends AppActivity implements PlaceAutoCompleteAdapter.PlaceAutoCompleteInterface, GoogleApiClient.OnConnectionFailedListener,
GoogleApiClient.ConnectionCallbacks, OnClickListener, GestureDetector.OnGestureListener {
Context mContext;
GoogleApiClient mGoogleApiClient;
GoogleApiClient mGoogleApiClientPlaces;
LinearLayout mParent;
@BindView(R.id.tv_noResults)
TextView tvNoResults;
@BindView(R.id.parent)
LinearLayout parent;
private RecyclerView mRecyclerView;
LinearLayoutManager llm;
PlaceAutoCompleteAdapter mAdapter;
// List<SavedAddress> mSavedAddressList;
// PlaceSavedAdapter mSavedAdapter;
private static final LatLngBounds BOUNDS_INDIA = new LatLngBounds(
new LatLng(-0, 0), new LatLng(0, 0));
EditText mSearchEdittext;
ImageView mClear;
int RESULT_CODE = 1;
int RESULT_CODE_PLACES = 2;
private GestureDetector gestureScanner;
/**
* ButterKnife Code
**/
@BindView(R.id.down)
ImageView down;
@BindView(R.id.search_et)
EditText searchEt;
@BindView(R.id.clear)
ImageView clear;
@BindView(R.id.list_search)
RecyclerView listSearch;
@BindView(R.id.google)
ImageView google;
@BindView(R.id.loc)
TextView etLoc;
/**
* ButterKnife Code
**/
@Override
public void onStart() {
mGoogleApiClient.connect();
mGoogleApiClientPlaces.connect();
super.onStart();
}
@Override
public void onStop() {
mGoogleApiClient.disconnect();
mGoogleApiClientPlaces.disconnect();
super.onStop();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search);
mContext = SearchActivity.this;
ButterKnife.bind(this);
/* *
* to handle search locations
*
*/
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, 0 /* clientId */, this)
.addApi(Places.GEO_DATA_API)
.build();
/* *
* to handle current location
*
*/
mGoogleApiClientPlaces = new GoogleApiClient.Builder(this)
.enableAutoManage(this, 1 /* clientId */, this)
.addApi(Places.PLACE_DETECTION_API)
.build();
initViews();
gestureScanner = new GestureDetector(this);
parent.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return gestureScanner.onTouchEvent(event);
}
});
}
/*
Initialize Views
*/
private void initViews() {
mRecyclerView = (RecyclerView) findViewById(R.id.list_search);
mRecyclerView.setHasFixedSize(true);
llm = new LinearLayoutManager(mContext);
mRecyclerView.setLayoutManager(llm);
mSearchEdittext = (EditText) findViewById(R.id.search_et);
mClear = (ImageView) findViewById(R.id.clear);
mClear.setOnClickListener(this);
AutocompleteFilter autocompleteFilter = new AutocompleteFilter.Builder()
.setTypeFilter(Place.TYPE_COUNTRY)
.setCountry("UK")
.build();
mAdapter = new PlaceAutoCompleteAdapter(this, R.layout.view_placesearch,
mGoogleApiClient, BOUNDS_INDIA, autocompleteFilter);
mRecyclerView.setAdapter(mAdapter);
mSearchEdittext.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (count > 0) {
mClear.setVisibility(View.VISIBLE);
if (mAdapter != null) {
mRecyclerView.setAdapter(mAdapter);
}/*else{
tvNoResults.setVisibility(View.VISIBLE);
etLoc.setVisibility(View.GONE);
}*/
} else {
mClear.setVisibility(View.GONE);
// if (mSavedAdapter != null && mSavedAddressList.size() > 0) {
// mRecyclerView.setAdapter(mSavedAdapter);
// }
}
if(s.toString().length()>=3) {
if (!s.toString().equals("") && mGoogleApiClient.isConnected()) {
mAdapter.getFilter().filter(s.toString());
} else if (!mGoogleApiClient.isConnected()) {
// Toast.makeText(getApplicationContext(), Constants.API_NOT_CONNECTED, Toast.LENGTH_SHORT).show();
Log.e("", "NOT CONNECTED");
}
}
}
@Override
public void afterTextChanged(Editable s) {
}
});
if (!searchEt.getText().toString().equalsIgnoreCase("")) {
clear.setVisibility(View.VISIBLE);
} else {
clear.setVisibility(View.GONE);
}
}
@Override
public void onClick(View v) {
if (v == mClear) {
mSearchEdittext.setText("");
if (mAdapter != null) {
mAdapter.clearList();
}
}
}
@Override
public void onConnected(Bundle bundle) {
}
@Override
public void onConnectionSuspended(int i) {
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
}
@Override
public void onPlaceClick(ArrayList<PlaceAutoCompleteAdapter.PlaceAutocomplete> mResultList, int position) {
if (mResultList != null) {
try {
final String placeId = String.valueOf(mResultList.get(position).placeId);
PendingResult<PlaceBuffer> placeResult = Places.GeoDataApi
.getPlaceById(mGoogleApiClient, placeId);
placeResult.setResultCallback(new ResultCallback<PlaceBuffer>() {
@Override
public void onResult(PlaceBuffer places) {
if (places.getCount() == 1) {
//Do the things here on Click.....
Intent data = new Intent();
data.putExtra("lat", String.valueOf(places.get(0).getLatLng().latitude));
data.putExtra("lng", String.valueOf(places.get(0).getLatLng().longitude));
data.putExtra("name", String.valueOf(places.get(0).getName()));
setResult(RESULT_CODE, data);
onBackPressed();
overridePendingTransition(R.anim.stay, R.anim.slide_out_down);
} else {
showWarning(SearchActivity.this, "", "Something went wrong", "error");
}
}
});
} catch (Exception e) {
}
}
}
@Override
public void onBackPressed() {
super.onBackPressed();
overridePendingTransition(R.anim.stay, R.anim.slide_out_down);
}
@OnClick(R.id.down)
public void click() {
onBackPressed();
overridePendingTransition(R.anim.stay, R.anim.slide_out_down);
}
@OnClick(R.id.clear)
public void onCrossClick() {
searchEt.setText("");
}
@OnClick(R.id.loc)
public void onLocClick() {
checkGPS();
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
if (e1.getY() < e2.getY()) {
Log.d("Gesture ", " Scroll Down");
onBackPressed();
overridePendingTransition(R.anim.stay, R.anim.slide_out_down);
}
return true;
}
@Override
public void finish() {
super.finish();
}
@Override
public boolean onDown(MotionEvent e) {
return true;
}
@Override
public void onShowPress(MotionEvent e) {
}
@Override
public boolean onSingleTapUp(MotionEvent e) {
return false;
}
@Override
public void onLongPress(MotionEvent e) {
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
return false;
}
public void checkGPS() {
final LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
buildAlertMessageNoGps();
} else {
if (ContextCompat.checkSelfPermission(this.getApplicationContext(),
Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {
PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
.getCurrentPlace(mGoogleApiClientPlaces, null);
result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
@Override
public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
for (PlaceLikelihood placeLikelihood : likelyPlaces) {
Intent data = new Intent();
Log.i("TAG", String.format("Place '%s' has likelihood: %g",
placeLikelihood.getPlace().getName(),
placeLikelihood.getLikelihood()));
data.putExtra("name", String.valueOf(placeLikelihood.getPlace().getName()));
setResult(RESULT_CODE_PLACES, data);
onBackPressed();
overridePendingTransition(R.anim.stay, R.anim.slide_out_down);
}
likelyPlaces.release();
}
});
} else {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
1);
}
}
}
private void buildAlertMessageNoGps() {
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Your GPS seems to be disabled, do you want to enable it?")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(final DialogInterface dialog, final int id) {
startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(final DialogInterface dialog, final int id) {
dialog.cancel();
}
});
final AlertDialog alert = builder.create();
alert.show();
}
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
}
}
|
UTF-8
|
Java
| 13,574 |
java
|
SearchActivity.java
|
Java
|
[
{
"context": "erKnife;\nimport butterknife.OnClick;\nimport uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;\n\n\npublic c",
"end": 2025,
"score": 0.9728674292564392,
"start": 2016,
"tag": "USERNAME",
"value": "chrisjenx"
}
] | null |
[] |
package com.mylocumchoice.MyLocumChoicePharmacy.view.bookings.activities;
import android.Manifest;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.LocationManager;
import android.os.Bundle;
import android.provider.Settings;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.PendingResult;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.location.places.AutocompleteFilter;
import com.google.android.gms.location.places.Place;
import com.google.android.gms.location.places.PlaceBuffer;
import com.google.android.gms.location.places.PlaceLikelihood;
import com.google.android.gms.location.places.PlaceLikelihoodBuffer;
import com.google.android.gms.location.places.Places;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.mylocumchoice.MyLocumChoicePharmacy.R;
import com.mylocumchoice.MyLocumChoicePharmacy.view.base.AppActivity;
import com.mylocumchoice.MyLocumChoicePharmacy.view.bookings.adapters.PlaceAutoCompleteAdapter;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
public class SearchActivity extends AppActivity implements PlaceAutoCompleteAdapter.PlaceAutoCompleteInterface, GoogleApiClient.OnConnectionFailedListener,
GoogleApiClient.ConnectionCallbacks, OnClickListener, GestureDetector.OnGestureListener {
Context mContext;
GoogleApiClient mGoogleApiClient;
GoogleApiClient mGoogleApiClientPlaces;
LinearLayout mParent;
@BindView(R.id.tv_noResults)
TextView tvNoResults;
@BindView(R.id.parent)
LinearLayout parent;
private RecyclerView mRecyclerView;
LinearLayoutManager llm;
PlaceAutoCompleteAdapter mAdapter;
// List<SavedAddress> mSavedAddressList;
// PlaceSavedAdapter mSavedAdapter;
private static final LatLngBounds BOUNDS_INDIA = new LatLngBounds(
new LatLng(-0, 0), new LatLng(0, 0));
EditText mSearchEdittext;
ImageView mClear;
int RESULT_CODE = 1;
int RESULT_CODE_PLACES = 2;
private GestureDetector gestureScanner;
/**
* ButterKnife Code
**/
@BindView(R.id.down)
ImageView down;
@BindView(R.id.search_et)
EditText searchEt;
@BindView(R.id.clear)
ImageView clear;
@BindView(R.id.list_search)
RecyclerView listSearch;
@BindView(R.id.google)
ImageView google;
@BindView(R.id.loc)
TextView etLoc;
/**
* ButterKnife Code
**/
@Override
public void onStart() {
mGoogleApiClient.connect();
mGoogleApiClientPlaces.connect();
super.onStart();
}
@Override
public void onStop() {
mGoogleApiClient.disconnect();
mGoogleApiClientPlaces.disconnect();
super.onStop();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search);
mContext = SearchActivity.this;
ButterKnife.bind(this);
/* *
* to handle search locations
*
*/
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, 0 /* clientId */, this)
.addApi(Places.GEO_DATA_API)
.build();
/* *
* to handle current location
*
*/
mGoogleApiClientPlaces = new GoogleApiClient.Builder(this)
.enableAutoManage(this, 1 /* clientId */, this)
.addApi(Places.PLACE_DETECTION_API)
.build();
initViews();
gestureScanner = new GestureDetector(this);
parent.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return gestureScanner.onTouchEvent(event);
}
});
}
/*
Initialize Views
*/
private void initViews() {
mRecyclerView = (RecyclerView) findViewById(R.id.list_search);
mRecyclerView.setHasFixedSize(true);
llm = new LinearLayoutManager(mContext);
mRecyclerView.setLayoutManager(llm);
mSearchEdittext = (EditText) findViewById(R.id.search_et);
mClear = (ImageView) findViewById(R.id.clear);
mClear.setOnClickListener(this);
AutocompleteFilter autocompleteFilter = new AutocompleteFilter.Builder()
.setTypeFilter(Place.TYPE_COUNTRY)
.setCountry("UK")
.build();
mAdapter = new PlaceAutoCompleteAdapter(this, R.layout.view_placesearch,
mGoogleApiClient, BOUNDS_INDIA, autocompleteFilter);
mRecyclerView.setAdapter(mAdapter);
mSearchEdittext.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (count > 0) {
mClear.setVisibility(View.VISIBLE);
if (mAdapter != null) {
mRecyclerView.setAdapter(mAdapter);
}/*else{
tvNoResults.setVisibility(View.VISIBLE);
etLoc.setVisibility(View.GONE);
}*/
} else {
mClear.setVisibility(View.GONE);
// if (mSavedAdapter != null && mSavedAddressList.size() > 0) {
// mRecyclerView.setAdapter(mSavedAdapter);
// }
}
if(s.toString().length()>=3) {
if (!s.toString().equals("") && mGoogleApiClient.isConnected()) {
mAdapter.getFilter().filter(s.toString());
} else if (!mGoogleApiClient.isConnected()) {
// Toast.makeText(getApplicationContext(), Constants.API_NOT_CONNECTED, Toast.LENGTH_SHORT).show();
Log.e("", "NOT CONNECTED");
}
}
}
@Override
public void afterTextChanged(Editable s) {
}
});
if (!searchEt.getText().toString().equalsIgnoreCase("")) {
clear.setVisibility(View.VISIBLE);
} else {
clear.setVisibility(View.GONE);
}
}
@Override
public void onClick(View v) {
if (v == mClear) {
mSearchEdittext.setText("");
if (mAdapter != null) {
mAdapter.clearList();
}
}
}
@Override
public void onConnected(Bundle bundle) {
}
@Override
public void onConnectionSuspended(int i) {
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
}
@Override
public void onPlaceClick(ArrayList<PlaceAutoCompleteAdapter.PlaceAutocomplete> mResultList, int position) {
if (mResultList != null) {
try {
final String placeId = String.valueOf(mResultList.get(position).placeId);
PendingResult<PlaceBuffer> placeResult = Places.GeoDataApi
.getPlaceById(mGoogleApiClient, placeId);
placeResult.setResultCallback(new ResultCallback<PlaceBuffer>() {
@Override
public void onResult(PlaceBuffer places) {
if (places.getCount() == 1) {
//Do the things here on Click.....
Intent data = new Intent();
data.putExtra("lat", String.valueOf(places.get(0).getLatLng().latitude));
data.putExtra("lng", String.valueOf(places.get(0).getLatLng().longitude));
data.putExtra("name", String.valueOf(places.get(0).getName()));
setResult(RESULT_CODE, data);
onBackPressed();
overridePendingTransition(R.anim.stay, R.anim.slide_out_down);
} else {
showWarning(SearchActivity.this, "", "Something went wrong", "error");
}
}
});
} catch (Exception e) {
}
}
}
@Override
public void onBackPressed() {
super.onBackPressed();
overridePendingTransition(R.anim.stay, R.anim.slide_out_down);
}
@OnClick(R.id.down)
public void click() {
onBackPressed();
overridePendingTransition(R.anim.stay, R.anim.slide_out_down);
}
@OnClick(R.id.clear)
public void onCrossClick() {
searchEt.setText("");
}
@OnClick(R.id.loc)
public void onLocClick() {
checkGPS();
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
if (e1.getY() < e2.getY()) {
Log.d("Gesture ", " Scroll Down");
onBackPressed();
overridePendingTransition(R.anim.stay, R.anim.slide_out_down);
}
return true;
}
@Override
public void finish() {
super.finish();
}
@Override
public boolean onDown(MotionEvent e) {
return true;
}
@Override
public void onShowPress(MotionEvent e) {
}
@Override
public boolean onSingleTapUp(MotionEvent e) {
return false;
}
@Override
public void onLongPress(MotionEvent e) {
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
return false;
}
public void checkGPS() {
final LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
buildAlertMessageNoGps();
} else {
if (ContextCompat.checkSelfPermission(this.getApplicationContext(),
Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {
PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
.getCurrentPlace(mGoogleApiClientPlaces, null);
result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
@Override
public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
for (PlaceLikelihood placeLikelihood : likelyPlaces) {
Intent data = new Intent();
Log.i("TAG", String.format("Place '%s' has likelihood: %g",
placeLikelihood.getPlace().getName(),
placeLikelihood.getLikelihood()));
data.putExtra("name", String.valueOf(placeLikelihood.getPlace().getName()));
setResult(RESULT_CODE_PLACES, data);
onBackPressed();
overridePendingTransition(R.anim.stay, R.anim.slide_out_down);
}
likelyPlaces.release();
}
});
} else {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
1);
}
}
}
private void buildAlertMessageNoGps() {
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Your GPS seems to be disabled, do you want to enable it?")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(final DialogInterface dialog, final int id) {
startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(final DialogInterface dialog, final int id) {
dialog.cancel();
}
});
final AlertDialog alert = builder.create();
alert.show();
}
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
}
}
| 13,574 | 0.603359 | 0.60137 | 403 | 32.682381 | 28.039734 | 155 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.528536 | false | false |
13
|
68d0dbe5c00f3e5ae3634b03f02b3441cb13c5c3
| 34,376,918,254,524 |
e4e1dc9093b48140340c243e416d48f710bf860d
|
/rtevo/src/main/java/org/rtevo/main/Main.java
|
0d270b50fdfc2cfdea66dc2c61b7c9fca5011523
|
[
"MIT"
] |
permissive
|
mrG7/Robot-Evolution
|
https://github.com/mrG7/Robot-Evolution
|
dab5407132477c8b4b094b7448b5bf198b87ad6b
|
33ee86d1da4def18a11417a58ddf16bbba30d39b
|
refs/heads/master
| 2021-01-18T02:26:28.423000 | 2015-09-27T23:10:59 | 2015-09-27T23:10:59 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/**
* Measurement units:
*
* length: meters
* time: seconds
* weight: kilograms
*/
package org.rtevo.main;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import org.rtevo.common.Configuration;
public class Main {
public static void main(String[] args) throws FileNotFoundException,
IOException {
Configuration config;
if (args.length == 0) {
config = new Configuration();
} else {
Properties properties = new Properties();
properties.load(new FileInputStream(args[0]));
config = new Configuration(properties);
}
RobotEvolution app = new RobotEvolution(config);
app.start();
}
}
|
UTF-8
|
Java
| 819 |
java
|
Main.java
|
Java
|
[] | null |
[] |
/**
* Measurement units:
*
* length: meters
* time: seconds
* weight: kilograms
*/
package org.rtevo.main;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import org.rtevo.common.Configuration;
public class Main {
public static void main(String[] args) throws FileNotFoundException,
IOException {
Configuration config;
if (args.length == 0) {
config = new Configuration();
} else {
Properties properties = new Properties();
properties.load(new FileInputStream(args[0]));
config = new Configuration(properties);
}
RobotEvolution app = new RobotEvolution(config);
app.start();
}
}
| 819 | 0.615385 | 0.612943 | 33 | 22.818182 | 19.363281 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.424242 | false | false |
13
|
8f0c0aacea958277d8b219a1fa79e0cd243433fa
| 5,549,097,811,714 |
e4ffaae3b76e816b286853dccfb14a0db7830cbb
|
/javaEksamDone/src/eksam/MainBackup.java
|
b944adb39c99a106a37a0a2086dc37741361a56f
|
[] |
no_license
|
kkkaur/JAVA-t13eksamitoo
|
https://github.com/kkkaur/JAVA-t13eksamitoo
|
8642c1415297535f8d7a087b3d3dd984a36b1d55
|
ba6784399cd24304469cc567554033f228d06d44
|
refs/heads/master
| 2020-03-20T23:21:37.094000 | 2018-06-19T12:00:01 | 2018-06-19T12:00:01 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package eksam;
import java.util.Scanner;
public class MainBackup {
double tellimusHamburger;
public static void main(String[] args) {
Scanner algus = new Scanner(System.in);
System.out.println("Kas Sinu soov on burger või terviseburger? (burger/terviseburger)");
String valik = algus.nextLine();
if(valik.equals("burger")){
Scanner start = new Scanner(System.in);
System.out.println("Sisesta burgeri liha");
String liha = start.nextLine();
System.out.println("Sisesta burgeri kukkel");
String kukkel = start.nextLine();
System.out.println("Sisesta burgeri hind");
double hind = start.nextDouble();
hamburger hamburger = new hamburger("Tavaline", liha, kukkel, hind);
//double HIND = hamburger.arvutaHind();
// LISANDID
Scanner lisandid1 = new Scanner(System.in);
System.out.println("Kas tahad lisandeid (tomat, kurk, juust, salat)");
String lisand1 = lisandid1.nextLine();
if(lisand1.equals("jah")){
Scanner lisandid11 = new Scanner(System.in);
System.out.println("Sisesta lisand (tomat, kurk, juust, salat)");
String lisand11 = lisandid11.nextLine();
// hamburger.lisaHamburgeriLisand1(lisand1, 0.50);
}
// PREMIUM-LISANDID
Scanner lisandid2 = new Scanner(System.in);
System.out.println("Kas tahad premium-lisandeid (kirsstomat, Luunja kurk, Cheddar-juust, vutimuna)");
String lisand2 = lisandid2.nextLine();
if(lisand2.equals("jah")){
Scanner lisandid22 = new Scanner(System.in);
System.out.println("Sisesta lisand (kirsstomat, Luunja kurk, Cheddar-juust, vutimuna)");
String lisand22 = lisandid22.nextLine();
hamburger.lisaHamburgeriLisand1(lisand1, 1.50);
}
//hamburger.lisaHamburgeriLisand2("Salat", 0.75);
//hamburger.lisaHamburgeriLisand3("Juust", 1.13);
System.out.println("Tavalise burgeri maksumus on kokku: " + hamburger.arvutaHind()+"\n");
System.out.println("Tavalise burgeri maksumus on kokku: " + hamburger.arvutaHind()+"\n");
// TERVISEBURGER
} else if (valik.equals("terviseburger")){
terviseBurger terviseBurger = new terviseBurger("sea sisefilee", 6);
terviseBurger.lisaHamburgeriLisand1("Muna", 1);
terviseBurger.lisaTerviseLisand1("Läätsed", 2);
System.out.println("Terviseburgeri maksumus on kokku: " + terviseBurger.arvutaHind()+"\n");
//double tellimusterviseBurger = terviseBurger.arvutaHind();
} else {
System.out.println("Sisestasid vale valiku!");
}
// terviseburgeri osa
/*
terviseBurger terviseBurger = new terviseBurger("sea sisefilee", 6);
terviseBurger.lisaHamburgeriLisand1("Muna", 1);
terviseBurger.lisaTerviseLisand1("Läätsed", 2);
System.out.println("Terviseburgeri maksumus on kokku: " + terviseBurger.arvutaHind()+"\n");
//double tellimusterviseBurger = terviseBurger.arvutaHind();
*/
// System.out.println("TELLIMUS: "+ (tellimusterviseBurger+tellimusHamburger));
//deluxeBurgeri osa
/*
DeluxeBurger db = new DeluxeBurger();
db.lisaHamburgeriLisand4("Should not do this", 50.53);
db.arvutaHind();
*/
}
}
|
UTF-8
|
Java
| 3,803 |
java
|
MainBackup.java
|
Java
|
[
{
"context": " hamburger hamburger = new hamburger(\"Tavaline\", liha, kukkel, hind);\n \n\n\n ",
"end": 816,
"score": 0.5062443614006042,
"start": 812,
"tag": "NAME",
"value": "aval"
}
] | null |
[] |
package eksam;
import java.util.Scanner;
public class MainBackup {
double tellimusHamburger;
public static void main(String[] args) {
Scanner algus = new Scanner(System.in);
System.out.println("Kas Sinu soov on burger või terviseburger? (burger/terviseburger)");
String valik = algus.nextLine();
if(valik.equals("burger")){
Scanner start = new Scanner(System.in);
System.out.println("Sisesta burgeri liha");
String liha = start.nextLine();
System.out.println("Sisesta burgeri kukkel");
String kukkel = start.nextLine();
System.out.println("Sisesta burgeri hind");
double hind = start.nextDouble();
hamburger hamburger = new hamburger("Tavaline", liha, kukkel, hind);
//double HIND = hamburger.arvutaHind();
// LISANDID
Scanner lisandid1 = new Scanner(System.in);
System.out.println("Kas tahad lisandeid (tomat, kurk, juust, salat)");
String lisand1 = lisandid1.nextLine();
if(lisand1.equals("jah")){
Scanner lisandid11 = new Scanner(System.in);
System.out.println("Sisesta lisand (tomat, kurk, juust, salat)");
String lisand11 = lisandid11.nextLine();
// hamburger.lisaHamburgeriLisand1(lisand1, 0.50);
}
// PREMIUM-LISANDID
Scanner lisandid2 = new Scanner(System.in);
System.out.println("Kas tahad premium-lisandeid (kirsstomat, Luunja kurk, Cheddar-juust, vutimuna)");
String lisand2 = lisandid2.nextLine();
if(lisand2.equals("jah")){
Scanner lisandid22 = new Scanner(System.in);
System.out.println("Sisesta lisand (kirsstomat, Luunja kurk, Cheddar-juust, vutimuna)");
String lisand22 = lisandid22.nextLine();
hamburger.lisaHamburgeriLisand1(lisand1, 1.50);
}
//hamburger.lisaHamburgeriLisand2("Salat", 0.75);
//hamburger.lisaHamburgeriLisand3("Juust", 1.13);
System.out.println("Tavalise burgeri maksumus on kokku: " + hamburger.arvutaHind()+"\n");
System.out.println("Tavalise burgeri maksumus on kokku: " + hamburger.arvutaHind()+"\n");
// TERVISEBURGER
} else if (valik.equals("terviseburger")){
terviseBurger terviseBurger = new terviseBurger("sea sisefilee", 6);
terviseBurger.lisaHamburgeriLisand1("Muna", 1);
terviseBurger.lisaTerviseLisand1("Läätsed", 2);
System.out.println("Terviseburgeri maksumus on kokku: " + terviseBurger.arvutaHind()+"\n");
//double tellimusterviseBurger = terviseBurger.arvutaHind();
} else {
System.out.println("Sisestasid vale valiku!");
}
// terviseburgeri osa
/*
terviseBurger terviseBurger = new terviseBurger("sea sisefilee", 6);
terviseBurger.lisaHamburgeriLisand1("Muna", 1);
terviseBurger.lisaTerviseLisand1("Läätsed", 2);
System.out.println("Terviseburgeri maksumus on kokku: " + terviseBurger.arvutaHind()+"\n");
//double tellimusterviseBurger = terviseBurger.arvutaHind();
*/
// System.out.println("TELLIMUS: "+ (tellimusterviseBurger+tellimusHamburger));
//deluxeBurgeri osa
/*
DeluxeBurger db = new DeluxeBurger();
db.lisaHamburgeriLisand4("Should not do this", 50.53);
db.arvutaHind();
*/
}
}
| 3,803 | 0.568984 | 0.555029 | 95 | 38.957893 | 30.568617 | 113 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.778947 | false | false |
13
|
baeb3d7f43510b274ff613c792f21fefbaf2008f
| 32,624,571,640,340 |
328b337e7089e5b9235d2f3d0cf32ba0b4d67cef
|
/src/com/lng/util/sequence/Sequence.java
|
f6856d266fae44c4df07cab35f06f267bd8d9c4d
|
[] |
no_license
|
luckgoodtime/smartlpg
|
https://github.com/luckgoodtime/smartlpg
|
15fae9bfdf7f9b29d7a9164d5d8220c2a8b0441f
|
1127b893096aad4e9b6c7139e1bda8bfdbb627bb
|
refs/heads/master
| 2020-02-21T05:36:26.401000 | 2020-02-18T06:08:36 | 2020-02-18T06:08:36 | 126,441,614 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.lng.util.sequence;
public interface Sequence {
public Integer getGlobalNextSeq();
public Integer getNextSeq(String flag);
}
|
UTF-8
|
Java
| 153 |
java
|
Sequence.java
|
Java
|
[] | null |
[] |
package com.lng.util.sequence;
public interface Sequence {
public Integer getGlobalNextSeq();
public Integer getNextSeq(String flag);
}
| 153 | 0.718954 | 0.718954 | 9 | 15 | 16.438437 | 40 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.777778 | false | false |
13
|
9797f870e95e785fcf75adb1eda101086646fb02
| 34,797,825,035,895 |
4b68001cc7f80007279eee86089e18b2191ff77f
|
/src/main/java/com/extensions/logmonitor/jsonContentParseies/jsonContentAnalyzer/NeedParsePathMatcher.java
|
17c625b2916c85307cdbc8011a1ac318addac4e5
|
[] |
no_license
|
rezar1/JsonSqlQuery
|
https://github.com/rezar1/JsonSqlQuery
|
5dbaabad5acfcb1870e904cef7da647ff8f5da12
|
ffd65e31ad9f57cc09bd380791c9123f6c193967
|
refs/heads/master
| 2020-04-03T21:19:51.988000 | 2018-10-31T14:27:48 | 2018-10-31T14:27:48 | 155,571,312 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.extensions.logmonitor.jsonContentParseies.jsonContentAnalyzer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;
/**
*
* @say little Boy, don't be sad.
* @name Rezar
* @time 2017年10月28日
* @Desc this guy is to lazy , noting left.
*
*/
public class NeedParsePathMatcher {
private Map<String, Boolean> matchResult = new HashMap<>();
private Map<String, Boolean> fullMatchResult = new HashMap<>();
private String path;
private List<String> partOfPaths = new ArrayList<>();
private String doMoreParsePath;
private String regexPattern;
private Pattern fullMatchPattern;
public NeedParsePathMatcher(String path) {
this.path = path;
this.doMoreParsePath = processDoMorePath(path);
this.partOfPaths = processPartOfPaths(this.doMoreParsePath);
this.regexPattern = this.fullProcessPath(path);
this.fullMatchPattern = Pattern.compile(regexPattern);
}
/**
* @param doMoreParsePath2
* @return
*/
private List<String> processPartOfPaths(String doMoreParsePath) {
return Arrays.asList(doMoreParsePath.split("\\."));
}
/**
* @param path2
* @return
*/
private String processDoMorePath(String path) {
return path.replaceAll("\\[(\\*|\\d+|#)\\]", ".$1");
}
/**
* @param path
* @return
*
*/
private String fullProcessPath(String path) {
path = "^" + path;
path = path.replaceAll("\\[", "\\\\[");
path = path.replaceAll("\\]", "\\\\]");
path = path.replaceAll("\\.", "\\\\.");
path = path.replaceAll("\\*", "(\\\\d+|.*)");
return path;
}
public boolean fullMatch(String path) {
boolean result = false;
if (this.fullMatchResult.containsKey(path)) {
result = this.fullMatchResult.get(path);
} else {
result = fullMatchPattern.matcher(path).matches();
this.fullMatchResult.put(path, result);
}
return result;
}
public boolean match(String path) {
boolean isMatchPrefix = true;
if (this.matchResult.containsKey(path)) {
isMatchPrefix = this.matchResult.get(path);
} else {
List<String> processPartOfPaths = this.processPartOfPaths(this.processDoMorePath(path));
int index = 0;
for (;index < processPartOfPaths.size() && index < this.partOfPaths.size() ;index ++) {
String partOfPath = processPartOfPaths.get(index);
if (!(partOfPath.equals(this.partOfPaths.get(index))
|| (StringUtils.isNumeric(partOfPath) && this.partOfPaths.get(index).equals("*")))) {
isMatchPrefix = false;
}
}
this.matchResult.put(path, isMatchPrefix);
}
return isMatchPrefix;
}
public boolean needMoreParse(String path) {
return this.doMoreParsePath.length() > path.length();
}
@Override
public String toString() {
return "NeedParsePathMatcher [path=" + path + ", doMoreParsePath=" + doMoreParsePath + ", regexPattern="
+ regexPattern + "]";
}
public static void main(String[] args) {
NeedParsePathMatcher matcher = new NeedParsePathMatcher("subUserInfos[1].adslotId");
System.out.println(matcher);
boolean match = matcher.match("subUserInfos[1]");
System.out.println(match);
boolean fullMatch = matcher.fullMatch("subUserInfos[1].adslotId");
System.out.println(fullMatch);
int times = 100000000;
long time1 = 0, time2 = 0;
time1 = System.currentTimeMillis();
for (int i = 0; i < times; i++) {
matcher.match("subUserInfos[1]");
matcher.needMoreParse("subUserInfos[1]");
}
time2 = System.currentTimeMillis();
System.out.println("use time" + (time2 - time1));
}
}
|
UTF-8
|
Java
| 3,585 |
java
|
NeedParsePathMatcher.java
|
Java
|
[
{
"context": "/**\n * \n * @say little Boy, don't be sad.\n * @name Rezar\n * @time 2017年10月28日\n * @Desc this guy is to lazy",
"end": 334,
"score": 0.9513471722602844,
"start": 329,
"tag": "USERNAME",
"value": "Rezar"
}
] | null |
[] |
package com.extensions.logmonitor.jsonContentParseies.jsonContentAnalyzer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;
/**
*
* @say little Boy, don't be sad.
* @name Rezar
* @time 2017年10月28日
* @Desc this guy is to lazy , noting left.
*
*/
public class NeedParsePathMatcher {
private Map<String, Boolean> matchResult = new HashMap<>();
private Map<String, Boolean> fullMatchResult = new HashMap<>();
private String path;
private List<String> partOfPaths = new ArrayList<>();
private String doMoreParsePath;
private String regexPattern;
private Pattern fullMatchPattern;
public NeedParsePathMatcher(String path) {
this.path = path;
this.doMoreParsePath = processDoMorePath(path);
this.partOfPaths = processPartOfPaths(this.doMoreParsePath);
this.regexPattern = this.fullProcessPath(path);
this.fullMatchPattern = Pattern.compile(regexPattern);
}
/**
* @param doMoreParsePath2
* @return
*/
private List<String> processPartOfPaths(String doMoreParsePath) {
return Arrays.asList(doMoreParsePath.split("\\."));
}
/**
* @param path2
* @return
*/
private String processDoMorePath(String path) {
return path.replaceAll("\\[(\\*|\\d+|#)\\]", ".$1");
}
/**
* @param path
* @return
*
*/
private String fullProcessPath(String path) {
path = "^" + path;
path = path.replaceAll("\\[", "\\\\[");
path = path.replaceAll("\\]", "\\\\]");
path = path.replaceAll("\\.", "\\\\.");
path = path.replaceAll("\\*", "(\\\\d+|.*)");
return path;
}
public boolean fullMatch(String path) {
boolean result = false;
if (this.fullMatchResult.containsKey(path)) {
result = this.fullMatchResult.get(path);
} else {
result = fullMatchPattern.matcher(path).matches();
this.fullMatchResult.put(path, result);
}
return result;
}
public boolean match(String path) {
boolean isMatchPrefix = true;
if (this.matchResult.containsKey(path)) {
isMatchPrefix = this.matchResult.get(path);
} else {
List<String> processPartOfPaths = this.processPartOfPaths(this.processDoMorePath(path));
int index = 0;
for (;index < processPartOfPaths.size() && index < this.partOfPaths.size() ;index ++) {
String partOfPath = processPartOfPaths.get(index);
if (!(partOfPath.equals(this.partOfPaths.get(index))
|| (StringUtils.isNumeric(partOfPath) && this.partOfPaths.get(index).equals("*")))) {
isMatchPrefix = false;
}
}
this.matchResult.put(path, isMatchPrefix);
}
return isMatchPrefix;
}
public boolean needMoreParse(String path) {
return this.doMoreParsePath.length() > path.length();
}
@Override
public String toString() {
return "NeedParsePathMatcher [path=" + path + ", doMoreParsePath=" + doMoreParsePath + ", regexPattern="
+ regexPattern + "]";
}
public static void main(String[] args) {
NeedParsePathMatcher matcher = new NeedParsePathMatcher("subUserInfos[1].adslotId");
System.out.println(matcher);
boolean match = matcher.match("subUserInfos[1]");
System.out.println(match);
boolean fullMatch = matcher.fullMatch("subUserInfos[1].adslotId");
System.out.println(fullMatch);
int times = 100000000;
long time1 = 0, time2 = 0;
time1 = System.currentTimeMillis();
for (int i = 0; i < times; i++) {
matcher.match("subUserInfos[1]");
matcher.needMoreParse("subUserInfos[1]");
}
time2 = System.currentTimeMillis();
System.out.println("use time" + (time2 - time1));
}
}
| 3,585 | 0.689857 | 0.680078 | 126 | 27.404762 | 24.093792 | 106 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.015873 | false | false |
13
|
8d1f7645c532848549ed76b8bc0e7f3b4d43e282
| 34,213,709,498,176 |
e44f8ec951faf40c6a9fb38d7799b02c4f32a975
|
/tests/test/ToDoListTest.java
|
4304e43a3eca28bfcdf952a56d816c5757565e41
|
[] |
no_license
|
DebSreerekha/TODOManagementSystem
|
https://github.com/DebSreerekha/TODOManagementSystem
|
0709752f7d80d71b4879bf7f1d1673b2b95b8e18
|
8fa02b86862e46fb5c3f13487cf6552959e2ab04
|
refs/heads/master
| 2020-06-05T20:08:02.305000 | 2015-09-15T07:32:46 | 2015-09-15T07:32:46 | 37,716,022 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package test;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import domain.Constants;
import domain.ListItem;
import domain.ToDoList;
/**
* This class contains the unit test cases for testing the TODOList component
* @author sreerekhadeb
*
*/
public class ToDoListTest {
@Test
public void checkListAddition() {
//create a list
ToDoList tdl = new ToDoList(Constants.PERSONAL);
//add items to the list
tdl.addListItem("Key1", "Value1");
tdl.addListItem("Key2", "Value2");
// test if the item is added
int size = tdl.getItems().size();
assertEquals(2,size);
}
@Test
public void checkListItemExtraction() {
//create a list
ToDoList tdl = new ToDoList(Constants.PERSONAL);
//add items to the list
tdl.addListItem("Key1", "Value1");
tdl.addListItem("Key2", "Value2");
String Value1 = (String)((ListItem)tdl.getListItem("Key1")).getItemDescription();
String Value2 = (String)((ListItem)tdl.getListItem("Key2")).getItemDescription();
assertEquals("Value1",Value1);
assertEquals("Value2",Value2);
}
@Test
public void checkListItemDeletion() {
//create a list
ToDoList tdl = new ToDoList(Constants.PERSONAL);
//add items to the list
tdl.addListItem("Key1", "Value1");
tdl.addListItem("Key2", "Value2");
//delete an item from the list
tdl.deleteItem("Key1");
ListItem Value1 = ((ListItem)tdl.getListItem("Key1"));
assertEquals(null,Value1) ;
}
@Test
public void checkListItemUpdation() {
//create a list
ToDoList tdl = new ToDoList(Constants.PERSONAL);
//add items to the list
tdl.addListItem("Key1", "Value1");
tdl.addListItem("Key2", "Value2");
//delete an item from the list
tdl.updateListItem("Key1","Value11");
String Value11 = (String)((ListItem)tdl.getListItem("Key1")).getItemDescription();
assertEquals("Value11",Value11) ;
}
}
|
UTF-8
|
Java
| 1,901 |
java
|
ToDoListTest.java
|
Java
|
[
{
"context": "ases for testing the TODOList component\n * @author sreerekhadeb\n *\n */\npublic class ToDoListTest {\n\t\n\t@Test\n\tpubl",
"end": 264,
"score": 0.9995753765106201,
"start": 252,
"tag": "USERNAME",
"value": "sreerekhadeb"
}
] | null |
[] |
package test;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import domain.Constants;
import domain.ListItem;
import domain.ToDoList;
/**
* This class contains the unit test cases for testing the TODOList component
* @author sreerekhadeb
*
*/
public class ToDoListTest {
@Test
public void checkListAddition() {
//create a list
ToDoList tdl = new ToDoList(Constants.PERSONAL);
//add items to the list
tdl.addListItem("Key1", "Value1");
tdl.addListItem("Key2", "Value2");
// test if the item is added
int size = tdl.getItems().size();
assertEquals(2,size);
}
@Test
public void checkListItemExtraction() {
//create a list
ToDoList tdl = new ToDoList(Constants.PERSONAL);
//add items to the list
tdl.addListItem("Key1", "Value1");
tdl.addListItem("Key2", "Value2");
String Value1 = (String)((ListItem)tdl.getListItem("Key1")).getItemDescription();
String Value2 = (String)((ListItem)tdl.getListItem("Key2")).getItemDescription();
assertEquals("Value1",Value1);
assertEquals("Value2",Value2);
}
@Test
public void checkListItemDeletion() {
//create a list
ToDoList tdl = new ToDoList(Constants.PERSONAL);
//add items to the list
tdl.addListItem("Key1", "Value1");
tdl.addListItem("Key2", "Value2");
//delete an item from the list
tdl.deleteItem("Key1");
ListItem Value1 = ((ListItem)tdl.getListItem("Key1"));
assertEquals(null,Value1) ;
}
@Test
public void checkListItemUpdation() {
//create a list
ToDoList tdl = new ToDoList(Constants.PERSONAL);
//add items to the list
tdl.addListItem("Key1", "Value1");
tdl.addListItem("Key2", "Value2");
//delete an item from the list
tdl.updateListItem("Key1","Value11");
String Value11 = (String)((ListItem)tdl.getListItem("Key1")).getItemDescription();
assertEquals("Value11",Value11) ;
}
}
| 1,901 | 0.685429 | 0.664913 | 86 | 21.10465 | 21.065804 | 84 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.906977 | false | false |
13
|
b15750c3c41fdd62b4b10301d7da01e5c70ac1df
| 5,257,040,032,714 |
2068cdfccc659a110e05238b3eec5659dc969c44
|
/.svn/pristine/b1/b15750c3c41fdd62b4b10301d7da01e5c70ac1df.svn-base
|
3fda5dd656dd9543ba89dac7a599659d72e19423
|
[] |
no_license
|
denny2014/EmptyActivity
|
https://github.com/denny2014/EmptyActivity
|
621ff5d3169bbcea9c5672dfd05854c1315e598f
|
e6e7ad3b49d0ba6dd874f0047710962fd1e771e9
|
refs/heads/master
| 2016-08-11T11:59:18.279000 | 2015-12-17T07:40:05 | 2015-12-17T07:40:05 | 48,159,253 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.zet.asyncHandler;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.Header;
import org.json.JSONException;
import org.json.JSONObject;
import com.bdkj.bdlibrary.utils.IMap;
import com.bdkj.bdlibrary.utils.JSONUtils;
import com.lidroid.xutils.utils.LogUtils;
import com.zet.Constants;
import com.zet.model.NewsInBrief;
import com.zet.net.BaseHandler;
public class NewsInBriefHandler extends BaseHandler{
@Override
public void onSuccess(int arg0, Header[] arg1, JSONObject jsonObject) {
// TODO Auto-generated method stub
super.onSuccess(arg0, arg1, jsonObject);
boolean success = false;
int resultCode = -1;
List<NewsInBrief> list = null;
String msg = "";
IMap map = null;
try {
map = JSONUtils.fromJson(jsonObject);
resultCode = map.getInt(Constants.RESULT_KEY);
LogUtils.e("resultCode : "+resultCode);
success = (resultCode == Constants.SUCCESS_CODE);
if (!success) {
msg = map.getString("msg");
} else {
if (map.containsKey("data") && map.get("data") instanceof List) {
list = new ArrayList<NewsInBrief>();
ArrayList<IMap> datas = (ArrayList<IMap>) map.get("data");
for (IMap single : datas) {
NewsInBrief mNewsInBrief = new NewsInBrief();
LogUtils.e("single : "+single.toString());
mNewsInBrief.build(single);
list.add(mNewsInBrief);
}
LogUtils.e("list.tostring :"+ list.toString());
}
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (success && list != null) {
success(resultCode, list);
} else {
dataErrorMsg(resultCode, msg);
}
}
}
|
UTF-8
|
Java
| 2,080 |
b15750c3c41fdd62b4b10301d7da01e5c70ac1df.svn-base
|
Java
|
[] | null |
[] |
package com.zet.asyncHandler;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.Header;
import org.json.JSONException;
import org.json.JSONObject;
import com.bdkj.bdlibrary.utils.IMap;
import com.bdkj.bdlibrary.utils.JSONUtils;
import com.lidroid.xutils.utils.LogUtils;
import com.zet.Constants;
import com.zet.model.NewsInBrief;
import com.zet.net.BaseHandler;
public class NewsInBriefHandler extends BaseHandler{
@Override
public void onSuccess(int arg0, Header[] arg1, JSONObject jsonObject) {
// TODO Auto-generated method stub
super.onSuccess(arg0, arg1, jsonObject);
boolean success = false;
int resultCode = -1;
List<NewsInBrief> list = null;
String msg = "";
IMap map = null;
try {
map = JSONUtils.fromJson(jsonObject);
resultCode = map.getInt(Constants.RESULT_KEY);
LogUtils.e("resultCode : "+resultCode);
success = (resultCode == Constants.SUCCESS_CODE);
if (!success) {
msg = map.getString("msg");
} else {
if (map.containsKey("data") && map.get("data") instanceof List) {
list = new ArrayList<NewsInBrief>();
ArrayList<IMap> datas = (ArrayList<IMap>) map.get("data");
for (IMap single : datas) {
NewsInBrief mNewsInBrief = new NewsInBrief();
LogUtils.e("single : "+single.toString());
mNewsInBrief.build(single);
list.add(mNewsInBrief);
}
LogUtils.e("list.tostring :"+ list.toString());
}
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (success && list != null) {
success(resultCode, list);
} else {
dataErrorMsg(resultCode, msg);
}
}
}
| 2,080 | 0.543269 | 0.540865 | 58 | 33.862068 | 20.615067 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.431034 | false | false |
13
|
|
58ffae1c1e2289c46182bfe1ea2e71f07bff1531
| 13,855,564,557,259 |
e30d8aa258401abb0ee7c110870f2da9c6747415
|
/frame/src/main/java/me/jerry/framework/utils/StringUtils.java
|
675892b4209695ccb54d225ab7dd95bdf7756890
|
[] |
no_license
|
Jerry-Geng/Framework
|
https://github.com/Jerry-Geng/Framework
|
3d590217358384f54dc35e0848b497c790ed7392
|
c97f9051ea87b152571098ba446bfdfd874a88e8
|
refs/heads/master
| 2018-11-09T19:58:16.703000 | 2018-08-21T08:13:38 | 2018-08-21T08:13:38 | 117,057,769 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package me.jerry.framework.utils;
/**
* 字符串处理相关工具类
* @author JerryGeng
*
*/
public class StringUtils {
/**
* 驼峰式命名转下划线式命名
* @param value
* @return
*/
public static String upTo_(String value){
String result = "";
for(int i = 0; i < value.length(); i ++) {
char ch = value.charAt(i);
if(ch <= 'Z' && ch >= 'A') {
if(i != 0) {
value = new StringBuilder(value).insert(i, "_").toString();
}
i ++;
}
}
result = value.toLowerCase();
return result;
}
/**
* 下划线式 命名转驼峰式命名
* @param value
* @param firstUp 是否需要首字符大写
* @return
*/
public static String _ToUp(String value, boolean firstUp) {
String[] ss = value.split("_");
String result = "";
boolean first = true;
for(String s : ss) {
if(first && !firstUp) {
result = s;
first = false;
} else {
result = result + s.substring(0, 1).toUpperCase() + s.substring(1);
}
}
return result;
}
}
|
UTF-8
|
Java
| 1,244 |
java
|
StringUtils.java
|
Java
|
[
{
"context": "erry.framework.utils;\r/**\r * 字符串处理相关工具类\r * @author JerryGeng\r *\r */\rpublic class StringUtils {\r\t/**\r\t * 驼峰式命名转",
"end": 72,
"score": 0.9994708299636841,
"start": 63,
"tag": "NAME",
"value": "JerryGeng"
}
] | null |
[] |
package me.jerry.framework.utils;
/**
* 字符串处理相关工具类
* @author JerryGeng
*
*/
public class StringUtils {
/**
* 驼峰式命名转下划线式命名
* @param value
* @return
*/
public static String upTo_(String value){
String result = "";
for(int i = 0; i < value.length(); i ++) {
char ch = value.charAt(i);
if(ch <= 'Z' && ch >= 'A') {
if(i != 0) {
value = new StringBuilder(value).insert(i, "_").toString();
}
i ++;
}
}
result = value.toLowerCase();
return result;
}
/**
* 下划线式 命名转驼峰式命名
* @param value
* @param firstUp 是否需要首字符大写
* @return
*/
public static String _ToUp(String value, boolean firstUp) {
String[] ss = value.split("_");
String result = "";
boolean first = true;
for(String s : ss) {
if(first && !firstUp) {
result = s;
first = false;
} else {
result = result + s.substring(0, 1).toUpperCase() + s.substring(1);
}
}
return result;
}
}
| 1,244 | 0.450777 | 0.446459 | 47 | 23.638298 | 18.27849 | 83 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.510638 | false | false |
13
|
8b02d578944b790c31135243026781170dc60492
| 13,855,564,558,192 |
8b47f5da7c6c43b23da11ba8a4446f3fbdcaa757
|
/imageprocessing/src/com/nk/imageprocessing/Constants.java
|
512a4faccfeecf768734526745e3a059c7ab07ff
|
[] |
no_license
|
numankaraaslan/ImageProcessing
|
https://github.com/numankaraaslan/ImageProcessing
|
a375eaf238924583183f1859b0d06a1c0fe7fef4
|
48cab36807d7f1861da5eef543b6b0e1963bc1b3
|
refs/heads/master
| 2021-05-24T03:55:11.085000 | 2021-03-11T17:55:16 | 2021-03-11T17:55:16 | 59,912,565 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.nk.imageprocessing;
import java.util.Properties;
import javafx.scene.text.Font;
public class Constants
{
public static Properties props;
public static Font default_font;
}
|
UTF-8
|
Java
| 189 |
java
|
Constants.java
|
Java
|
[] | null |
[] |
package com.nk.imageprocessing;
import java.util.Properties;
import javafx.scene.text.Font;
public class Constants
{
public static Properties props;
public static Font default_font;
}
| 189 | 0.793651 | 0.793651 | 11 | 16.181818 | 14.65865 | 33 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.636364 | false | false |
13
|
0b787c1ff72442370efe17a57104b9fc96df0f31
| 10,445,360,497,077 |
9ac2ab2d2a0a3fdfbeb5d643cf8c810b8a4424aa
|
/src/functionalinterface/FuntionalInterface2.java
|
9f59c080269c589cb9fd9aa16b901fec07baf704
|
[] |
no_license
|
jeraldmuthu/functional-programming-with-java
|
https://github.com/jeraldmuthu/functional-programming-with-java
|
818012143762d236fa1d712db0defb4b2082f165
|
82d4d9d7a7eaca150d2a12743d65f41cc4704571
|
refs/heads/master
| 2022-12-24T16:31:22.140000 | 2020-09-28T06:19:43 | 2020-09-28T06:19:43 | 286,643,105 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package functionalinterface;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.BiPredicate;
import java.util.function.Supplier;
import java.util.function.UnaryOperator;
/**
* Functional Interface :
* Supplier,
* UnaryOperatory,
* BiPredicate,
* BiFunction,
* BiConsumer
* @author jemuthu
*
*/
public class FuntionalInterface2 {
public static void main(String[] args) {
//Supplier Interface wont accept any input it only return output. Eg : Factory pattern
System.out.println("Supplier interface");
Supplier<Integer> supplier = () ->2;
System.out.println(supplier.get());
System.out.println("UnaryOperator interface");
//UnaryOperatory takes single input and return the output
UnaryOperator<Integer> unaryOperatory = x -> x * 10;
System.out.println(unaryOperatory.apply(3));
System.out.println("BiPredicate interface");
//BiPrdicate will accept tow argument
BiPredicate<Integer, String> biPredicate = (num, str) -> {
return num < 10 && str.length() > 4;
};
System.out.println(biPredicate.test(5, "Layahis Queen"));
System.out.println("BiFuntion interface");
//BiFuntion will accept three parameter (First parameter Input Type, Second parameter input Type,
// thrid parameter output type)
BiFunction<Integer, String, String> biFunction = (num, str) -> {
return num + " " + str;
};
System.out.println(biFunction.apply(29, "Layahis Queen"));
System.out.println("BiConsumer interface");
//BiConsumer will accept two parameter (two input Type)
BiConsumer<Integer, String> consumer = (i , str) -> {
System.out.println(i);
System.out.println(str);
};
consumer.accept(1, "Layah Jerald");
}
}
|
UTF-8
|
Java
| 1,736 |
java
|
FuntionalInterface2.java
|
Java
|
[
{
"context": "redicate,\n * BiFunction, \n * BiConsumer\n * @author jemuthu\n *\n */\npublic class FuntionalInterface2 {\n\n\tpubli",
"end": 349,
"score": 0.9973709583282471,
"start": 342,
"tag": "USERNAME",
"value": "jemuthu"
}
] | null |
[] |
package functionalinterface;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.BiPredicate;
import java.util.function.Supplier;
import java.util.function.UnaryOperator;
/**
* Functional Interface :
* Supplier,
* UnaryOperatory,
* BiPredicate,
* BiFunction,
* BiConsumer
* @author jemuthu
*
*/
public class FuntionalInterface2 {
public static void main(String[] args) {
//Supplier Interface wont accept any input it only return output. Eg : Factory pattern
System.out.println("Supplier interface");
Supplier<Integer> supplier = () ->2;
System.out.println(supplier.get());
System.out.println("UnaryOperator interface");
//UnaryOperatory takes single input and return the output
UnaryOperator<Integer> unaryOperatory = x -> x * 10;
System.out.println(unaryOperatory.apply(3));
System.out.println("BiPredicate interface");
//BiPrdicate will accept tow argument
BiPredicate<Integer, String> biPredicate = (num, str) -> {
return num < 10 && str.length() > 4;
};
System.out.println(biPredicate.test(5, "Layahis Queen"));
System.out.println("BiFuntion interface");
//BiFuntion will accept three parameter (First parameter Input Type, Second parameter input Type,
// thrid parameter output type)
BiFunction<Integer, String, String> biFunction = (num, str) -> {
return num + " " + str;
};
System.out.println(biFunction.apply(29, "Layahis Queen"));
System.out.println("BiConsumer interface");
//BiConsumer will accept two parameter (two input Type)
BiConsumer<Integer, String> consumer = (i , str) -> {
System.out.println(i);
System.out.println(str);
};
consumer.accept(1, "Layah Jerald");
}
}
| 1,736 | 0.711406 | 0.704493 | 57 | 29.456141 | 23.695488 | 99 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.157895 | false | false |
13
|
8e71412179e8e4f0512c69c04ddd1a6d4a5d42d9
| 13,194,139,535,953 |
8065d0b77c33daf8f73fc92339c50ec777a3fbd3
|
/src/main/java/com/ozymern/spring/user/manager/util/Encrypt.java
|
3613844c9f2d02d291dc173e8b55c229db474f1c
|
[] |
no_license
|
Ozymern/spring-user-manager
|
https://github.com/Ozymern/spring-user-manager
|
3f3aa82188540b567be74688474e7ce4fa42e356
|
e9e061f8ab5f1da3931ae7e28605237eee1fc98f
|
refs/heads/master
| 2020-04-21T17:59:40.083000 | 2019-02-08T15:16:11 | 2019-02-08T15:16:11 | 169,753,481 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.ozymern.spring.user.manager.util;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.Random;
import org.springframework.stereotype.Component;
import com.google.common.hash.Hashing;
@Component
public class Encrypt {
public String getEncrypt(String base) {
Instant instant = Instant.now();
long timeStampMillis = instant.toEpochMilli();
Random aleatorio = new Random(timeStampMillis);
String originalString = base + timeStampMillis + aleatorio.nextLong();
String sha256hex = Hashing.sha256()
.hashString(originalString, StandardCharsets.UTF_8)
.toString();
sha256hex = sha256hex.substring(0, 32);
return sha256hex;
}
}
|
UTF-8
|
Java
| 773 |
java
|
Encrypt.java
|
Java
|
[] | null |
[] |
package com.ozymern.spring.user.manager.util;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.Random;
import org.springframework.stereotype.Component;
import com.google.common.hash.Hashing;
@Component
public class Encrypt {
public String getEncrypt(String base) {
Instant instant = Instant.now();
long timeStampMillis = instant.toEpochMilli();
Random aleatorio = new Random(timeStampMillis);
String originalString = base + timeStampMillis + aleatorio.nextLong();
String sha256hex = Hashing.sha256()
.hashString(originalString, StandardCharsets.UTF_8)
.toString();
sha256hex = sha256hex.substring(0, 32);
return sha256hex;
}
}
| 773 | 0.686934 | 0.662354 | 34 | 21.735294 | 23.409788 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.441176 | false | false |
13
|
a53d242a221325cc3bc051f6626947469967cf97
| 764,504,224,223 |
9c084a027905b53afa0ff48faf73b3950555052c
|
/src/main/java/Main.java
|
e0d04119d3e89bcb80bc43480f0415cb453d5e57
|
[] |
no_license
|
fjddhd/gdut_hw_elite
|
https://github.com/fjddhd/gdut_hw_elite
|
7e91413bcc0926c00082eb3ad40224f9af642eaf
|
2cfdb7fd7f4a759b78a8f879e5983c3570bc7e60
|
refs/heads/master
| 2023-03-24T19:38:54.704000 | 2021-03-13T11:49:39 | 2021-03-13T11:49:39 | 346,979,071 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
public class Main extends OurAlgorithm {
public static void main(String[] args) {
// initial_standard1();
initial();
purchaseServer();
computeAssignment();
// initial_standard();
// System.err.println("ok");
// compute();
}
}
|
UTF-8
|
Java
| 294 |
java
|
Main.java
|
Java
|
[] | null |
[] |
public class Main extends OurAlgorithm {
public static void main(String[] args) {
// initial_standard1();
initial();
purchaseServer();
computeAssignment();
// initial_standard();
// System.err.println("ok");
// compute();
}
}
| 294 | 0.537415 | 0.534014 | 11 | 25.727272 | 13.225945 | 44 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.636364 | false | false |
13
|
0ccc18adbaa0454cf06ac74297bb93446c353e65
| 14,645,838,512,628 |
aa60d948941a8cc869887838dd50d1ceaf31ebb1
|
/src/main/java/com/insure/tech/api/policies/repository/PolicyRepository.java
|
1c1e97bb04345b9d04193fb4a6d56b90cdb3e95f
|
[] |
no_license
|
bhupender1080/Insure-tech-service
|
https://github.com/bhupender1080/Insure-tech-service
|
0e67c9c0bc7941ff6a391e178e93c592cc073ea6
|
05071598d53b98327d90b08d313b61142cba665e
|
refs/heads/master
| 2022-04-23T07:04:49.352000 | 2020-03-30T10:27:03 | 2020-03-30T10:27:03 | 249,953,362 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.insure.tech.api.policies.repository;
import java.util.List;
import java.util.UUID;
import org.springframework.data.jpa.repository.JpaRepository;
import com.insure.tech.api.policies.entity.Policy;
public interface PolicyRepository extends JpaRepository<Policy, UUID>{
List<Policy> findAllByCustomerId (UUID customerId);
}
|
UTF-8
|
Java
| 343 |
java
|
PolicyRepository.java
|
Java
|
[] | null |
[] |
package com.insure.tech.api.policies.repository;
import java.util.List;
import java.util.UUID;
import org.springframework.data.jpa.repository.JpaRepository;
import com.insure.tech.api.policies.entity.Policy;
public interface PolicyRepository extends JpaRepository<Policy, UUID>{
List<Policy> findAllByCustomerId (UUID customerId);
}
| 343 | 0.80758 | 0.80758 | 16 | 20.4375 | 25.514626 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5625 | false | false |
13
|
ca5307c5cad34b683872ae69c049bbdeba281243
| 25,993,142,138,351 |
d7856ddd748146048c81337b6c5e70c81c2c6a08
|
/src/lesson3/MainApp.java
|
b6089db22cf40f184f0b49011ae7ff520965d893
|
[] |
no_license
|
antonageev/AlgorithmsJava
|
https://github.com/antonageev/AlgorithmsJava
|
e6c842c2c22a65e254a1a5698548c280ff844367
|
09a29d850b53da45896de08725b2bb6a12c5a075
|
refs/heads/master
| 2021-05-23T12:15:19.070000 | 2020-04-25T08:40:22 | 2020-04-25T08:40:22 | 253,281,665 | 0 | 0 | null | false | 2020-04-25T08:40:40 | 2020-04-05T16:36:57 | 2020-04-25T08:40:26 | 2020-04-25T08:40:23 | 28 | 0 | 0 | 1 |
Java
| false | false |
package lesson3;
public class MainApp {
public static void main(String[] args) {
//стэк
MyStack<Integer> myStack = new MyStack<>(7);
myStack.push(1);
myStack.push(2);
myStack.push(3);
myStack.push(4);
myStack.push(5);
myStack.push(6);
myStack.push(7);
for (int i = 0; i < 7; i++) {
System.out.println(myStack.pop());
}
System.out.println(myStack.isEmpty());
//очередь
MyQueue<Integer> queue = new MyQueue<>();
queue.insert(1);
queue.insert(2);
queue.insert(3);
queue.insert(4);
queue.insert(5);
queue.insert(6);
queue.remove();
queue.remove();
queue.remove();
queue.insert(1);
queue.insert(2);
queue.insert(3);
int temp = queue.size();
for (int i = 0; i < temp; i++) {
System.out.println(queue.remove());
}
//сортированная очередь
MySortedQueue<Integer> msq = new MySortedQueue<>(15);
msq.insert(4);
msq.insert(10);
msq.insert(5);
msq.insert(12);
msq.insert(41);
msq.insert(1);
System.out.println(msq.toString());
msq.remove();
System.out.println(msq.toString());
//читинг с переворотом строки
StringBuilder stringBuilder = new StringBuilder("reverseString");
System.out.println(stringBuilder.reverse());
//свой метод переворота строки
System.out.println(reverseOrder("OneMoreReverseString"));
// дека
MyDeque<Integer> deque = new MyDeque<>();
deque.insertFront(3);
deque.insertFront(2);
deque.insertFront(1);
deque.insertEnd(4);
deque.insertEnd(5);
deque.myToString();
System.out.println();
deque.removeFront();
deque.removeEnd();
deque.removeEnd();
deque.myToString();
}
public static String reverseOrder(String string){
StringBuilder sb = new StringBuilder();
for (int i = string.length()-1; i >=0 ; i--) {
sb.append(string.charAt(i));
}
return sb.toString();
}
}
|
UTF-8
|
Java
| 2,315 |
java
|
MainApp.java
|
Java
|
[] | null |
[] |
package lesson3;
public class MainApp {
public static void main(String[] args) {
//стэк
MyStack<Integer> myStack = new MyStack<>(7);
myStack.push(1);
myStack.push(2);
myStack.push(3);
myStack.push(4);
myStack.push(5);
myStack.push(6);
myStack.push(7);
for (int i = 0; i < 7; i++) {
System.out.println(myStack.pop());
}
System.out.println(myStack.isEmpty());
//очередь
MyQueue<Integer> queue = new MyQueue<>();
queue.insert(1);
queue.insert(2);
queue.insert(3);
queue.insert(4);
queue.insert(5);
queue.insert(6);
queue.remove();
queue.remove();
queue.remove();
queue.insert(1);
queue.insert(2);
queue.insert(3);
int temp = queue.size();
for (int i = 0; i < temp; i++) {
System.out.println(queue.remove());
}
//сортированная очередь
MySortedQueue<Integer> msq = new MySortedQueue<>(15);
msq.insert(4);
msq.insert(10);
msq.insert(5);
msq.insert(12);
msq.insert(41);
msq.insert(1);
System.out.println(msq.toString());
msq.remove();
System.out.println(msq.toString());
//читинг с переворотом строки
StringBuilder stringBuilder = new StringBuilder("reverseString");
System.out.println(stringBuilder.reverse());
//свой метод переворота строки
System.out.println(reverseOrder("OneMoreReverseString"));
// дека
MyDeque<Integer> deque = new MyDeque<>();
deque.insertFront(3);
deque.insertFront(2);
deque.insertFront(1);
deque.insertEnd(4);
deque.insertEnd(5);
deque.myToString();
System.out.println();
deque.removeFront();
deque.removeEnd();
deque.removeEnd();
deque.myToString();
}
public static String reverseOrder(String string){
StringBuilder sb = new StringBuilder();
for (int i = string.length()-1; i >=0 ; i--) {
sb.append(string.charAt(i));
}
return sb.toString();
}
}
| 2,315 | 0.535634 | 0.518153 | 88 | 24.352272 | 17.174929 | 73 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.681818 | false | false |
13
|
1273dbb2bb577cd39830496f3af0a539a42ff87c
| 15,522,011,833,527 |
01c30bc3f2525b8978f24ad635af5ac72a446a3b
|
/shoppinglist/shoppinglist-ms/shoppinglist-resource/src/main/java/org/awesley/digital/shoppinglist/resources/configuration/ResourcesConfiguration.java
|
58bde3dcfef8eb79ec6468fda84cc81a7b5d5502
|
[] |
no_license
|
AdarWesley/ms
|
https://github.com/AdarWesley/ms
|
d55fcc5050069342aa3c4a78e6768458f02fb87c
|
2b8f00141ed7bce931f8ea179158dd9ab39b9f40
|
refs/heads/master
| 2021-06-09T02:17:34.868000 | 2021-06-06T23:39:04 | 2021-06-06T23:39:04 | 140,976,641 | 0 | 0 | null | false | 2021-06-06T23:39:05 | 2018-07-14T20:41:14 | 2021-06-06T23:38:48 | 2021-06-06T23:39:04 | 270 | 0 | 0 | 0 |
Java
| false | false |
package org.awesley.digital.shoppinglist.resources.configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.awesley.digital.shoppinglist.resources.implementation.ListItemResourceToModelMapper;
import org.awesley.digital.shoppinglist.resources.implementation.ShoppingListResourceFromModelMapper;
import org.awesley.digital.shoppinglist.resources.implementation.ShoppingListResourceToModelMapper;
import org.awesley.digital.shoppinglist.resources.implementation.delegate.ShoppingListApiImpl;
import org.awesley.digital.shoppinglist.resources.interfaces.IResourceFromModelMapper;
import org.awesley.digital.shoppinglist.resources.interfaces.IResourceToModelMapper;
import org.awesley.digital.shoppinglist.resources.interfaces.ShoppingListApi;
import org.awesley.digital.shoppinglist.resources.models.ListItem;
import org.awesley.digital.shoppinglist.resources.models.ShoppingList;
@Configuration
public class ResourcesConfiguration {
@Bean
public ShoppingListApi shoppingListApi(){
return new ShoppingListApiImpl();
}
@Bean
public IResourceFromModelMapper<ShoppingList, org.awesley.digital.shoppinglist.service.model.ShoppingList>
shoppingListResourceFromModelMapper(){
return new ShoppingListResourceFromModelMapper();
}
@Bean
public IResourceToModelMapper<ShoppingList, org.awesley.digital.shoppinglist.service.model.ShoppingList>
shoppingListResourceToModelMapper(){
return new ShoppingListResourceToModelMapper();
}
@Bean
public IResourceToModelMapper<ListItem, org.awesley.digital.shoppinglist.service.model.ListItem>
listItemResourceToModelMapper() {
return new ListItemResourceToModelMapper();
}
}
|
UTF-8
|
Java
| 1,758 |
java
|
ResourcesConfiguration.java
|
Java
|
[] | null |
[] |
package org.awesley.digital.shoppinglist.resources.configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.awesley.digital.shoppinglist.resources.implementation.ListItemResourceToModelMapper;
import org.awesley.digital.shoppinglist.resources.implementation.ShoppingListResourceFromModelMapper;
import org.awesley.digital.shoppinglist.resources.implementation.ShoppingListResourceToModelMapper;
import org.awesley.digital.shoppinglist.resources.implementation.delegate.ShoppingListApiImpl;
import org.awesley.digital.shoppinglist.resources.interfaces.IResourceFromModelMapper;
import org.awesley.digital.shoppinglist.resources.interfaces.IResourceToModelMapper;
import org.awesley.digital.shoppinglist.resources.interfaces.ShoppingListApi;
import org.awesley.digital.shoppinglist.resources.models.ListItem;
import org.awesley.digital.shoppinglist.resources.models.ShoppingList;
@Configuration
public class ResourcesConfiguration {
@Bean
public ShoppingListApi shoppingListApi(){
return new ShoppingListApiImpl();
}
@Bean
public IResourceFromModelMapper<ShoppingList, org.awesley.digital.shoppinglist.service.model.ShoppingList>
shoppingListResourceFromModelMapper(){
return new ShoppingListResourceFromModelMapper();
}
@Bean
public IResourceToModelMapper<ShoppingList, org.awesley.digital.shoppinglist.service.model.ShoppingList>
shoppingListResourceToModelMapper(){
return new ShoppingListResourceToModelMapper();
}
@Bean
public IResourceToModelMapper<ListItem, org.awesley.digital.shoppinglist.service.model.ListItem>
listItemResourceToModelMapper() {
return new ListItemResourceToModelMapper();
}
}
| 1,758 | 0.83959 | 0.83959 | 40 | 41.950001 | 37.288704 | 108 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.125 | false | false |
13
|
fdca200f8abaf2bd8428aa762f4531342bf77c01
| 8,993,661,531,021 |
8f0c6757bb914222b549849b882f13609038c7b2
|
/runtime-parent/runtime-compute/src/main/java/com/speedment/runtime/compute/expression/NonNullableExpression.java
|
72f97d6a5850160413cb61fa0492d8cf0ff3948b
|
[
"Apache-2.0",
"LicenseRef-scancode-generic-cla",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
speedment/speedment
|
https://github.com/speedment/speedment
|
6419a884c8800abd95bc2c9010bc9d7868ac3274
|
c83df6444effcda731df8c7ba9fd1e900b54cdb3
|
refs/heads/master
| 2023-09-01T01:33:46.355000 | 2023-08-10T07:54:09 | 2023-08-10T07:54:09 | 29,480,568 | 2,300 | 312 |
Apache-2.0
| false | 2023-09-14T17:37:18 | 2015-01-19T16:41:52 | 2023-09-05T13:59:38 | 2023-09-14T17:37:17 | 26,487 | 2,071 | 233 | 84 |
Java
| false | false |
/*
*
* Copyright (c) 2006-2020, Speedment, Inc. All Rights Reserved.
*
* 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.speedment.runtime.compute.expression;
import com.speedment.runtime.compute.expression.orelse.OrElseGetExpression;
import com.speedment.runtime.compute.expression.orelse.OrElseThrowExpression;
/**
* Specialized {@link Expression} that is not nullable, but that wraps an
* expression that is and that has some routine for dealing with {@code null}
* values determined by {@link #nullStrategy()}.
* <p>
* Equality is determined by looking at {@link #innerNullable()} and
* {@link #nullStrategy()}, and additionally by the
* {@link OrElseGetExpression#defaultValueGetter()} or the
* {@code getDefaultValue()} if the strategy is
* {@link NullStrategy#APPLY_DEFAULT_METHOD} or
* {@link NullStrategy#USE_DEFAULT_VALUE} respectively.
*
* @param <T> the input entity type
* @param <INNER> the type of the inner expression
*
* @author Emil Forslund
* @since 3.1.0
*/
public interface NonNullableExpression<T, INNER extends Expression<T>>
extends Expression<T> {
/**
* Returns the inner nullable expression.
*
* @return the inner nullable expression
*/
INNER innerNullable();
/**
* Returns the strategy used by this expression to deal with the case when
* {@link #innerNullable()} would have returned {@code null}.
*
* @return the null-strategy used
*/
NullStrategy nullStrategy();
/**
* The strategies possible when dealing with {@code null}-values.
*/
enum NullStrategy {
/**
* Whenever the {@link #innerNullable() inner} expression returns a
* {@code null} value, a specific constant value will be returned by
* this expression. If this strategy is used, then the class should also
* implement the corresponding {@code To__OrElseExpression} depending on
* the {@link Expression#expressionType() type}.
*/
USE_DEFAULT_VALUE,
/**
* Whenever the {@link #innerNullable() inner} expression returns a
* {@code null} value, the
* {@link OrElseGetExpression#defaultValueGetter() other} expression
* will be invoked to determine the value instead. If this strategy is
* used, then the class should also implement
* {@link OrElseGetExpression}.
*/
APPLY_DEFAULT_METHOD,
/**
* Whenever the {@link #innerNullable() inner} expression returns a
* {@code null} value, a {@code NullPointerException} is thrown. If this
* strategy is used, then the class should also implement
* {@link OrElseThrowExpression}.
*/
THROW_EXCEPTION
}
}
|
UTF-8
|
Java
| 3,276 |
java
|
NonNullableExpression.java
|
Java
|
[
{
"context": "R> the type of the inner expression\n *\n * @author Emil Forslund\n * @since 3.1.0\n */\npublic interface NonNullable",
"end": 1503,
"score": 0.9998066425323486,
"start": 1490,
"tag": "NAME",
"value": "Emil Forslund"
}
] | null |
[] |
/*
*
* Copyright (c) 2006-2020, Speedment, Inc. All Rights Reserved.
*
* 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.speedment.runtime.compute.expression;
import com.speedment.runtime.compute.expression.orelse.OrElseGetExpression;
import com.speedment.runtime.compute.expression.orelse.OrElseThrowExpression;
/**
* Specialized {@link Expression} that is not nullable, but that wraps an
* expression that is and that has some routine for dealing with {@code null}
* values determined by {@link #nullStrategy()}.
* <p>
* Equality is determined by looking at {@link #innerNullable()} and
* {@link #nullStrategy()}, and additionally by the
* {@link OrElseGetExpression#defaultValueGetter()} or the
* {@code getDefaultValue()} if the strategy is
* {@link NullStrategy#APPLY_DEFAULT_METHOD} or
* {@link NullStrategy#USE_DEFAULT_VALUE} respectively.
*
* @param <T> the input entity type
* @param <INNER> the type of the inner expression
*
* @author <NAME>
* @since 3.1.0
*/
public interface NonNullableExpression<T, INNER extends Expression<T>>
extends Expression<T> {
/**
* Returns the inner nullable expression.
*
* @return the inner nullable expression
*/
INNER innerNullable();
/**
* Returns the strategy used by this expression to deal with the case when
* {@link #innerNullable()} would have returned {@code null}.
*
* @return the null-strategy used
*/
NullStrategy nullStrategy();
/**
* The strategies possible when dealing with {@code null}-values.
*/
enum NullStrategy {
/**
* Whenever the {@link #innerNullable() inner} expression returns a
* {@code null} value, a specific constant value will be returned by
* this expression. If this strategy is used, then the class should also
* implement the corresponding {@code To__OrElseExpression} depending on
* the {@link Expression#expressionType() type}.
*/
USE_DEFAULT_VALUE,
/**
* Whenever the {@link #innerNullable() inner} expression returns a
* {@code null} value, the
* {@link OrElseGetExpression#defaultValueGetter() other} expression
* will be invoked to determine the value instead. If this strategy is
* used, then the class should also implement
* {@link OrElseGetExpression}.
*/
APPLY_DEFAULT_METHOD,
/**
* Whenever the {@link #innerNullable() inner} expression returns a
* {@code null} value, a {@code NullPointerException} is thrown. If this
* strategy is used, then the class should also implement
* {@link OrElseThrowExpression}.
*/
THROW_EXCEPTION
}
}
| 3,269 | 0.674298 | 0.669719 | 90 | 35.41111 | 29.683102 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.255556 | false | false |
13
|
70a746af82794675e6241d19a083d161d79b8844
| 18,803,366,867,340 |
ae95d0576f88d858332b9b1ec7cf6660e5b9a289
|
/app/src/main/java/com/example/mac/chartr/objects/User.java
|
80c101a2fff004ada703cbc2d8a047664408320b
|
[] |
no_license
|
ghayat2/chartr-android
|
https://github.com/ghayat2/chartr-android
|
55283d73f32f127e482ea4e8cb793d1a30132708
|
f8e0ec1de915a58d9c93c7816809d161b9aa75d9
|
refs/heads/master
| 2021-04-28T15:25:21.005000 | 2018-04-30T18:45:17 | 2018-04-30T18:45:17 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.example.mac.chartr.objects;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
* POJO for a User on Chartr representing all information that we have about
* each user. Can be serialized back and forth in order to send to or receive from the database.
*/
public class User {
@SerializedName("uid")
@Expose
private String uid;
// Format for email is +12223334444
@SerializedName("email")
@Expose
private String email;
@SerializedName("name")
@Expose
private String name;
@SerializedName("birthdate")
@Expose
private String birthdate;
@SerializedName("phone")
@Expose
private String phone;
@SerializedName("rating")
@Expose
private float rating;
@SerializedName("review_count")
@Expose
private int reviewCount;
public User() { }
public User(String email, String name, float rating) {
this.email = email;
this.name = name;
this.rating = rating;
}
public User(String email,
String name,
String birthdate,
String phone,
float rating,
int reviewCount) {
this.email = email;
this.name = name;
this.birthdate = birthdate;
this.phone = phone;
this.rating = rating;
this.reviewCount = reviewCount;
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getBirthdate() {
return birthdate;
}
public void setBirthdate(String birthdate) {
this.birthdate = birthdate;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public float getRating() {
return rating;
}
public void setRating(float rating) {
this.rating = rating;
}
public int getReviewCount() {
return reviewCount;
}
public void setReviewCount(int reviewCount) {
this.reviewCount = reviewCount;
}
/**
* Formats a stored phone number from the +12223334444 to the +1-222-333-4444 format.
* @return
*/
public String getFormattedPhone() {
return phone.substring(0, 2) + "-" + phone.substring(2, 5) + "-" + phone.substring(5, 8)
+ "-" + phone.substring(8);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
User user = (User) o;
if (Float.compare(user.rating, rating) != 0) {
return false;
}
if (reviewCount != user.reviewCount) {
return false;
}
if (uid != null ? !uid.equals(user.uid) : user.uid != null) {
return false;
}
if (email != null ? !email.equals(user.email) : user.email != null) {
return false;
}
if (name != null ? !name.equals(user.name) : user.name != null) {
return false;
}
if (birthdate != null ? !birthdate.equals(user.birthdate) : user.birthdate != null) {
return false;
}
return phone != null ? phone.equals(user.phone) : user.phone == null;
}
@Override
public int hashCode() {
int result = uid != null ? uid.hashCode() : 0;
result = 31 * result + (email != null ? email.hashCode() : 0);
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (birthdate != null ? birthdate.hashCode() : 0);
result = 31 * result + (phone != null ? phone.hashCode() : 0);
result = 31 * result + (rating != +0.0f ? Float.floatToIntBits(rating) : 0);
result = 31 * result + reviewCount;
return result;
}
}
|
UTF-8
|
Java
| 4,225 |
java
|
User.java
|
Java
|
[
{
"context": " {\n this.email = email;\n this.name = name;\n this.rating = rating;\n }\n\n public ",
"end": 1001,
"score": 0.5902904272079468,
"start": 997,
"tag": "NAME",
"value": "name"
}
] | null |
[] |
package com.example.mac.chartr.objects;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
* POJO for a User on Chartr representing all information that we have about
* each user. Can be serialized back and forth in order to send to or receive from the database.
*/
public class User {
@SerializedName("uid")
@Expose
private String uid;
// Format for email is +12223334444
@SerializedName("email")
@Expose
private String email;
@SerializedName("name")
@Expose
private String name;
@SerializedName("birthdate")
@Expose
private String birthdate;
@SerializedName("phone")
@Expose
private String phone;
@SerializedName("rating")
@Expose
private float rating;
@SerializedName("review_count")
@Expose
private int reviewCount;
public User() { }
public User(String email, String name, float rating) {
this.email = email;
this.name = name;
this.rating = rating;
}
public User(String email,
String name,
String birthdate,
String phone,
float rating,
int reviewCount) {
this.email = email;
this.name = name;
this.birthdate = birthdate;
this.phone = phone;
this.rating = rating;
this.reviewCount = reviewCount;
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getBirthdate() {
return birthdate;
}
public void setBirthdate(String birthdate) {
this.birthdate = birthdate;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public float getRating() {
return rating;
}
public void setRating(float rating) {
this.rating = rating;
}
public int getReviewCount() {
return reviewCount;
}
public void setReviewCount(int reviewCount) {
this.reviewCount = reviewCount;
}
/**
* Formats a stored phone number from the +12223334444 to the +1-222-333-4444 format.
* @return
*/
public String getFormattedPhone() {
return phone.substring(0, 2) + "-" + phone.substring(2, 5) + "-" + phone.substring(5, 8)
+ "-" + phone.substring(8);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
User user = (User) o;
if (Float.compare(user.rating, rating) != 0) {
return false;
}
if (reviewCount != user.reviewCount) {
return false;
}
if (uid != null ? !uid.equals(user.uid) : user.uid != null) {
return false;
}
if (email != null ? !email.equals(user.email) : user.email != null) {
return false;
}
if (name != null ? !name.equals(user.name) : user.name != null) {
return false;
}
if (birthdate != null ? !birthdate.equals(user.birthdate) : user.birthdate != null) {
return false;
}
return phone != null ? phone.equals(user.phone) : user.phone == null;
}
@Override
public int hashCode() {
int result = uid != null ? uid.hashCode() : 0;
result = 31 * result + (email != null ? email.hashCode() : 0);
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (birthdate != null ? birthdate.hashCode() : 0);
result = 31 * result + (phone != null ? phone.hashCode() : 0);
result = 31 * result + (rating != +0.0f ? Float.floatToIntBits(rating) : 0);
result = 31 * result + reviewCount;
return result;
}
}
| 4,225 | 0.557396 | 0.542959 | 170 | 23.852942 | 22.407104 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.382353 | false | false |
13
|
f7f38a8d69a66579698c9c592641246f2b1a6a04
| 32,049,045,990,525 |
df755f1ad9f30e2968faaf65d5f203ac9de8dcf1
|
/mftcc-platform-web-master/src/main/java/app/component/frontview/feign/VwFeatureManageFeign.java
|
50a4021c3a7b83da4b24f3b454fa913e22900f3b
|
[] |
no_license
|
gaoqiang9399/eclipsetogit
|
https://github.com/gaoqiang9399/eclipsetogit
|
afabf761f77fe542b3da1535b15d4005274b8db7
|
03e02ef683929ea408d883ea35cbccf07a4c43e6
|
refs/heads/master
| 2023-01-22T16:42:32.813000 | 2020-11-23T07:31:23 | 2020-11-23T07:31:23 | 315,209,391 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package app.component.frontview.feign;
import java.util.List;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import app.base.ServiceException;
import app.component.frontview.entity.VwFeatureManage;
import app.util.toolkit.Ipage;
/**
* Title: VwFeatureManageBo.java Description:
*
* @author:kaifa@dhcc.com.cn
* @Wed May 10 19:16:00 CST 2017
**/
@FeignClient("mftcc-platform-factor")
public interface VwFeatureManageFeign {
/**
* 新增平台特点
*
* @param vwFeatureManage
* @throws ServiceException
*/
@RequestMapping("/vwFeatureManage/insert")
public void insert(@RequestBody VwFeatureManage vwFeatureManage) throws ServiceException;
/**
* 删除平台特点
*
* @param vwFeatureManage
* @throws ServiceException
*/
@RequestMapping("/vwFeatureManage/delete")
public void delete(@RequestBody VwFeatureManage vwFeatureManage) throws ServiceException;
/**
* 修改平台特点
*
* @param vwFeatureManage
* @throws ServiceException
*/
@RequestMapping("/vwFeatureManage/update")
public void update(@RequestBody VwFeatureManage vwFeatureManage) throws ServiceException;
/**
* 详情
*
* @param vwFeatureManage
* @return
* @throws ServiceException
*/
@RequestMapping("/vwFeatureManage/getById")
public VwFeatureManage getById(@RequestBody VwFeatureManage vwFeatureManage) throws ServiceException;
/**
* 获取列表
*
* @param ipage
* @param vwFeatureManage
* @return
* @throws ServiceException
*/
@RequestMapping("/vwFeatureManage/findByPage")
public Ipage findByPage(@RequestBody Ipage ipage, @RequestParam("vwFeatureManage") VwFeatureManage vwFeatureManage) throws ServiceException;
/**
* 获取所有启用的平台特点
*
* @return
* @throws ServiceException
* @throws Exception
*/
@RequestMapping("/vwFeatureManage/getAllFeature")
public List<VwFeatureManage> getAllFeature() throws ServiceException, Exception;
}
|
UTF-8
|
Java
| 2,123 |
java
|
VwFeatureManageFeign.java
|
Java
|
[
{
"context": "wFeatureManageBo.java Description:\n * \n * @author:kaifa@dhcc.com.cn\n * @Wed May 10 19:16:00 CST 2017\n **/\n\n@FeignClie",
"end": 512,
"score": 0.999920129776001,
"start": 495,
"tag": "EMAIL",
"value": "kaifa@dhcc.com.cn"
}
] | null |
[] |
package app.component.frontview.feign;
import java.util.List;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import app.base.ServiceException;
import app.component.frontview.entity.VwFeatureManage;
import app.util.toolkit.Ipage;
/**
* Title: VwFeatureManageBo.java Description:
*
* @author:<EMAIL>
* @Wed May 10 19:16:00 CST 2017
**/
@FeignClient("mftcc-platform-factor")
public interface VwFeatureManageFeign {
/**
* 新增平台特点
*
* @param vwFeatureManage
* @throws ServiceException
*/
@RequestMapping("/vwFeatureManage/insert")
public void insert(@RequestBody VwFeatureManage vwFeatureManage) throws ServiceException;
/**
* 删除平台特点
*
* @param vwFeatureManage
* @throws ServiceException
*/
@RequestMapping("/vwFeatureManage/delete")
public void delete(@RequestBody VwFeatureManage vwFeatureManage) throws ServiceException;
/**
* 修改平台特点
*
* @param vwFeatureManage
* @throws ServiceException
*/
@RequestMapping("/vwFeatureManage/update")
public void update(@RequestBody VwFeatureManage vwFeatureManage) throws ServiceException;
/**
* 详情
*
* @param vwFeatureManage
* @return
* @throws ServiceException
*/
@RequestMapping("/vwFeatureManage/getById")
public VwFeatureManage getById(@RequestBody VwFeatureManage vwFeatureManage) throws ServiceException;
/**
* 获取列表
*
* @param ipage
* @param vwFeatureManage
* @return
* @throws ServiceException
*/
@RequestMapping("/vwFeatureManage/findByPage")
public Ipage findByPage(@RequestBody Ipage ipage, @RequestParam("vwFeatureManage") VwFeatureManage vwFeatureManage) throws ServiceException;
/**
* 获取所有启用的平台特点
*
* @return
* @throws ServiceException
* @throws Exception
*/
@RequestMapping("/vwFeatureManage/getAllFeature")
public List<VwFeatureManage> getAllFeature() throws ServiceException, Exception;
}
| 2,113 | 0.758889 | 0.753044 | 81 | 24.345678 | 27.973162 | 141 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.851852 | false | false |
13
|
243fa108d7f2f7604d8468a1e1651a66bea0fb13
| 16,080,357,594,992 |
d6c8af0b6f57cd2c055cea58a10a2f2a336bc2fc
|
/src/main/java/com/sap/charging/util/random/Distribution.java
|
7d32751fa9ea30dce166d0caf75e865d3d2b6f3e
|
[
"Apache-2.0"
] |
permissive
|
SAP/emobility-smart-charging
|
https://github.com/SAP/emobility-smart-charging
|
56291f0a7da884bca0baf3d0a22fa2cb3a98e817
|
b1e7767a0a977b559226e0dd4248d12db74db5bf
|
refs/heads/master
| 2023-06-24T00:00:52.751000 | 2022-06-28T08:30:43 | 2022-06-28T08:30:43 | 228,855,233 | 41 | 30 |
Apache-2.0
| false | 2023-05-07T13:51:11 | 2019-12-18T14:18:01 | 2023-05-05T14:59:36 | 2023-05-07T13:51:07 | 2,342 | 35 | 45 | 29 |
Java
| false | false |
package com.sap.charging.util.random;
import java.util.Random;
public abstract class Distribution {
private final Random random;
public Distribution(Random random) {
this.random = random;
}
public Random getRandom() {
return random;
}
public abstract Distribution clone(Random random);
public abstract double getNextDouble();
}
|
UTF-8
|
Java
| 373 |
java
|
Distribution.java
|
Java
|
[] | null |
[] |
package com.sap.charging.util.random;
import java.util.Random;
public abstract class Distribution {
private final Random random;
public Distribution(Random random) {
this.random = random;
}
public Random getRandom() {
return random;
}
public abstract Distribution clone(Random random);
public abstract double getNextDouble();
}
| 373 | 0.699732 | 0.699732 | 21 | 15.761905 | 16.928152 | 51 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.095238 | false | false |
13
|
37bccfe394537d9078429837bdab04afb312e3d2
| 34,333,968,575,805 |
f2175db7bf78aadf14bc80e94dd6137949c84abd
|
/core/src/tv/rocketbeans/rbcgj/ui/AchievementWidget.java
|
e987dbb554a4ba15dd07b5614b90806f957d2f0d
|
[
"Apache-2.0"
] |
permissive
|
MyRealityCoding/rbcgj-2016
|
https://github.com/MyRealityCoding/rbcgj-2016
|
b3a72d8e04dd5d33be19eb274804aae6ae025314
|
7bbd9903ed202d977ae765bb0bab1118d27f3e42
|
refs/heads/master
| 2021-01-01T05:12:58.961000 | 2016-05-29T18:08:48 | 2016-05-29T18:08:48 | 56,834,046 | 0 | 0 | null | false | 2016-05-29T18:12:58 | 2016-04-22T07:07:18 | 2016-04-22T07:54:25 | 2016-05-29T18:12:58 | 90,476 | 0 | 0 | 6 |
Java
| null | null |
package tv.rocketbeans.rbcgj.ui;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import tv.rocketbeans.rbcgj.core.GameObjectType;
import tv.rocketbeans.rbcgj.graphics.TextureResolver;
import tv.rocketbeans.rbcgj.i18n.Bundle;
import tv.rocketbeans.rbcgj.i18n.Messages;
public class AchievementWidget extends Actor {
private static final float ICON_SIZE = 100f;
private static final float PADDING = 20f;
private Sprite icon;
private Label text;
public AchievementWidget(int type) {
Texture texture = TextureResolver.resolveTexture(type, true);
icon = new Sprite(texture);
String contents = Bundle.general.get(resolveTextKey(type));
text = new Label(contents, Styles.ACHIEVEMENT);
}
@Override
public void draw(Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha);
setPosition(Gdx.graphics.getWidth() / 2f - (ICON_SIZE + PADDING + text.getPrefWidth()) / 2f,
Gdx.graphics.getHeight() - 200f);
icon.setColor(getColor());
icon.setPosition(getX(), getY() - ICON_SIZE / 3f);
icon.setSize(ICON_SIZE, ICON_SIZE);
text.setPosition(getX() + ICON_SIZE + PADDING, getY());
text.getColor().a = getColor().a;
icon.draw(batch, parentAlpha);
text.draw(batch, parentAlpha);
}
private String resolveTextKey(int type) {
switch (type) {
case GameObjectType.CRUMB:
return Messages.ACHIEVEMENT_CRUMBS;
case GameObjectType.CASHEW:
return Messages.ACHIEVEMENT_CASHEW;
case GameObjectType.RUISIN:
return Messages.ACHIEVEMENT_RUISIN;
case GameObjectType.ALMOND:
return Messages.ACHIEVEMENT_ALMOND;
case GameObjectType.BRAZIL:
return Messages.ACHIEVEMENT_BRAZIL;
}
return Messages.ACHIEVEMENT;
}
}
|
UTF-8
|
Java
| 2,124 |
java
|
AchievementWidget.java
|
Java
|
[] | null |
[] |
package tv.rocketbeans.rbcgj.ui;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import tv.rocketbeans.rbcgj.core.GameObjectType;
import tv.rocketbeans.rbcgj.graphics.TextureResolver;
import tv.rocketbeans.rbcgj.i18n.Bundle;
import tv.rocketbeans.rbcgj.i18n.Messages;
public class AchievementWidget extends Actor {
private static final float ICON_SIZE = 100f;
private static final float PADDING = 20f;
private Sprite icon;
private Label text;
public AchievementWidget(int type) {
Texture texture = TextureResolver.resolveTexture(type, true);
icon = new Sprite(texture);
String contents = Bundle.general.get(resolveTextKey(type));
text = new Label(contents, Styles.ACHIEVEMENT);
}
@Override
public void draw(Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha);
setPosition(Gdx.graphics.getWidth() / 2f - (ICON_SIZE + PADDING + text.getPrefWidth()) / 2f,
Gdx.graphics.getHeight() - 200f);
icon.setColor(getColor());
icon.setPosition(getX(), getY() - ICON_SIZE / 3f);
icon.setSize(ICON_SIZE, ICON_SIZE);
text.setPosition(getX() + ICON_SIZE + PADDING, getY());
text.getColor().a = getColor().a;
icon.draw(batch, parentAlpha);
text.draw(batch, parentAlpha);
}
private String resolveTextKey(int type) {
switch (type) {
case GameObjectType.CRUMB:
return Messages.ACHIEVEMENT_CRUMBS;
case GameObjectType.CASHEW:
return Messages.ACHIEVEMENT_CASHEW;
case GameObjectType.RUISIN:
return Messages.ACHIEVEMENT_RUISIN;
case GameObjectType.ALMOND:
return Messages.ACHIEVEMENT_ALMOND;
case GameObjectType.BRAZIL:
return Messages.ACHIEVEMENT_BRAZIL;
}
return Messages.ACHIEVEMENT;
}
}
| 2,124 | 0.666196 | 0.65725 | 60 | 34.400002 | 21.672718 | 100 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.733333 | false | false |
13
|
7ea8df0daf08968bd2ce52c88af12d62dca62c50
| 36,524,401,887,915 |
10c416cbce61b5ab75b59741bf9ce76b38340c94
|
/multithreads/Deadlock.java
|
2729b68f6b88a91a8f62b9a4311d33e0734667f2
|
[] |
no_license
|
manju07/Data-structure-And-Alagorithms-using-Java
|
https://github.com/manju07/Data-structure-And-Alagorithms-using-Java
|
32c04771a781fbfbe0a6e81c3f4a8d34d8663b96
|
e2ab433f1111d750182a27ecbada1191b167d360
|
refs/heads/master
| 2021-04-17T10:41:25.195000 | 2021-04-05T03:28:11 | 2021-04-05T03:28:11 | 249,438,697 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package multithreads;
/**
* SharedObject1
*/
class SharedObject1 {
public synchronized void method1(SharedObject1 so1, SharedObject2 so2) {
System.out.println("method1 executing, current thread:" + Thread.currentThread().getName());
try {
Thread.sleep(1000);
} catch (Exception e) {
e.printStackTrace();
}
so2.method2(so1, so2);
}
}
/**
* SharedObject2
*/
class SharedObject2 {
public synchronized void method2(SharedObject1 so1, SharedObject2 so2) {
System.out.println("method2 executing, current thread:" + Thread.currentThread().getName());
try {
Thread.sleep(1000);
} catch (Exception e) {
e.printStackTrace();
}
so1.method1(so1, so2);
}
}
/**
* Deadlock
*
* @author Manjunath Asundi
*/
public class Deadlock {
public static void main(String[] args) {
SharedObject1 so1 = new SharedObject1();
SharedObject2 so2 = new SharedObject2();
Thread t1 = new Thread(new Runnable() {
@Override
public void run() {
so1.method1(so1, so2);
}
});
Thread t2 = new Thread(new Runnable() {
@Override
public void run() {
so2.method2(so1, so2);
}
});
t1.start();
try {
// t1.join();
} catch (Exception e) {
e.printStackTrace();
}
t2.start();
}
}
|
UTF-8
|
Java
| 1,518 |
java
|
Deadlock.java
|
Java
|
[
{
"context": "so1, so2);\n }\n}\n\n/**\n * Deadlock\n * \n * @author Manjunath Asundi\n */\n\npublic class Deadlock {\n\n public static v",
"end": 844,
"score": 0.9998292326927185,
"start": 828,
"tag": "NAME",
"value": "Manjunath Asundi"
}
] | null |
[] |
package multithreads;
/**
* SharedObject1
*/
class SharedObject1 {
public synchronized void method1(SharedObject1 so1, SharedObject2 so2) {
System.out.println("method1 executing, current thread:" + Thread.currentThread().getName());
try {
Thread.sleep(1000);
} catch (Exception e) {
e.printStackTrace();
}
so2.method2(so1, so2);
}
}
/**
* SharedObject2
*/
class SharedObject2 {
public synchronized void method2(SharedObject1 so1, SharedObject2 so2) {
System.out.println("method2 executing, current thread:" + Thread.currentThread().getName());
try {
Thread.sleep(1000);
} catch (Exception e) {
e.printStackTrace();
}
so1.method1(so1, so2);
}
}
/**
* Deadlock
*
* @author <NAME>
*/
public class Deadlock {
public static void main(String[] args) {
SharedObject1 so1 = new SharedObject1();
SharedObject2 so2 = new SharedObject2();
Thread t1 = new Thread(new Runnable() {
@Override
public void run() {
so1.method1(so1, so2);
}
});
Thread t2 = new Thread(new Runnable() {
@Override
public void run() {
so2.method2(so1, so2);
}
});
t1.start();
try {
// t1.join();
} catch (Exception e) {
e.printStackTrace();
}
t2.start();
}
}
| 1,508 | 0.527668 | 0.494071 | 70 | 20.700001 | 22.01321 | 100 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.385714 | false | false |
13
|
6b38a326eb05361cb29d2738ef2fff8937f3621e
| 34,265,249,104,159 |
cd13cc410015d1eae8aabc0aa7699e220334ca17
|
/app/src/main/java/com/example/therehabapp/AboutAnxiety.java
|
b43cc05b1f70d8eaa791c37b09278972a7dc1170
|
[] |
no_license
|
StephenKalinde/TheRehabApp2
|
https://github.com/StephenKalinde/TheRehabApp2
|
8cac809ae4d2ca5b06609e93bbb8d4157dd81bd6
|
f592bacd194ab124f504a9b64543ae4d3f3a638e
|
refs/heads/master
| 2020-07-23T18:01:55.324000 | 2020-05-26T04:57:42 | 2020-05-26T04:57:42 | 207,659,057 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.example.therehabapp;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
public class AboutAnxiety extends AppCompatActivity {
private Button continueBtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.about_anxiety);
continueBtn = (Button) findViewById(R.id.continue_btn);
continueBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent (AboutAnxiety.this, ThankYouNote.class);
intent.putExtra("Diagnosis", "Anxiety");
startActivity(intent);
}
});
}
}
|
UTF-8
|
Java
| 860 |
java
|
AboutAnxiety.java
|
Java
|
[] | null |
[] |
package com.example.therehabapp;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
public class AboutAnxiety extends AppCompatActivity {
private Button continueBtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.about_anxiety);
continueBtn = (Button) findViewById(R.id.continue_btn);
continueBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent (AboutAnxiety.this, ThankYouNote.class);
intent.putExtra("Diagnosis", "Anxiety");
startActivity(intent);
}
});
}
}
| 860 | 0.676744 | 0.676744 | 34 | 24.294117 | 23.854374 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.470588 | false | false |
13
|
6ab8e6605cad5b12c15698f02973da681abbbe27
| 22,058,952,067,184 |
625f2536f0c32c82889cb6b1645443d5fd1bf0a5
|
/sell-project-product/product-server/src/main/java/com/mx/product/exception/ProductException.java
|
0cc9f61beb9bb3a4aac8eaceea53b44cf688f50b
|
[] |
no_license
|
mxjesse/springcloud-sell-project
|
https://github.com/mxjesse/springcloud-sell-project
|
0ab6451d81fac2cb1e408f5ddac6bf3af004ec15
|
d0b7fdfffb4a1d480e4e33b96d695130ec4878d2
|
refs/heads/master
| 2022-06-30T17:17:38.101000 | 2019-05-23T01:39:17 | 2019-05-23T01:39:17 | 186,779,947 | 5 | 2 | null | false | 2022-06-17T02:09:43 | 2019-05-15T08:09:31 | 2019-05-24T05:58:00 | 2022-06-17T02:09:42 | 184 | 3 | 2 | 2 |
Java
| false | false |
package com.mx.product.exception;
import com.mx.product.enums.ResultEnum;
/**
* @author mx
* @date 2019/5/20 4:42 PM
*/
public class ProductException extends RuntimeException {
private String msg;
private Integer code;
public ProductException(String msg, Integer code) {
super(msg);
this.code = code;
}
public ProductException(ResultEnum resultEnum) {
this(resultEnum.getMsg(), resultEnum.getCode());
}
}
|
UTF-8
|
Java
| 462 |
java
|
ProductException.java
|
Java
|
[
{
"context": "t com.mx.product.enums.ResultEnum;\n\n/**\n * @author mx\n * @date 2019/5/20 4:42 PM\n */\npublic class Produ",
"end": 93,
"score": 0.9965797066688538,
"start": 91,
"tag": "USERNAME",
"value": "mx"
}
] | null |
[] |
package com.mx.product.exception;
import com.mx.product.enums.ResultEnum;
/**
* @author mx
* @date 2019/5/20 4:42 PM
*/
public class ProductException extends RuntimeException {
private String msg;
private Integer code;
public ProductException(String msg, Integer code) {
super(msg);
this.code = code;
}
public ProductException(ResultEnum resultEnum) {
this(resultEnum.getMsg(), resultEnum.getCode());
}
}
| 462 | 0.670996 | 0.649351 | 23 | 19.086956 | 20.093073 | 56 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.391304 | false | false |
13
|
0ae97fb59eb6e1aa94d8a04e82590a4bbeb72eca
| 1,365,799,638,154 |
a979dbdc89bc77728199998b2e7292ec0aeaf5b4
|
/AccessService/src/main/java/se/wegelius/accessservice/model/RolePermission.java
|
a690a7d56e58cea2dfcc1c948e56e9b2a8fbb0b8
|
[] |
no_license
|
asawegelius/BachelorProject
|
https://github.com/asawegelius/BachelorProject
|
f0dbd46f440252fbae8cff1405d6e4fcc21bc588
|
9aa11e8c9f4e858b5ee770c9e25362cda98e58a9
|
refs/heads/master
| 2021-01-12T22:50:13.300000 | 2017-03-06T02:54:39 | 2017-03-06T02:54:39 | 81,754,856 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package se.wegelius.accessservice.model;
/**
*
* @author asawe
*/
public class RolePermission {
private int rolePermissionId;
private int permissionId;
private int roleId;
public RolePermission() {
}
public RolePermission(int rolePermissionId, int permissionId, int roleId) {
this.rolePermissionId = rolePermissionId;
this.permissionId = permissionId;
this.roleId = roleId;
}
public int getRolePermissionId() {
return this.rolePermissionId;
}
public void setRolePermissionId(int rolePermissionId) {
this.rolePermissionId = rolePermissionId;
}
public int getPermissionId() {
return permissionId;
}
public void setPermissionId(int permissionId) {
this.permissionId = permissionId;
}
public int getRoleId() {
return roleId;
}
public void setRoleId(int roleId) {
this.roleId = roleId;
}
}
|
UTF-8
|
Java
| 1,132 |
java
|
RolePermission.java
|
Java
|
[
{
"context": "e.wegelius.accessservice.model;\n\n/**\n *\n * @author asawe\n */\npublic class RolePermission {\n\n private in",
"end": 250,
"score": 0.9733298420906067,
"start": 245,
"tag": "USERNAME",
"value": "asawe"
}
] | null |
[] |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package se.wegelius.accessservice.model;
/**
*
* @author asawe
*/
public class RolePermission {
private int rolePermissionId;
private int permissionId;
private int roleId;
public RolePermission() {
}
public RolePermission(int rolePermissionId, int permissionId, int roleId) {
this.rolePermissionId = rolePermissionId;
this.permissionId = permissionId;
this.roleId = roleId;
}
public int getRolePermissionId() {
return this.rolePermissionId;
}
public void setRolePermissionId(int rolePermissionId) {
this.rolePermissionId = rolePermissionId;
}
public int getPermissionId() {
return permissionId;
}
public void setPermissionId(int permissionId) {
this.permissionId = permissionId;
}
public int getRoleId() {
return roleId;
}
public void setRoleId(int roleId) {
this.roleId = roleId;
}
}
| 1,132 | 0.668728 | 0.668728 | 51 | 21.196079 | 21.712036 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.352941 | false | false |
13
|
1f067bb6e94911440b5d9f2fe5ad0fdf5ae3b092
| 3,719,441,716,531 |
e61731ec9fd3cd0604fd2c3fffc2f1b57a974999
|
/app/src/main/java/com/codingtive/sportapps/view/fragment/favorite/FavoriteFragment.java
|
3962e8e6edb84f1651b907a3824b67b3df5292e5
|
[] |
no_license
|
TimurHaryo/SportApps
|
https://github.com/TimurHaryo/SportApps
|
834aa0b3f219f93bdc90042301414e990afaf6a1
|
4182b213d3c1d47cc9539a74cc789bf119a21893
|
refs/heads/master
| 2020-12-27T17:22:07.003000 | 2020-02-02T14:14:28 | 2020-02-02T14:14:28 | 237,987,470 | 1 | 1 | null | true | 2020-02-03T14:41:28 | 2020-02-03T14:41:28 | 2020-02-02T14:13:35 | 2020-02-02T14:13:33 | 4,799 | 0 | 0 | 0 | null | false | false |
package com.codingtive.sportapps.view.fragment.favorite;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.codingtive.sportapps.R;
import com.codingtive.sportapps.adapter.SportAdapter;
import com.codingtive.sportapps.data.database.RoomClient;
import com.codingtive.sportapps.data.model.Sport;
import com.codingtive.sportapps.interfaces.ItemSportListener;
import com.codingtive.sportapps.view.activity.detail.SportDetailActivity;
import java.lang.ref.WeakReference;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
public class FavoriteFragment extends Fragment implements ItemSportListener {
private TextView emptyTextView;
private RecyclerView sportsRecyclerView;
private SportAdapter sportAdapter;
private SwipeRefreshLayout swipeRefreshLayout;
private FavoriteViewModel favoriteViewModel;
private GetFavoriteTask getFavoriteTask;
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_home, container, false);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
initialize();
bindView(view);
setupSportsRecyclerView();
registerObserver();
setupRefreshLayout();
getFavoriteTask.execute();
}
private void initialize() {
initViewModel();
initFavoriteTask();
}
private void initFavoriteTask() {
getFavoriteTask = new GetFavoriteTask(this);
}
private void initViewModel() {
favoriteViewModel = ViewModelProviders.of(this).get(FavoriteViewModel.class);
}
private void bindView(View view) {
emptyTextView = view.findViewById(R.id.tv_empty);
sportsRecyclerView = view.findViewById(R.id.rv_sports);
swipeRefreshLayout = view.findViewById(R.id.swipe_refresh_layout);
}
private void setupSportsRecyclerView() {
sportAdapter = new SportAdapter(this);
sportsRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
sportsRecyclerView.setAdapter(sportAdapter);
}
private void setupRefreshLayout() {
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
refreshFavorite();
}
});
}
private void refreshFavorite() {
getFavoriteTask = null;
initFavoriteTask();
getFavoriteTask.execute();
}
private void registerObserver() {
favoriteViewModel.getSportList().observe(this, new Observer<List<Sport>>() {
@Override
public void onChanged(List<Sport> sports) {
emptyTextView.setVisibility(sports.isEmpty() ? View.VISIBLE : View.GONE);
sportAdapter.setSportList(sports);
sportAdapter.notifyDataSetChanged();
}
});
}
@Override
public void onItemClicked(Sport sport) {
if (getActivity() != null) {
Intent intent = new Intent(getActivity(), SportDetailActivity.class);
intent.putExtra(SportDetailActivity.EXTRA_SPORT, sport);
getActivity().startActivity(intent);
}
}
public static class GetFavoriteTask extends AsyncTask<Void, Void, List<Sport>> {
private WeakReference<FavoriteFragment> fragment;
GetFavoriteTask(FavoriteFragment fragment) {
this.fragment = new WeakReference<>(fragment);
}
@Override
protected List<Sport> doInBackground(Void... voids) {
return RoomClient.getInstance(fragment.get().getContext())
.getSportDatabase()
.getSportDao()
.getSportList();
}
@Override
protected void onPostExecute(List<Sport> sports) {
super.onPostExecute(sports);
fragment.get().favoriteViewModel.setSportList(sports);
fragment.get().swipeRefreshLayout.setRefreshing(false);
}
}
}
|
UTF-8
|
Java
| 4,686 |
java
|
FavoriteFragment.java
|
Java
|
[] | null |
[] |
package com.codingtive.sportapps.view.fragment.favorite;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.codingtive.sportapps.R;
import com.codingtive.sportapps.adapter.SportAdapter;
import com.codingtive.sportapps.data.database.RoomClient;
import com.codingtive.sportapps.data.model.Sport;
import com.codingtive.sportapps.interfaces.ItemSportListener;
import com.codingtive.sportapps.view.activity.detail.SportDetailActivity;
import java.lang.ref.WeakReference;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
public class FavoriteFragment extends Fragment implements ItemSportListener {
private TextView emptyTextView;
private RecyclerView sportsRecyclerView;
private SportAdapter sportAdapter;
private SwipeRefreshLayout swipeRefreshLayout;
private FavoriteViewModel favoriteViewModel;
private GetFavoriteTask getFavoriteTask;
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_home, container, false);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
initialize();
bindView(view);
setupSportsRecyclerView();
registerObserver();
setupRefreshLayout();
getFavoriteTask.execute();
}
private void initialize() {
initViewModel();
initFavoriteTask();
}
private void initFavoriteTask() {
getFavoriteTask = new GetFavoriteTask(this);
}
private void initViewModel() {
favoriteViewModel = ViewModelProviders.of(this).get(FavoriteViewModel.class);
}
private void bindView(View view) {
emptyTextView = view.findViewById(R.id.tv_empty);
sportsRecyclerView = view.findViewById(R.id.rv_sports);
swipeRefreshLayout = view.findViewById(R.id.swipe_refresh_layout);
}
private void setupSportsRecyclerView() {
sportAdapter = new SportAdapter(this);
sportsRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
sportsRecyclerView.setAdapter(sportAdapter);
}
private void setupRefreshLayout() {
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
refreshFavorite();
}
});
}
private void refreshFavorite() {
getFavoriteTask = null;
initFavoriteTask();
getFavoriteTask.execute();
}
private void registerObserver() {
favoriteViewModel.getSportList().observe(this, new Observer<List<Sport>>() {
@Override
public void onChanged(List<Sport> sports) {
emptyTextView.setVisibility(sports.isEmpty() ? View.VISIBLE : View.GONE);
sportAdapter.setSportList(sports);
sportAdapter.notifyDataSetChanged();
}
});
}
@Override
public void onItemClicked(Sport sport) {
if (getActivity() != null) {
Intent intent = new Intent(getActivity(), SportDetailActivity.class);
intent.putExtra(SportDetailActivity.EXTRA_SPORT, sport);
getActivity().startActivity(intent);
}
}
public static class GetFavoriteTask extends AsyncTask<Void, Void, List<Sport>> {
private WeakReference<FavoriteFragment> fragment;
GetFavoriteTask(FavoriteFragment fragment) {
this.fragment = new WeakReference<>(fragment);
}
@Override
protected List<Sport> doInBackground(Void... voids) {
return RoomClient.getInstance(fragment.get().getContext())
.getSportDatabase()
.getSportDao()
.getSportList();
}
@Override
protected void onPostExecute(List<Sport> sports) {
super.onPostExecute(sports);
fragment.get().favoriteViewModel.setSportList(sports);
fragment.get().swipeRefreshLayout.setRefreshing(false);
}
}
}
| 4,686 | 0.689287 | 0.689287 | 137 | 33.20438 | 25.541761 | 92 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.562044 | false | false |
13
|
16cb52bbfaec0633d5ca9ae72d1caf29796ccad1
| 14,319,421,002,836 |
e6b942c87d8a353d28ae66086b89aff84604f065
|
/TBDao/src/main/java/com/upc/service/IDistritoService.java
|
536afa14ceb1f7230e483fbf3c6db83f9fa96441
|
[] |
no_license
|
sriosGit/TBOpenSource
|
https://github.com/sriosGit/TBOpenSource
|
9067d7d83ab37e0c788d87c299f966b18691af13
|
c27903822aa6f4240837edb98f31e1ded9a5f5a8
|
refs/heads/master
| 2021-01-13T10:14:29.091000 | 2016-09-29T00:15:03 | 2016-09-29T00:15:03 | 69,513,532 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.upc.service;
import com.upc.dto.Distrito;
public interface IDistritoService extends ICrudservice<Distrito>, IRowmapper<Distrito>{
}
|
UTF-8
|
Java
| 147 |
java
|
IDistritoService.java
|
Java
|
[] | null |
[] |
package com.upc.service;
import com.upc.dto.Distrito;
public interface IDistritoService extends ICrudservice<Distrito>, IRowmapper<Distrito>{
}
| 147 | 0.809524 | 0.809524 | 7 | 20 | 29.59247 | 87 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.428571 | false | false |
13
|
e9c65a56643caf3f3103bac20ff2bf52101717ce
| 4,801,773,497,840 |
39a2848a539e8a40eace7f86cb5f5ac6e9a4b558
|
/branches/oplatform.log/src/com/risetek/operation/platform/log/client/dialog/FilterLogDialog.java
|
ce4b8b9403eec90cfc3bb4f824604ce4d9104958
|
[] |
no_license
|
jiangzhu1212/oplatform
|
https://github.com/jiangzhu1212/oplatform
|
be2f00be143ea2c38b07eeb50d23b3b1b3b55ac1
|
95bf6e9ec6024936701128751f9853dac2e20d45
|
refs/heads/master
| 2020-06-07T07:33:09.013000 | 2011-01-27T16:22:54 | 2011-01-27T16:22:54 | 35,592,960 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.risetek.operation.platform.log.client.dialog;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.TextBox;
import com.risetek.operation.platform.launch.client.dialog.CustomDialog;
public class FilterLogDialog extends CustomDialog {
private TextBox value = new TextBox();
public FilterLogDialog(){
setText("过滤日志");
setTitle("过滤日志");
setDescript("根据输入的关键字过滤日志");
Grid grid = new Grid(2, 2);
grid.setWidth("340px");
grid.setStyleName("table");
grid.getColumnFormatter().setWidth(0, "80px");
grid.getColumnFormatter().setWidth(1, "260px");
grid.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT);
grid.setText(0, 0, "过滤条件:");
grid.setWidget(0, 1, value);
grid.setText(1, 1, "若不输入任何内容,则显示全部日志。");
mainPanel.add(grid);
}
public void show(){
submit.setText("确定");
super.show();
}
public String getValue(){
return value.getValue();
}
}
|
UTF-8
|
Java
| 1,137 |
java
|
FilterLogDialog.java
|
Java
|
[] | null |
[] |
package com.risetek.operation.platform.log.client.dialog;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.TextBox;
import com.risetek.operation.platform.launch.client.dialog.CustomDialog;
public class FilterLogDialog extends CustomDialog {
private TextBox value = new TextBox();
public FilterLogDialog(){
setText("过滤日志");
setTitle("过滤日志");
setDescript("根据输入的关键字过滤日志");
Grid grid = new Grid(2, 2);
grid.setWidth("340px");
grid.setStyleName("table");
grid.getColumnFormatter().setWidth(0, "80px");
grid.getColumnFormatter().setWidth(1, "260px");
grid.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT);
grid.setText(0, 0, "过滤条件:");
grid.setWidget(0, 1, value);
grid.setText(1, 1, "若不输入任何内容,则显示全部日志。");
mainPanel.add(grid);
}
public void show(){
submit.setText("确定");
super.show();
}
public String getValue(){
return value.getValue();
}
}
| 1,137 | 0.701621 | 0.682555 | 37 | 26.351351 | 22.285877 | 91 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.054054 | false | false |
13
|
691cb57a09da9ec8e8270ba6600037d7194ed00b
| 20,323,785,284,350 |
8aea2fbcd54681c3fb1c60a378158bf38f1f9f9c
|
/geoportal_1/src/main/java/org/OpenGeoPortal/Download/DownloadPackager.java
|
d39d96b3b9f2917e0b032dfeb0e3754e75f7b2b5
|
[
"Apache-2.0"
] |
permissive
|
jgpawletko/OGP
|
https://github.com/jgpawletko/OGP
|
34ab43f5e441f632f848287f4d153db0eec34a41
|
96cb9a767feda8daf6cef9467742439298313ec3
|
refs/heads/master
| 2017-04-29T01:46:25.855000 | 2016-01-21T14:55:09 | 2016-01-21T14:55:09 | 50,114,093 | 0 | 0 | null | true | 2016-01-21T14:46:15 | 2016-01-21T14:46:15 | 2015-01-23T20:26:54 | 2015-08-03T17:30:08 | 125,291 | 0 | 0 | 0 | null | null | null |
package org.OpenGeoPortal.Download;
import java.util.UUID;
public interface DownloadPackager {
void packageFiles(UUID requestId) throws Exception;
}
|
UTF-8
|
Java
| 152 |
java
|
DownloadPackager.java
|
Java
|
[] | null |
[] |
package org.OpenGeoPortal.Download;
import java.util.UUID;
public interface DownloadPackager {
void packageFiles(UUID requestId) throws Exception;
}
| 152 | 0.815789 | 0.815789 | 7 | 20.714285 | 19.403345 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.571429 | false | false |
13
|
639fe6d27e4677b9ce5c8369f794fa6a92ae5a27
| 12,352,325,983,019 |
855285d94ca7740d9d629a93af31287f2c002862
|
/src/ChessBoard.java
|
301e1400504a20c2afa2ae07e2364375a8274624
|
[] |
no_license
|
thymemanagement/chess-project
|
https://github.com/thymemanagement/chess-project
|
76e66e31f436e7be6651c6e4ba509f28822a636e
|
5618e1de230496defb5a5c1f0c3e158c677e6e9d
|
refs/heads/master
| 2021-01-23T06:28:52.630000 | 2017-06-03T19:24:17 | 2017-06-03T19:24:17 | 93,023,811 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import java.util.ArrayList;
public class ChessBoard {
private static final int BOARD_SIZE = 8;
private ArrayList<ChessPiece> pieces;
private ChessPiece currentPiece;
private ChessPiece lastPiece;
private ChessPiece lastRemoved;
private boolean getPiece;
private boolean gameOver;
private Team currentTurn;
private Team loser;
private King whiteKing;
private King blackKing;
private int turnCount;
public ChessBoard(King white, King black) {
pieces = new ArrayList<ChessPiece>();
lastRemoved = null;
lastPiece = null;
whiteKing = white;
blackKing = black;
getPiece = true;
gameOver = false;
currentTurn = Team.WHITE;
loser = null;
turnCount = 1;
}
public static ChessBoard initGame() {
King white = new King(Team.WHITE, 0, 4);
King black = new King(Team.BLACK, 7, 4);
ChessBoard newBoard = new ChessBoard(white, black);
newBoard.pieces.add(white);
newBoard.pieces.add(black);
newBoard.pieces.add(new Queen(Team.WHITE, 0, 3));
newBoard.pieces.add(new Queen(Team.BLACK, 7, 3));
newBoard.pieces.add(new Bishop(Team.WHITE, 0, 2));
newBoard.pieces.add(new Bishop(Team.WHITE, 0, 5));
newBoard.pieces.add(new Bishop(Team.BLACK, 7, 2));
newBoard.pieces.add(new Bishop(Team.BLACK, 7, 5));
newBoard.pieces.add(new Knight(Team.WHITE, 0, 1));
newBoard.pieces.add(new Knight(Team.WHITE, 0, 6));
newBoard.pieces.add(new Knight(Team.BLACK, 7, 1));
newBoard.pieces.add(new Knight(Team.BLACK, 7, 6));
newBoard.pieces.add(new Rook(Team.WHITE, 0, 0));
newBoard.pieces.add(new Rook(Team.WHITE, 0, 7));
newBoard.pieces.add(new Rook(Team.BLACK, 7, 0));
newBoard.pieces.add(new Rook(Team.BLACK, 7, 7));
for (int i = 0; i < 8; i++) {
newBoard.pieces.add(new Pawn(Team.WHITE, 1, i));
newBoard.pieces.add(new Pawn(Team.BLACK, 6, i));
}
newBoard.calcAllMoves();
return newBoard;
}
public void processMove(int row, int col) {
if (row < BOARD_SIZE && col < BOARD_SIZE) {
Pos pos = new Pos(row, col);
if (getPiece) {
int foundPiece = indexAtPos(pos);
if (foundPiece > -1 && getPiece(foundPiece).getTeam() == currentTurn) {
currentPiece = getPiece(foundPiece);
getPiece = false;
}
} else {
if (currentPiece.moveIsPossible(pos)) {
int oldPiece = currentPiece.move(pos, this);
if (oldPiece > -1) {
lastRemoved = pieces.remove(oldPiece);
} else {
lastRemoved = null;
}
if (currentTurn == Team.WHITE)
currentTurn = Team.BLACK;
else
currentTurn = Team.WHITE;
calcAllMoves();
turnCount++;
if (noPossibleMoves()) {
gameOver = true;
if (inCheck(currentTurn, getKing(currentTurn).getPos())) {
loser = currentTurn;
} else {
System.out.println("It's a Stalemate!");
}
}
lastPiece = currentPiece;
getPiece = true;
} else if (currentPiece.getPos().equals(pos)) {
getPiece = true;
}
}
}
}
public String getMessage() {
if (gameOver) {
if (loser == Team.WHITE) {
return "Checkmate! Black Wins!";
} else if (loser == Team.BLACK) {
return "Checkmate! White Wins!";
} else {
return "Stalemate! How Unfortunate.";
}
} else {
if (currentTurn == Team.WHITE) {
return "White's Turn";
} else {
return "Black's Turn";
}
}
}
public void undoMove() {
if (lastPiece != null) {
lastPiece.unmove(this);
if (lastRemoved != null) {
pieces.add(lastRemoved);
lastRemoved = null;
}
currentTurn = lastPiece.getTeam();
}
getPiece = true;
}
public boolean noPossibleMoves() {
for (ChessPiece piece : pieces) {
if (piece.getTeam() == currentTurn && !piece.getPossibleMoves().isEmpty())
return false;
}
return true;
}
public boolean gameOver() {
return gameOver;
}
public void calcAllMoves() {
King currentKing = getKing(currentTurn);
for (int p = 0; p < pieces.size(); p++) {
ChessPiece piece = pieces.get(p);
if (piece.getTeam() == currentTurn) {
piece.calcPossibleMoves(this);
int i = 0;
ArrayList<Pos> moves = piece.getPossibleMoves();
while (i < moves.size()) {
Pos oldPos = piece.getPos();
int oldPiece = piece.setPos(moves.get(i), this);
ChessPiece justRemoved = null;
if (oldPiece > -1)
justRemoved = pieces.remove(oldPiece);
boolean found = false;
for (ChessPiece otherPiece : pieces) {
if (otherPiece.getTeam() != currentTurn && otherPiece.moveIsValid(this, currentKing.getPos()) && !found) {
moves.remove(i);
found = true;
}
}
if (!found)
i++;
piece.setPos(oldPos, this);
if (justRemoved != null)
pieces.add(justRemoved);
}
}
}
}
public void addPiece(ChessPiece piece) {
pieces.add(piece);
}
public boolean inCheck(Team team, Pos kingPos) {
for (ChessPiece piece : pieces) {
if (piece.getTeam() != team && piece.moveIsValid(this, kingPos))
return true;
}
return false;
}
public ChessPiece getPiece(int index) {
return pieces.get(index);
}
public ChessPiece removePiece(Pos piecePos) {
int removeIndex = indexAtPos(piecePos);
if (removeIndex > -1)
return pieces.remove(removeIndex);
return null;
}
public int size() {
return pieces.size();
}
public int indexAtPos(Pos pos) {
for (int i = 0; i < pieces.size(); i++)
if (pieces.get(i).getPos().equals(pos))
return i;
return -1;
}
public int indexAtPos(int row, int col) {
for (int i = 0; i < pieces.size(); i++) {
Pos nextPos = pieces.get(i).getPos();
if (nextPos.getRow() == row && nextPos.getCol() == col)
return i;
}
return -1;
}
public King getKing(Team team) {
if (team == Team.WHITE)
return whiteKing;
return blackKing;
}
public int getSide(Team team) {
if (team == Team.WHITE)
return 0;
return 7;
}
public ChessPiece getCurrentPiece() {
if (getPiece)
return null;
return currentPiece;
}
public boolean posInBounds(Pos pos) {
return pos.getRow() < BOARD_SIZE && pos.getRow() >= 0 && pos.getCol() < BOARD_SIZE && pos.getCol() >= 0;
}
public int getTurn() {
return turnCount;
}
public ChessPiece getLastRemoved() {
return lastRemoved;
}
}
|
UTF-8
|
Java
| 6,184 |
java
|
ChessBoard.java
|
Java
|
[] | null |
[] |
import java.util.ArrayList;
public class ChessBoard {
private static final int BOARD_SIZE = 8;
private ArrayList<ChessPiece> pieces;
private ChessPiece currentPiece;
private ChessPiece lastPiece;
private ChessPiece lastRemoved;
private boolean getPiece;
private boolean gameOver;
private Team currentTurn;
private Team loser;
private King whiteKing;
private King blackKing;
private int turnCount;
public ChessBoard(King white, King black) {
pieces = new ArrayList<ChessPiece>();
lastRemoved = null;
lastPiece = null;
whiteKing = white;
blackKing = black;
getPiece = true;
gameOver = false;
currentTurn = Team.WHITE;
loser = null;
turnCount = 1;
}
public static ChessBoard initGame() {
King white = new King(Team.WHITE, 0, 4);
King black = new King(Team.BLACK, 7, 4);
ChessBoard newBoard = new ChessBoard(white, black);
newBoard.pieces.add(white);
newBoard.pieces.add(black);
newBoard.pieces.add(new Queen(Team.WHITE, 0, 3));
newBoard.pieces.add(new Queen(Team.BLACK, 7, 3));
newBoard.pieces.add(new Bishop(Team.WHITE, 0, 2));
newBoard.pieces.add(new Bishop(Team.WHITE, 0, 5));
newBoard.pieces.add(new Bishop(Team.BLACK, 7, 2));
newBoard.pieces.add(new Bishop(Team.BLACK, 7, 5));
newBoard.pieces.add(new Knight(Team.WHITE, 0, 1));
newBoard.pieces.add(new Knight(Team.WHITE, 0, 6));
newBoard.pieces.add(new Knight(Team.BLACK, 7, 1));
newBoard.pieces.add(new Knight(Team.BLACK, 7, 6));
newBoard.pieces.add(new Rook(Team.WHITE, 0, 0));
newBoard.pieces.add(new Rook(Team.WHITE, 0, 7));
newBoard.pieces.add(new Rook(Team.BLACK, 7, 0));
newBoard.pieces.add(new Rook(Team.BLACK, 7, 7));
for (int i = 0; i < 8; i++) {
newBoard.pieces.add(new Pawn(Team.WHITE, 1, i));
newBoard.pieces.add(new Pawn(Team.BLACK, 6, i));
}
newBoard.calcAllMoves();
return newBoard;
}
public void processMove(int row, int col) {
if (row < BOARD_SIZE && col < BOARD_SIZE) {
Pos pos = new Pos(row, col);
if (getPiece) {
int foundPiece = indexAtPos(pos);
if (foundPiece > -1 && getPiece(foundPiece).getTeam() == currentTurn) {
currentPiece = getPiece(foundPiece);
getPiece = false;
}
} else {
if (currentPiece.moveIsPossible(pos)) {
int oldPiece = currentPiece.move(pos, this);
if (oldPiece > -1) {
lastRemoved = pieces.remove(oldPiece);
} else {
lastRemoved = null;
}
if (currentTurn == Team.WHITE)
currentTurn = Team.BLACK;
else
currentTurn = Team.WHITE;
calcAllMoves();
turnCount++;
if (noPossibleMoves()) {
gameOver = true;
if (inCheck(currentTurn, getKing(currentTurn).getPos())) {
loser = currentTurn;
} else {
System.out.println("It's a Stalemate!");
}
}
lastPiece = currentPiece;
getPiece = true;
} else if (currentPiece.getPos().equals(pos)) {
getPiece = true;
}
}
}
}
public String getMessage() {
if (gameOver) {
if (loser == Team.WHITE) {
return "Checkmate! Black Wins!";
} else if (loser == Team.BLACK) {
return "Checkmate! White Wins!";
} else {
return "Stalemate! How Unfortunate.";
}
} else {
if (currentTurn == Team.WHITE) {
return "White's Turn";
} else {
return "Black's Turn";
}
}
}
public void undoMove() {
if (lastPiece != null) {
lastPiece.unmove(this);
if (lastRemoved != null) {
pieces.add(lastRemoved);
lastRemoved = null;
}
currentTurn = lastPiece.getTeam();
}
getPiece = true;
}
public boolean noPossibleMoves() {
for (ChessPiece piece : pieces) {
if (piece.getTeam() == currentTurn && !piece.getPossibleMoves().isEmpty())
return false;
}
return true;
}
public boolean gameOver() {
return gameOver;
}
public void calcAllMoves() {
King currentKing = getKing(currentTurn);
for (int p = 0; p < pieces.size(); p++) {
ChessPiece piece = pieces.get(p);
if (piece.getTeam() == currentTurn) {
piece.calcPossibleMoves(this);
int i = 0;
ArrayList<Pos> moves = piece.getPossibleMoves();
while (i < moves.size()) {
Pos oldPos = piece.getPos();
int oldPiece = piece.setPos(moves.get(i), this);
ChessPiece justRemoved = null;
if (oldPiece > -1)
justRemoved = pieces.remove(oldPiece);
boolean found = false;
for (ChessPiece otherPiece : pieces) {
if (otherPiece.getTeam() != currentTurn && otherPiece.moveIsValid(this, currentKing.getPos()) && !found) {
moves.remove(i);
found = true;
}
}
if (!found)
i++;
piece.setPos(oldPos, this);
if (justRemoved != null)
pieces.add(justRemoved);
}
}
}
}
public void addPiece(ChessPiece piece) {
pieces.add(piece);
}
public boolean inCheck(Team team, Pos kingPos) {
for (ChessPiece piece : pieces) {
if (piece.getTeam() != team && piece.moveIsValid(this, kingPos))
return true;
}
return false;
}
public ChessPiece getPiece(int index) {
return pieces.get(index);
}
public ChessPiece removePiece(Pos piecePos) {
int removeIndex = indexAtPos(piecePos);
if (removeIndex > -1)
return pieces.remove(removeIndex);
return null;
}
public int size() {
return pieces.size();
}
public int indexAtPos(Pos pos) {
for (int i = 0; i < pieces.size(); i++)
if (pieces.get(i).getPos().equals(pos))
return i;
return -1;
}
public int indexAtPos(int row, int col) {
for (int i = 0; i < pieces.size(); i++) {
Pos nextPos = pieces.get(i).getPos();
if (nextPos.getRow() == row && nextPos.getCol() == col)
return i;
}
return -1;
}
public King getKing(Team team) {
if (team == Team.WHITE)
return whiteKing;
return blackKing;
}
public int getSide(Team team) {
if (team == Team.WHITE)
return 0;
return 7;
}
public ChessPiece getCurrentPiece() {
if (getPiece)
return null;
return currentPiece;
}
public boolean posInBounds(Pos pos) {
return pos.getRow() < BOARD_SIZE && pos.getRow() >= 0 && pos.getCol() < BOARD_SIZE && pos.getCol() >= 0;
}
public int getTurn() {
return turnCount;
}
public ChessPiece getLastRemoved() {
return lastRemoved;
}
}
| 6,184 | 0.63632 | 0.627911 | 246 | 24.138212 | 19.083397 | 112 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.227642 | false | false |
13
|
94c54a03bcf292d2bc2f533aa9268ace45ac2c8d
| 22,110,491,670,896 |
739d6a2e387e7f62a4abacdc18fcd106cc57cafc
|
/app/src/main/java/com/autumntechcreation/click4panditcustomer/ui/addupdateremoveaddress/AddUpdateRemoveFragment.java
|
fa512ae459a794870c2b4292b76e81b6c3eb2f1e
|
[] |
no_license
|
soumen81/click4pandit_update
|
https://github.com/soumen81/click4pandit_update
|
226075588bb231f3be947a47cb67c47899de0d5c
|
3fc5f966d693955f48a137a49ee513bdb8985696
|
refs/heads/main
| 2023-07-31T06:40:58.950000 | 2021-09-20T08:29:12 | 2021-09-20T08:29:12 | 408,363,275 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.autumntechcreation.click4panditcustomer.ui.addupdateremoveaddress;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelProviders;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import com.autumntechcreation.click4panditcustomer.MainActivity;
import com.autumntechcreation.click4panditcustomer.R;
import com.autumntechcreation.click4panditcustomer.databinding.FragmentAddupdateremoveBinding;
import com.autumntechcreation.click4panditcustomer.di.Injectable;
import com.autumntechcreation.click4panditcustomer.loader.DisplayDialog;
import com.autumntechcreation.click4panditcustomer.network.Resource;
import com.autumntechcreation.click4panditcustomer.ui.address.AddressFragment;
import com.autumntechcreation.click4panditcustomer.ui.address.AddressViewModel;
import com.autumntechcreation.click4panditcustomer.ui.billingdetails.BillingDetailsFragment;
import com.autumntechcreation.click4panditcustomer.ui.billingdetails.BillingDetailsFragmentArgs;
import com.autumntechcreation.click4panditcustomer.ui.billingdetails.ProceedtoPayModel;
import com.autumntechcreation.click4panditcustomer.ui.bookpuja.BookingPujaFragmentArgs;
import com.autumntechcreation.click4panditcustomer.util.Static;
import com.google.gson.Gson;
import org.json.JSONException;
import org.json.JSONObject;
import javax.inject.Inject;
import cn.pedant.SweetAlert.SweetAlertDialog;
import static androidx.navigation.Navigation.findNavController;
public class AddUpdateRemoveFragment extends Fragment implements Injectable {
@Inject
public ViewModelProvider.Factory viewModelFactory;
FragmentAddupdateremoveBinding mFragmentAddupdateremoveBinding;
AddUpdateRemoveViewModel mAddUpdateRemoveViewModel;
private View mView;
NavController navController;
String addAction="",updateAction="",removeAction="",getFirstName,getLastName,getAddress1,getAddress2,getAddress3,getCity,
getState,getPincode,updtStamp,orglStamp;
int shippingAddressId,custMasterId;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
mFragmentAddupdateremoveBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_addupdateremove, container, false);
mFragmentAddupdateremoveBinding.setLifecycleOwner(this);
if(AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getFirstName().length()>0) {
getFirstName = AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getFirstName();
Log.e("getFirstName", "" + getFirstName);
} if(AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getLastName().length()>0) {
getLastName = AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getLastName();
Log.e("getLastName", "" + getLastName);
} if(AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getAddress1().length()>0) {
getAddress1 = AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getAddress1();
Log.e("getAddress1", "" + getAddress1);
} if(AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getAddress2().length()>0 ||AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getAddress2()!=null) {
getAddress2 = AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getAddress2();
Log.e("getAddress2", "" + getAddress2);
} else{
getAddress2="";
}
if(AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getAddress3().length()>0) {
getAddress3 = AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getAddress3();
Log.e("getAddress3", "" + getAddress3);
} else{
getAddress3="";
}
if(AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getCity().length()>0) {
getCity = AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getCity();
Log.e("getCity", "" + getCity);
} if(AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getState().length()>0) {
getState = AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getState();
Log.e("getState", "" + getState);
} if(AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getPincode().length()>0) {
getPincode = AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getPincode();
Log.e("getPincode", "" + getPincode);
}if(AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getShippingAddressId()!=0){
shippingAddressId=AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getShippingAddressId();
}if(AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getCustMasterId()!=0){
custMasterId=AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getCustMasterId();
} if(AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getUpdtStamp().length()>0) {
updtStamp = AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getUpdtStamp();
Log.e("updtStamp", "" + updtStamp);
} if(AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getOrglStamp().length()>0) {
orglStamp = AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getOrglStamp();
Log.e("orglStamp", "" + orglStamp);
}
addAction = AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getAddAction();
Log.e("addAction", "" + addAction);
if(addAction.equals("ADD")) {
mFragmentAddupdateremoveBinding.tvUpdateConfirm.setVisibility(View.GONE);
mFragmentAddupdateremoveBinding.removeConfirm.setVisibility(View.GONE);
mFragmentAddupdateremoveBinding.tvAddConfirm.setVisibility(View.VISIBLE);
mFragmentAddupdateremoveBinding.edtTxtCity.setText("Kolkata");
mFragmentAddupdateremoveBinding.edtTxtState.setText("West Bengal");
}
updateAction = AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getUpdateAction();
Log.e("updateAction", "" + updateAction);
if(updateAction.equals("UPDATE")) {
mFragmentAddupdateremoveBinding.tvUpdateConfirm.setVisibility(View.VISIBLE);
mFragmentAddupdateremoveBinding.removeConfirm.setVisibility(View.GONE);
mFragmentAddupdateremoveBinding.tvAddConfirm.setVisibility(View.GONE);
mFragmentAddupdateremoveBinding.edtTxtFirstName.setText(getFirstName);
mFragmentAddupdateremoveBinding.edtTxtLastName.setText(getLastName);
mFragmentAddupdateremoveBinding.edtTxtAddress1.setText(getAddress1);
if(getAddress2.equals("null")){
mFragmentAddupdateremoveBinding.edtTxtAddress2.setText("");
}else{
mFragmentAddupdateremoveBinding.edtTxtAddress2.setText(getAddress2);
} if(getAddress3.equals("null")){
mFragmentAddupdateremoveBinding.edtTxtAddress3.setText("");
}else{
mFragmentAddupdateremoveBinding.edtTxtAddress3.setText(getAddress3);
}
mFragmentAddupdateremoveBinding.edtTxtCity.setText("Kolkata");
mFragmentAddupdateremoveBinding.edtTxtState.setText("West Bengal");
mFragmentAddupdateremoveBinding.edtTxtPinCode.setText(getPincode);
}
removeAction = AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getRemoveAction();
Log.e("removeAction", "" + removeAction);
if(removeAction.equals("DELETE")) {
mFragmentAddupdateremoveBinding.tvUpdateConfirm.setVisibility(View.GONE);
mFragmentAddupdateremoveBinding.removeConfirm.setVisibility(View.VISIBLE);
mFragmentAddupdateremoveBinding.tvAddConfirm.setVisibility(View.GONE);
mFragmentAddupdateremoveBinding.edtTxtFirstName.setText(getFirstName);
mFragmentAddupdateremoveBinding.edtTxtLastName.setText(getLastName);
mFragmentAddupdateremoveBinding.edtTxtAddress1.setText(getAddress1);
mFragmentAddupdateremoveBinding.edtTxtAddress2.setText(getAddress2);
mFragmentAddupdateremoveBinding.edtTxtAddress3.setText(getAddress3);
mFragmentAddupdateremoveBinding.edtTxtCity.setText("Kolkata");
mFragmentAddupdateremoveBinding.edtTxtState.setText("West Bengal");
mFragmentAddupdateremoveBinding.edtTxtPinCode.setText(getPincode);
}
return mFragmentAddupdateremoveBinding.getRoot();
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mView = view;
navController=findNavController(mView);
((MainActivity) getActivity()).setToolbar(false,true,false,false);
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mAddUpdateRemoveViewModel = ViewModelProviders.of(AddUpdateRemoveFragment.this, viewModelFactory).get(AddUpdateRemoveViewModel.class);
mFragmentAddupdateremoveBinding.setAddUpdateRemoveViewModel(mAddUpdateRemoveViewModel);
mFragmentAddupdateremoveBinding.tvAddConfirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(mFragmentAddupdateremoveBinding.edtTxtFirstName.getText().toString().trim().equals("")){
new SweetAlertDialog(getActivity(), SweetAlertDialog.ERROR_TYPE)
.setTitleText("Error")
.setContentText("Please Enter First Name...")
.show();
} else if(mFragmentAddupdateremoveBinding.edtTxtLastName.getText().toString().trim().equals("")){
new SweetAlertDialog(getActivity(), SweetAlertDialog.ERROR_TYPE)
.setTitleText("Error")
.setContentText("Please Enter Last Name...")
.show();
}else if(mFragmentAddupdateremoveBinding.edtTxtAddress1.getText().toString().trim().equals("")){
new SweetAlertDialog(getActivity(), SweetAlertDialog.ERROR_TYPE)
.setTitleText("Error")
.setContentText("Please Enter Address1...")
.show();
}
else if(mFragmentAddupdateremoveBinding.edtTxtCity.getText().toString().trim().equals("")){
new SweetAlertDialog(getActivity(), SweetAlertDialog.ERROR_TYPE)
.setTitleText("Error")
.setContentText("Please Enter City...")
.show();
}
else if(mFragmentAddupdateremoveBinding.edtTxtState.getText().toString().trim().equals("")){
new SweetAlertDialog(getActivity(), SweetAlertDialog.ERROR_TYPE)
.setTitleText("Error")
.setContentText("Please Enter State...")
.show();
} else if(mFragmentAddupdateremoveBinding.edtTxtPinCode.getText().toString().trim().equals("")||(mFragmentAddupdateremoveBinding.edtTxtPinCode.getText().toString().length()<6)){
new SweetAlertDialog(getActivity(), SweetAlertDialog.ERROR_TYPE)
.setTitleText("Error")
.setContentText("Please Enter PinCode...")
.show();
}else{
mAddUpdateRemoveViewModel.getNewAddAddress(addAction,
mFragmentAddupdateremoveBinding.edtTxtFirstName.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtLastName.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtAddress1.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtAddress2.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtAddress3.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtPinCode.getText().toString()).observe(getActivity(), AddUpdateRemoveFragment.this::handleAddAdrress);
}
}
});
mFragmentAddupdateremoveBinding.tvUpdateConfirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mAddUpdateRemoveViewModel.getAddAddress(updateAction,shippingAddressId,custMasterId,orglStamp,
mFragmentAddupdateremoveBinding.edtTxtFirstName.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtLastName.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtAddress1.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtAddress2.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtAddress3.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtPinCode.getText().toString())
.observe(getActivity(), AddUpdateRemoveFragment.this::handleAddAdrress);
}
});
mFragmentAddupdateremoveBinding.removeConfirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mAddUpdateRemoveViewModel.getAddAddress(removeAction,shippingAddressId,custMasterId,orglStamp,
mFragmentAddupdateremoveBinding.edtTxtFirstName.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtLastName.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtAddress1.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtAddress2.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtAddress3.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtPinCode.getText().toString())
.observe(getActivity(), AddUpdateRemoveFragment.this::handleAddAdrress);
}
});
}
private void handleAddAdrress(Resource<AddAddressModel> resource) {
if (resource != null) {
switch (resource.status) {
case ERROR:
DisplayDialog.getInstance().dismissAlertDialog();
if (resource.message != null && resource.data==null) {
JSONObject jsonObject;
try {
jsonObject = new JSONObject(resource.message);
new SweetAlertDialog(getActivity(), SweetAlertDialog.ERROR_TYPE)
.setTitleText(jsonObject.getString("error"))
.setContentText(jsonObject.getString("error_description"))
.show();
} catch (JSONException e) {
new SweetAlertDialog(getActivity(), SweetAlertDialog.ERROR_TYPE)
.setTitleText("Error")
.setContentText("Unhandle Error")
.show();
}
} else if (!Static.isNetworkAvailable(getActivity()) && resource.data==null) {
new SweetAlertDialog(getActivity(), SweetAlertDialog.ERROR_TYPE)
.setTitleText(this.getString(R.string.nointernet))
.setContentText(this.getString(R.string.nointernetdetails))
.show();
}
break;
case LOADING:
Log.e("handleRegisterResponse", "LOADING");
DisplayDialog.getInstance().showAlertDialog(getActivity(), getActivity().getString(R.string.please_wait));
break;
case SUCCESS:
Log.e("handleRegisterResponse", "SUCCESS");
// Log.e("handleLoginResponse",resource.message);
Log.e("handleRegisterResponse", resource.status + "");
Log.e("handleRegisterResponse", resource.data + "");
Gson gson = new Gson();
String json = gson.toJson(resource.data);
Log.e("handleRegisterResponse", json + "");
if ( resource.data.returnStatus.equals("SUCCESS")) {
AddUpdateRemoveFragmentDirections.ActionAddUpdateRemoveFragmentToAddressFragment action=
AddUpdateRemoveFragmentDirections.actionAddUpdateRemoveFragmentToAddressFragment();
Navigation.findNavController(mView).navigate(action);
}
DisplayDialog.getInstance().dismissAlertDialog();
break;
default:
DisplayDialog.getInstance().dismissAlertDialog();
break;
}
}
}
}
|
UTF-8
|
Java
| 17,778 |
java
|
AddUpdateRemoveFragment.java
|
Java
|
[] | null |
[] |
package com.autumntechcreation.click4panditcustomer.ui.addupdateremoveaddress;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelProviders;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import com.autumntechcreation.click4panditcustomer.MainActivity;
import com.autumntechcreation.click4panditcustomer.R;
import com.autumntechcreation.click4panditcustomer.databinding.FragmentAddupdateremoveBinding;
import com.autumntechcreation.click4panditcustomer.di.Injectable;
import com.autumntechcreation.click4panditcustomer.loader.DisplayDialog;
import com.autumntechcreation.click4panditcustomer.network.Resource;
import com.autumntechcreation.click4panditcustomer.ui.address.AddressFragment;
import com.autumntechcreation.click4panditcustomer.ui.address.AddressViewModel;
import com.autumntechcreation.click4panditcustomer.ui.billingdetails.BillingDetailsFragment;
import com.autumntechcreation.click4panditcustomer.ui.billingdetails.BillingDetailsFragmentArgs;
import com.autumntechcreation.click4panditcustomer.ui.billingdetails.ProceedtoPayModel;
import com.autumntechcreation.click4panditcustomer.ui.bookpuja.BookingPujaFragmentArgs;
import com.autumntechcreation.click4panditcustomer.util.Static;
import com.google.gson.Gson;
import org.json.JSONException;
import org.json.JSONObject;
import javax.inject.Inject;
import cn.pedant.SweetAlert.SweetAlertDialog;
import static androidx.navigation.Navigation.findNavController;
public class AddUpdateRemoveFragment extends Fragment implements Injectable {
@Inject
public ViewModelProvider.Factory viewModelFactory;
FragmentAddupdateremoveBinding mFragmentAddupdateremoveBinding;
AddUpdateRemoveViewModel mAddUpdateRemoveViewModel;
private View mView;
NavController navController;
String addAction="",updateAction="",removeAction="",getFirstName,getLastName,getAddress1,getAddress2,getAddress3,getCity,
getState,getPincode,updtStamp,orglStamp;
int shippingAddressId,custMasterId;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
mFragmentAddupdateremoveBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_addupdateremove, container, false);
mFragmentAddupdateremoveBinding.setLifecycleOwner(this);
if(AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getFirstName().length()>0) {
getFirstName = AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getFirstName();
Log.e("getFirstName", "" + getFirstName);
} if(AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getLastName().length()>0) {
getLastName = AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getLastName();
Log.e("getLastName", "" + getLastName);
} if(AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getAddress1().length()>0) {
getAddress1 = AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getAddress1();
Log.e("getAddress1", "" + getAddress1);
} if(AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getAddress2().length()>0 ||AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getAddress2()!=null) {
getAddress2 = AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getAddress2();
Log.e("getAddress2", "" + getAddress2);
} else{
getAddress2="";
}
if(AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getAddress3().length()>0) {
getAddress3 = AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getAddress3();
Log.e("getAddress3", "" + getAddress3);
} else{
getAddress3="";
}
if(AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getCity().length()>0) {
getCity = AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getCity();
Log.e("getCity", "" + getCity);
} if(AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getState().length()>0) {
getState = AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getState();
Log.e("getState", "" + getState);
} if(AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getPincode().length()>0) {
getPincode = AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getPincode();
Log.e("getPincode", "" + getPincode);
}if(AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getShippingAddressId()!=0){
shippingAddressId=AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getShippingAddressId();
}if(AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getCustMasterId()!=0){
custMasterId=AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getCustMasterId();
} if(AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getUpdtStamp().length()>0) {
updtStamp = AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getUpdtStamp();
Log.e("updtStamp", "" + updtStamp);
} if(AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getOrglStamp().length()>0) {
orglStamp = AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getOrglStamp();
Log.e("orglStamp", "" + orglStamp);
}
addAction = AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getAddAction();
Log.e("addAction", "" + addAction);
if(addAction.equals("ADD")) {
mFragmentAddupdateremoveBinding.tvUpdateConfirm.setVisibility(View.GONE);
mFragmentAddupdateremoveBinding.removeConfirm.setVisibility(View.GONE);
mFragmentAddupdateremoveBinding.tvAddConfirm.setVisibility(View.VISIBLE);
mFragmentAddupdateremoveBinding.edtTxtCity.setText("Kolkata");
mFragmentAddupdateremoveBinding.edtTxtState.setText("West Bengal");
}
updateAction = AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getUpdateAction();
Log.e("updateAction", "" + updateAction);
if(updateAction.equals("UPDATE")) {
mFragmentAddupdateremoveBinding.tvUpdateConfirm.setVisibility(View.VISIBLE);
mFragmentAddupdateremoveBinding.removeConfirm.setVisibility(View.GONE);
mFragmentAddupdateremoveBinding.tvAddConfirm.setVisibility(View.GONE);
mFragmentAddupdateremoveBinding.edtTxtFirstName.setText(getFirstName);
mFragmentAddupdateremoveBinding.edtTxtLastName.setText(getLastName);
mFragmentAddupdateremoveBinding.edtTxtAddress1.setText(getAddress1);
if(getAddress2.equals("null")){
mFragmentAddupdateremoveBinding.edtTxtAddress2.setText("");
}else{
mFragmentAddupdateremoveBinding.edtTxtAddress2.setText(getAddress2);
} if(getAddress3.equals("null")){
mFragmentAddupdateremoveBinding.edtTxtAddress3.setText("");
}else{
mFragmentAddupdateremoveBinding.edtTxtAddress3.setText(getAddress3);
}
mFragmentAddupdateremoveBinding.edtTxtCity.setText("Kolkata");
mFragmentAddupdateremoveBinding.edtTxtState.setText("West Bengal");
mFragmentAddupdateremoveBinding.edtTxtPinCode.setText(getPincode);
}
removeAction = AddUpdateRemoveFragmentArgs.fromBundle(getArguments()).getRemoveAction();
Log.e("removeAction", "" + removeAction);
if(removeAction.equals("DELETE")) {
mFragmentAddupdateremoveBinding.tvUpdateConfirm.setVisibility(View.GONE);
mFragmentAddupdateremoveBinding.removeConfirm.setVisibility(View.VISIBLE);
mFragmentAddupdateremoveBinding.tvAddConfirm.setVisibility(View.GONE);
mFragmentAddupdateremoveBinding.edtTxtFirstName.setText(getFirstName);
mFragmentAddupdateremoveBinding.edtTxtLastName.setText(getLastName);
mFragmentAddupdateremoveBinding.edtTxtAddress1.setText(getAddress1);
mFragmentAddupdateremoveBinding.edtTxtAddress2.setText(getAddress2);
mFragmentAddupdateremoveBinding.edtTxtAddress3.setText(getAddress3);
mFragmentAddupdateremoveBinding.edtTxtCity.setText("Kolkata");
mFragmentAddupdateremoveBinding.edtTxtState.setText("West Bengal");
mFragmentAddupdateremoveBinding.edtTxtPinCode.setText(getPincode);
}
return mFragmentAddupdateremoveBinding.getRoot();
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mView = view;
navController=findNavController(mView);
((MainActivity) getActivity()).setToolbar(false,true,false,false);
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mAddUpdateRemoveViewModel = ViewModelProviders.of(AddUpdateRemoveFragment.this, viewModelFactory).get(AddUpdateRemoveViewModel.class);
mFragmentAddupdateremoveBinding.setAddUpdateRemoveViewModel(mAddUpdateRemoveViewModel);
mFragmentAddupdateremoveBinding.tvAddConfirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(mFragmentAddupdateremoveBinding.edtTxtFirstName.getText().toString().trim().equals("")){
new SweetAlertDialog(getActivity(), SweetAlertDialog.ERROR_TYPE)
.setTitleText("Error")
.setContentText("Please Enter First Name...")
.show();
} else if(mFragmentAddupdateremoveBinding.edtTxtLastName.getText().toString().trim().equals("")){
new SweetAlertDialog(getActivity(), SweetAlertDialog.ERROR_TYPE)
.setTitleText("Error")
.setContentText("Please Enter Last Name...")
.show();
}else if(mFragmentAddupdateremoveBinding.edtTxtAddress1.getText().toString().trim().equals("")){
new SweetAlertDialog(getActivity(), SweetAlertDialog.ERROR_TYPE)
.setTitleText("Error")
.setContentText("Please Enter Address1...")
.show();
}
else if(mFragmentAddupdateremoveBinding.edtTxtCity.getText().toString().trim().equals("")){
new SweetAlertDialog(getActivity(), SweetAlertDialog.ERROR_TYPE)
.setTitleText("Error")
.setContentText("Please Enter City...")
.show();
}
else if(mFragmentAddupdateremoveBinding.edtTxtState.getText().toString().trim().equals("")){
new SweetAlertDialog(getActivity(), SweetAlertDialog.ERROR_TYPE)
.setTitleText("Error")
.setContentText("Please Enter State...")
.show();
} else if(mFragmentAddupdateremoveBinding.edtTxtPinCode.getText().toString().trim().equals("")||(mFragmentAddupdateremoveBinding.edtTxtPinCode.getText().toString().length()<6)){
new SweetAlertDialog(getActivity(), SweetAlertDialog.ERROR_TYPE)
.setTitleText("Error")
.setContentText("Please Enter PinCode...")
.show();
}else{
mAddUpdateRemoveViewModel.getNewAddAddress(addAction,
mFragmentAddupdateremoveBinding.edtTxtFirstName.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtLastName.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtAddress1.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtAddress2.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtAddress3.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtPinCode.getText().toString()).observe(getActivity(), AddUpdateRemoveFragment.this::handleAddAdrress);
}
}
});
mFragmentAddupdateremoveBinding.tvUpdateConfirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mAddUpdateRemoveViewModel.getAddAddress(updateAction,shippingAddressId,custMasterId,orglStamp,
mFragmentAddupdateremoveBinding.edtTxtFirstName.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtLastName.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtAddress1.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtAddress2.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtAddress3.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtPinCode.getText().toString())
.observe(getActivity(), AddUpdateRemoveFragment.this::handleAddAdrress);
}
});
mFragmentAddupdateremoveBinding.removeConfirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mAddUpdateRemoveViewModel.getAddAddress(removeAction,shippingAddressId,custMasterId,orglStamp,
mFragmentAddupdateremoveBinding.edtTxtFirstName.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtLastName.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtAddress1.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtAddress2.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtAddress3.getText().toString(),
mFragmentAddupdateremoveBinding.edtTxtPinCode.getText().toString())
.observe(getActivity(), AddUpdateRemoveFragment.this::handleAddAdrress);
}
});
}
private void handleAddAdrress(Resource<AddAddressModel> resource) {
if (resource != null) {
switch (resource.status) {
case ERROR:
DisplayDialog.getInstance().dismissAlertDialog();
if (resource.message != null && resource.data==null) {
JSONObject jsonObject;
try {
jsonObject = new JSONObject(resource.message);
new SweetAlertDialog(getActivity(), SweetAlertDialog.ERROR_TYPE)
.setTitleText(jsonObject.getString("error"))
.setContentText(jsonObject.getString("error_description"))
.show();
} catch (JSONException e) {
new SweetAlertDialog(getActivity(), SweetAlertDialog.ERROR_TYPE)
.setTitleText("Error")
.setContentText("Unhandle Error")
.show();
}
} else if (!Static.isNetworkAvailable(getActivity()) && resource.data==null) {
new SweetAlertDialog(getActivity(), SweetAlertDialog.ERROR_TYPE)
.setTitleText(this.getString(R.string.nointernet))
.setContentText(this.getString(R.string.nointernetdetails))
.show();
}
break;
case LOADING:
Log.e("handleRegisterResponse", "LOADING");
DisplayDialog.getInstance().showAlertDialog(getActivity(), getActivity().getString(R.string.please_wait));
break;
case SUCCESS:
Log.e("handleRegisterResponse", "SUCCESS");
// Log.e("handleLoginResponse",resource.message);
Log.e("handleRegisterResponse", resource.status + "");
Log.e("handleRegisterResponse", resource.data + "");
Gson gson = new Gson();
String json = gson.toJson(resource.data);
Log.e("handleRegisterResponse", json + "");
if ( resource.data.returnStatus.equals("SUCCESS")) {
AddUpdateRemoveFragmentDirections.ActionAddUpdateRemoveFragmentToAddressFragment action=
AddUpdateRemoveFragmentDirections.actionAddUpdateRemoveFragmentToAddressFragment();
Navigation.findNavController(mView).navigate(action);
}
DisplayDialog.getInstance().dismissAlertDialog();
break;
default:
DisplayDialog.getInstance().dismissAlertDialog();
break;
}
}
}
}
| 17,778 | 0.649961 | 0.645742 | 323 | 54.040249 | 38.452755 | 193 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.705882 | false | false |
13
|
dadbdf1608cd913573634cc6fb9220bd121ad108
| 26,285,199,912,633 |
5c318927e52bced5b44b34c6ee9de0c12b839f22
|
/absir-developer/src/main/java/com/absir/appserv/system/bean/base/JbPermission.java
|
6005ccec9031ba286f958a1b1db9313d1d55ef9b
|
[
"Apache-2.0"
] |
permissive
|
linving/absir
|
https://github.com/linving/absir
|
5433e6fa7b38a21c6c05b83f840662aecb43dd90
|
6093620eda2071ff06df7f07eac09eca756b70c9
|
refs/heads/master
| 2020-04-06T04:19:13.726000 | 2015-07-22T05:39:21 | 2015-07-22T05:39:21 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/**
* Copyright 2013 ABSir's Studio
*
* All right reserved
*
* Create on 2013-3-8 下午12:43:09
*/
package com.absir.appserv.system.bean.base;
import javax.persistence.MappedSuperclass;
import com.absir.appserv.system.bean.proxy.JiUser;
import com.absir.appserv.system.bean.value.JaLang;
/**
* @author absir
*
*/
@MappedSuperclass
public class JbPermission extends JbAssoc implements JiUser {
@JaLang("关联用户")
private Long userId;
/*
* (non-Javadoc)
*
* @see com.absir.appserv.system.bean.proxy.JpUser#getUserId()
*/
@Override
public Long getUserId() {
return userId;
}
/*
* (non-Javadoc)
*
* @see com.absir.appserv.system.bean.proxy.JpUser#setUserId(java.lang.Long)
*/
@Override
public void setUserId(Long userId) {
this.userId = userId;
}
}
|
UTF-8
|
Java
| 800 |
java
|
JbPermission.java
|
Java
|
[
{
"context": ".appserv.system.bean.value.JaLang;\n\n/**\n * @author absir\n * \n */\n@MappedSuperclass\npublic class JbPermissi",
"end": 315,
"score": 0.9995193481445312,
"start": 310,
"tag": "USERNAME",
"value": "absir"
}
] | null |
[] |
/**
* Copyright 2013 ABSir's Studio
*
* All right reserved
*
* Create on 2013-3-8 下午12:43:09
*/
package com.absir.appserv.system.bean.base;
import javax.persistence.MappedSuperclass;
import com.absir.appserv.system.bean.proxy.JiUser;
import com.absir.appserv.system.bean.value.JaLang;
/**
* @author absir
*
*/
@MappedSuperclass
public class JbPermission extends JbAssoc implements JiUser {
@JaLang("关联用户")
private Long userId;
/*
* (non-Javadoc)
*
* @see com.absir.appserv.system.bean.proxy.JpUser#getUserId()
*/
@Override
public Long getUserId() {
return userId;
}
/*
* (non-Javadoc)
*
* @see com.absir.appserv.system.bean.proxy.JpUser#setUserId(java.lang.Long)
*/
@Override
public void setUserId(Long userId) {
this.userId = userId;
}
}
| 800 | 0.695431 | 0.675127 | 44 | 16.90909 | 19.736696 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.659091 | false | false |
10
|
8c71b9dbae89ba0bb908a7187e7b4c1ff348acf4
| 1,039,382,135,753 |
bea6aee94edfc45aeec76f1d7efd9db7b6ff781c
|
/src/MaxOccurence.java
|
1a31ec284944c30dd29cf5d7f517bf6ccdfc795f
|
[] |
no_license
|
abhishekbhandari22/hacker-earth
|
https://github.com/abhishekbhandari22/hacker-earth
|
5f881dbbd0fff491d9f3287cd4ab385757f1d233
|
f7c7942833f16404a63296283fe516dcfbfc7923
|
refs/heads/master
| 2021-01-10T14:47:45.227000 | 2016-01-14T17:50:24 | 2016-01-14T17:50:24 | 49,583,571 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* Works completely fine
* Created by Abhishek Bhandari 20/12/2015
*
* */
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.Scanner;
import java.util.Vector;
class MaxOccurence {
static class Alphabet implements Comparable<Alphabet>{
char lab;
int count;
public Alphabet(char lab){
this.lab=lab;
this.count=1;
}
@Override
public int compareTo(Alphabet o) {
// TODO Auto-generated method stub
if(this.count==o.count)
return this.lab-o.lab;
return o.count-this.count;
}
}//end of class number
public static void main(String[] args){
Scanner scanner= new Scanner(new InputStreamReader(System.in));
char[] arr = scanner.nextLine().toCharArray();
Vector<Alphabet> v = new Vector<Alphabet>();
for(int i=0;i<arr.length;i++){
char temp = arr[i];
boolean jump = false;
for(int j=0;j<v.size();j++){
Alphabet alpha =v.get(j);
if(alpha.lab==temp){
alpha.count++;
jump=true;
break;
}
}//end of inner loop
if(!jump){
v.add(new Alphabet(temp));
}
}//end of outer loop
Collections.sort(v);
System.out.println(v.get(0).lab +" "+v.get(0).count);
scanner.close();
}//end of main
}
|
UTF-8
|
Java
| 1,221 |
java
|
MaxOccurence.java
|
Java
|
[
{
"context": "/*\n * Works completely fine \n * Created by Abhishek Bhandari 20/12/2015\n * \n * */\nimport java.io.InputStreamRe",
"end": 60,
"score": 0.9998822212219238,
"start": 43,
"tag": "NAME",
"value": "Abhishek Bhandari"
}
] | null |
[] |
/*
* Works completely fine
* Created by <NAME> 20/12/2015
*
* */
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.Scanner;
import java.util.Vector;
class MaxOccurence {
static class Alphabet implements Comparable<Alphabet>{
char lab;
int count;
public Alphabet(char lab){
this.lab=lab;
this.count=1;
}
@Override
public int compareTo(Alphabet o) {
// TODO Auto-generated method stub
if(this.count==o.count)
return this.lab-o.lab;
return o.count-this.count;
}
}//end of class number
public static void main(String[] args){
Scanner scanner= new Scanner(new InputStreamReader(System.in));
char[] arr = scanner.nextLine().toCharArray();
Vector<Alphabet> v = new Vector<Alphabet>();
for(int i=0;i<arr.length;i++){
char temp = arr[i];
boolean jump = false;
for(int j=0;j<v.size();j++){
Alphabet alpha =v.get(j);
if(alpha.lab==temp){
alpha.count++;
jump=true;
break;
}
}//end of inner loop
if(!jump){
v.add(new Alphabet(temp));
}
}//end of outer loop
Collections.sort(v);
System.out.println(v.get(0).lab +" "+v.get(0).count);
scanner.close();
}//end of main
}
| 1,210 | 0.645373 | 0.634726 | 56 | 20.785715 | 15.522696 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.482143 | false | false |
10
|
c0164636c39c964bcf295d08bec590d04dcec5db
| 21,096,879,399,705 |
c40f1ad7f40f452950b5f343816ba8119638ce41
|
/Vehicles/src/main/java/sii/maroc/vehicle/parameters/ConsumptionParam.java
|
38f90f5b2247d4b1663feb919ea4860700b50306
|
[] |
no_license
|
selharrak/test-driven-development
|
https://github.com/selharrak/test-driven-development
|
66c50601d89ea4abe5ad5d5a39efcc41d7167af8
|
2a71dde7f743850f06ac982c0f2f855c8027ee81
|
refs/heads/master
| 2016-08-09T08:11:03.147000 | 2016-03-09T16:40:14 | 2016-03-09T16:40:14 | 53,517,211 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package sii.maroc.vehicle.parameters;
import sii.maroc.provider.VehicleParser;
import sii.maroc.vehicle.Vehicle;
public final class ConsumptionParam extends Parameters{
private final Double consumption;
public ConsumptionParam(final Vehicle vehicle, final String distanceInKm) {
final Double distance = VehicleParser.getInstance().convertTo(distanceInKm);
this.consumption = vehicle.calculateConsumption(distance);
}
@Override
public String getMessage() {
final String newConsumption = VehicleParser.getInstance().format(consumption);
return String.format("will consume %s L", newConsumption);
}
}
|
UTF-8
|
Java
| 618 |
java
|
ConsumptionParam.java
|
Java
|
[] | null |
[] |
package sii.maroc.vehicle.parameters;
import sii.maroc.provider.VehicleParser;
import sii.maroc.vehicle.Vehicle;
public final class ConsumptionParam extends Parameters{
private final Double consumption;
public ConsumptionParam(final Vehicle vehicle, final String distanceInKm) {
final Double distance = VehicleParser.getInstance().convertTo(distanceInKm);
this.consumption = vehicle.calculateConsumption(distance);
}
@Override
public String getMessage() {
final String newConsumption = VehicleParser.getInstance().format(consumption);
return String.format("will consume %s L", newConsumption);
}
}
| 618 | 0.796117 | 0.796117 | 20 | 29.9 | 29.091064 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.2 | false | false |
10
|
51525f5441b3f93b0f58ac5b338f8aa778c532fe
| 1,176,821,088,002 |
ee158b4b49a2400b4e6ce7cf7f6f1ffe067425de
|
/app/src/main/java/fr/esiea/ferre/usefuel/UserActivities/MapActivity.java
|
486049f4ab482746606b1957c7b4ac1195b11c2d
|
[] |
no_license
|
6305527396/usefuel
|
https://github.com/6305527396/usefuel
|
3f7a33f27ff18868fb5018b2eb5f415ee1980462
|
5e6c5d889bbdc8f4923b56ef81eaa83536c7528b
|
refs/heads/master
| 2021-12-16T07:18:31.615000 | 2017-07-26T22:10:27 | 2017-07-26T22:10:27 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package fr.esiea.ferre.usefuel.UserActivities;
import android.Manifest;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Address;
import android.location.Criteria;
import android.location.Geocoder;
import android.location.Location;
import android.location.LocationManager;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentActivity;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import java.io.IOException;
import java.util.List;
import fr.esiea.ferre.usefuel.R;
/**
* Created by rob on 6/27/2017.
*/
public class MapActivity extends FragmentActivity implements OnMapReadyCallback {
private DatabaseReference mDatabase;
private FirebaseAuth firebaseAuth;
private FirebaseUser firebaseUser;
private GoogleMap mMap;
private Marker marker;
Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
context = MapActivity.this;
firebaseAuth = FirebaseAuth.getInstance();
// If already connected
if (firebaseAuth.getCurrentUser() != null){
// Get the SupportMapFragment and request notification
// when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
updatePrintData();
}
public void onSearch(View view){
mDatabase = FirebaseDatabase.getInstance().getReference();
firebaseAuth = FirebaseAuth.getInstance();
FirebaseUser FireUser = firebaseAuth.getCurrentUser();
EditText location_tf = (EditText)findViewById(R.id.TFaddress);
String location = location_tf.getText().toString();
List<Address> addressList=null;
if (location != null || !location.equals("")){
Geocoder geocoder = new Geocoder(this);
try {
addressList = geocoder.getFromLocationName(location, 1);
} catch (IOException e) {
e.printStackTrace();
}
//TODO block if address is bullshit like "flekadhgljzhg" it crash
//show a marker from the address entered
Address address = addressList.get(0);
LatLng latLng = new LatLng(address.getLatitude(), address.getLongitude());
//adjust camera
CameraPosition myPosition = new CameraPosition.Builder().target(latLng).zoom(17).bearing(0).tilt(30).build();
mMap.animateCamera(CameraUpdateFactory.newCameraPosition(myPosition));
//place marker
if(marker == null){
marker = mMap.addMarker(new MarkerOptions().position(latLng).title("Address"));
}
else {
marker.setPosition(latLng);
}
//update database with the address entered
firebaseUser = firebaseAuth.getCurrentUser();
String uID = firebaseUser.getUid();
mDatabase.child("orders").child(uID).child("address").setValue(location);
mDatabase.child("orders").child(uID).child("lat").setValue(address.getLatitude());
mDatabase.child("orders").child(uID).child("lng").setValue(address.getLongitude());
//Hide keyboard after button
InputMethodManager inputManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
}
public void onReturn(View view)
{
firebaseUser = firebaseAuth.getCurrentUser();
String uID = firebaseUser.getUid();
mDatabase.child("orders").child(uID).child("address").setValue("none");
mDatabase.child("orders").child(uID).child("lat").setValue(0);
mDatabase.child("orders").child(uID).child("lng").setValue(0);
finish();
}
// Override onBack to do the same thing as onReturn
@Override
public void onBackPressed() {
firebaseUser = firebaseAuth.getCurrentUser();
String uID = firebaseUser.getUid();
mDatabase.child("orders").child(uID).child("address").setValue("none");
mDatabase.child("orders").child(uID).child("lat").setValue(0);
mDatabase.child("orders").child(uID).child("lng").setValue(0);
finish();
}
public void onBook(View view)
{
mDatabase = FirebaseDatabase.getInstance().getReference();
firebaseAuth = FirebaseAuth.getInstance();
FirebaseUser FireUser = firebaseAuth.getCurrentUser();
final String uid = FireUser.getUid().toString();
mDatabase.child("orders").child(uid).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String address = dataSnapshot.child("address").getValue(String.class);
//get searched address and place a marker
if(address.equals("none")){
final AlertDialog.Builder builderBook = new AlertDialog.Builder(MapActivity.this);
final AlertDialog myDialog;
builderBook.setTitle("Booking");
builderBook.setIcon(R.drawable.ic_menu_map);
builderBook.setMessage("Choose an address before booking");
//Button to decide what to do next
builderBook.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
//nothing here, just pass
}
});
myDialog = builderBook.create();
myDialog.show();
}
else{
startActivity(new Intent(getApplicationContext(),LoadingScreenBookActivity.class));
mDatabase.child("orders").child(uid).child("status").setValue("booking");
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
// Failed to read value
}
});
}
void updatePrintData(){
mDatabase = FirebaseDatabase.getInstance().getReference();
firebaseAuth = FirebaseAuth.getInstance();
FirebaseUser FireUser = firebaseAuth.getCurrentUser();
if(FireUser != null)
{
final String uid = FireUser.getUid().toString();
mDatabase.child("orders").child(uid).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String address = dataSnapshot.child("address").getValue(String.class);
//get searched address and place a marker
if(address != "none"){
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
// Failed to read value
}
});
}
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {
mMap.setMyLocationEnabled(true);
} else {
// Show rationale and request permission.
}
//Geolocalise l'utilisateur (Point bleu)
if(mMap!=null){
mMap.setMyLocationEnabled(true);
mMap.getMyLocation();
}
}
}
|
UTF-8
|
Java
| 9,532 |
java
|
MapActivity.java
|
Java
|
[
{
"context": "mport fr.esiea.ferre.usefuel.R;\n\n/**\n * Created by rob on 6/27/2017.\n */\n\npublic class MapActivity exten",
"end": 1631,
"score": 0.9987691044807434,
"start": 1628,
"tag": "USERNAME",
"value": "rob"
}
] | null |
[] |
package fr.esiea.ferre.usefuel.UserActivities;
import android.Manifest;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Address;
import android.location.Criteria;
import android.location.Geocoder;
import android.location.Location;
import android.location.LocationManager;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentActivity;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import java.io.IOException;
import java.util.List;
import fr.esiea.ferre.usefuel.R;
/**
* Created by rob on 6/27/2017.
*/
public class MapActivity extends FragmentActivity implements OnMapReadyCallback {
private DatabaseReference mDatabase;
private FirebaseAuth firebaseAuth;
private FirebaseUser firebaseUser;
private GoogleMap mMap;
private Marker marker;
Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
context = MapActivity.this;
firebaseAuth = FirebaseAuth.getInstance();
// If already connected
if (firebaseAuth.getCurrentUser() != null){
// Get the SupportMapFragment and request notification
// when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
updatePrintData();
}
public void onSearch(View view){
mDatabase = FirebaseDatabase.getInstance().getReference();
firebaseAuth = FirebaseAuth.getInstance();
FirebaseUser FireUser = firebaseAuth.getCurrentUser();
EditText location_tf = (EditText)findViewById(R.id.TFaddress);
String location = location_tf.getText().toString();
List<Address> addressList=null;
if (location != null || !location.equals("")){
Geocoder geocoder = new Geocoder(this);
try {
addressList = geocoder.getFromLocationName(location, 1);
} catch (IOException e) {
e.printStackTrace();
}
//TODO block if address is bullshit like "flekadhgljzhg" it crash
//show a marker from the address entered
Address address = addressList.get(0);
LatLng latLng = new LatLng(address.getLatitude(), address.getLongitude());
//adjust camera
CameraPosition myPosition = new CameraPosition.Builder().target(latLng).zoom(17).bearing(0).tilt(30).build();
mMap.animateCamera(CameraUpdateFactory.newCameraPosition(myPosition));
//place marker
if(marker == null){
marker = mMap.addMarker(new MarkerOptions().position(latLng).title("Address"));
}
else {
marker.setPosition(latLng);
}
//update database with the address entered
firebaseUser = firebaseAuth.getCurrentUser();
String uID = firebaseUser.getUid();
mDatabase.child("orders").child(uID).child("address").setValue(location);
mDatabase.child("orders").child(uID).child("lat").setValue(address.getLatitude());
mDatabase.child("orders").child(uID).child("lng").setValue(address.getLongitude());
//Hide keyboard after button
InputMethodManager inputManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
}
public void onReturn(View view)
{
firebaseUser = firebaseAuth.getCurrentUser();
String uID = firebaseUser.getUid();
mDatabase.child("orders").child(uID).child("address").setValue("none");
mDatabase.child("orders").child(uID).child("lat").setValue(0);
mDatabase.child("orders").child(uID).child("lng").setValue(0);
finish();
}
// Override onBack to do the same thing as onReturn
@Override
public void onBackPressed() {
firebaseUser = firebaseAuth.getCurrentUser();
String uID = firebaseUser.getUid();
mDatabase.child("orders").child(uID).child("address").setValue("none");
mDatabase.child("orders").child(uID).child("lat").setValue(0);
mDatabase.child("orders").child(uID).child("lng").setValue(0);
finish();
}
public void onBook(View view)
{
mDatabase = FirebaseDatabase.getInstance().getReference();
firebaseAuth = FirebaseAuth.getInstance();
FirebaseUser FireUser = firebaseAuth.getCurrentUser();
final String uid = FireUser.getUid().toString();
mDatabase.child("orders").child(uid).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String address = dataSnapshot.child("address").getValue(String.class);
//get searched address and place a marker
if(address.equals("none")){
final AlertDialog.Builder builderBook = new AlertDialog.Builder(MapActivity.this);
final AlertDialog myDialog;
builderBook.setTitle("Booking");
builderBook.setIcon(R.drawable.ic_menu_map);
builderBook.setMessage("Choose an address before booking");
//Button to decide what to do next
builderBook.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
//nothing here, just pass
}
});
myDialog = builderBook.create();
myDialog.show();
}
else{
startActivity(new Intent(getApplicationContext(),LoadingScreenBookActivity.class));
mDatabase.child("orders").child(uid).child("status").setValue("booking");
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
// Failed to read value
}
});
}
void updatePrintData(){
mDatabase = FirebaseDatabase.getInstance().getReference();
firebaseAuth = FirebaseAuth.getInstance();
FirebaseUser FireUser = firebaseAuth.getCurrentUser();
if(FireUser != null)
{
final String uid = FireUser.getUid().toString();
mDatabase.child("orders").child(uid).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String address = dataSnapshot.child("address").getValue(String.class);
//get searched address and place a marker
if(address != "none"){
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
// Failed to read value
}
});
}
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {
mMap.setMyLocationEnabled(true);
} else {
// Show rationale and request permission.
}
//Geolocalise l'utilisateur (Point bleu)
if(mMap!=null){
mMap.setMyLocationEnabled(true);
mMap.getMyLocation();
}
}
}
| 9,532 | 0.643831 | 0.641523 | 253 | 36.67984 | 29.958143 | 126 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.494071 | false | false |
10
|
474c9298e3bdfbc666447a9db0c0090c90bc3b0a
| 1,176,821,087,822 |
f4b113bfcd2ef1ef6a28c9324947e9b5d9532c10
|
/OfficeQueueManagement/workspace/QueueManagement/src/application/Controller.java
|
443107e5452a667229fdaf60b57ea26a002d3a67
|
[] |
no_license
|
ilagioda/SoftEng2
|
https://github.com/ilagioda/SoftEng2
|
f4b170cc45d8a137db3e2ed5ca016fcf4820db87
|
1c1a0ebb9dc23ba174686c23d13fe98e70bf77f8
|
refs/heads/master
| 2021-07-02T16:10:48.849000 | 2020-01-21T13:07:34 | 2020-01-21T13:07:34 | 213,958,412 | 0 | 0 | null | false | 2021-06-22T15:37:51 | 2019-10-09T15:43:31 | 2020-05-17T18:15:43 | 2021-06-22T15:37:48 | 11,526 | 0 | 0 | 31 |
PHP
| false | false |
package application;
/**
* Sample Skeleton for 'Screen.fxml' Controller Class
*/
import java.net.URL;
import java.util.ArrayList;
import java.util.ResourceBundle;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import model.Counter;
import model.Model;
import model.Ticket;
public class Controller {
Model model;
@FXML // ResourceBundle that was given to the FXMLLoader
private ResourceBundle resources;
@FXML // URL location of the FXML file that was given to the FXMLLoader
private URL location;
@FXML // fx:id="ticketC1"
private TextField ticketC1; // Value injected by FXMLLoader
@FXML // fx:id="ticketC2"
private TextField ticketC2; // Value injected by FXMLLoader
@FXML // fx:id="ticketC3"
private TextField ticketC3; // Value injected by FXMLLoader
@FXML // fx:id="queueA"
private TextArea queueA; // Value injected by FXMLLoader
@FXML // fx:id="queueB"
private TextArea queueB; // Value injected by FXMLLoader
@FXML // This method is called by the FXMLLoader when initialization is complete
void initialize() {
assert ticketC1 != null : "fx:id=\"ticketC1\" was not injected: check your FXML file 'Screen.fxml'.";
assert ticketC2 != null : "fx:id=\"ticketC2\" was not injected: check your FXML file 'Screen.fxml'.";
assert ticketC3 != null : "fx:id=\"ticketC3\" was not injected: check your FXML file 'Screen.fxml'.";
assert queueA != null : "fx:id=\"queueA\" was not injected: check your FXML file 'Screen.fxml'.";
assert queueB != null : "fx:id=\"queueB\" was not injected: check your FXML file 'Screen.fxml'.";
}
public void setModel(Model model) {
this.model = model;
// Listener : whenever the list of tickets related to service 1 changes the
// method onChanged is called.
model.getList1().addListener(new ListChangeListener<Ticket>() {
// This method updates the view by printing the new queue and the tickets served
// to the new counters.
@Override
public void onChanged(ListChangeListener.Change change) {
ObservableList<Ticket> lista1 = model.getList1();
queueA.clear();
if (!lista1.isEmpty()) {
for (Ticket t : lista1) {
if(t!=null)
queueA.appendText(t.toString() + System.lineSeparator());
}
}
updateCounters();
}
});
// Listener : whenever the list of tickets related to service 2 changes the
// method onChanged is called.
model.getList2().addListener(new ListChangeListener<Ticket>() {
// This method updates the view by printing the new queue and the tickets served
// to the new counters.
@Override
public void onChanged(ListChangeListener.Change change) {
ObservableList<Ticket> lista2 = model.getList2();
queueB.clear();
if (!lista2.isEmpty()) {
for (Ticket t : lista2) {
if(t!=null)
queueB.appendText(t.toString() + System.lineSeparator());
}
}
updateCounters();
}
});
}
// Method used to update the TextArea of the Counters by printing their current
// ticket
private void setTextCounter(int counterID, Ticket t) {
String text="Free";
if(t!= null)
text = t.toString().split("-")[0];
switch (counterID) {
case 0:
ticketC1.setText(text);
break;
case 1:
ticketC2.setText(text);
break;
case 2:
ticketC3.setText(text);
break;
}
}
// Method used to update the counters
private void updateCounters() {
ArrayList<Counter> counters = new ArrayList<Counter>(model.getCounters());
for (Counter c : counters) {
setTextCounter(c.getCounterId(), c.getTicket());
}
}
}
|
UTF-8
|
Java
| 3,860 |
java
|
Controller.java
|
Java
|
[] | null |
[] |
package application;
/**
* Sample Skeleton for 'Screen.fxml' Controller Class
*/
import java.net.URL;
import java.util.ArrayList;
import java.util.ResourceBundle;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import model.Counter;
import model.Model;
import model.Ticket;
public class Controller {
Model model;
@FXML // ResourceBundle that was given to the FXMLLoader
private ResourceBundle resources;
@FXML // URL location of the FXML file that was given to the FXMLLoader
private URL location;
@FXML // fx:id="ticketC1"
private TextField ticketC1; // Value injected by FXMLLoader
@FXML // fx:id="ticketC2"
private TextField ticketC2; // Value injected by FXMLLoader
@FXML // fx:id="ticketC3"
private TextField ticketC3; // Value injected by FXMLLoader
@FXML // fx:id="queueA"
private TextArea queueA; // Value injected by FXMLLoader
@FXML // fx:id="queueB"
private TextArea queueB; // Value injected by FXMLLoader
@FXML // This method is called by the FXMLLoader when initialization is complete
void initialize() {
assert ticketC1 != null : "fx:id=\"ticketC1\" was not injected: check your FXML file 'Screen.fxml'.";
assert ticketC2 != null : "fx:id=\"ticketC2\" was not injected: check your FXML file 'Screen.fxml'.";
assert ticketC3 != null : "fx:id=\"ticketC3\" was not injected: check your FXML file 'Screen.fxml'.";
assert queueA != null : "fx:id=\"queueA\" was not injected: check your FXML file 'Screen.fxml'.";
assert queueB != null : "fx:id=\"queueB\" was not injected: check your FXML file 'Screen.fxml'.";
}
public void setModel(Model model) {
this.model = model;
// Listener : whenever the list of tickets related to service 1 changes the
// method onChanged is called.
model.getList1().addListener(new ListChangeListener<Ticket>() {
// This method updates the view by printing the new queue and the tickets served
// to the new counters.
@Override
public void onChanged(ListChangeListener.Change change) {
ObservableList<Ticket> lista1 = model.getList1();
queueA.clear();
if (!lista1.isEmpty()) {
for (Ticket t : lista1) {
if(t!=null)
queueA.appendText(t.toString() + System.lineSeparator());
}
}
updateCounters();
}
});
// Listener : whenever the list of tickets related to service 2 changes the
// method onChanged is called.
model.getList2().addListener(new ListChangeListener<Ticket>() {
// This method updates the view by printing the new queue and the tickets served
// to the new counters.
@Override
public void onChanged(ListChangeListener.Change change) {
ObservableList<Ticket> lista2 = model.getList2();
queueB.clear();
if (!lista2.isEmpty()) {
for (Ticket t : lista2) {
if(t!=null)
queueB.appendText(t.toString() + System.lineSeparator());
}
}
updateCounters();
}
});
}
// Method used to update the TextArea of the Counters by printing their current
// ticket
private void setTextCounter(int counterID, Ticket t) {
String text="Free";
if(t!= null)
text = t.toString().split("-")[0];
switch (counterID) {
case 0:
ticketC1.setText(text);
break;
case 1:
ticketC2.setText(text);
break;
case 2:
ticketC3.setText(text);
break;
}
}
// Method used to update the counters
private void updateCounters() {
ArrayList<Counter> counters = new ArrayList<Counter>(model.getCounters());
for (Counter c : counters) {
setTextCounter(c.getCounterId(), c.getTicket());
}
}
}
| 3,860 | 0.663212 | 0.655181 | 142 | 25.183098 | 27.371111 | 103 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.112676 | false | false |
10
|
c8e8de38296f5597b5d50438f2550f5c7540bc00
| 4,037,269,299,751 |
347b997fac09bb2d1e29ad9c5612b698269b5d0a
|
/src/pages/ChangePreferencesPage.java
|
c157a217d4ea5c3eae3d9b178a326b88e4327c4e
|
[] |
no_license
|
Jahanra/GE_Automation
|
https://github.com/Jahanra/GE_Automation
|
1d9ba72e7cf01995e03f3337fbf8122700373818
|
9e16e43fbd3fe0afbc60f71e8779e12ce324c3f9
|
refs/heads/master
| 2021-04-27T15:18:24.720000 | 2018-02-22T11:13:25 | 2018-02-22T11:13:25 | 122,467,589 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package pages;
import base.BasePageLogin;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy;
import org.testng.Reporter;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.List;
public class ChangePreferencesPage extends BasePageLogin {
public ChangePreferencesPage(WebDriver driver, Connection conn, Statement stmt, ResultSet resultSet,Actions actions) {
super(driver,conn,stmt,resultSet,actions);
}
//Variable declaration
String technologyMatch;
String techVal;
String industryMatch;
String indstryVal;
@FindBy(xpath = "//div[@class='block-level-input-holder']/input[@type='text']")
WebElement companyName;
@FindBy(xpath = "//input[@ng-model='searchFilter.technologyFilterText']")
private WebElement technologiesText;
@FindBy(xpath = "//div[@class='options perfect-scroll ps ps--theme_default ps--active-y']//input[@class='material-icons' and @type='checkbox']")
private List<WebElement> technologySuggestion;
@FindBy(xpath = "//div[@ng-click='top_level_tech.hidden = !top_level_tech.hidden']//input[@type='checkbox']")
//"//span[@ng-bind-html='top_level_tech.name | highlight:technologyFilterTextModal']//input[@type='checkbox']")
private List<WebElement> topTechnology;
@FindBy(xpath = "//div[@ng-click='upper_level_tech.hidden = !upper_level_tech.hidden']//input[@type='checkbox']")
private List<WebElement> upperTechnology;
@FindBy(xpath = "//div[@ng-click='mid_level_tech.hidden = !mid_level_tech.hidden']//input[@type='checkbox']")
private List<WebElement> middleTechnology;
@FindBy(xpath="//div[@ng-click='lower_level_tech.hidden = !lower_level_tech.hidden']//input[contains(@id,'advanced-tech')]")
private List<WebElement> lowerTechnology;
//input[@ng-model='searchFilter.industryFilterText']
@FindBy(css="input[ng-model='searchFilter.industryFilterText'][type='text']")
private WebElement industryText;
@FindBy(xpath = "//div[@class='options perfect-scroll ps ps--theme_default' or @class='folder-items ng-scope']//input[contains(@id,'advanced-sector')]")
private List<WebElement> industrySuggestion;
@FindBy(xpath = "//span[@ng-bind-html='top_level_sector.name | highlight:searchFilter.industryFilterText' and @class='ng-binding']")
private List<WebElement> topIndustry;
@FindBy(xpath = "//div[@ng-click='upper_level_sector.hidden = !upper_level_sector.hidden']//input[@type='checkbox']")
private List<WebElement> upperIndustry;
@FindBy(xpath = "//div[@ng-click='mid_level_sector.hidden = !mid_level_sector.hidden']//input[@type='checkbox']")
private List<WebElement> middleIndustry;
String solutionMatch;
//input[@ng-model='searchFilter.solutionFilterText']
@FindBy(css="input[ng-model='searchFilter.solutionFilterText'][type='text']")
private WebElement solutionText;
String solVal;
@FindBy(xpath = "//div[@ng-repeat='solution in queried_solutions | filter: searchFilter.solutionFilterText']//input[@type='checkbox']")
private List<WebElement> solutionSuggestion;
@FindBy(xpath = "//div[@class='add-instance' and contains(text(),'Add Solution')]")
private WebElement addSolution;
@FindBy(xpath = "//span[@class='highlight ng-binding' and contains(text(),'Add')]")
private WebElement addNewSolutionText;
@FindBy(xpath = "//input[@ng-model='searchFilter.challengeFilterText']")
private WebElement challenge;
String challengesMatch;
String challengesVal;
String topTechVal;
String uppTechVal;
@FindBy(xpath = " //div[@ng-repeat='challenge in queried_challenges | filter: searchFilter.challengeFilterText']//input[@type='checkbox']")
private List<WebElement> challengesSuggestions;
@FindBy(xpath = "//span[@class='highlight ng-binding' and contains(text(),'Add')]")
private WebElement addNewChallengeText;
@FindBy(xpath = "//span[@class='action-button close' and @ng-click='goToDashboard(companyProfileDto);']")
private WebElement saveButton;
public void clickOnTechnology(String technologyExcel) throws InterruptedException {
try {
/*Thread.sleep(2000);
verifyElementPresentOrNot("//div[@class='input-label' and contains(text(),'Technologies')]");*/
Thread.sleep(2000);
boolean displayResult=technologiesText.isDisplayed();
Reporter.log("Display of technology text--->"+displayResult,true);
actions.moveToElement(technologiesText);
actions.click();
actions.sendKeys(technologyExcel);
actions.build().perform();
System.out.println("Technology value------>" + technologyExcel);
technologyMatch = technologyExcel;
System.out.println("Technology match----------------->" + technologyMatch);
} catch (Exception e)
{
e.printStackTrace();
System.out.println("Exception in click on technology method");
}
}
public void selectTechnology() throws InterruptedException {
try {
System.out.println("Total technology fetched-----" + technologySuggestion.size());
for (int i = 0; i <technologySuggestion.size(); i++)
{
techVal=technologySuggestion.get(i).getAttribute("value").toString();
if (techVal.equalsIgnoreCase(technologyMatch))
{
technologySuggestion.get(i).click();
break;
}
}
}
catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in selecting the technology");
}
}
public boolean checkTopLevelTechnology()
{
boolean result=true;
try {
System.out.println("Top Level technology size-----> " + topTechnology.size());
for (int i = 0; i < topTechnology.size(); i++) {
String topTech = topTechnology.get(i).getAttribute("value").toString();
if (topTech != null && topTech.equalsIgnoreCase(technologyMatch)) {
System.out.println("Its A Top Level Technology-------->" + topTechnology.get(i).getAttribute("value").toString());
companyName.click();
result=true;
break;
}
else
{
result=false;
}
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in top level technology");
}
return result;
}
public boolean checkUpperTechnology()
{
boolean result=true;
try {
System.out.println("Size Of Upper Technology----->" + upperTechnology.size());
for (int i = 0; i<upperTechnology.size(); i++) {
String uppTech = upperTechnology.get(i).getAttribute("value").toString();
if (uppTech != null && uppTech.equalsIgnoreCase(technologyMatch))
{
System.out.println("Its A Upper Level Technology----------->" + upperTechnology.get(i).getAttribute("value").toString());
companyName.click();
result=true;
break;
}
else
{
result=false;
}
}
} catch (Exception e)
{
e.printStackTrace();
System.out.println("Exception in upper Technology---------->");
}
return result;
}
public boolean checkMiddleTechnology()
{
boolean result=true;
try {
System.out.println("The Size of Middle level Technology-------->" + middleTechnology.size());
for (int i = 0; i < middleTechnology.size(); i++)
{
String midTech = middleTechnology.get(i).getAttribute("value").toString();
if (midTech != null && midTech.equalsIgnoreCase(technologyMatch)) {
System.out.println("Its a middle Level Technology------------->" + middleTechnology.get(i).getAttribute("value").toString());
companyName.click();
result=true;
break;
}
else
{
result=false;
}
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in Middle Level Technology");
}
return result;
}
public void checkLowerTechnology() {
try {
System.out.println("The Size of Lower level Technology-------->" + lowerTechnology.size());
for (int i = 0; i < lowerTechnology.size(); i++)
{
String lowTech = lowerTechnology.get(i).getAttribute("value").toString();
if (lowTech != null && lowTech.equalsIgnoreCase(technologyMatch)) {
System.out.println("Its a Lower Level Technology------------->" +lowTech);
companyName.click();;
break;
}
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in Lower Level Technology");
}
}
//Industry Scenarios to check the top level Industry ,Upper Level Industry and Middle Level Industry
public void clickOnIndustry(String industryExcel) throws InterruptedException
{
Thread.sleep(2000);
boolean displayResult=industryText.isDisplayed();
Reporter.log("Display of industry test--->"+displayResult,true);
actions.moveToElement(industryText);
actions.click();
actions.sendKeys(industryExcel);
actions.build().perform();
System.out.println("Industry value------>" + industryExcel);
industryMatch = industryExcel;
System.out.println("industry match----------------->" + industryMatch);
Thread.sleep(1000);
}
public void selectIndustry() throws InterruptedException {
try {
System.out.println("Total Industry fetched-----" + industrySuggestion.size());
for (int i = 0; i < industrySuggestion.size(); i++) {
indstryVal = industrySuggestion.get(i).getAttribute("value");
if (indstryVal.equalsIgnoreCase(industryMatch)) {
industrySuggestion.get(i).click();
break;
}
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in selecting the Industry");
}
}
public boolean checkTopLevelIndustry()
{
boolean result=true;
try {
System.out.println("Top Level Industry size-----> " + topIndustry.size());
for (int i = 0; i < topIndustry.size(); i++) {
String topIndus = topIndustry.get(i).getText().toString();
if (topIndus != null && topIndus.equalsIgnoreCase(industryMatch)) {
System.out.println("Its A Top Level Industry-------->" + topIndustry.get(i).getText().toString());
companyName.click();
result=true;
break;
}
else
{
result=false;
}
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in top level Industry");
}
return result;
}
public boolean checkUpperIndustry()
{
boolean result = true;
try {
System.out.println("Size Of Upper Industry----->" + upperIndustry.size());
for (int i = 0; i < upperIndustry.size(); i++) {
String uppIndus = upperIndustry.get(i).getAttribute("value").toString();
if (uppIndus != null && uppIndus.equalsIgnoreCase(industryMatch)) {
System.out.println("Its A Upper Level Industry----------->" + upperIndustry.get(i).getAttribute("value").toString());
companyName.click();
result = true;
break;
} else {
result = false;
}
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in upper Industry---------->");
}
return result;
}
public boolean checkMiddleIndustry()
{
boolean result=true;
try {
System.out.println("The Size of Middle level Industry-------->" + middleIndustry.size());
for (int i = 0; i < middleIndustry.size(); i++)
{
String midIndus = middleIndustry.get(i).getAttribute("value").toString();
if (midIndus != null && midIndus.equalsIgnoreCase(industryMatch)) {
System.out.println("Its a middle Level Industry------------->" + middleIndustry.get(i).getAttribute("value").toString());
companyName.click();
result=true;
break;
}
else
{
result=false;
}
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in Middle Level Industry");
}
return result;
}
//Solutions scenarios
public void clickOnSolution(String solutionExcel) throws InterruptedException {
try {
actions.moveToElement(solutionText);
actions.click();
actions.sendKeys(solutionExcel);
actions.build().perform();
System.out.println("Solution value------>" + solutionExcel);
solutionMatch = solutionExcel;
System.out.println("Solution match----------------->" + solutionMatch);
Thread.sleep(1000);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in click on solution method");
}
}
public void selectSolution() throws InterruptedException
{
try {
System.out.println("Total Solution fetched-----" + solutionSuggestion.size());
for (int i = 0; i <= solutionSuggestion.size(); i++)
{
solVal = solutionSuggestion.get(i).getAttribute("value").toString();
System.out.println("solution value------------>" + solVal);
if(solutionMatch.equalsIgnoreCase(solVal)) {
solutionSuggestion.get(i).click();
companyName.click();
break;
}
else
{
setNewSolution(solutionMatch);
addNewSolution();
}
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in selecting the Solution");
}
}
public void setNewSolution(String newSolutionExcel) throws InterruptedException
{
try {
actions.moveToElement(solutionText);
actions.click();
actions.sendKeys(newSolutionExcel);
actions.build().perform();
Thread.sleep(1000);
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception in adding new solution");
}
}
public void addNewSolution() throws InterruptedException {
try {
actions.moveToElement(addNewSolutionText);
actions.click();
actions.build().perform();
Thread.sleep(1000);
}
catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in add new solution method");
}
}
//Challenges Scenarios
public void clickOnChallenges(String challengeExcel) {
try {
actions.moveToElement(challenge);
actions.click();
actions.sendKeys(challengeExcel);
actions.build().perform();
challengesMatch=challengeExcel;
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in click on challenges method!!!!!!!!!!!!!1");
}
}
public void selectChallenges() throws InterruptedException
{
try {
System.out.println("Total challenges fetched-----" + challengesSuggestions.size());
for (int i = 0; i <= challengesSuggestions.size(); i++) {
challengesVal = challengesSuggestions.get(i).getAttribute("value").toString();
System.out.println("Challenges value------------>" + challengesVal);
if (challengesMatch.equalsIgnoreCase(challengesVal))
{
challengesSuggestions.get(i).click();
companyName.click();
break;
}
else
{
setNewSolution(challengesMatch);
addNewChallenge();
}
}
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception in selecting the challenges");
}
}
public void setNewChallenges(String newChallengesExcel) throws InterruptedException {
actions.moveToElement(challenge);
actions.click();
actions.sendKeys(newChallengesExcel);
actions.build().perform();
Thread.sleep(1000);
}
public void addNewChallenge() throws InterruptedException {
try {
actions.moveToElement(addNewChallengeText);
actions.click();
actions.build().perform();
Thread.sleep(1000);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in add new challenge method");
}
}
public void clickSavePreferencesButton() {
try {
System.out.println("click on save button in change preferences page");
actions.moveToElement(saveButton);
actions.click();
actions.build().perform();
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in save preferences button!!!!!!!");
}
}
}
|
UTF-8
|
Java
| 18,849 |
java
|
ChangePreferencesPage.java
|
Java
|
[
{
"context": "n;\n\n @FindBy(xpath = \"//span[@ng-bind-html='top_level_sector.name | highlight:searchFilter.industr",
"end": 2396,
"score": 0.5460603833198547,
"start": 2396,
"tag": "EMAIL",
"value": ""
},
{
"context": " @FindBy(xpath = \"//span[@ng-bind-html='top_level_sector.name | highlight:searchFilter.industryFilterText' and ",
"end": 2414,
"score": 0.6042495965957642,
"start": 2403,
"tag": "EMAIL",
"value": "sector.name"
}
] | null |
[] |
package pages;
import base.BasePageLogin;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy;
import org.testng.Reporter;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.List;
public class ChangePreferencesPage extends BasePageLogin {
public ChangePreferencesPage(WebDriver driver, Connection conn, Statement stmt, ResultSet resultSet,Actions actions) {
super(driver,conn,stmt,resultSet,actions);
}
//Variable declaration
String technologyMatch;
String techVal;
String industryMatch;
String indstryVal;
@FindBy(xpath = "//div[@class='block-level-input-holder']/input[@type='text']")
WebElement companyName;
@FindBy(xpath = "//input[@ng-model='searchFilter.technologyFilterText']")
private WebElement technologiesText;
@FindBy(xpath = "//div[@class='options perfect-scroll ps ps--theme_default ps--active-y']//input[@class='material-icons' and @type='checkbox']")
private List<WebElement> technologySuggestion;
@FindBy(xpath = "//div[@ng-click='top_level_tech.hidden = !top_level_tech.hidden']//input[@type='checkbox']")
//"//span[@ng-bind-html='top_level_tech.name | highlight:technologyFilterTextModal']//input[@type='checkbox']")
private List<WebElement> topTechnology;
@FindBy(xpath = "//div[@ng-click='upper_level_tech.hidden = !upper_level_tech.hidden']//input[@type='checkbox']")
private List<WebElement> upperTechnology;
@FindBy(xpath = "//div[@ng-click='mid_level_tech.hidden = !mid_level_tech.hidden']//input[@type='checkbox']")
private List<WebElement> middleTechnology;
@FindBy(xpath="//div[@ng-click='lower_level_tech.hidden = !lower_level_tech.hidden']//input[contains(@id,'advanced-tech')]")
private List<WebElement> lowerTechnology;
//input[@ng-model='searchFilter.industryFilterText']
@FindBy(css="input[ng-model='searchFilter.industryFilterText'][type='text']")
private WebElement industryText;
@FindBy(xpath = "//div[@class='options perfect-scroll ps ps--theme_default' or @class='folder-items ng-scope']//input[contains(@id,'advanced-sector')]")
private List<WebElement> industrySuggestion;
@FindBy(xpath = "//span[@ng-bind-html='top_level_<EMAIL> | highlight:searchFilter.industryFilterText' and @class='ng-binding']")
private List<WebElement> topIndustry;
@FindBy(xpath = "//div[@ng-click='upper_level_sector.hidden = !upper_level_sector.hidden']//input[@type='checkbox']")
private List<WebElement> upperIndustry;
@FindBy(xpath = "//div[@ng-click='mid_level_sector.hidden = !mid_level_sector.hidden']//input[@type='checkbox']")
private List<WebElement> middleIndustry;
String solutionMatch;
//input[@ng-model='searchFilter.solutionFilterText']
@FindBy(css="input[ng-model='searchFilter.solutionFilterText'][type='text']")
private WebElement solutionText;
String solVal;
@FindBy(xpath = "//div[@ng-repeat='solution in queried_solutions | filter: searchFilter.solutionFilterText']//input[@type='checkbox']")
private List<WebElement> solutionSuggestion;
@FindBy(xpath = "//div[@class='add-instance' and contains(text(),'Add Solution')]")
private WebElement addSolution;
@FindBy(xpath = "//span[@class='highlight ng-binding' and contains(text(),'Add')]")
private WebElement addNewSolutionText;
@FindBy(xpath = "//input[@ng-model='searchFilter.challengeFilterText']")
private WebElement challenge;
String challengesMatch;
String challengesVal;
String topTechVal;
String uppTechVal;
@FindBy(xpath = " //div[@ng-repeat='challenge in queried_challenges | filter: searchFilter.challengeFilterText']//input[@type='checkbox']")
private List<WebElement> challengesSuggestions;
@FindBy(xpath = "//span[@class='highlight ng-binding' and contains(text(),'Add')]")
private WebElement addNewChallengeText;
@FindBy(xpath = "//span[@class='action-button close' and @ng-click='goToDashboard(companyProfileDto);']")
private WebElement saveButton;
public void clickOnTechnology(String technologyExcel) throws InterruptedException {
try {
/*Thread.sleep(2000);
verifyElementPresentOrNot("//div[@class='input-label' and contains(text(),'Technologies')]");*/
Thread.sleep(2000);
boolean displayResult=technologiesText.isDisplayed();
Reporter.log("Display of technology text--->"+displayResult,true);
actions.moveToElement(technologiesText);
actions.click();
actions.sendKeys(technologyExcel);
actions.build().perform();
System.out.println("Technology value------>" + technologyExcel);
technologyMatch = technologyExcel;
System.out.println("Technology match----------------->" + technologyMatch);
} catch (Exception e)
{
e.printStackTrace();
System.out.println("Exception in click on technology method");
}
}
public void selectTechnology() throws InterruptedException {
try {
System.out.println("Total technology fetched-----" + technologySuggestion.size());
for (int i = 0; i <technologySuggestion.size(); i++)
{
techVal=technologySuggestion.get(i).getAttribute("value").toString();
if (techVal.equalsIgnoreCase(technologyMatch))
{
technologySuggestion.get(i).click();
break;
}
}
}
catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in selecting the technology");
}
}
public boolean checkTopLevelTechnology()
{
boolean result=true;
try {
System.out.println("Top Level technology size-----> " + topTechnology.size());
for (int i = 0; i < topTechnology.size(); i++) {
String topTech = topTechnology.get(i).getAttribute("value").toString();
if (topTech != null && topTech.equalsIgnoreCase(technologyMatch)) {
System.out.println("Its A Top Level Technology-------->" + topTechnology.get(i).getAttribute("value").toString());
companyName.click();
result=true;
break;
}
else
{
result=false;
}
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in top level technology");
}
return result;
}
public boolean checkUpperTechnology()
{
boolean result=true;
try {
System.out.println("Size Of Upper Technology----->" + upperTechnology.size());
for (int i = 0; i<upperTechnology.size(); i++) {
String uppTech = upperTechnology.get(i).getAttribute("value").toString();
if (uppTech != null && uppTech.equalsIgnoreCase(technologyMatch))
{
System.out.println("Its A Upper Level Technology----------->" + upperTechnology.get(i).getAttribute("value").toString());
companyName.click();
result=true;
break;
}
else
{
result=false;
}
}
} catch (Exception e)
{
e.printStackTrace();
System.out.println("Exception in upper Technology---------->");
}
return result;
}
public boolean checkMiddleTechnology()
{
boolean result=true;
try {
System.out.println("The Size of Middle level Technology-------->" + middleTechnology.size());
for (int i = 0; i < middleTechnology.size(); i++)
{
String midTech = middleTechnology.get(i).getAttribute("value").toString();
if (midTech != null && midTech.equalsIgnoreCase(technologyMatch)) {
System.out.println("Its a middle Level Technology------------->" + middleTechnology.get(i).getAttribute("value").toString());
companyName.click();
result=true;
break;
}
else
{
result=false;
}
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in Middle Level Technology");
}
return result;
}
public void checkLowerTechnology() {
try {
System.out.println("The Size of Lower level Technology-------->" + lowerTechnology.size());
for (int i = 0; i < lowerTechnology.size(); i++)
{
String lowTech = lowerTechnology.get(i).getAttribute("value").toString();
if (lowTech != null && lowTech.equalsIgnoreCase(technologyMatch)) {
System.out.println("Its a Lower Level Technology------------->" +lowTech);
companyName.click();;
break;
}
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in Lower Level Technology");
}
}
//Industry Scenarios to check the top level Industry ,Upper Level Industry and Middle Level Industry
public void clickOnIndustry(String industryExcel) throws InterruptedException
{
Thread.sleep(2000);
boolean displayResult=industryText.isDisplayed();
Reporter.log("Display of industry test--->"+displayResult,true);
actions.moveToElement(industryText);
actions.click();
actions.sendKeys(industryExcel);
actions.build().perform();
System.out.println("Industry value------>" + industryExcel);
industryMatch = industryExcel;
System.out.println("industry match----------------->" + industryMatch);
Thread.sleep(1000);
}
public void selectIndustry() throws InterruptedException {
try {
System.out.println("Total Industry fetched-----" + industrySuggestion.size());
for (int i = 0; i < industrySuggestion.size(); i++) {
indstryVal = industrySuggestion.get(i).getAttribute("value");
if (indstryVal.equalsIgnoreCase(industryMatch)) {
industrySuggestion.get(i).click();
break;
}
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in selecting the Industry");
}
}
public boolean checkTopLevelIndustry()
{
boolean result=true;
try {
System.out.println("Top Level Industry size-----> " + topIndustry.size());
for (int i = 0; i < topIndustry.size(); i++) {
String topIndus = topIndustry.get(i).getText().toString();
if (topIndus != null && topIndus.equalsIgnoreCase(industryMatch)) {
System.out.println("Its A Top Level Industry-------->" + topIndustry.get(i).getText().toString());
companyName.click();
result=true;
break;
}
else
{
result=false;
}
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in top level Industry");
}
return result;
}
public boolean checkUpperIndustry()
{
boolean result = true;
try {
System.out.println("Size Of Upper Industry----->" + upperIndustry.size());
for (int i = 0; i < upperIndustry.size(); i++) {
String uppIndus = upperIndustry.get(i).getAttribute("value").toString();
if (uppIndus != null && uppIndus.equalsIgnoreCase(industryMatch)) {
System.out.println("Its A Upper Level Industry----------->" + upperIndustry.get(i).getAttribute("value").toString());
companyName.click();
result = true;
break;
} else {
result = false;
}
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in upper Industry---------->");
}
return result;
}
public boolean checkMiddleIndustry()
{
boolean result=true;
try {
System.out.println("The Size of Middle level Industry-------->" + middleIndustry.size());
for (int i = 0; i < middleIndustry.size(); i++)
{
String midIndus = middleIndustry.get(i).getAttribute("value").toString();
if (midIndus != null && midIndus.equalsIgnoreCase(industryMatch)) {
System.out.println("Its a middle Level Industry------------->" + middleIndustry.get(i).getAttribute("value").toString());
companyName.click();
result=true;
break;
}
else
{
result=false;
}
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in Middle Level Industry");
}
return result;
}
//Solutions scenarios
public void clickOnSolution(String solutionExcel) throws InterruptedException {
try {
actions.moveToElement(solutionText);
actions.click();
actions.sendKeys(solutionExcel);
actions.build().perform();
System.out.println("Solution value------>" + solutionExcel);
solutionMatch = solutionExcel;
System.out.println("Solution match----------------->" + solutionMatch);
Thread.sleep(1000);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in click on solution method");
}
}
public void selectSolution() throws InterruptedException
{
try {
System.out.println("Total Solution fetched-----" + solutionSuggestion.size());
for (int i = 0; i <= solutionSuggestion.size(); i++)
{
solVal = solutionSuggestion.get(i).getAttribute("value").toString();
System.out.println("solution value------------>" + solVal);
if(solutionMatch.equalsIgnoreCase(solVal)) {
solutionSuggestion.get(i).click();
companyName.click();
break;
}
else
{
setNewSolution(solutionMatch);
addNewSolution();
}
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in selecting the Solution");
}
}
public void setNewSolution(String newSolutionExcel) throws InterruptedException
{
try {
actions.moveToElement(solutionText);
actions.click();
actions.sendKeys(newSolutionExcel);
actions.build().perform();
Thread.sleep(1000);
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception in adding new solution");
}
}
public void addNewSolution() throws InterruptedException {
try {
actions.moveToElement(addNewSolutionText);
actions.click();
actions.build().perform();
Thread.sleep(1000);
}
catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in add new solution method");
}
}
//Challenges Scenarios
public void clickOnChallenges(String challengeExcel) {
try {
actions.moveToElement(challenge);
actions.click();
actions.sendKeys(challengeExcel);
actions.build().perform();
challengesMatch=challengeExcel;
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in click on challenges method!!!!!!!!!!!!!1");
}
}
public void selectChallenges() throws InterruptedException
{
try {
System.out.println("Total challenges fetched-----" + challengesSuggestions.size());
for (int i = 0; i <= challengesSuggestions.size(); i++) {
challengesVal = challengesSuggestions.get(i).getAttribute("value").toString();
System.out.println("Challenges value------------>" + challengesVal);
if (challengesMatch.equalsIgnoreCase(challengesVal))
{
challengesSuggestions.get(i).click();
companyName.click();
break;
}
else
{
setNewSolution(challengesMatch);
addNewChallenge();
}
}
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception in selecting the challenges");
}
}
public void setNewChallenges(String newChallengesExcel) throws InterruptedException {
actions.moveToElement(challenge);
actions.click();
actions.sendKeys(newChallengesExcel);
actions.build().perform();
Thread.sleep(1000);
}
public void addNewChallenge() throws InterruptedException {
try {
actions.moveToElement(addNewChallengeText);
actions.click();
actions.build().perform();
Thread.sleep(1000);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in add new challenge method");
}
}
public void clickSavePreferencesButton() {
try {
System.out.println("click on save button in change preferences page");
actions.moveToElement(saveButton);
actions.click();
actions.build().perform();
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception in save preferences button!!!!!!!");
}
}
}
| 18,845 | 0.56247 | 0.559924 | 539 | 33.972172 | 33.026291 | 156 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.491651 | false | false |
10
|
5e5121735c6c2a3f3dd0cf6631314cc7b2aeedd0
| 1,254,130,494,855 |
e052386d1f3c8886533d99c3c0b2c845acb2498a
|
/PowersProject/Powers/src/main/java/edu/mit/powers/activity/WifiActivity.java
|
39ecaad0b659f96802a7c28e6955b2e241a68f91
|
[] |
no_license
|
garrettvparrish/Powers-Live-Android
|
https://github.com/garrettvparrish/Powers-Live-Android
|
af4e8faec9ec9fea9c86f464b9998bd7267a1c17
|
172bae225bca702586a633f3e667b4ae76495970
|
refs/heads/master
| 2020-05-17T22:23:26.824000 | 2014-01-26T21:31:59 | 2014-01-26T21:32:00 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package edu.mit.powers.activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import edu.mit.powers.R;
public class WifiActivity extends PowersView
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_wifi);
configureUI();
}
private void configureUI()
{
String message;
String ssid = application.getRequiredSSID();
if (ssid == null)
{
message = getResources().getString(R.string.join_wifi);
}
else
{
String fmt = getResources().getString(R.string.join_specific_wifi);
message = String.format(fmt, ssid);
}
TextView wifiMessage = (TextView) this.findViewById(R.id.wifiMessage);
wifiMessage.setText(message);
Button startOver = (Button) this.findViewById(R.id.wifiStartOver);
startOver.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
application.setVenue(null);
}
});
Button connected = (Button) this.findViewById(R.id.wifiContinueButton);
connected.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
checkNetworkFromWifi();
}
});
}
private void checkNetworkFromWifi()
{
if(!application.userSaysCorrectWifi())
{
int titleID;
int messageID;
if(application.getRequiredSSID() == null)
{
titleID = R.string.wrong_wifi_title;
messageID = R.string.wrong_wifi_message;
}
else
{
titleID = R.string.wrong_specific_wifi_title;
messageID = R.string.wrong_specific_wifi_message;
}
showMessage(messageID, titleID, null);
}
}
}
|
UTF-8
|
Java
| 2,076 |
java
|
WifiActivity.java
|
Java
|
[] | null |
[] |
package edu.mit.powers.activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import edu.mit.powers.R;
public class WifiActivity extends PowersView
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_wifi);
configureUI();
}
private void configureUI()
{
String message;
String ssid = application.getRequiredSSID();
if (ssid == null)
{
message = getResources().getString(R.string.join_wifi);
}
else
{
String fmt = getResources().getString(R.string.join_specific_wifi);
message = String.format(fmt, ssid);
}
TextView wifiMessage = (TextView) this.findViewById(R.id.wifiMessage);
wifiMessage.setText(message);
Button startOver = (Button) this.findViewById(R.id.wifiStartOver);
startOver.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
application.setVenue(null);
}
});
Button connected = (Button) this.findViewById(R.id.wifiContinueButton);
connected.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
checkNetworkFromWifi();
}
});
}
private void checkNetworkFromWifi()
{
if(!application.userSaysCorrectWifi())
{
int titleID;
int messageID;
if(application.getRequiredSSID() == null)
{
titleID = R.string.wrong_wifi_title;
messageID = R.string.wrong_wifi_message;
}
else
{
titleID = R.string.wrong_specific_wifi_title;
messageID = R.string.wrong_specific_wifi_message;
}
showMessage(messageID, titleID, null);
}
}
}
| 2,076 | 0.568882 | 0.568882 | 76 | 26.31579 | 22.952589 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.421053 | false | false |
10
|
e962bde52591763c9188ea79f0915857e9244969
| 29,944,512,038,896 |
d38900c06a75e6c71b51f4290809763218626411
|
/.svn/pristine/e9/e962bde52591763c9188ea79f0915857e9244969.svn-base
|
66031528c24aa6ff6c9f761b995527e22c08c51f
|
[] |
no_license
|
XClouded/avp
|
https://github.com/XClouded/avp
|
ef5d0df5fd06d67793f93539e6421c5c8cef06c5
|
4a41681376cd3e1ec7f814dcd1f178d89e94f3d6
|
refs/heads/master
| 2017-02-26T23:03:31.245000 | 2014-07-22T19:03:40 | 2014-07-22T19:03:40 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.lvsint.abp.utilities.marketcontrolmanagement.controller;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.Composite;
import com.lvsint.abp.notifications.GoalsByIntervalClockAdvancedAlerter;
import com.lvsint.abp.notifications.Notifier;
import com.lvsint.abp.pdt.common.gui.controller.Context;
import com.lvsint.abp.utilities.marketcontrolmanagement.view.GoalsByIntervalClockAdvancedAlertConfigurationView;
public class GoalsByIntervalClockAdvancedAlertController extends AbstractAlertConfigurationController {
private GoalsByIntervalClockAdvancedAlertConfigurationView view;
@Override
void display(Composite parent, Context context, Notifier notifier) {
this.context = context;
this.notifier = notifier;
this.view = new GoalsByIntervalClockAdvancedAlertConfigurationView(parent, SWT.NONE);
view.getToleranceText().setText(
Long.toString(((GoalsByIntervalClockAdvancedAlerter) notifier).getToleranceSeconds()));
view.getToleranceText().addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent modifyEvent) {
updateNotifier();
}
});
}
private void updateNotifier() {
((GoalsByIntervalClockAdvancedAlerter) notifier).setToleranceSeconds(view.getToleranceText().getValue());
context.getLibrary().markModified();
}
}
|
UTF-8
|
Java
| 1,550 |
e962bde52591763c9188ea79f0915857e9244969.svn-base
|
Java
|
[] | null |
[] |
package com.lvsint.abp.utilities.marketcontrolmanagement.controller;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.Composite;
import com.lvsint.abp.notifications.GoalsByIntervalClockAdvancedAlerter;
import com.lvsint.abp.notifications.Notifier;
import com.lvsint.abp.pdt.common.gui.controller.Context;
import com.lvsint.abp.utilities.marketcontrolmanagement.view.GoalsByIntervalClockAdvancedAlertConfigurationView;
public class GoalsByIntervalClockAdvancedAlertController extends AbstractAlertConfigurationController {
private GoalsByIntervalClockAdvancedAlertConfigurationView view;
@Override
void display(Composite parent, Context context, Notifier notifier) {
this.context = context;
this.notifier = notifier;
this.view = new GoalsByIntervalClockAdvancedAlertConfigurationView(parent, SWT.NONE);
view.getToleranceText().setText(
Long.toString(((GoalsByIntervalClockAdvancedAlerter) notifier).getToleranceSeconds()));
view.getToleranceText().addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent modifyEvent) {
updateNotifier();
}
});
}
private void updateNotifier() {
((GoalsByIntervalClockAdvancedAlerter) notifier).setToleranceSeconds(view.getToleranceText().getValue());
context.getLibrary().markModified();
}
}
| 1,550 | 0.739355 | 0.739355 | 38 | 38.789474 | 34.765499 | 113 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.552632 | false | false |
10
|
|
5549ce77565530b20bad07847ac11b340df25714
| 14,224,931,723,274 |
96a9519aa94cdacfe09770b998a8554a9e832fb1
|
/app/src/main/java/gca/com/beexprss/data/LoginDataResponse.java
|
56f5687ba2c3b87331ddaafb435745c0e44cb23b
|
[] |
no_license
|
sengaungardi/beexprss-final
|
https://github.com/sengaungardi/beexprss-final
|
8c361e083068b604cc95e767d7218cc3dd4f77b4
|
4f05204a5329191f2d24469f2618153093f5b08e
|
refs/heads/master
| 2020-09-23T18:13:40.065000 | 2019-12-03T04:13:10 | 2019-12-03T04:13:10 | 225,556,340 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package gca.com.beexprss.data;
import com.google.gson.annotations.SerializedName;
import java.util.List;
import gca.com.beexprss.entity.AreaEntity;
import gca.com.beexprss.entity.CityEntity;
import gca.com.beexprss.entity.PaymentTypeEntity;
import gca.com.beexprss.entity.RecipientTypeEntity;
import gca.com.beexprss.entity.ServiceTypeEntity;
import gca.com.beexprss.entity.StatusEntity;
import gca.com.beexprss.entity.TownshipEntity;
import gca.com.beexprss.entity.UserEntity;
public class LoginDataResponse {
@SerializedName("payment_type")
private List<PaymentTypeEntity> paymentType;
@SerializedName("city")
private List<CityEntity> city;
@SerializedName("service_type")
private List<ServiceTypeEntity> serviceType;
@SerializedName("township")
private List<TownshipEntity> townships;
@SerializedName("status")
private List<StatusEntity> status;
@SerializedName("user")
private UserEntity user;
@SerializedName("area")
private List<AreaEntity> area;
@SerializedName("recipient_type")
private List<RecipientTypeEntity> recipientTypeEntities;
@SerializedName("error")
private String error;
@SerializedName("result")
public String result;
public List<PaymentTypeEntity> getPaymentType() {
return paymentType;
}
public void setPaymentType(List<PaymentTypeEntity> paymentType) {
this.paymentType = paymentType;
}
public List<CityEntity> getCity() {
return city;
}
public void setCity(List<CityEntity> city) {
this.city = city;
}
public List<ServiceTypeEntity> getServiceType() {
return serviceType;
}
public void setServiceType(List<ServiceTypeEntity> serviceType) {
this.serviceType = serviceType;
}
public List<TownshipEntity> getTownships() {
return townships;
}
public void setTownships(List<TownshipEntity> townships) {
this.townships = townships;
}
public List<StatusEntity> getStatus() {
return status;
}
public void setStatus(List<StatusEntity> status) {
this.status = status;
}
public UserEntity getUser() {
return user;
}
public void setUser(UserEntity user) {
this.user = user;
}
public List<AreaEntity> getArea() {
return area;
}
public void setArea(List<AreaEntity> area) {
this.area = area;
}
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
public List<RecipientTypeEntity> getRecipientTypeEntities() {
return recipientTypeEntities;
}
public void setRecipientTypeEntities(List<RecipientTypeEntity> recipientTypeEntities) {
this.recipientTypeEntities = recipientTypeEntities;
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
}
|
UTF-8
|
Java
| 2,987 |
java
|
LoginDataResponse.java
|
Java
|
[] | null |
[] |
package gca.com.beexprss.data;
import com.google.gson.annotations.SerializedName;
import java.util.List;
import gca.com.beexprss.entity.AreaEntity;
import gca.com.beexprss.entity.CityEntity;
import gca.com.beexprss.entity.PaymentTypeEntity;
import gca.com.beexprss.entity.RecipientTypeEntity;
import gca.com.beexprss.entity.ServiceTypeEntity;
import gca.com.beexprss.entity.StatusEntity;
import gca.com.beexprss.entity.TownshipEntity;
import gca.com.beexprss.entity.UserEntity;
public class LoginDataResponse {
@SerializedName("payment_type")
private List<PaymentTypeEntity> paymentType;
@SerializedName("city")
private List<CityEntity> city;
@SerializedName("service_type")
private List<ServiceTypeEntity> serviceType;
@SerializedName("township")
private List<TownshipEntity> townships;
@SerializedName("status")
private List<StatusEntity> status;
@SerializedName("user")
private UserEntity user;
@SerializedName("area")
private List<AreaEntity> area;
@SerializedName("recipient_type")
private List<RecipientTypeEntity> recipientTypeEntities;
@SerializedName("error")
private String error;
@SerializedName("result")
public String result;
public List<PaymentTypeEntity> getPaymentType() {
return paymentType;
}
public void setPaymentType(List<PaymentTypeEntity> paymentType) {
this.paymentType = paymentType;
}
public List<CityEntity> getCity() {
return city;
}
public void setCity(List<CityEntity> city) {
this.city = city;
}
public List<ServiceTypeEntity> getServiceType() {
return serviceType;
}
public void setServiceType(List<ServiceTypeEntity> serviceType) {
this.serviceType = serviceType;
}
public List<TownshipEntity> getTownships() {
return townships;
}
public void setTownships(List<TownshipEntity> townships) {
this.townships = townships;
}
public List<StatusEntity> getStatus() {
return status;
}
public void setStatus(List<StatusEntity> status) {
this.status = status;
}
public UserEntity getUser() {
return user;
}
public void setUser(UserEntity user) {
this.user = user;
}
public List<AreaEntity> getArea() {
return area;
}
public void setArea(List<AreaEntity> area) {
this.area = area;
}
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
public List<RecipientTypeEntity> getRecipientTypeEntities() {
return recipientTypeEntities;
}
public void setRecipientTypeEntities(List<RecipientTypeEntity> recipientTypeEntities) {
this.recipientTypeEntities = recipientTypeEntities;
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
}
| 2,987 | 0.685303 | 0.685303 | 127 | 22.519686 | 20.888098 | 91 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.322835 | false | false |
10
|
b2ce509404ff11a21513bf9f1b7f616fbc42be9b
| 5,617,817,278,330 |
cbe9d280d1df42280996b77f2b74b67db70fba26
|
/common/src/main/java/com/codename1/rad/models/DateProperty.java
|
454296a98850d0ca26dbe8d0f2932b11ef95d843
|
[] |
no_license
|
shannah/CodeRAD
|
https://github.com/shannah/CodeRAD
|
0cdaeaeb8c65d599a86eef16c502ebbaba8dba77
|
57b5566b411cd9c32855cc7e48a4d985e256e64c
|
refs/heads/master
| 2023-01-24T00:11:32.663000 | 2023-01-15T15:07:16 | 2023-01-15T15:07:16 | 240,612,918 | 27 | 10 | null | false | 2023-01-15T14:27:00 | 2020-02-14T22:58:04 | 2023-01-06T16:08:40 | 2023-01-15T14:26:59 | 72,958 | 21 | 8 | 11 |
Java
| false | false |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.codename1.rad.models;
import static com.codename1.rad.models.ContentType.DateType;
import java.util.Date;
/**
* A {@link Property} that stores {@link java.util.Date} values.
* @author shannah
*
* @see EntityType#date(com.codename1.rad.models.Attribute...)
*/
public class DateProperty extends AbstractProperty<Date> {
public DateProperty() {
super(DateType);
}
}
|
UTF-8
|
Java
| 585 |
java
|
DateProperty.java
|
Java
|
[
{
"context": "t stores {@link java.util.Date} values.\n * @author shannah\n * \n * @see EntityType#date(com.codename1.rad.mod",
"end": 392,
"score": 0.9697049260139465,
"start": 385,
"tag": "USERNAME",
"value": "shannah"
}
] | null |
[] |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.codename1.rad.models;
import static com.codename1.rad.models.ContentType.DateType;
import java.util.Date;
/**
* A {@link Property} that stores {@link java.util.Date} values.
* @author shannah
*
* @see EntityType#date(com.codename1.rad.models.Attribute...)
*/
public class DateProperty extends AbstractProperty<Date> {
public DateProperty() {
super(DateType);
}
}
| 585 | 0.719658 | 0.71453 | 21 | 26.857143 | 25.967537 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false |
10
|
1aa46164812923d98f6ba26464f6d8befbabc3b8
| 15,960,098,510,046 |
6ac25b8bdc3b080cd97d0e7d2fdf0f3d472e2024
|
/binary-tree-inorder-traversal/Solution.java
|
e6d3d76714512a5dd286b753f72f5ed0e8cd577e
|
[] |
no_license
|
jmazala/leetcode
|
https://github.com/jmazala/leetcode
|
852e5fc9e8529ee059fcb031109431cd074d6a8f
|
8a3bc5aa8fe827d5f63cab0f680a17500c2f90e0
|
refs/heads/master
| 2023-08-09T20:45:29.740000 | 2023-08-02T05:57:22 | 2023-08-02T05:57:22 | 252,583,974 | 0 | 0 | null | false | 2023-01-07T19:14:33 | 2020-04-02T23:06:42 | 2020-07-02T20:28:48 | 2023-01-07T19:14:32 | 491 | 0 | 0 | 8 |
JavaScript
| false | false |
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
/**
* Definition for a binary tree node. public class TreeNode { int val; TreeNode
* left; TreeNode right; TreeNode(int x) { val = x; } }
*/
class Solution {
// iterative
public List<Integer> inorderTraversal(TreeNode root) {
List<Integer> answer = new ArrayList<>();
Stack<TreeNode> stack = new Stack<>();
TreeNode current = root;
while (current != null || !stack.isEmpty()) {
while (current != null) {
stack.push(current);
current = current.left;
}
current = stack.pop();
answer.add(current.val);
current = current.right;
}
return answer;
}
// recursive
// public List<Integer> inorderTraversal(TreeNode root) {
// List<Integer> answer = new ArrayList<>();
// if (root == null) {
// return answer;
// }
// answer.addAll(inorderTraversal(root.left));
// answer.add(root.val);
// answer.addAll(inorderTraversal(root.right));
// return answer;
// }
}
|
UTF-8
|
Java
| 1,031 |
java
|
Solution.java
|
Java
|
[] | null |
[] |
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
/**
* Definition for a binary tree node. public class TreeNode { int val; TreeNode
* left; TreeNode right; TreeNode(int x) { val = x; } }
*/
class Solution {
// iterative
public List<Integer> inorderTraversal(TreeNode root) {
List<Integer> answer = new ArrayList<>();
Stack<TreeNode> stack = new Stack<>();
TreeNode current = root;
while (current != null || !stack.isEmpty()) {
while (current != null) {
stack.push(current);
current = current.left;
}
current = stack.pop();
answer.add(current.val);
current = current.right;
}
return answer;
}
// recursive
// public List<Integer> inorderTraversal(TreeNode root) {
// List<Integer> answer = new ArrayList<>();
// if (root == null) {
// return answer;
// }
// answer.addAll(inorderTraversal(root.left));
// answer.add(root.val);
// answer.addAll(inorderTraversal(root.right));
// return answer;
// }
}
| 1,031 | 0.624636 | 0.624636 | 42 | 23.571428 | 19.817192 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.571429 | false | false |
10
|
36131b8602299ca1315c21b6024eaba0528eef0c
| 28,767,690,982,736 |
aafc3e007e143cc774558fb1b09d5d6a4102362d
|
/chapter 4/src/__04_Literals/BooleanLiteral.java
|
2bcd1471235c9274851b14b7ba0c052cb29b55ea
|
[] |
no_license
|
sevgigundogdu7834/Java-SE
|
https://github.com/sevgigundogdu7834/Java-SE
|
d8c7dae6f57ebc2cdd1aa1ad2636d38d0afa6bb8
|
0081e97003cfcdde35a5dc759338a3c969be6334
|
refs/heads/master
| 2020-03-29T17:02:18.115000 | 2018-11-13T07:18:03 | 2018-11-13T07:18:03 | 150,140,771 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package __04_Literals;
public class BooleanLiteral {
//boolean literal;
//true ya da false olabilir.
//boolean için 0 ya da 1 olamaz.
}
|
UTF-8
|
Java
| 151 |
java
|
BooleanLiteral.java
|
Java
|
[] | null |
[] |
package __04_Literals;
public class BooleanLiteral {
//boolean literal;
//true ya da false olabilir.
//boolean için 0 ya da 1 olamaz.
}
| 151 | 0.666667 | 0.64 | 8 | 17.75 | 14.184058 | 36 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.25 | false | false |
10
|
1c08c8b39b6e165d7f2cf5c8a3dbc49187f0994e
| 28,767,690,982,302 |
e6b91240c7c1e4cd9fb9eed7f10232c9281c7fcc
|
/src/main/java/ues/fmocc/ingenieria/tpi1352019/accesodatos/libreriadatostaller/Propietario.java
|
fa3707cc3f04220543098264a0dd1453f6f5b6f7
|
[] |
no_license
|
tpi135-2019/DataLib
|
https://github.com/tpi135-2019/DataLib
|
114640b5ca07ea4c0097f624df1b5e7a60150d75
|
02dd756765ed71769e4ceb31e2ad6c9661f12bde
|
refs/heads/master
| 2022-07-09T13:09:54.180000 | 2019-06-25T03:19:30 | 2019-06-25T03:19:30 | 178,628,359 | 0 | 0 | null | false | 2022-06-21T01:19:59 | 2019-03-31T01:12:52 | 2019-06-25T03:19:37 | 2022-06-21T01:19:58 | 50 | 0 | 0 | 2 |
Java
| false | false |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ues.fmocc.ingenieria.tpi1352019.accesodatos.libreriadatostaller;
import java.io.Serializable;
import java.util.Collection;
import javax.json.bind.annotation.JsonbTransient;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
/**
*
* @author kevin
*/
@Entity
@Table(name = "propietario")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Propietario.findAll", query = "SELECT p FROM Propietario p")
, @NamedQuery(name = "Propietario.VehiculosPropietario", query = "SELECT t FROM Vehiculo t WHERE t.idPropietario.idPropietario = :idPropietario")
, @NamedQuery(name = "Propietario.findByIdPropietario", query = "SELECT p FROM Propietario p WHERE p.idPropietario = :idPropietario")
, @NamedQuery(name = "Propietario.findByIdLike", query = "SELECT p FROM Propietario p WHERE p.idPropietario LIKE CONCAT(:id ,'%')")
, @NamedQuery(name = "Propietario.findByNombre", query = "SELECT p FROM Propietario p WHERE p.nombre = :nombre")
, @NamedQuery(name = "Propietario.findByApellido", query = "SELECT p FROM Propietario p WHERE p.apellido = :apellido")
, @NamedQuery(name = "Propietario.findByDireccion", query = "SELECT p FROM Propietario p WHERE p.direccion = :direccion")
, @NamedQuery(name = "Propietario.findByTelefono", query = "SELECT p FROM Propietario p WHERE p.telefono = :telefono")})
public class Propietario implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(name = "id_propietario", nullable = false)
@javax.validation.constraints.NotNull(message = "Identificador no debe ser nulo")
private Integer idPropietario;
@Basic(optional = false)
@Column(name = "nombre", nullable = false, length = 45)
@NotBlank(message = "Introdusca un nombre de propietario")
private String nombre;
@Basic(optional = false)
@Column(name = "apellido", nullable = false, length = 45)
private String apellido;
@Column(name = "direccion", length = 200)
@Size(min = 10)
private String direccion;
@Column(name = "telefono", length = 45)
@Pattern(regexp = "[0-9]{4}-[0-9]{4}", message = "Introdusca un numero de telefono correcto")
private String telefono;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "idPropietario")
private Collection<Vehiculo> vehiculoCollection;
public Propietario() {
}
public Propietario(Integer idPropietario) {
this.idPropietario = idPropietario;
}
public Propietario(Integer idPropietario, String nombre, String apellido) {
this.idPropietario = idPropietario;
this.nombre = nombre;
this.apellido = apellido;
}
public Integer getIdPropietario() {
return idPropietario;
}
public void setIdPropietario(Integer idPropietario) {
this.idPropietario = idPropietario;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getApellido() {
return apellido;
}
public void setApellido(String apellido) {
this.apellido = apellido;
}
public String getDireccion() {
return direccion;
}
public void setDireccion(String direccion) {
this.direccion = direccion;
}
public String getTelefono() {
return telefono;
}
public void setTelefono(String telefono) {
this.telefono = telefono;
}
@XmlTransient
@JsonbTransient
public Collection<Vehiculo> getVehiculoCollection() {
return vehiculoCollection;
}
public void setVehiculoCollection(Collection<Vehiculo> vehiculoCollection) {
this.vehiculoCollection = vehiculoCollection;
}
@Override
public int hashCode() {
int hash = 0;
hash += (idPropietario != null ? idPropietario.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Propietario)) {
return false;
}
Propietario other = (Propietario) object;
return !((this.idPropietario == null && other.idPropietario != null) || (this.idPropietario != null && !this.idPropietario.equals(other.idPropietario))
|| (this.nombre != null && !this.nombre.equals(other.getNombre())));
}
@Override
public String toString() {
return "ues.fmocc.ingenieria.tpi1352019.accesodatos.libreriadatostaller.Propietario[ idPropietario=" + idPropietario + " ]";
}
}
|
UTF-8
|
Java
| 5,297 |
java
|
Propietario.java
|
Java
|
[
{
"context": "l.bind.annotation.XmlTransient;\n\n/**\n *\n * @author kevin\n */\n@Entity\n@Table(name = \"propietario\")\n@XmlR",
"end": 926,
"score": 0.723237156867981,
"start": 924,
"tag": "NAME",
"value": "ke"
},
{
"context": "ind.annotation.XmlTransient;\n\n/**\n *\n * @author kevin\n */\n@Entity\n@Table(name = \"propietario\")\n@XmlRoot",
"end": 929,
"score": 0.8715366125106812,
"start": 926,
"tag": "USERNAME",
"value": "vin"
}
] | null |
[] |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ues.fmocc.ingenieria.tpi1352019.accesodatos.libreriadatostaller;
import java.io.Serializable;
import java.util.Collection;
import javax.json.bind.annotation.JsonbTransient;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
/**
*
* @author kevin
*/
@Entity
@Table(name = "propietario")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Propietario.findAll", query = "SELECT p FROM Propietario p")
, @NamedQuery(name = "Propietario.VehiculosPropietario", query = "SELECT t FROM Vehiculo t WHERE t.idPropietario.idPropietario = :idPropietario")
, @NamedQuery(name = "Propietario.findByIdPropietario", query = "SELECT p FROM Propietario p WHERE p.idPropietario = :idPropietario")
, @NamedQuery(name = "Propietario.findByIdLike", query = "SELECT p FROM Propietario p WHERE p.idPropietario LIKE CONCAT(:id ,'%')")
, @NamedQuery(name = "Propietario.findByNombre", query = "SELECT p FROM Propietario p WHERE p.nombre = :nombre")
, @NamedQuery(name = "Propietario.findByApellido", query = "SELECT p FROM Propietario p WHERE p.apellido = :apellido")
, @NamedQuery(name = "Propietario.findByDireccion", query = "SELECT p FROM Propietario p WHERE p.direccion = :direccion")
, @NamedQuery(name = "Propietario.findByTelefono", query = "SELECT p FROM Propietario p WHERE p.telefono = :telefono")})
public class Propietario implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(name = "id_propietario", nullable = false)
@javax.validation.constraints.NotNull(message = "Identificador no debe ser nulo")
private Integer idPropietario;
@Basic(optional = false)
@Column(name = "nombre", nullable = false, length = 45)
@NotBlank(message = "Introdusca un nombre de propietario")
private String nombre;
@Basic(optional = false)
@Column(name = "apellido", nullable = false, length = 45)
private String apellido;
@Column(name = "direccion", length = 200)
@Size(min = 10)
private String direccion;
@Column(name = "telefono", length = 45)
@Pattern(regexp = "[0-9]{4}-[0-9]{4}", message = "Introdusca un numero de telefono correcto")
private String telefono;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "idPropietario")
private Collection<Vehiculo> vehiculoCollection;
public Propietario() {
}
public Propietario(Integer idPropietario) {
this.idPropietario = idPropietario;
}
public Propietario(Integer idPropietario, String nombre, String apellido) {
this.idPropietario = idPropietario;
this.nombre = nombre;
this.apellido = apellido;
}
public Integer getIdPropietario() {
return idPropietario;
}
public void setIdPropietario(Integer idPropietario) {
this.idPropietario = idPropietario;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getApellido() {
return apellido;
}
public void setApellido(String apellido) {
this.apellido = apellido;
}
public String getDireccion() {
return direccion;
}
public void setDireccion(String direccion) {
this.direccion = direccion;
}
public String getTelefono() {
return telefono;
}
public void setTelefono(String telefono) {
this.telefono = telefono;
}
@XmlTransient
@JsonbTransient
public Collection<Vehiculo> getVehiculoCollection() {
return vehiculoCollection;
}
public void setVehiculoCollection(Collection<Vehiculo> vehiculoCollection) {
this.vehiculoCollection = vehiculoCollection;
}
@Override
public int hashCode() {
int hash = 0;
hash += (idPropietario != null ? idPropietario.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Propietario)) {
return false;
}
Propietario other = (Propietario) object;
return !((this.idPropietario == null && other.idPropietario != null) || (this.idPropietario != null && !this.idPropietario.equals(other.idPropietario))
|| (this.nombre != null && !this.nombre.equals(other.getNombre())));
}
@Override
public String toString() {
return "ues.fmocc.ingenieria.tpi1352019.accesodatos.libreriadatostaller.Propietario[ idPropietario=" + idPropietario + " ]";
}
}
| 5,297 | 0.694544 | 0.688125 | 152 | 33.848682 | 34.020844 | 159 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.539474 | false | false |
10
|
b96e68d07c8c028ed2454fd7c2e63736a0b57986
| 26,688,926,827,954 |
194808b66f004ebf8cd0cff4689c66f15ee5899f
|
/jrpc-core/src/main/java/com/zjj/jrpc/registry/NotifyListener.java
|
21908803daefbbfef386f2f02434ac0d42a6471f
|
[
"Apache-2.0"
] |
permissive
|
JJ-Zou/jRPC
|
https://github.com/JJ-Zou/jRPC
|
b6ed878c06fdfa6c11ce2f95181ad5eca875525c
|
cccc653c90804e9eeaa916ae7d80f45be5d2ca70
|
refs/heads/master
| 2023-04-08T12:23:37.557000 | 2021-04-18T12:08:19 | 2021-04-18T12:08:19 | 347,322,789 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.zjj.jrpc.registry;
import com.zjj.jrpc.common.JRpcURL;
import java.util.List;
public interface NotifyListener {
void notify(JRpcURL url, List<JRpcURL> urls);
}
|
UTF-8
|
Java
| 179 |
java
|
NotifyListener.java
|
Java
|
[] | null |
[] |
package com.zjj.jrpc.registry;
import com.zjj.jrpc.common.JRpcURL;
import java.util.List;
public interface NotifyListener {
void notify(JRpcURL url, List<JRpcURL> urls);
}
| 179 | 0.759777 | 0.759777 | 9 | 18.888889 | 17.916128 | 49 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.555556 | false | false |
10
|
b3122cd8e841d928a07738a06ff562ab45b23428
| 26,688,926,827,818 |
8bcfef7347c5d5488425229d2368cd2face1c745
|
/app/src/main/java/com/omrobbie/cataloguemovie/utils/RxUtil.java
|
94ff65f6aadd459c53c36802643acee7ca67c7bb
|
[] |
no_license
|
madesaguna/CatalogueMovie
|
https://github.com/madesaguna/CatalogueMovie
|
f0c45282b8c4d816038fef22c5ec3afab7cb0fca
|
58c1f425d66470e7f9aec885c7e3c8a821acd9e6
|
refs/heads/configuration_change
| 2022-12-07T23:36:26.905000 | 2017-10-20T03:07:41 | 2017-10-20T03:07:41 | 109,651,551 | 0 | 0 | null | true | 2017-11-06T05:27:24 | 2017-11-06T05:27:24 | 2017-10-02T04:17:20 | 2017-10-20T03:07:53 | 496 | 0 | 0 | 0 | null | false | null |
package com.omrobbie.cataloguemovie.utils;
import android.util.Log;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
public class RxUtil {
public static void dispose(Disposable disposable) {
if (disposable != null && !disposable.isDisposed()) {
disposable.dispose();
}
}
public static void dispose(CompositeDisposable compositeDisposable){
if (compositeDisposable != null && !compositeDisposable.isDisposed()){
compositeDisposable.clear();
}
}
}
|
UTF-8
|
Java
| 571 |
java
|
RxUtil.java
|
Java
|
[] | null |
[] |
package com.omrobbie.cataloguemovie.utils;
import android.util.Log;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
public class RxUtil {
public static void dispose(Disposable disposable) {
if (disposable != null && !disposable.isDisposed()) {
disposable.dispose();
}
}
public static void dispose(CompositeDisposable compositeDisposable){
if (compositeDisposable != null && !compositeDisposable.isDisposed()){
compositeDisposable.clear();
}
}
}
| 571 | 0.690018 | 0.690018 | 21 | 26.190475 | 25.676781 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.285714 | false | false |
10
|
cc0917cbd2b22633ead2484e83073cbd55084c93
| 4,853,313,095,204 |
1690b1a472c7ae779832c00b762464c073baed09
|
/src/org/scapesoft/utilities/game/player/CoinCaskets.java
|
97f1bded3a49ce1329d2e60cf824dea1e15dae6b
|
[] |
no_license
|
bradleysixx/insomniapk-server
|
https://github.com/bradleysixx/insomniapk-server
|
e5d78ab14786e49b18dccf742a6572da698b8ec6
|
e5ec12bfca18ed6885c2a99320f12d908a9168f5
|
refs/heads/master
| 2022-01-23T20:23:22.177000 | 2019-04-02T18:42:24 | 2019-04-02T18:42:24 | 177,716,541 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package org.scapesoft.utilities.game.player;
/**
*
* @author Tyluur <itstyluur@gmail.com>
* @since Aug 11, 2013
*/
public enum CoinCaskets {
/** The casket dropped when a monster dies */
REWARDS(7237, 25000, 75000),
REGULAR(405, 1000, 9000);
CoinCaskets(int itemId, int baseCoinAmount, int extraCoinAmount) {
this.itemId = itemId;
this.baseCoinAmount = baseCoinAmount;
this.extraCoinAmount = extraCoinAmount;
}
private final int itemId;
private final int baseCoinAmount;
private final int extraCoinAmount;
/**
* @return the itemId
*/
public int getItemId() {
return itemId;
}
/**
* @return the baseCoinAmount
*/
public int getBaseCoinAmount() {
return baseCoinAmount;
}
/**
* @return the extraCoinAmount
*/
public int getExtraCoinAmount() {
return extraCoinAmount;
}
/**
* Gets a casket by the item id
*
* @param itemId
* The id of the item
* @return
*/
public static CoinCaskets getCasket(int itemId) {
for (CoinCaskets caskets : CoinCaskets.values())
if (caskets.getItemId() == itemId)
return caskets;
return null;
}
}
|
UTF-8
|
Java
| 1,116 |
java
|
CoinCaskets.java
|
Java
|
[
{
"context": "capesoft.utilities.game.player;\n\n/**\n *\n * @author Tyluur <itstyluur@gmail.com>\n * @since Aug 11, 2013\n */\n",
"end": 70,
"score": 0.999351978302002,
"start": 64,
"tag": "USERNAME",
"value": "Tyluur"
},
{
"context": "utilities.game.player;\n\n/**\n *\n * @author Tyluur <itstyluur@gmail.com>\n * @since Aug 11, 2013\n */\npublic enum CoinCaske",
"end": 91,
"score": 0.9999324083328247,
"start": 72,
"tag": "EMAIL",
"value": "itstyluur@gmail.com"
}
] | null |
[] |
package org.scapesoft.utilities.game.player;
/**
*
* @author Tyluur <<EMAIL>>
* @since Aug 11, 2013
*/
public enum CoinCaskets {
/** The casket dropped when a monster dies */
REWARDS(7237, 25000, 75000),
REGULAR(405, 1000, 9000);
CoinCaskets(int itemId, int baseCoinAmount, int extraCoinAmount) {
this.itemId = itemId;
this.baseCoinAmount = baseCoinAmount;
this.extraCoinAmount = extraCoinAmount;
}
private final int itemId;
private final int baseCoinAmount;
private final int extraCoinAmount;
/**
* @return the itemId
*/
public int getItemId() {
return itemId;
}
/**
* @return the baseCoinAmount
*/
public int getBaseCoinAmount() {
return baseCoinAmount;
}
/**
* @return the extraCoinAmount
*/
public int getExtraCoinAmount() {
return extraCoinAmount;
}
/**
* Gets a casket by the item id
*
* @param itemId
* The id of the item
* @return
*/
public static CoinCaskets getCasket(int itemId) {
for (CoinCaskets caskets : CoinCaskets.values())
if (caskets.getItemId() == itemId)
return caskets;
return null;
}
}
| 1,104 | 0.676523 | 0.648746 | 60 | 17.616667 | 16.914581 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.316667 | false | false |
10
|
1ed184fc3504cd771b6219d5c0a3a9d0d188c926
| 13,761,075,238,749 |
8102e0d7deb44d4d8ee4aca82055563519930946
|
/EcrireImage.java
|
da3b9c1d150680271e73dcb192376502aefa9601
|
[] |
no_license
|
CiaohoanG/ProjetImageNGUYEN
|
https://github.com/CiaohoanG/ProjetImageNGUYEN
|
d8a694f421ff29fed7dbdd4bdf61e2714bec90d8
|
ac727375308a9ccb6b008b0100ce8a152bf05f9c
|
refs/heads/master
| 2020-06-05T06:41:53.967000 | 2014-06-30T00:00:31 | 2014-06-30T00:00:31 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class EcrireImage {
static void write(BufferedImage img, String format, String name)throws IOException {
try {
ImageIO.write(img, format, new File(name));
} catch (IOException e) {
System.out.println("ERREUR");
e.printStackTrace();
}
}
}
|
UTF-8
|
Java
| 403 |
java
|
EcrireImage.java
|
Java
|
[] | null |
[] |
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class EcrireImage {
static void write(BufferedImage img, String format, String name)throws IOException {
try {
ImageIO.write(img, format, new File(name));
} catch (IOException e) {
System.out.println("ERREUR");
e.printStackTrace();
}
}
}
| 403 | 0.687345 | 0.687345 | 19 | 19.210526 | 21.313644 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.473684 | false | false |
10
|
b49603ebd582abf0a02c7df91f8dac3f4693bb0e
| 22,351,009,813,825 |
2cd7f7c67f33c53e32c5a9b3067827d577a6d5ea
|
/bddapi/StepDefination/Runner.java
|
2c4544ae41fdbd9967a34ebf3499cd8c330c9e94
|
[] |
no_license
|
rahul1590/Practice
|
https://github.com/rahul1590/Practice
|
4099df6189eb17b6f7bb9058c4ecec42bb6fb2fa
|
741c996b4e95cb3478b5ce1c39af3b8608c802d4
|
refs/heads/master
| 2023-02-02T13:46:45.635000 | 2023-01-14T00:53:48 | 2023-01-14T00:53:48 | 234,861,656 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package bddapi.StepDefination;
import org.junit.runner.RunWith;
import io.cucumber.junit.CucumberOptions;
//@RunWith(Cucumber.class)
@CucumberOptions(
features = "src/test/java/bddapi.features",
glue = "bddapi.StepDefinitions",
tags = "@smoke"
)
public class Runner {
}
|
UTF-8
|
Java
| 315 |
java
|
Runner.java
|
Java
|
[] | null |
[] |
package bddapi.StepDefination;
import org.junit.runner.RunWith;
import io.cucumber.junit.CucumberOptions;
//@RunWith(Cucumber.class)
@CucumberOptions(
features = "src/test/java/bddapi.features",
glue = "bddapi.StepDefinitions",
tags = "@smoke"
)
public class Runner {
}
| 315 | 0.663492 | 0.663492 | 16 | 17.6875 | 17.207262 | 51 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.3125 | false | false |
10
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.