blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
7
332
content_id
stringlengths
40
40
detected_licenses
listlengths
0
50
license_type
stringclasses
2 values
repo_name
stringlengths
7
115
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
557 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
5.85k
684M
star_events_count
int64
0
77.7k
fork_events_count
int64
0
48k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
82 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
7
5.41M
extension
stringclasses
11 values
content
stringlengths
7
5.41M
authors
listlengths
1
1
author
stringlengths
0
161
59a1e6e94daa373485b3f7170433413a9e31f09a
990b3036c509963af343e5d90af03bc05d586a6b
/OrderService/src/main/java/demo/model/Order.java
6c2396d4e76f2d804408d7ab33dd47fe2606e5be
[]
no_license
sibendu/EventDrivenMicroServices
a79e92ff9a158cdd14af5cd85be4f99b15eeced5
ef013c1113e93dba3eaf9e6b742308db407e8c01
refs/heads/master
2020-09-13T17:39:15.128153
2019-11-20T05:38:52
2019-11-20T05:38:52
222,857,713
0
0
null
null
null
null
UTF-8
Java
false
false
3,370
java
package demo.model; import java.io.*; import java.util.*; import javax.persistence.*; import org.springframework.data.domain.*; @Entity @Table(name = "demo_order") public class Order implements Serializable{ @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id; private String status; private Date createdDate; private Date updatedDate; private Double totalValue; public void addItem(Item item){ if(this.items == null){ this.items = new ArrayList<Item>(); } if(item.getValue() == null){ item.setValue(item.getBasePrice() * item.getQuantity() * item.getDiscount()); } this.items.add(item); if(this.totalValue == null){ this.totalValue = new Double(0); } this.totalValue = this.totalValue + item.getValue(); } @OneToOne(cascade = CascadeType.PERSIST , fetch=FetchType.EAGER) @JoinColumn(name = "customer_id") private Customer customer; @OneToOne(cascade = CascadeType.PERSIST, fetch=FetchType.EAGER) @JoinColumn(name = "bill_address_id") private Address billAddress; @OneToOne(cascade = CascadeType.PERSIST, fetch=FetchType.EAGER) @JoinColumn(name = "ship_address_id") private Address shipAddress; @OneToMany(cascade = CascadeType.PERSIST, fetch=FetchType.EAGER) @JoinColumn(name = "item_id") private List<Item> items; protected Order() {} public Order(Customer customer, Address billAddress, Address shipAddress) { this.createdDate= new Date(); this.customer = customer; this.status = "NEW"; this.billAddress = billAddress; this.shipAddress = shipAddress; this.totalValue = new Double(0); } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getStatus() { return status; } public void setStatus(String status) { this.status = status; } public Date getCreatedDate() { return createdDate; } public void setCreatedDate(Date createdDate) { this.createdDate = createdDate; } public Date getUpdatedDate() { return updatedDate; } public void setUpdatedDate(Date updatedDate) { this.updatedDate = updatedDate; } public Double getTotalValue() { return totalValue; } public void setTotalValue(Double totalValue) { this.totalValue = totalValue; } public Customer getCustomer() { return customer; } public void setCustomer(Customer customer) { this.customer = customer; } public Address getBillAddress() { return billAddress; } public void setBillAddress(Address billAddress) { this.billAddress = billAddress; } public Address getShipAddress() { return shipAddress; } public void setShipAddress(Address shipAddress) { this.shipAddress = shipAddress; } @Override public String toString() { return String.format( "Order[id=%d, status='%s', createdDate='%s', customer='%s', billAddress='%s', shipAddress='%s', items='%s' ]", id, status, createdDate, customer, billAddress, shipAddress, items); } public List<Item> getItems() { return items; } public void setItems(List<Item> items) { this.items = items; } }
d6c9f179c3cd6d4684dbe1f4ea1dac58f7a1efaa
73ffe17f1fc7fb0105471acea4bacf2a2d7a7905
/sort sorted array by center.java
e262add62333ea040350a5b3e2f8425d87854781
[]
no_license
hengshaochen/DS-ALOG-HG
208a73460caff72a218257c694118f40b0d74943
7e52cbc07d3fceb543c00aa2eb36962d43771ba4
refs/heads/master
2020-03-31T04:25:27.110731
2019-05-26T23:03:27
2019-05-26T23:03:27
151,904,446
0
0
null
null
null
null
UTF-8
Java
false
false
1,560
java
// "static void main" must be defined in a public class. public class Main { public static void main(String[] args) { new Main(); } public Main() { int[] nums = {1, 3, 4, 5, 9}; double center = 4.5; int[] ans = sortByCenter(nums, center); for (int i = 0; i < ans.length; i++) { System.out.print(ans[i] + " "); } } int[] sortByCenter(int[] nums, double center) { int[] ans = new int[nums.length]; int start = 0, end = nums.length - 1; while (start + 1 < end) { int mid = (start + end) / 2; if (nums[mid] < center) { start = mid; } else { end = mid; } } int l = 0, r = 0; if (Math.abs(nums[start] - center) <= Math.abs(nums[end] - center)) { // start比較接近 l = start; r = start; } else { l = end; r = end; } int idx = 0; ans[idx++] = nums[l]; l--; r++; while (l >= 0 && r < nums.length) { if (Math.abs(nums[l] - center) <= Math.abs(nums[r] - center)) { ans[idx++] = nums[l--]; } else { ans[idx++] = nums[r++]; } } while (l >= 0) { ans[idx++] = nums[l--]; } while (r < nums.length) { ans[idx++] = nums[r++]; } return ans; } }
0072fec3c14c7c381d0cb88696539d3e29e2b0a8
a5157e3cb802588df0f9c9b9a92f3bbd43d384d9
/VotesCounter.java
ed339ef7f31b2d6839d4df73449c36e69f5d626d
[]
no_license
Azaro1805/Java-Thread-Project
e9f58c7dd2a534b55df77ab9128cf34fcf9fdbe2
f1817119f01bc69b56312fdffb3b27c4b0b0aa28
refs/heads/master
2022-12-01T07:21:16.060632
2020-08-02T07:35:52
2020-08-02T07:35:52
284,228,861
0
0
null
null
null
null
UTF-8
Java
false
false
2,344
java
import java.util.Vector; public class VotesCounter { protected Vector <VoteTicket> VoteTickets; //constructor public VotesCounter (Vector <VoteTicket> VoteTickets) { this.VoteTickets=VoteTickets; } //Calculate the results for the mayors- return the mayor name of the winner public String calculateMayorResults() { Vector <String> MayorVotes= new Vector <String>(); for(int i=0; i<VoteTickets.size(); i++) { String mayor=VoteTickets.elementAt(i).mayorSelection; MayorVotes.add(mayor); } int num=0, max=0; String mayorwinner= ""; while (!MayorVotes.isEmpty()){ num=0; String s= MayorVotes.elementAt(0); for(int i=0; i<MayorVotes.size(); i++) if(MayorVotes.elementAt(i).equals(s)){ num++; MayorVotes.removeElementAt(i); i--; } if(num>max){ max=num; mayorwinner= s; } } return mayorwinner; } //Calculate the results for the lists- return the list name of the winner public String calculateListResults() { Vector <String> ListVotes= new Vector <String>(); for(int i=0; i<VoteTickets.size(); i++) { String list=VoteTickets.elementAt(i).listSelection; ListVotes.add(list); } int num=0, max=0; String listwinner= ""; while (!ListVotes.isEmpty()){ num=0; String s= ListVotes.elementAt(0); for(int i=0; i<ListVotes.size(); i++) if(ListVotes.elementAt(i).equals(s)){ num++; ListVotes.removeElementAt(i); i--; } if(num>max){ max=num; listwinner= s; } } return listwinner; } //prints the election results public void printResults() { System.out.println("The next mayor is :" + calculateMayorResults()); System.out.println("The list with most votes is :" + calculateListResults()); } //Calculate the voting percentage of the mayor public void calculatePercent() { Vector <VoteTicket> VoteTickets2= new Vector <VoteTicket> (); VoteTickets2.addAll(VoteTickets); while (!VoteTickets2.isEmpty()) { String mayor= VoteTickets2.elementAt(0).mayorSelection; double num=0; for(int i=0; i<VoteTickets2.size(); i++) if (mayor.equals(VoteTickets2.elementAt(i).mayorSelection)) { num=num+1; VoteTickets2.removeElementAt(i); i--; } double percent= (num/VoteTickets.size())*100; System.out.println("Percent voted for "+ mayor+ " : "+ percent+"%"); } } }
89019b9f2ac872c31f73f9ba99f5d77f434b3046
655a67d0327f470801b7dc4cd67ce8b5cb54108d
/duke/oracle_idm/connectors/tasks_email/trunk/src/edu/duke/oit/idms/oracle/connectors/tasks_email/routing/RoutingData.java
5ebf89ad918de2cc5cef60c1c126966a08edb7d2
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
carte018/i2pr-collab
690b8608a0801d66b2dc0dda829a841e75b35f68
b1aa7af56d71ee2ccb414a86031eed174316d509
refs/heads/master
2021-01-18T14:38:35.185180
2011-08-01T13:37:28
2011-08-01T13:37:28
1,691,858
2
0
null
null
null
null
UTF-8
Java
false
false
3,758
java
package edu.duke.oit.idms.oracle.connectors.tasks_email.routing; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import com.thortech.util.logging.Logger; import com.thortech.xl.util.logging.LoggerModules; import edu.duke.oit.idms.oracle.connectors.tasks_email.EmailUsers; import edu.duke.oit.idms.oracle.connectors.tasks_email.TasksData; import Thor.API.tcResultSet; import Thor.API.Exceptions.tcAPIException; import Thor.API.Exceptions.tcColumnNotFoundException; import Thor.API.Exceptions.tcGroupNotFoundException; import Thor.API.Operations.tcGroupOperationsIntf; public class RoutingData { private static Logger logger = Logger.getLogger(LoggerModules.XL_SCHEDULER_TASKS); private TasksData tasksData; private DepartmentRestrictionsData deptRestrictionsData; private HashSet<Long> groupMembers; /** * @param resourceName * @param moProvUtility * @param moUserUtility * @param moObjectUtility * @param moITResourceUtility * @throws Exception */ public RoutingData (String connectorName, String resourceName, tcGroupOperationsIntf moGroupUtility) throws Exception { if (resourceName.equals("") || resourceName == null) { String msg = EmailUsers.addLogEntry(connectorName, "FAILED", "Can't instantiate RoutingData with null resourceName value"); logger.info(msg); } else { tasksData = TasksData.getInstance(resourceName); deptRestrictionsData = DepartmentRestrictionsData.getInstance(); String groupName = tasksData.getProperty("group"); groupMembers = addGroupMembers(connectorName, groupName, moGroupUtility); if (groupMembers == null || groupMembers.isEmpty()) { throw new RuntimeException(EmailUsers.addLogEntry(connectorName, "WARNING", "Could not populate group for: " + groupName)); } } } private HashSet<Long> addGroupMembers(String connectorName, String groupName, tcGroupOperationsIntf moGroupUtility) { HashSet<Long> userKeys = new HashSet<Long>(); try { Map<String, String> groupAttributes = new HashMap<String, String>(); groupAttributes.put("Groups.Group Name", groupName); tcResultSet groupKeySet = moGroupUtility.findGroups(groupAttributes); if (groupKeySet.getRowCount() != 1) { logger.info(EmailUsers.addLogEntry(connectorName, "WARNING", "Expected 1 result for eDiscovery group name, received: " + groupKeySet.getRowCount())); } groupKeySet.goToRow(0); long groupKey = (groupKeySet.getLongValue("Groups.Key")); tcResultSet memberUsers = moGroupUtility.getAllMemberUsers(groupKey); for (int i = 0; i < memberUsers.getRowCount(); ++i) { memberUsers.goToRow(i); userKeys.add(memberUsers.getLongValue("Users.Key")); } } catch (tcAPIException e) { String msg = EmailUsers.addLogEntry(connectorName, "WARNING", "Could not initialize tcGroupOperationIntf to retrieve eDiscovery Group Key: " + e.getMessage()); logger.info(msg); } catch (tcColumnNotFoundException e) { String msg = EmailUsers.addLogEntry(connectorName, "WARNING", "Group Key not found for Group, verify name in properties file: " + groupName); logger.info(msg); } catch (tcGroupNotFoundException e) { String msg = EmailUsers.addLogEntry(connectorName, "WARNING", "Group Key not found for Group, verify name in properties file: " + groupName); logger.info(msg); } return userKeys; } public TasksData getTasksData() { return tasksData; } public DepartmentRestrictions getDeptRestrictionsClass(String dept) throws InstantiationException, IllegalAccessException { return deptRestrictionsData.getDeptRestrictionsClass(dept); } public DepartmentRestrictionsData getRestrictionsData() { return deptRestrictionsData; } public HashSet<Long> getGroupMembers() { return groupMembers; } }
e7a0023f414d193d9f3c5bf385d220b53b0cb387
c756df50936189899909e78377c26622cf59e61c
/src/main/java/com/ensa/services/EnseignantService.java
afcdc515b0f2c15df67e3490821409eabe60f277
[]
no_license
Imayd/siback
aa5547d04d7a67ac1ed9d417c0c57c54551162c3
19c49edb7529abdcb807098bdfec7275fe85a527
refs/heads/main
2023-03-03T16:37:01.290489
2021-02-10T07:36:47
2021-02-10T07:36:47
337,650,419
0
0
null
null
null
null
UTF-8
Java
false
false
691
java
package com.ensa.services; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ensa.entities.Enseignant; import com.ensa.repositories.EnseignantRepo; @Service public class EnseignantService { @Autowired private EnseignantRepo profRepository; public Enseignant addProf(Enseignant prof) throws Exception { Enseignant savedProf = this.profRepository.save(prof); return savedProf; } public Enseignant updateProf(Long id, Enseignant prof) throws Exception { prof.setId(id); Enseignant savedProf = this.profRepository.save(prof); return savedProf; } }
100929848ffaa4788b3bad2a5d8fe7e6a1a33991
a195a0e0e2d43e50e66d697f84327861d4b9b5b3
/src/java/com/rapleaf/hank/storage/curly/CurlyUpdater.java
09dccac5a83d7e3b20a7a68c5c01ddf1051576bd
[]
no_license
ekoontz/hank
9d2dadacb14388933f62784f077e8a2fa5aae1ff
5d0c44e306b4a35d208dd5969934e5a5a27eb0ac
refs/heads/master
2021-01-24T00:54:50.479306
2011-06-30T22:42:47
2011-06-30T22:42:47
2,002,356
0
0
null
null
null
null
UTF-8
Java
false
false
7,323
java
/** * Copyright 2011 Rapleaf * * 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.rapleaf.hank.storage.curly; import java.io.File; import java.io.IOException; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; import com.rapleaf.hank.compress.CompressionCodec; import com.rapleaf.hank.storage.Updater; import com.rapleaf.hank.storage.cueball.Cueball; import com.rapleaf.hank.storage.cueball.CueballMerger; import com.rapleaf.hank.storage.cueball.Fetcher; import com.rapleaf.hank.storage.cueball.ICueballMerger; import com.rapleaf.hank.storage.cueball.IFetcher; import com.rapleaf.hank.storage.cueball.IFileOps; import com.rapleaf.hank.storage.cueball.ValueTransformer; import com.rapleaf.hank.util.EncodingHelper; public class CurlyUpdater implements Updater { public static final class OffsetTransformer implements ValueTransformer { private final long[] offsetAdjustments; private final int offsetSize; public OffsetTransformer(int offsetSize, long[] offsetAdjustments) { this.offsetSize = offsetSize; this.offsetAdjustments = offsetAdjustments; } @Override public void transform(byte[] buf, int valueOff, int relIndex) { long adjustment = offsetAdjustments[relIndex]; if (adjustment != 0) { long offset = EncodingHelper.decodeLittleEndianFixedWidthLong(buf, valueOff, offsetSize); offset += adjustment; EncodingHelper.encodeLittleEndianFixedWidthLong(offset, buf, valueOff, offsetSize); } } } private final String localPartitionRoot; private final int keyHashSize; private final int offsetSize; private final IFetcher fetcher; private final ICurlyMerger curlyMerger; private final ICueballMerger cueballMerger; private final int hashIndexBits; private final CompressionCodec compressionCodec; public CurlyUpdater(String localPartitionRoot, String remotePartitionRoot, int keyHashSize, int offsetSize, IFileOps fileOps, CompressionCodec compressionCodec, int hashIndexBits) { this(localPartitionRoot, keyHashSize, offsetSize, new Fetcher(fileOps, new CurlyFileSelector()), new CurlyMerger(), new CueballMerger(), compressionCodec, hashIndexBits); } CurlyUpdater(String localPartitionRoot, int keyHashSize, int offsetSize, IFetcher fetcher, ICurlyMerger curlyMerger, ICueballMerger cueballMerger, CompressionCodec compressonCodec, int hashIndexBits) { this.localPartitionRoot = localPartitionRoot; this.keyHashSize = keyHashSize; this.offsetSize = offsetSize; this.fetcher = fetcher; this.curlyMerger = curlyMerger; this.cueballMerger = cueballMerger; this.compressionCodec = compressonCodec; this.hashIndexBits = hashIndexBits; } @Override public void update(int toVersion, Set<Integer> excludeVersions) throws IOException { // fetch all the curly and cueball files fetcher.fetch(getLocalVersionNumber(), toVersion, excludeVersions); // figure out which curly files we want to merge SortedSet<String> curlyBases = new TreeSet<String>(); SortedSet<String> curlyDeltas = new TreeSet<String>(); getBasesAndDeltas(localPartitionRoot, curlyBases, curlyDeltas); // merge the latest base and all the deltas newer than it if (curlyBases.isEmpty()) { throw new IllegalStateException("There are no curly bases in " + localPartitionRoot + " after the fetcher ran!"); } String latestCurlyBase = curlyBases.last(); SortedSet<String> relevantCurlyDeltas = curlyDeltas.tailSet(latestCurlyBase); // merge the curly files long[] offsetAdjustments = curlyMerger.merge(latestCurlyBase, relevantCurlyDeltas); // figure out which cueball files we want to merge SortedSet<String> cueballBases = Cueball.getBases(localPartitionRoot); SortedSet<String> cueballDeltas = Cueball.getDeltas(localPartitionRoot); if (cueballBases.isEmpty()) { throw new IllegalStateException("There are no cueball bases in " + localPartitionRoot + " after the fetcher ran!"); } String latestCueballBase = cueballBases.last(); SortedSet<String> relevantCueballDeltas = cueballDeltas.tailSet(latestCurlyBase); if (relevantCueballDeltas.isEmpty()) { // no need to merge! in fact, we're done. } else { // run the cueball merger String newCueballBasePath = localPartitionRoot + "/" + String.format("%05d", Cueball.parseVersionNumber(relevantCueballDeltas.last())) + ".base.cueball"; cueballMerger.merge(latestCueballBase, relevantCueballDeltas, newCueballBasePath, keyHashSize, offsetSize, new OffsetTransformer(offsetSize, offsetAdjustments), hashIndexBits, compressionCodec); // rename the modified base to the current version String newCurlyBasePath = localPartitionRoot + "/" + String.format("%05d", Curly.parseVersionNumber(relevantCurlyDeltas.last())) + ".base.curly"; // TODO: this can fail. watch it. new File(latestCurlyBase).renameTo(new File(newCurlyBasePath)); } // delete all the old curly bases deleteFiles(curlyBases.headSet(latestCurlyBase), cueballBases.headSet(latestCueballBase), curlyDeltas, cueballDeltas); } private int getLocalVersionNumber() { File local = new File(localPartitionRoot); String[] filesInLocal = local.list(); int bestVer = -1; if (filesInLocal != null) { // identify all the bases and deltas for (String file : filesInLocal) { if (file.matches(Curly.BASE_REGEX)) { int thisVer = Curly.parseVersionNumber(file); if (thisVer > bestVer) { bestVer = thisVer; } } } } return bestVer; } public static void getBasesAndDeltas(String localPartitionRoot, SortedSet<String> bases, SortedSet<String> deltas) { File local = new File(localPartitionRoot); String[] filesInLocal = local.list(); if (filesInLocal != null) { // identify all the bases and deltas for (String file : filesInLocal) { if (file.matches(Curly.BASE_REGEX)) { bases.add(localPartitionRoot + "/" + file); } if (file.matches(Curly.DELTA_REGEX)) { deltas.add(localPartitionRoot + "/" + file); } } } } /** * Convenience method for deleting all the files in a bunch of sets * @param sets */ private static void deleteFiles(Set<String>... sets) { for (Set<String> set : sets) { for (String s : set) { if (!new File(s).delete()) { throw new RuntimeException("failed to delete file " + s); } } } } }
e9f11fc922c43a07a993dc8c312be837fbbbde59
6b9baba368ab03acfda8057a724baafbca972697
/src/main/java/com/yiminwu/mapper/CustomMapper.java
e7fbb9e924cd5eb4cf1648e86fb9d8bb5badfa4d
[]
no_license
yiminwu1987/cloudProj
0c9b08a05ddfe1eb14c4c619f2950082b8b8a6f2
712aefeb111e532d0fcacb60b81095a51d053ce6
refs/heads/master
2020-03-22T17:00:31.249695
2018-07-10T02:31:54
2018-07-10T02:31:54
140,366,302
0
0
null
null
null
null
UTF-8
Java
false
false
474
java
package com.yiminwu.mapper; import java.io.Serializable; import java.util.List; import org.apache.ibatis.annotations.Param; import com.github.pagehelper.Page; public interface CustomMapper<T, PK extends Serializable> { /** * 分页查询数据 * @return */ Page<T> getList(@Param(value="name") String name); /** * 删除多个 * @param ids */ int batchDelete(PK[] ids); List<T> selectByName(@Param(value="name") String name); }
16d24afd9ab5fab89007a8b9fb53df3b1c8d527f
fa0db48c91eba43d41707a8963982cc7a6520628
/geo/src/main/java/org/dreambitc/geo/entity/Entity.java
11f3afc86ad51987776de0a4f8101d41ecb5cb4d
[]
no_license
dreambit/geo-project
b93d187aca4ecaee9d0d5e14c113c707170a9a49
1e09841a3a0fd52f6f8de9bc86221d0572e2efb2
refs/heads/master
2021-01-17T06:27:04.621975
2015-04-19T22:41:24
2015-04-19T22:41:24
27,999,396
0
0
null
null
null
null
UTF-8
Java
false
false
115
java
package org.dreambitc.geo.entity; import java.io.Serializable; public interface Entity extends Serializable { }
a9d022037f85152d2cd152bc4c644d5f5541f1c1
4627d514d6664526f58fbe3cac830a54679749cd
/results/cling/closure-com.google.javascript.rhino.head.NativeObject-com.google.javascript.rhino.head.ScriptableObject-16/com/google/javascript/rhino/head/NativeObject_ESTest.java
ffd55831688c04f955cbffb59880eea34796cf1b
[]
no_license
STAMP-project/Cling-application
c624175a4aa24bb9b29b53f9b84c42a0f18631bd
0ff4d7652b434cbfd9be8d8bb38cfc8d8eaa51b5
refs/heads/master
2022-07-27T09:30:16.423362
2022-07-19T12:01:46
2022-07-19T12:01:46
254,310,667
2
2
null
2021-07-12T12:29:50
2020-04-09T08:11:35
null
UTF-8
Java
false
false
16,542
java
/* * Tue Mar 03 18:55:04 GMT 2020 */ package com.google.javascript.rhino.head; import org.junit.Test; import org.junit.Ignore; import static org.junit.Assert.*; import static org.evosuite.shaded.org.mockito.Mockito.*; import static org.evosuite.runtime.EvoAssertions.*; import com.google.javascript.rhino.head.BaseFunction; import com.google.javascript.rhino.head.BoundFunction; import com.google.javascript.rhino.head.CompilerEnvirons; import com.google.javascript.rhino.head.Context; import com.google.javascript.rhino.head.ContextFactory; import com.google.javascript.rhino.head.EcmaError; import com.google.javascript.rhino.head.ErrorReporter; import com.google.javascript.rhino.head.Evaluator; import com.google.javascript.rhino.head.EvaluatorException; import com.google.javascript.rhino.head.IdFunctionObject; import com.google.javascript.rhino.head.ImporterTopLevel; import com.google.javascript.rhino.head.Interpreter; import com.google.javascript.rhino.head.JavaAdapter; import com.google.javascript.rhino.head.LazilyLoadedCtor; import com.google.javascript.rhino.head.NativeArray; import com.google.javascript.rhino.head.NativeContinuation; import com.google.javascript.rhino.head.NativeGenerator; import com.google.javascript.rhino.head.NativeIterator; import com.google.javascript.rhino.head.NativeJavaClass; import com.google.javascript.rhino.head.NativeJavaPackage; import com.google.javascript.rhino.head.NativeJavaTopPackage; import com.google.javascript.rhino.head.NativeNumber; import com.google.javascript.rhino.head.NativeObject; import com.google.javascript.rhino.head.Script; import com.google.javascript.rhino.head.Scriptable; import com.google.javascript.rhino.head.ScriptableObject; import org.evosuite.runtime.EvoRunner; import org.evosuite.runtime.EvoRunnerParameters; import org.evosuite.runtime.ViolatedAssumptionAnswer; import org.junit.runner.RunWith; @RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, separateClassLoader = false, useJEE = true) public class NativeObject_ESTest extends NativeObject_ESTest_scaffolding { @Test(timeout = 4000) @Ignore public void test00() throws Throwable { NativeObject nativeObject0 = new NativeObject(); Class<NativeContinuation> class0 = NativeContinuation.class; String string0 = ScriptableObject.defineClass((Scriptable) nativeObject0, class0, true, true); assertNull(string0); } @Test(timeout = 4000) public void test01() throws Throwable { NativeIterator.StopIteration nativeIterator_StopIteration0 = new NativeIterator.StopIteration(); Class<NativeJavaPackage> class0 = NativeJavaPackage.class; // Undeclared exception! try { nativeIterator_StopIteration0.defineProperty("+bXOc5S tzFnU==u", class0, (-1446)); fail("Expecting exception: IllegalArgumentException"); } catch(IllegalArgumentException e) { // // -1445 // verifyException("com.google.javascript.rhino.head.ScriptableObject", e); } } @Test(timeout = 4000) @Ignore public void test02() throws Throwable { NativeObject nativeObject0 = new NativeObject(); Class<NativeArray> class0 = NativeArray.class; // Undeclared exception! try { ScriptableObject.buildClassCtor((Scriptable) nativeObject0, class0, false, false); fail("Expecting exception: EvaluatorException"); } catch(EvaluatorException e) { // // Cannot load class \"com.google.javascript.rhino.head.NativeArray\" which has no zero-parameter constructor. // verifyException("com.google.javascript.rhino.head.DefaultErrorReporter", e); } } @Test(timeout = 4000) @Ignore public void test03() throws Throwable { NativeIterator.StopIteration nativeIterator_StopIteration0 = new NativeIterator.StopIteration(); boolean boolean0 = ScriptableObject.isFalse(nativeIterator_StopIteration0); assertFalse(boolean0); } @Test(timeout = 4000) public void test04() throws Throwable { NativeObject nativeObject0 = new NativeObject(); boolean boolean0 = nativeObject0.sameValue(nativeObject0, nativeObject0); assertTrue(boolean0); } @Test(timeout = 4000) public void test05() throws Throwable { NativeObject nativeObject0 = new NativeObject(); ImporterTopLevel importerTopLevel0 = new ImporterTopLevel(); IdFunctionObject idFunctionObject0 = nativeObject0.exportAsJSClass(1000000, importerTopLevel0, false); // Undeclared exception! try { nativeObject0.execIdCall(idFunctionObject0, (Context) null, importerTopLevel0, idFunctionObject0, (Object[]) null); fail("Expecting exception: NullPointerException"); } catch(NullPointerException e) { // // no message in exception (getMessage() returned null) // verifyException("com.google.javascript.rhino.head.NativeObject", e); } } @Test(timeout = 4000) @Ignore public void test06() throws Throwable { NativeObject nativeObject0 = new NativeObject(); Context context0 = Context.getCurrentContext(); ImporterTopLevel importerTopLevel0 = new ImporterTopLevel(context0, true); boolean boolean0 = nativeObject0.sameValue(importerTopLevel0, context0.VERSION_1_4); assertFalse(boolean0); } @Test(timeout = 4000) @Ignore public void test07() throws Throwable { NativeObject nativeObject0 = new NativeObject(); String[] stringArray0 = new String[4]; stringArray0[0] = "R$c)$f;N"; Class<NativeObject> class0 = NativeObject.class; // Undeclared exception! try { nativeObject0.defineFunctionProperties(stringArray0, class0, 180); fail("Expecting exception: EvaluatorException"); } catch(EvaluatorException e) { // // Method \"R$c)$f;N\" not found in \"com.google.javascript.rhino.head.NativeObject\". // verifyException("com.google.javascript.rhino.head.DefaultErrorReporter", e); } } @Test(timeout = 4000) public void test08() throws Throwable { NativeNumber nativeNumber0 = new NativeNumber((-1239.7585836379)); NativeObject nativeObject0 = new NativeObject(); IdFunctionObject idFunctionObject0 = mock(IdFunctionObject.class, new ViolatedAssumptionAnswer()); doReturn(true).when(idFunctionObject0).hasTag(any()); doReturn(0).when(idFunctionObject0).methodId(); Context context0 = mock(Context.class, new ViolatedAssumptionAnswer()); // Undeclared exception! try { nativeObject0.execIdCall(idFunctionObject0, context0, nativeNumber0, nativeNumber0, context0.emptyArgs); fail("Expecting exception: IllegalArgumentException"); } catch(IllegalArgumentException e) { // // 0 // verifyException("com.google.javascript.rhino.head.NativeObject", e); } } @Test(timeout = 4000) public void test09() throws Throwable { NativeObject nativeObject0 = new NativeObject(); // Undeclared exception! try { Context.toNumber(nativeObject0); fail("Expecting exception: EcmaError"); } catch(EcmaError e) { // // TypeError: Cannot find default value for object. // verifyException("com.google.javascript.rhino.head.ScriptRuntime", e); } } @Test(timeout = 4000) @Ignore public void test10() throws Throwable { NativeIterator.StopIteration nativeIterator_StopIteration0 = new NativeIterator.StopIteration(); NativeGenerator nativeGenerator0 = NativeGenerator.init(nativeIterator_StopIteration0, true); ClassLoader classLoader0 = ClassLoader.getSystemClassLoader(); NativeJavaTopPackage nativeJavaTopPackage0 = new NativeJavaTopPackage(classLoader0); NativeJavaPackage nativeJavaPackage0 = nativeJavaTopPackage0.forcePackage("__lookupSetter__", nativeGenerator0); // Undeclared exception! try { nativeIterator_StopIteration0.checkPropertyChange("mExuG", nativeGenerator0, nativeJavaPackage0); fail("Expecting exception: EcmaError"); } catch(EcmaError e) { // // TypeError: Cannot change the configurable attribute of \"mExuG\" from false to true. // verifyException("com.google.javascript.rhino.head.ScriptRuntime", e); } } @Test(timeout = 4000) public void test11() throws Throwable { boolean boolean0 = ScriptableObject.isTrue((Object) null); assertFalse(boolean0); } @Test(timeout = 4000) public void test12() throws Throwable { ContextFactory contextFactory0 = new ContextFactory(); Context context0 = contextFactory0.enterContext(); Interpreter interpreter0 = new Interpreter(); CompilerEnvirons compilerEnvirons0 = new CompilerEnvirons(); ErrorReporter errorReporter0 = compilerEnvirons0.getErrorReporter(); Script script0 = context0.compileString("FiL", (Evaluator) interpreter0, errorReporter0, "FiL", 11, (Object) null); // Undeclared exception! try { JavaAdapter.runScript(script0); fail("Expecting exception: EcmaError"); } catch(EcmaError e) { // // ReferenceError: \"FiL\" is not defined. (FiL#11) // verifyException("com.google.javascript.rhino.head.ScriptRuntime", e); } } @Test(timeout = 4000) public void test13() throws Throwable { NativeIterator.StopIteration nativeIterator_StopIteration0 = new NativeIterator.StopIteration(); NativeJavaTopPackage nativeJavaTopPackage0 = new NativeJavaTopPackage((ClassLoader) null); nativeJavaTopPackage0.forcePackage("jsFunction_", nativeIterator_StopIteration0); Context context0 = Context.enter(); // Undeclared exception! try { nativeIterator_StopIteration0.defineOwnProperties(context0, nativeJavaTopPackage0); fail("Expecting exception: EcmaError"); } catch(EcmaError e) { // // TypeError: [JavaPackage jsFunction_.get] is not a function, it is object. // verifyException("com.google.javascript.rhino.head.ScriptRuntime", e); } } @Test(timeout = 4000) public void test14() throws Throwable { NativeIterator.StopIteration nativeIterator_StopIteration0 = new NativeIterator.StopIteration(); Context context0 = Context.enter(); nativeIterator_StopIteration0.defineOwnProperties(context0, nativeIterator_StopIteration0); assertEquals(0, ScriptableObject.EMPTY); } @Test(timeout = 4000) public void test15() throws Throwable { NativeObject nativeObject0 = new NativeObject(); IdFunctionObject idFunctionObject0 = new IdFunctionObject(nativeObject0, "Object", 8, 12); ContextFactory contextFactory0 = new ContextFactory(); Context context0 = contextFactory0.makeContext(); Object object0 = nativeObject0.execIdCall(idFunctionObject0, context0, idFunctionObject0, idFunctionObject0, context0.emptyArgs); assertEquals("({})", object0); } @Test(timeout = 4000) public void test16() throws Throwable { NativeIterator.StopIteration nativeIterator_StopIteration0 = new NativeIterator.StopIteration(); EcmaError ecmaError0 = null; try { ecmaError0 = new EcmaError(nativeIterator_StopIteration0, (String) null, 8, 13, "object"); fail("Expecting exception: EcmaError"); } catch(EcmaError e) { // // TypeError: Cannot find default value for object. // verifyException("com.google.javascript.rhino.head.ScriptRuntime", e); } } @Test(timeout = 4000) public void test17() throws Throwable { NativeIterator.StopIteration nativeIterator_StopIteration0 = new NativeIterator.StopIteration(); Object object0 = nativeIterator_StopIteration0.equivalentValues("Qe1-WP#-\""); assertNotNull(object0); } @Test(timeout = 4000) public void test18() throws Throwable { NativeObject nativeObject0 = new NativeObject(); LazilyLoadedCtor lazilyLoadedCtor0 = new LazilyLoadedCtor(nativeObject0, (String) null, (String) null, false); assertFalse(nativeObject0.isSealed()); } @Test(timeout = 4000) public void test19() throws Throwable { NativeIterator.StopIteration nativeIterator_StopIteration0 = new NativeIterator.StopIteration(); NativeObject.KeySet nativeObject_KeySet0 = nativeIterator_StopIteration0.new KeySet(); Context context0 = Context.getCurrentContext(); nativeIterator_StopIteration0.defineOwnProperty(context0, nativeObject_KeySet0, nativeIterator_StopIteration0); assertEquals(13, ScriptableObject.CONST); } @Test(timeout = 4000) public void test20() throws Throwable { NativeObject nativeObject0 = new NativeObject(); // Undeclared exception! try { nativeObject0.addLazilyInitializedValue("toLocaleString", 694, (LazilyLoadedCtor) null, 124); fail("Expecting exception: IllegalArgumentException"); } catch(IllegalArgumentException e) { // // toLocaleString // verifyException("com.google.javascript.rhino.head.ScriptableObject", e); } } @Test(timeout = 4000) @Ignore public void test21() throws Throwable { NativeIterator.StopIteration nativeIterator_StopIteration0 = new NativeIterator.StopIteration(); Class<NativeContinuation> class0 = NativeContinuation.class; // Undeclared exception! try { nativeIterator_StopIteration0.getDefaultValue(class0); fail("Expecting exception: EvaluatorException"); } catch(EvaluatorException e) { // // Invalid JavaScript value of type class com.google.javascript.rhino.head.NativeContinuation // verifyException("com.google.javascript.rhino.head.DefaultErrorReporter", e); } } @Test(timeout = 4000) public void test22() throws Throwable { NativeObject nativeObject0 = new NativeObject(); Class<BaseFunction> class0 = BaseFunction.class; BaseFunction baseFunction0 = ScriptableObject.buildClassCtor((Scriptable) nativeObject0, class0, true, true); assertTrue(nativeObject0.isEmpty()); assertTrue(baseFunction0.isEmpty()); assertTrue(baseFunction0.isSealed()); } @Test(timeout = 4000) public void test23() throws Throwable { NativeObject nativeObject0 = new NativeObject(); NativeIterator.StopIteration nativeIterator_StopIteration0 = new NativeIterator.StopIteration(); nativeIterator_StopIteration0.exportAsJSClass(130, nativeObject0, false); // Undeclared exception! try { nativeIterator_StopIteration0.getIds(); fail("Expecting exception: IllegalArgumentException"); } catch(IllegalArgumentException e) { // // 13 // verifyException("com.google.javascript.rhino.head.NativeObject", e); } } @Test(timeout = 4000) public void test24() throws Throwable { NativeObject nativeObject0 = new NativeObject(); Context context0 = mock(Context.class, new ViolatedAssumptionAnswer()); NativeJavaClass nativeJavaClass0 = new NativeJavaClass(); BoundFunction boundFunction0 = new BoundFunction(context0, nativeObject0, nativeJavaClass0, nativeObject0, context0.emptyArgs); assertTrue(nativeObject0.isEmpty()); assertTrue(boundFunction0.isExtensible()); } @Test(timeout = 4000) @Ignore public void test25() throws Throwable { NativeObject nativeObject0 = new NativeObject(); nativeObject0.sealObject(); Long long0 = new Long(0); // Undeclared exception! try { nativeObject0.remove((Object) long0); fail("Expecting exception: EvaluatorException"); } catch(EvaluatorException e) { // // Cannot modify a property of a sealed object: 0. // verifyException("com.google.javascript.rhino.head.DefaultErrorReporter", e); } } @Test(timeout = 4000) public void test26() throws Throwable { NativeObject nativeObject0 = new NativeObject(); nativeObject0.checkPropertyChange("9I,91$Vm0iR", nativeObject0, nativeObject0); assertTrue(nativeObject0.isEmpty()); assertTrue(nativeObject0.isExtensible()); } }
826af6b4b6246dc33e3a0ee0acbb8591ff05a804
13aeb1f7593b7b67fcaa531471d357bf577bdc5c
/target/generated-sources/cxf/org/tmdd/_303/messages/LinkGeomLocation.java
ee4147b2a78bd493e7a58a7e4cf3fc9133b47f83
[]
no_license
Qijian-Gan/RealtimeDataManagement
77efe7e6ddd345189729d0bb4242859fd441f847
16a0792d7253b966496b6ce1ec47aef1a57073eb
refs/heads/master
2020-04-15T19:03:35.484160
2019-06-05T20:45:29
2019-06-05T20:45:29
164,934,584
0
0
null
null
null
null
UTF-8
Java
false
false
1,603
java
package org.tmdd._303.messages; import java.io.Serializable; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyElement; import javax.xml.bind.annotation.XmlType; import org.w3c.dom.Element; /** * <p>Java class for LinkGeomLocation complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType name="LinkGeomLocation"&gt; * &lt;complexContent&gt; * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"&gt; * &lt;sequence&gt; * &lt;any processContents='lax' namespace='##other' minOccurs="0"/&gt; * &lt;/sequence&gt; * &lt;/restriction&gt; * &lt;/complexContent&gt; * &lt;/complexType&gt; * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "LinkGeomLocation", propOrder = { "any" }) public class LinkGeomLocation implements Serializable { private final static long serialVersionUID = -1L; @XmlAnyElement(lax = true) protected Object any; /** * Gets the value of the any property. * * @return * possible object is * {@link Object } * {@link Element } * */ public Object getAny() { return any; } /** * Sets the value of the any property. * * @param value * allowed object is * {@link Object } * {@link Element } * */ public void setAny(Object value) { this.any = value; } }
bcc0aa4b33fce1187d0d917c33c0a0f73bc5d6d5
8f428871182f39c03f2b24c866d0d870c2806363
/tesco-api/tesco-ware-api/src/main/java/com/jerusalem/ware/feign/WareSkuFeign.java
a05eeadc06015f22084a649632f6af879182f921
[ "Apache-2.0" ]
permissive
jbzhang99/tesco-mall
c24e97ac702f573a1b6a8a6f5b7823e3c9959e93
09c9a3678fd0ce58ed8a449a9649031630538626
refs/heads/master
2023-04-18T01:16:07.292687
2020-12-03T02:31:45
2020-12-03T02:31:48
null
0
0
null
null
null
null
UTF-8
Java
false
false
912
java
package com.jerusalem.ware.feign; import com.jerusalem.common.utils.R; import com.jerusalem.common.vo.LockStockVo; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import java.util.List; /**** * @Author: jerusalem * @Description: WareSkuFeign业务层接口 * @Date 2020/5/19 14:26 *****/ @FeignClient("ware-service") @RequestMapping("ware/ware/sku") public interface WareSkuFeign { /*** * 批量查询Sku是否有库存 * @param skuIds * @return */ @PostMapping("/stock") R getSkuStock(@RequestBody List<Long> skuIds); /*** * 锁定库存 * @param lockStockVo * @return */ @PostMapping("/lock") R lockStock(@RequestBody LockStockVo lockStockVo); }
03fd60fe3907cf7b6c44d639035eb0945a4947b3
8c157c50c96835464771f2b183cf027a769af437
/Lab2/TestMyInteger.java
f836ac4d9faa9dfc03e80ed496539ee8ce1a707a
[]
no_license
SulaimaanSiddiqui/CSE-260-Labs
3114d62e44c3f484aa6c8062661c02967a54e2ea
02bf185b7bf19b0956c0fbe1a3e5f706ac8488d5
refs/heads/master
2021-07-13T05:38:03.696451
2017-10-12T20:21:58
2017-10-12T20:21:58
105,939,099
0
0
null
null
null
null
UTF-8
Java
false
false
422
java
public class TestMyInteger { public static void main(String[] args){ System.out.println("Test MyInteger"); MyInteger tester = new MyInteger(13); System.out.println("Is odd: " + tester.isOdd()); System.out.println("Is even: " + tester.isEven()); System.out.println("Is prime: " + tester.isPrime()); System.out.println("Equals 13: " + tester.equals(13)); System.out.println(MyInteger.parseInt("1")+1); } }
5540b0b0235f34bf5cbeede1855e68a2032c700a
f597672808519972e040a54502f9ab6a1841de1e
/HackerRankProblems/src/com/capgemini/interviewpreparation/SherlockandValidString.java
96b3b95ef18208c4eaff2d15b9b7a530928f77b8
[]
no_license
E0227472/JavaCode
46d5c019ed52a13ecc15275d1079ee4ae67d7494
455fd3828ba7ec530f79b2e8cd5ab5d7d93d0d2a
refs/heads/master
2022-12-22T04:58:00.333113
2019-07-31T04:04:21
2019-07-31T04:04:21
199,775,480
0
0
null
2022-12-16T09:54:05
2019-07-31T04:01:55
Java
UTF-8
Java
false
false
2,122
java
package com.capgemini.interviewpreparation; import java.io.IOException; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Scanner; import java.util.TreeMap; public class SherlockandValidString { // Complete the isValid function below. static String isValid(String s) { String result = null; if (s.length() <= 2 && s.length() > 0) result = "YES"; else { Map<Character, Integer> map = new TreeMap<Character, Integer>(); char[] chars = s.toCharArray(); Arrays.sort(chars); for (int i = 0; i < chars.length; i++) { map.put(chars[i], !map.containsKey(chars[i]) ? 1 : map.get(chars[i]) + 1); } Map<Integer, Integer> mapCount = new HashMap<Integer, Integer>(); // adding the frequency of each elements and determining their count for (Map.Entry<Character, Integer> val : map.entrySet()) { int key = val.getValue(); System.out.println("The frequency for " + val.getKey() + " is: "+ key); mapCount.put(key, !mapCount.containsKey(key) ? 1 : mapCount.get(key) + 1); } if (mapCount.size() > 2) result = "NO"; else if (mapCount.size() == 1) result = "YES"; else if (mapCount.size() == 2) { int [] count = new int [2]; int[] keys = new int [2]; int i = 0; int j = 0; for (Map.Entry<Integer, Integer> val : mapCount.entrySet()) { System.out.println("The values for frequency count is: " + val.getValue()); count[i++] = val.getValue(); keys[j++] = val.getKey(); } if(count[0] > 1 && count[1] > 1) result = "NO"; else if(Math.abs(keys[0] - keys[1]) ==1 && (count[0] ==1 || count[1] ==1)) result = "YES"; else if((keys[0] ==1 && count[0] ==1) || (keys[1] == 1 && count[1] ==1)) result = "YES"; else result = "NO"; } } return result; } private static final Scanner scanner = new Scanner(System.in); public static void main(String[] args) throws IOException { System.out.println("Enter a value for s: "); String s = scanner.nextLine(); String result = isValid(s); System.out.println(result); scanner.close(); } }
820c6da1537f8d3ff3265e415c6455eb907fe524
8a926231aa00e4ce6308090d1b2b4ac20a4fc243
/src/main/java/org/dselent/course_load_scheduler/client/action/OpenCreateAdminAction.java
997969836fae1396a0a000020f39ace63000f48b
[]
no_license
WPI-CS3733-Team1/course_load_scheduler
86e0da476aabd583efb9ecb00c8a17b8c3d0de2d
69e96db929919fcc2d58ed9786f62f50c06ee4f6
refs/heads/master
2021-05-01T21:16:40.505091
2018-02-28T04:52:56
2018-02-28T04:52:56
120,974,243
0
0
null
2018-02-10T01:40:01
2018-02-10T01:40:00
null
UTF-8
Java
false
false
487
java
package org.dselent.course_load_scheduler.client.action; public class OpenCreateAdminAction { private String userName; public OpenCreateAdminAction(String userName) { this.userName = userName; } public String getUserName() { return userName; } @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("OpenCreateAdminAction [userName="); builder.append(userName); builder.append("]"); return builder.toString(); } }
8a08834c42188198748c202621146d853717f252
2df7dfe7059687c78c7f6a1bc9f572ce5990a04d
/trend-trading-backtest-view/src/test/java/cn/trend/TrendTradingBackTestViewApplicationTest.java
03c4d3b6271b7e79432a7c1fa5e46c1798abd6f0
[]
no_license
Xuanzhihao/trendParentProject
f77cb9f769527efeeacd8d86d16494226cf60d3a
bc274e4e5a02d9a931c7ccfbf5b03c1169d54533
refs/heads/master
2021-01-26T12:51:54.990668
2020-05-18T13:56:36
2020-05-18T13:56:36
243,438,470
0
0
null
2020-10-13T20:06:30
2020-02-27T05:26:58
Java
UTF-8
Java
false
false
343
java
package cn.trend; import static org.junit.Assert.assertTrue; import org.junit.Test; /** * Unit test for simple TrendTradingBackTestViewApplication. */ public class TrendTradingBackTestViewApplicationTest { /** * Rigorous Test :-) */ @Test public void shouldAnswerWithTrue() { assertTrue( true ); } }
45719a8493d6e3820469b6bc46b662ead4b22d61
9f6ba3ee5096668c50b89c09d8b6e5cf4c2946dc
/CommonRecyclerViewLibrary/src/main/java/com/androidlongs/pullrefreshrecyclerylib/common/PullRecyclerViewUtils.java
bcd51d0cd9d3596bcb465172d5576d7ffecea87f
[]
no_license
zhaolongs/AndroidCommonDiscreLibrary
a7e66e53e097de242296e62c9fd41346bcf23d46
003015f394302301bb2f22314294eda71186d9a1
refs/heads/master
2021-01-19T19:44:04.039672
2017-08-25T17:09:36
2017-08-25T17:09:36
101,205,587
0
0
null
null
null
null
UTF-8
Java
false
false
106,724
java
package com.androidlongs.pullrefreshrecyclerylib.common; import android.animation.Animator; import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Color; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Handler; import android.os.Looper; import android.support.v7.widget.DefaultItemAnimator; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.text.TextUtils; import android.util.DisplayMetrics; import android.util.Log; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.view.animation.AlphaAnimation; import android.view.animation.Animation; import android.view.animation.LinearInterpolator; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.RelativeLayout; import android.widget.TextView; import com.androidlongs.pullrefreshrecyclerylib.R; import com.androidlongs.pullrefreshrecyclerylib.inter.PullRecyclerViewLinserner; import com.androidlongs.pullrefreshrecyclerylib.inter.PullRecyclerViewOnItemClickLinserner; import com.androidlongs.pullrefreshrecyclerylib.model.PullRecyclerMoreStatueModel; import com.androidlongs.pullrefreshrecyclerylib.view.PullCustomRecyclerView; import com.androidlongs.pullrefreshrecyclerylib.view.QuickIndexBar; import java.util.ArrayList; import java.util.List; /** * Created by androidlongs on 2017/8/21. * 站在顶峰,看世界 * 落在谷底,思人生 */ public class PullRecyclerViewUtils<T> { private PullCustomRecyclerView mRecyclerView; private LinearLayoutManager mLinearLayoutManager; private RelativeLayout mMainRefreshView; private ProgressBar mPullRefProgressBar; private ImageView mPullRefImageView; private LinearLayout mMainBackgroundRelativeLayout; private LinearLayout mLoadingNoDataLinearLayout; private TextView mLoadingNoDataTextView; private LinearLayout mLoadingIngLinearLayout; private TextView mLoadingIngTextView; //索引 private QuickIndexBar mQuickIndexBar; private Handler mHandler = new Handler(Looper.getMainLooper()); private ImageView mLoadingNoDataImageView; private ObjectAnimator mClickNoDataHidIngAndShowDataAnimator; private ObjectAnimator mClickNoDataHidIngAndShowNoDataAnimator; private PullRecyclerViewUtils() { } public static PullRecyclerViewUtils getInstance() { return new PullRecyclerViewUtils(); } //条目点击事件监听回调 private PullRecyclerViewOnItemClickLinserner mPullRecyclerViewOnItemClickLinserner; //刷新布局的高度 px 会根据屏幕密度来进行计算 private int mPullRefshLayoutHeight; // private Context mContext; private int mItemLayoutId = 0; //回调接口 private PullRecyclerViewLinserner mPullRecyclerViewLinserner; //数据 private List<T> mStringList; private boolean mIsOneceRemoveRefreshLayout = false; //多布局集合 /** * mMoreItemLayoutIdMap * key 对应item中的 position * value 对应item中的 layout id */ // private LinkedHashMap<Integer, Integer> mMoreItemLayoutIdMap; /** * 设置 * * @param context 上下文对象 * @param itemLayoutId 单布局 layout id * @param list 数据集合 * @param linserner 回调监听 */ public RelativeLayout setRecyclerViewFunction(Context context, int itemLayoutId, List<T> list, PullRecyclerViewLinserner linserner) { return setRecyclerViewFunction(context, itemLayoutId, list, linserner, null, RECYCLRYVIEW_STATUE.PULL_AND_UP, SHOW_DEFAUTLE_PAGE_TYPE.LOADING, LOADING_NO_DATA_PAGE_TYPE.TEXT); } /** * 设置 * * @param context 上下文对象 * @param itemLayoutId 单布局 layout id * @param list 数据集合 * @param linserner 回调监听 * @param itemClickLinserner 条目点击监听 */ public RelativeLayout setRecyclerViewFunction(Context context, int itemLayoutId, List<T> list, PullRecyclerViewLinserner linserner, PullRecyclerViewOnItemClickLinserner itemClickLinserner) { return setRecyclerViewFunction(context, itemLayoutId, list, linserner, itemClickLinserner, RECYCLRYVIEW_STATUE.PULL_AND_UP, SHOW_DEFAUTLE_PAGE_TYPE.LOADING, LOADING_NO_DATA_PAGE_TYPE.TEXT); } public RelativeLayout setRecyclerViewFunction(Context context, int itemLayoutId, List<T> list, SHOW_DEFAUTLE_PAGE_TYPE page_type, PullRecyclerViewLinserner linserner, PullRecyclerViewOnItemClickLinserner itemClickLinserner) { return setRecyclerViewFunction(context, itemLayoutId, list, linserner, itemClickLinserner, RECYCLRYVIEW_STATUE.PULL_AND_UP, page_type, LOADING_NO_DATA_PAGE_TYPE.TEXT); } /** * @param context 上下文对象 * @param itemLayoutId 条目布局 * @param linserner 设置监听 * @param defautlePageType 默认显示无数据页面 */ public RelativeLayout setRecyclerViewFunction(Context context, int itemLayoutId, PullRecyclerViewLinserner linserner, SHOW_DEFAUTLE_PAGE_TYPE defautlePageType) { return setRecyclerViewFunction(context, itemLayoutId, null, linserner, null, RECYCLRYVIEW_STATUE.PULL_AND_UP, defautlePageType, LOADING_NO_DATA_PAGE_TYPE.TEXT); } /** * @param context 上下文对象 * @param itemLayoutId 条目布局 * @param dataList 数据 * @param linserner 设置监听 * @param defautlePageType 默认显示无数据页面 */ public RelativeLayout setRecyclerViewFunction(Context context, int itemLayoutId, List<T> dataList, PullRecyclerViewLinserner linserner, SHOW_DEFAUTLE_PAGE_TYPE defautlePageType) { return setRecyclerViewFunction(context, itemLayoutId, dataList, linserner, null, RECYCLRYVIEW_STATUE.PULL_AND_UP, defautlePageType, LOADING_NO_DATA_PAGE_TYPE.TEXT); } /** * @param context 上下文对象 * @param itemLayoutId 布局ID * 多布局状态下 传 -1 * @param list 数据 * 多布局下 list数据为 PullRecyclerMoreStatueModel * @param linserner 操作回调 * @param itemClickLinserner 条目点击事件回调 * @param statue 功能设置 * RECYCLRYVIEW_STATUE.NORMAL,//正常状态下,没有下拉刷新也没有上拉加载更多 * RECYCLRYVIEW_STATUE.PULL_REFRESH,//只有下拉刷新功能 * RECYCLRYVIEW_STATUE.UP_LOAD_MORE,//只有上拉加载更多功能 * RECYCLRYVIEW_STATUE.PULL_AND_UP//下拉刷新 上拉加载功能 * @param defautle_page_type 默认显示页面 @see SHOW_DEFAUTLE_PAGE_TYPE * SHOW_DEFAUTLE_PAGE_TYPE.NO_DATA,//无数据 * SHOW_DEFAUTLE_PAGE_TYPE.LOADING//加载中 * @param noDataPageType 默认显示页面 无数据状态显示类型 * LOADING_NO_DATA_PAGE_TYPE.IMAGE,//只显示图片 * LOADING_NO_DATA_PAGE_TYPE.IMAGE_AND_TEXT,//显示图片和文字 * LOADING_NO_DATA_PAGE_TYPE.TEXT//只显示文字 * @see SHOW_DEFAUTLE_PAGE_TYPE 默认显示页面 * @see RECYCLRYVIEW_STATUE 功能设置 * @see LOADING_NO_DATA_PAGE_TYPE 无数据页面显示类型 */ @SuppressLint("ClickableViewAccessibility") public RelativeLayout setRecyclerViewFunction( Context context, int itemLayoutId, List<T> list, PullRecyclerViewLinserner linserner, PullRecyclerViewOnItemClickLinserner itemClickLinserner, RECYCLRYVIEW_STATUE statue, SHOW_DEFAUTLE_PAGE_TYPE defautle_page_type, LOADING_NO_DATA_PAGE_TYPE noDataPageType) { if (mRecyclerView == null) { mContext = context; //单布局 mItemLayoutId = itemLayoutId; //加载数据回调监听 mPullRecyclerViewLinserner = linserner; //数据集合 if (list == null) { mStringList = new ArrayList<>(); } else { mStringList = new ArrayList<>(); mStringList.addAll(list); } //当前RecyclerView 的显示功能模式 mCurrentStatue = statue; //条目点击回调 mPullRecyclerViewOnItemClickLinserner = itemClickLinserner; //当前默认显示的页面 mCurrentShowDefaultType = defautle_page_type; //当前默认页面显示无数据类型 mCurrentLoadingNoDataType = noDataPageType; DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); float scaledDensity = displayMetrics.scaledDensity; mPullRefshLayoutHeight = (int) (62 * scaledDensity); mMainRefreshView = (RelativeLayout) View.inflate(context, R.layout.pull_refresh_main, null); //加载无数据布局 mLoadingNoDataLinearLayout = (LinearLayout) mMainRefreshView.findViewById(R.id.ll_pull_refresh_loading_no_data); //加载无数数据显示文字 mLoadingNoDataTextView = (TextView) mMainRefreshView.findViewById(R.id.tv_pull_refresh_loading_no_data); mLoadingNoDataImageView = (ImageView) mMainRefreshView.findViewById(R.id.iv_pull_refresh_loading_no_data); mLoadingNoDataTextView.setOnClickListener(mNoDataOnClickListener); switch (mCurrentLoadingNoDataType) { case TEXT: mLoadingNoDataImageView.setVisibility(View.GONE); mLoadingNoDataTextView.setVisibility(View.VISIBLE); break; case IMAGE: mLoadingNoDataImageView.setVisibility(View.VISIBLE); mLoadingNoDataTextView.setVisibility(View.GONE); break; case IMAGE_AND_TEXT: mLoadingNoDataImageView.setVisibility(View.VISIBLE); mLoadingNoDataTextView.setVisibility(View.VISIBLE); break; } //索引 mQuickIndexBar = (QuickIndexBar) mMainRefreshView.findViewById(R.id.pull_refresh_index_bar); mQuickIndexBar.setVisibility(View.GONE); //加载中布局 mLoadingIngLinearLayout = (LinearLayout) mMainRefreshView.findViewById(R.id.ll_pull_refresh_loading_ing); //加载上显示文字 mLoadingIngTextView = (TextView) mMainRefreshView.findViewById(R.id.tv_pull_refresh_loading_ing); switch (mCurrentShowDefaultType) { case LOADING: /** * 默认显示加载中页面 * @see mStringList size 为0 显示加载中页页面,否则显示数据页面 * @see mCurrentShowDefaultType 不前显示的页面类型 * @see mLoadingIngLinearLayout 加载中页面 * @see mLoadingNoDataLinearLayout 无数据页面 * @see mNetLoadingStatue 当前网络加载状态 */ if (mStringList == null || mStringList.size() == 0) { //显示加载中 mLoadingIngLinearLayout.setVisibility(View.VISIBLE); //隐藏无数据页面 mLoadingNoDataLinearLayout.setVisibility(View.GONE); //更新网络加载标识 mNetLoadingStatue = NETLOADINGSTATE.DEFAULT_LOADING; } else { //隐藏加载中 mLoadingIngLinearLayout.setVisibility(View.GONE); //隐藏无数据 mLoadingNoDataLinearLayout.setVisibility(View.GONE); //更新网络无加载标识 mNetLoadingStatue = NETLOADINGSTATE.NO_LOADING; } break; case NO_DATA: /** * 默认显示无数据页面 * @see mStringList size 为0 显示无数据页页面,否则显示数据页面 **/ if (mStringList == null || mStringList.size() == 0) { mLoadingIngLinearLayout.setVisibility(View.GONE); mLoadingNoDataLinearLayout.setVisibility(View.VISIBLE); } else { mLoadingIngLinearLayout.setVisibility(View.GONE); mLoadingNoDataLinearLayout.setVisibility(View.GONE); mNetLoadingStatue = NETLOADINGSTATE.NO_LOADING; } break; } //主显示背景 mMainBackgroundRelativeLayout = (LinearLayout) mMainRefreshView.findViewById(R.id.ll_root_background); //刷新的布局 mPullRefshLayout = (LinearLayout) mMainRefreshView.findViewById(R.id.ll_pull_refresh_main); //刷新的提示文字 mPullRefTextView = (TextView) mMainRefreshView.findViewById(R.id.tv_pull_refesh); //刷新的进度 mPullRefProgressBar = (ProgressBar) mMainRefreshView.findViewById(R.id.pb_pull_refresh_main); //imagevIWE mPullRefImageView = (ImageView) mMainRefreshView.findViewById(R.id.iv_pull_refresh_main); mPullRefshLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { Log.e("global", "mPullRefshLayout global layout " + mPullRefshLayoutHeight + " " + mPullRefshLayout.getTop()); mPullRefshLayout.layout(0, -mPullRefshLayoutHeight, mPullRefshLayout.getWidth(), 0); // if (mStringList==null||mStringList.size()==0) { // mLoadingIngLinearLayout.setVisibility(View.GONE); // mLoadingNoDataLinearLayout.setVisibility(View.VISIBLE); // }else { // mLoadingIngLinearLayout.setVisibility(View.GONE); // mLoadingNoDataLinearLayout.setVisibility(View.GONE); // } } }); //初始化RecyclerView mRecyclerView = (PullCustomRecyclerView) mMainRefreshView.findViewById(R.id.rv_list); //设置adapter //设置布局样式 mLinearLayoutManager = new LinearLayoutManager(context); //设置方向 mLinearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); //关联RecyclerView mRecyclerView.setLayoutManager(mLinearLayoutManager); //设置分割线 //关联Adapter mRecyclerView.setAdapter(mViewHolderAdapter); mRecyclerView.setItemAnimator(new DefaultItemAnimator()); if ((mCurrentStatue == RECYCLRYVIEW_STATUE.UP_LOAD_MORE) || (mCurrentStatue == RECYCLRYVIEW_STATUE.PULL_AND_UP)) { //设置滑动监听事件 mRecyclerView.setOnScrollListener(mOnScrollListener); } if ((mCurrentStatue == RECYCLRYVIEW_STATUE.PULL_REFRESH) || (mCurrentStatue == RECYCLRYVIEW_STATUE.PULL_AND_UP)) { //设置触摸 mRecyclerView.setOnTouchListener(mOnTouchListener); } } return mMainRefreshView; } private SHOW_DEFAUTLE_PAGE_TYPE mCurrentShowDefaultType = SHOW_DEFAUTLE_PAGE_TYPE.LOADING; public void setNetLoadingType(NETLOADINGSTATE netLoadingStatue) { mNetLoadingStatue = netLoadingStatue; } public void setDefaultPageType(SHOW_DEFAUTLE_PAGE_TYPE netLoadingStatue) { mCurrentShowDefaultType = netLoadingStatue; } public enum SHOW_DEFAUTLE_PAGE_TYPE { NO_DATA,//无数据 LOADING//加载中 } private RecyclerView.Adapter<RecyclerView.ViewHolder> mViewHolderAdapter = new RecyclerView.Adapter<RecyclerView.ViewHolder>() { @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { log(" itemviewType is --- " + viewType); //单一布局情况 if (viewType == 0) { //加载条目布局文件 View view = View.inflate(mContext, mItemLayoutId, null); //创建ViewHolder CustomViewHolder customViewHolder = new CustomViewHolder(view, mPullRecyclerViewLinserner, mPullRecyclerViewOnItemClickLinserner); return customViewHolder; } else if (viewType == -11) { //最后一个条目设置刷新布局显示 View view = View.inflate(mContext, R.layout.refresh_view_footer, null); //创建ViewHolder UpLoadViewHolder customViewHolder = new UpLoadViewHolder(view, mContext, mOnLastItemClickListerner); return customViewHolder; } else { //其他多布局模式 View view = View.inflate(mContext, viewType, null); //创建ViewHolder CustomViewHolder customViewHolder = new CustomViewHolder(view, mPullRecyclerViewLinserner, mPullRecyclerViewOnItemClickLinserner); return customViewHolder; } } @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { //根据position来获取ViewHolder的类型 int itemViewType = this.getItemViewType(position); log(" itemviewType is " + itemViewType); if (itemViewType == 0) { //获取 显示普通数据 Holder CustomViewHolder viewHolder = (CustomViewHolder) holder; Object s = mStringList.get(position); //设置数据 viewHolder.setDatas(position, itemViewType, s); } else if (itemViewType == -11) { //最后一个条目 获取刷新布局对应的Holder UpLoadViewHolder viewHolder = (UpLoadViewHolder) holder; viewHolder.setDatas(position, mCurrentUpLoadingStatue, mLoadingMoreTextColor, mLoadingMoreBackGroundColor); } else { //获取 显示普通数据 Holder CustomViewHolder viewHolder = (CustomViewHolder) holder; Object s = mStringList.get(position); //设置数据 viewHolder.setDatas(position, itemViewType, s); } } @Override public int getItemCount() { /** * 只有当显示的条目个数大于10 才启用上拉到底部加载更多数据功能 */ if (mStringList == null) { return 0; } else if (mStringList.size() > 10 && ((mCurrentStatue == RECYCLRYVIEW_STATUE.UP_LOAD_MORE) || (mCurrentStatue == RECYCLRYVIEW_STATUE.PULL_AND_UP))) { return mStringList.size() + 1; } else { return mStringList.size(); } } @Override public int getItemViewType(int position) { if (mStringList != null) { if (mStringList.size() > 10) { if (position == mStringList.size()) { //如果是最后一个条目 那么返回1 //用来加载显示刷新布局 return -11; } else { Object lO = mStringList.get(position); if (lO instanceof PullRecyclerMoreStatueModel) { return ((PullRecyclerMoreStatueModel) lO).itemLayoutId; } //用来加载显示普通布局 return 0; } } else { //用来加载显示普通布局 Object lO = mStringList.get(position); if (lO instanceof PullRecyclerMoreStatueModel) { return ((PullRecyclerMoreStatueModel) lO).itemLayoutId; } return 0; } } else { return 0; } } }; //当前屏幕上显示的最后一个条目数据对应的位置 private int mLastVisibleItemPosition; //当前屏幕显示的第一个条目数据对应的位置 private int mFirstVisibleItemPosition; //获取当前RecyclerView完全显示出的第一个条目的位置 private int mFirstCompletelyVisibleItemPosition; //获取当前RecyclerView完全显示出的最后一个条目的位置 private int mLastCompletelyVisibleItemPosition; /** * RecyclerView是否滑动到了顶部 只有滑动到了顶部才可以启用下拉刷新功能 * 这里通过RecyclerView的布局管理者 mLinearLayoutManager来动态的获取当前屏幕上显示的RecyclerView的第一个条目对应的 角标索引 */ private boolean mIsToTop = true; /** * 上拉加载更多数据 是否正在加载 * 当正在加载更多数据时,此时可能还会滑动RecyclerView * 为防止同时发起多次请求数据 所设置的标识 */ private boolean mIsLoading = false; /** * RecyclerView 的滑动监听事件 * 在这里可以判断RecyclerView是否滑动到了顶部 * 在这里用来判断RecyclerView是否滑动到了底部 */ private RecyclerView.OnScrollListener mOnScrollListener = new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); //根据当前的布局管理都来获取显示的条目位置 if (mLinearLayoutManager != null) { //获取当前RecyclerView显示最后一个条目的位置 mLastVisibleItemPosition = mLinearLayoutManager.findLastVisibleItemPosition(); //获取当前RecyclerView显示的第一个条目的位置 mFirstVisibleItemPosition = mLinearLayoutManager.findFirstVisibleItemPosition(); //获取当前RecyclerView完全显示出的最后一个条目的位置 mLastCompletelyVisibleItemPosition = mLinearLayoutManager.findLastCompletelyVisibleItemPosition(); //获取当前RecyclerView完全显示出的第一个条目的位置 mFirstCompletelyVisibleItemPosition = mLinearLayoutManager.findFirstCompletelyVisibleItemPosition(); /** * 当RecyclerView 显示的第一个条目 完全加载出来时 * mFirstVisibleItemPosition 为 0 * mFirstCompletelyVisibleItemPosition 也为0 * 当RecyclerView 显示的第一个条目 并没有完全加载出来,也就是显示了一半(显示不完全 ) * mFirstVisibleItemPosition 为 0 * mFirstCompletelyVisibleItemPosition 为1 * * 所以 当mFirstCompletelyVisibleItemPosition 为 0 表示 完全滑动到了顶部 */ if (mFirstCompletelyVisibleItemPosition == 0) { //更新滑动到顶部标识 mIsToTop = true; Log.e("scroll ", "滑动到顶部 "); } else { //更新滑动到顶部标识 false不在顶部 mIsToTop = false; //获取当前屏幕上显示的条目的个数 int childCount = mLinearLayoutManager.getChildCount(); //获取总共的条目个数 int itemCount = mLinearLayoutManager.getItemCount(); //当显示的条目数据大于10条时 才启用上拉加载更多功能 if (itemCount > 10) { //当显示出最后一个条目时 if (mLastVisibleItemPosition == itemCount - 1) { log("大于10 可以加载更多 " + itemCount); //加载更多 if (!mIsLoading) { //更新加载标识 mIsLoading = true; //加载更多数据 //接口回调 //上拉加载更多 int size = 0; if (mStringList != null && mStringList.size() > 0) { size = mStringList.size(); } mCurrentUpLoadingStatue = RECYCLERVIEW_UP_LOADING_STATUE.LIST_NOT_NULL; mViewHolderAdapter.notifyItemChanged(size); if (mPullRecyclerViewLinserner != null) { mPullRecyclerViewLinserner.loadMoreData(); } //更新网络加载状态 mNetLoadingStatue = NETLOADINGSTATE.UP_LOADING; } } } else { log("小于10 不可以加载更多 " + itemCount + " " + childCount); } } } } @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); if (mViewHolderAdapter != null) { //当滑动停止时 if (newState == RecyclerView.SCROLL_STATE_IDLE) { } } } }; private ValueAnimator mValueAnimator; /** * 下拉刷新状态标识 */ public enum RefresState { PULL_DEFAULE,//开始默认 PULL_SHOW,//显示释放加载 PULL_LOADING,//显示正在加载中 PULL_LOADING_FINISH//显示刷新完毕 } /** * 网络加载标识 */ public enum NETLOADINGSTATE { NO_LOADING,//无加载 DEFAULT_LOADING,//默认加载 PULL_LOADING,//下拉加载中 UP_LOADING,//上拉加载中 CLICK_NO_DATA//无数据下点击加载 } //网络加载标识 private NETLOADINGSTATE mNetLoadingStatue = NETLOADINGSTATE.DEFAULT_LOADING; //滑动自动回弹的时间 private long mPullDuration = 200; //手指按下的位置 private float mDownY; //手指按下时 刷新控件的位置 private int mPullTop; //手指按下时 RecyclerView控件的位置 private int mRecyTop; //手指按下标识 public boolean mIsDown = false; //当前的刷新状态 public RefresState mCurrentRefresState = RefresState.PULL_DEFAULE; //下拉刷新显示的布局 private LinearLayout mPullRefshLayout; //下拉刷新中显示的文字提示 private TextView mPullRefTextView; private View.OnTouchListener mOnTouchListener = new View.OnTouchListener() { @Override public boolean onTouch(final View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: /** * mValueAnimator 是当手指离开屏幕时,页面显示布局文件滚回原始默认位置或者指定位置的 动画 * * 当手指按下去时,如果当前的下拉刷新布局或者 RecyclerView 正在移动,需要停止 */ if (mValueAnimator != null) { if (mValueAnimator.isRunning() || mValueAnimator.isStarted()) { mValueAnimator.cancel(); } } //获取手指按下的纵坐标 mDownY = event.getRawY(); //获取刷新控件当前的位置 mPullTop = mPullRefshLayout.getTop(); //获取列表控件当前的位置 mRecyTop = mRecyclerView.getTop(); //手指按下的标识 mIsDown = true; log("down top is mRecyTop" + mRecyTop + " mPullTop " + mPullTop); if (mIsToTop) { return true; } else { return false; } case MotionEvent.ACTION_MOVE: if (mDownY == 0) { /** * mValueAnimator 是当手指离开屏幕时,页面显示布局文件滚回原始默认位置或者指定位置的 动画 * * 当手指按下去时,如果当前的下拉刷新布局或者 RecyclerView 正在移动,需要停止 */ if (mValueAnimator != null) { if (mValueAnimator.isRunning() || mValueAnimator.isStarted()) { mValueAnimator.cancel(); } } //获取手指按下的纵坐标 mDownY = event.getRawY(); //获取刷新控件当前的位置 mPullTop = mPullRefshLayout.getTop(); //获取列表控件当前的位置 mRecyTop = mRecyclerView.getTop(); //手指按下的标识 mIsDown = true; } //获取实时手指触摸屏幕的 Y轴位置 float moveY = event.getRawY(); //计算 手指移动的距离 int flagY = (int) (moveY - mDownY); /** * 缩小 要不布局会随着滑动的距离变化太大 * flagY >0 向下滑动 * flagY < 0向上滑动 */ flagY = flagY / 2; //当RecyclerView滑动到顶部的时候才可以拖动 if (mIsToTop) { if (mCurrentRefresState == RefresState.PULL_DEFAULE) { /** * PULL_DEFAULE 状态时 RecyclerView处于屏幕的顶部 * 向上滑动时不做处理 * 向下滑动时 处理移动 */ if (flagY >= 0) { /** * 当下滑到一定距离(显示刷新布局 mPullRefshLayout完全显示出来后) * 更新状态为 PULL_SHOW * 更新刷新布局的显示 */ if (mPullRefshLayout.getTop() >= 0) { if (mCurrentRefresState != RefresState.PULL_SHOW) { mCurrentRefresState = RefresState.PULL_SHOW; mPullRefTextView.setText("释放刷新"); } } //RecyclerView 位置限定 int recyTop = mRecyTop + flagY; if (recyTop <= 0) { recyTop = 0; } int recyBottom = mRecyclerView.getHeight() + recyTop; //下拉刷新位置限定 int pullTop = mPullTop + flagY; if (pullTop <= -mPullRefshLayoutHeight) { pullTop = -mPullRefshLayoutHeight; } int pullBottom = mPullRefshLayout.getHeight() + pullTop; //重新设置RecyclerView的显示 setRecyclerViewLayout(getRecyclerViewRect(recyTop, recyBottom)); //重新设置刷新布局文件的显示 setPullRefreshLayout(getPullRefreshLayoutRect(pullTop, pullBottom)); return true; } } else if (mCurrentRefresState == RefresState.PULL_SHOW) { int recyTop = mRecyTop + flagY; int recyBottom = mRecyclerView.getHeight() + recyTop; //更新列表的 int pullTop = mPullTop + flagY; if (pullTop <= -mPullRefshLayoutHeight) { pullTop = -mPullRefshLayoutHeight; } int pullBottom = mPullRefshLayout.getHeight() + pullTop; /** * mPullRefshLayout没完全显示出来 * 也就是 mPullRefshLayout.getTop() < 0 * 更新为 PULL_DEFAULE 状态 */ if (mPullRefshLayout.getTop() < 0) { if (mCurrentRefresState != RefresState.PULL_DEFAULE) { mCurrentRefresState = RefresState.PULL_DEFAULE; mPullRefTextView.setText("下拉刷新"); } } //重新设置RecyclerView的显示 setRecyclerViewLayout(getRecyclerViewRect(recyTop, recyBottom)); //重新设置刷新布局文件的显示 setPullRefreshLayout(getPullRefreshLayoutRect(pullTop, pullBottom)); return true; } else if (mCurrentRefresState == RefresState.PULL_LOADING) { /** * 正在加载中 状态 * * 在这里设置的是 如果下拉刷新正在进行中 * 那么只允许下拉 不可上滑 */ if (flagY > 0) { int recyTop = mRecyTop + flagY; int recyBottom = mRecyclerView.getHeight() + recyTop; //更新列表的 int pullTop = mPullTop + flagY; int pullBottom = mPullRefshLayout.getHeight() + pullTop; //重新设置RecyclerView的显示 setRecyclerViewLayout(getRecyclerViewRect(recyTop, recyBottom)); //重新设置刷新布局文件的显示 setPullRefreshLayout(getPullRefreshLayoutRect(pullTop, pullBottom)); return true; } else { return true; } } else if (mCurrentRefresState == RefresState.PULL_LOADING_FINISH) { /** * 加载完成 状态 * * 在这里设置的是 如果下拉刷新正在进行中 * 那么只允许下拉 不可上滑 */ int recyTop = mRecyTop + flagY; if (recyTop <= 0) { recyTop = 0; } int recyBottom = mRecyclerView.getHeight() + recyTop; //更新列表的 int pullTop = mPullTop + flagY; if (pullTop <= -mPullRefshLayoutHeight) { pullTop = -mPullRefshLayoutHeight; } int pullBottom = mPullRefshLayout.getHeight() + pullTop; //重新设置RecyclerView的显示 setRecyclerViewLayout(getRecyclerViewRect(recyTop, recyBottom)); //重新设置刷新布局文件的显示 setPullRefreshLayout(getPullRefreshLayoutRect(pullTop, pullBottom)); mRecyclerView.setDispatchBoolean(false); return true; } } else { return false; } case MotionEvent.ACTION_UP: //手指抬起 mIsDown = false; mDownY = 0; mRecyclerView.setDispatchBoolean(true); //获取RecyclerView当前的位置 final int recyUpTop = mRecyclerView.getTop(); /** * PULL_DEFAULE 状态,弹回初始默认隐藏页面 */ if (mCurrentRefresState == RefresState.PULL_DEFAULE) { //不刷新,隐藏 mValueAnimator = ValueAnimator.ofFloat(1f, 0f); mValueAnimator.setDuration(mPullDuration); mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { //0 -- 1 Float value = (Float) animation.getAnimatedValue(); int recyTop = (int) (recyUpTop * value); int recyBottom = mRecyclerView.getHeight() + recyTop; int pullTop = recyTop - mPullRefshLayoutHeight; int pullBottom = mPullRefshLayout.getHeight() + pullTop; //重新设置RecyclerView的显示 setRecyclerViewLayout(getRecyclerViewRect(recyTop, recyBottom)); //重新设置刷新布局文件的显示 setPullRefreshLayout(getPullRefreshLayoutRect(pullTop, pullBottom)); } }); //开启 mValueAnimator.start(); } else if (mCurrentRefresState == RefresState.PULL_SHOW || mCurrentRefresState == RefresState.PULL_LOADING) { mRecyclerView.setDispatchBoolean(false); /** * PULL_SHOW 状态 * PULL_LOADING 状态 * 都将进入显示 加载中数据状态 */ log("up state is " + mCurrentRefresState); //设置文字 mPullRefTextView.setText("正在加载中"); //刷新 显示正在加载中 mValueAnimator = ValueAnimator.ofFloat(0f, 1f); mValueAnimator.setDuration(mPullDuration); mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { //0 -- 1 Float value = (Float) animation.getAnimatedValue(); int recyTop = (int) (recyUpTop - ((recyUpTop - mPullRefshLayoutHeight) * value)); int recyBottom = mRecyclerView.getHeight() + recyTop; int pullTop = recyTop - mPullRefshLayoutHeight; int pullBottom = mPullRefshLayout.getHeight() + pullTop; //重新设置刷新布局文件的显示 setPullRefreshLayout(getPullRefreshLayoutRect(pullTop, pullBottom)); //重新设置RecyclerView的显示 setRecyclerViewLayout(getRecyclerViewRect(recyTop, recyBottom)); int top = mRecyclerView.getTop(); int bot = mRecyclerView.getBottom(); Log.e("pull ing ", "top " + pullTop + " " + pullBottom + " sourTop " + top + " " + bot); } }); mValueAnimator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { //正在加载中状态 if (mCurrentRefresState != RefresState.PULL_LOADING) { mCurrentRefresState = RefresState.PULL_LOADING; //加载更多数据方法 //下拉加载刷新回调 if (mPullRecyclerViewLinserner != null) { mPullRecyclerViewLinserner.loadingRefresDataFunction(); } } mCurrentRefresState = RefresState.PULL_LOADING; //更新网络加载状 为下拉刷新状态 mNetLoadingStatue = NETLOADINGSTATE.PULL_LOADING; } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); mValueAnimator.start(); } else if (mCurrentRefresState == RefresState.PULL_LOADING_FINISH) { log("up state is loading_finish "); //设置文字 mPullRefTextView.setText("已更新数据完成"); //关闭刷新 mValueAnimator = ValueAnimator.ofFloat(1f, 0f); mValueAnimator.setDuration(mPullDuration); mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { //0 -- 1 Float value = (Float) animation.getAnimatedValue(); int recyTop = (int) (recyUpTop * value); int recyBottom = mRecyclerView.getHeight() + recyTop; int pullTop = recyTop - mPullRefshLayoutHeight; int pullBottom = mPullRefshLayout.getHeight() + pullTop; //重新设置RecyclerView的显示 setRecyclerViewLayout(getRecyclerViewRect(recyTop, recyBottom)); //重新设置刷新布局文件的显示 setPullRefreshLayout(getPullRefreshLayoutRect(pullTop, pullBottom)); } }); mValueAnimator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { //更新为初始状态 mCurrentRefresState = RefresState.PULL_DEFAULE; } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); mValueAnimator.start(); } break; } return false; } }; /** * 重新布局RecyclerView 并进行刷新 */ public void setRecyclerViewLayout(Rect rect) { mRecyclerView.layout(rect.left, rect.top, rect.right, rect.bottom); //mRecyclerView.invalidate(); } /** * 将RecyclerView 的left top right bottom 封装到Rect */ public Rect getRecyclerViewRect(int top, int bottom) { return new Rect(mRecyclerView.getLeft(), top, mRecyclerView.getWidth(), bottom); } public Rect getPullRefreshLayoutRect(int top, int bottom) { return new Rect(mPullRefshLayout.getLeft(), top, mPullRefshLayout.getWidth(), bottom); } public void setPullRefreshLayout(Rect rect) { mPullRefshLayout.layout(rect.left, rect.top, rect.right, rect.bottom); mPullRefshLayout.invalidate(); } private void log(String msg) { Log.e("recy", "|------------------------------------------------------------"); Log.d("recy", "|-------- " + msg); } public void closePullRefresh() { if (mRecyclerView != null) { mRecyclerView.setDispatchBoolean(false); } log("加载完成"); //加载完成 mCurrentRefresState = RefresState.PULL_LOADING_FINISH; //更新显示 mPullRefTextView.setText("刷新数据完成"); if (mIsDown) { //正在滑动中不需要结束布局显示 } else { log("结束刷新"); closePullRefresh(true); } } public void closePullRefresh(boolean flag) { if (flag) { mValueAnimator = ValueAnimator.ofFloat(1f, 0f); mValueAnimator.setDuration(mPullDuration); mValueAnimator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { mCurrentRefresState = RefresState.PULL_DEFAULE; //更新列表 mViewHolderAdapter.notifyDataSetChanged(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { //1 --- 0 Float value = (Float) animation.getAnimatedValue(); int recyTop = (int) (mPullRefshLayoutHeight * value); int recyBottom = mRecyclerView.getHeight() + recyTop; int pullTop = recyTop - mPullRefshLayoutHeight; int pullBottom = mPullRefshLayout.getHeight() + pullTop; //重新设置RecyclerView的显示 setRecyclerViewLayout(getRecyclerViewRect(recyTop, recyBottom)); //重新设置刷新布局文件的显示 setPullRefreshLayout(getPullRefreshLayoutRect(pullTop, pullBottom)); } }); mValueAnimator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { //重新设置RecyclerView的显示 setRecyclerViewLayout(getRecyclerViewRect(0, mRecyclerView.getHeight())); //重新设置刷新布局文件的显示 setPullRefreshLayout(getPullRefreshLayoutRect(-mPullRefshLayoutHeight, mPullRefshLayout.getHeight())); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); mValueAnimator.start(); } } //普通加载项的ViewHolder private static class CustomViewHolder extends RecyclerView.ViewHolder { private PullRecyclerViewLinserner mPullRecyclerViewLinserner; private PullRecyclerViewOnItemClickLinserner mPullRecyclerViewOnItemClickLinserner; public CustomViewHolder(View itemView, PullRecyclerViewLinserner linserner, PullRecyclerViewOnItemClickLinserner pullRecyclerViewOnItemClickLinserner) { super(itemView); mPullRecyclerViewLinserner = linserner; mPullRecyclerViewOnItemClickLinserner = pullRecyclerViewOnItemClickLinserner; } public void setDatas(final int position, final int itemType, final Object object) { if (mPullRecyclerViewLinserner != null) { mPullRecyclerViewLinserner.setViewDatas(itemView, position, itemType, object); } if (itemView != null && itemView instanceof ViewGroup) { if (((ViewGroup) itemView).getChildCount() > 0 && ((ViewGroup) itemView).getChildAt(0) != null) { ((ViewGroup) itemView).getChildAt(0).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mPullRecyclerViewOnItemClickLinserner != null) { mPullRecyclerViewOnItemClickLinserner.setonItemClick(position, itemType, object); } } }); } } } } // public interface OnLastItemClickListerner { void loadMoreData(); } public OnLastItemClickListerner mOnLastItemClickListerner = new OnLastItemClickListerner() { @Override public void loadMoreData() { //点击条目最后一条 加载更多 if (mPullRecyclerViewLinserner != null) { mPullRecyclerViewLinserner.loadMoreData(); } //网络加载标识 加载更多 mNetLoadingStatue = NETLOADINGSTATE.UP_LOADING; } }; //上拉加载更多的 ViewHolder private static class UpLoadViewHolder extends RecyclerView.ViewHolder { private final TextView mTextView; private Context mContext; private final String mLoadingMoreNoDataString; private final String mLoadingMoreString; private final ProgressBar mLoadingMoreProgressBar; private final RelativeLayout mRootView; private OnLastItemClickListerner mOnLastItemClickListerner; public UpLoadViewHolder(View itemView, Context context, OnLastItemClickListerner linserner) { super(itemView); mContext = context; mOnLastItemClickListerner = linserner; mRootView = (RelativeLayout) itemView.findViewById(R.id.rl_loadiing_more_rootview); mLoadingMoreProgressBar = (ProgressBar) itemView.findViewById(R.id.pb_loading_more); mTextView = (TextView) itemView.findViewById(R.id.tv_loading_more); mLoadingMoreString = context.getResources().getString(R.string.up_loading_more); mLoadingMoreNoDataString = context.getResources().getString(R.string.up_loading_more_no_data); } public void setDatas(int position, RECYCLERVIEW_UP_LOADING_STATUE currentStatue, int loadingMoreTextColor, int loadingMoreBackGroundColor) { Log.d("recy", "设置加载更多布局"); //设置显示字体颜色 mTextView.setTextColor(loadingMoreTextColor); //设置显示背景颜色 mRootView.setBackgroundColor(loadingMoreBackGroundColor); if (currentStatue == RECYCLERVIEW_UP_LOADING_STATUE.LIST_IS_NULL) { //显示暂无更多数据 mTextView.setText(mLoadingMoreNoDataString); //隐藏加载中 mLoadingMoreProgressBar.setVisibility(View.GONE); //设置点击事件 mTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mOnLastItemClickListerner != null) { mTextView.setOnClickListener(null); mTextView.setText(mLoadingMoreString); mLoadingMoreProgressBar.setVisibility(View.VISIBLE); //回调 mOnLastItemClickListerner.loadMoreData(); } } }); } else { mTextView.setOnClickListener(null); //显示加载更多数据 mTextView.setText(mLoadingMoreString); //显示加载中 mLoadingMoreProgressBar.setVisibility(View.VISIBLE); } } } //功能 状态 private RECYCLRYVIEW_STATUE mCurrentStatue = RECYCLRYVIEW_STATUE.PULL_AND_UP; /*** * RecyclerView 功能设置 */ public enum RECYCLRYVIEW_STATUE { NORMAL,//正常状态下,没有下拉刷新也没有上拉加载更多 PULL_REFRESH,//只有下拉刷新功能 UP_LOAD_MORE,//只有上拉加载更多功能 PULL_AND_UP//下拉刷新 上拉加载功能 } private LOADING_NO_DATA_PAGE_TYPE mCurrentLoadingNoDataType = LOADING_NO_DATA_PAGE_TYPE.TEXT; /** * 默认显示无数据页面显示类型 */ public enum LOADING_NO_DATA_PAGE_TYPE { IMAGE,//只显示图片 IMAGE_AND_TEXT,//显示图片和文字 TEXT//只显示文字 } private RECYCLERVIEW_UP_LOADING_STATUE mCurrentUpLoadingStatue = RECYCLERVIEW_UP_LOADING_STATUE.LIST_NOT_NULL; //上拉加载更多数据VIEW功能状态 public enum RECYCLERVIEW_UP_LOADING_STATUE { LIST_IS_NULL,//没有数据 LIST_NOT_NULL//有数据 } //-------------------------------------------------------------------------------------------------- //更新新数据 更新所有的数据 //下拉刷新时可以使用 /** * @param isLoadingListNull 加载的数据 是否为null 是:true */ public void updateDataList(List<T> list, final boolean isLoadingListNull) { mIsLoading = false; //隐藏加载中 //closePullRefresh(); if (list == null) { list = new ArrayList<>(); } log("recy mNetLoadingStatue " + mNetLoadingStatue); switch (mNetLoadingStatue) { case PULL_LOADING: //下拉 //结束刷新状态 closePullRefresh(); if (mStringList.size() == 0) { mStringList.clear(); mViewHolderAdapter.notifyDataSetChanged(); //显示无数据页面 ObjectAnimator lAlphaAnimation = ObjectAnimator.ofFloat(mLoadingNoDataLinearLayout, "alpha", 0f, 1f); lAlphaAnimation.setDuration(300); lAlphaAnimation.setInterpolator(new LinearInterpolator()); lAlphaAnimation.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { mLoadingNoDataLinearLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animator) { } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); lAlphaAnimation.start(); } else { //刷新 final List<T> finalList = list; mHandler.postDelayed(new Runnable() { @Override public void run() { mStringList.clear(); mViewHolderAdapter.notifyDataSetChanged(); mStringList.addAll(finalList); mViewHolderAdapter.notifyDataSetChanged(); } }, 400); } break; case UP_LOADING: //上拉 final List<T> finalList1 = list; mHandler.postDelayed(new Runnable() { @Override public void run() { mStringList.clear(); mStringList.addAll(finalList1); if (isLoadingListNull) { log("上拉 LIST_IS_NULL"); mCurrentUpLoadingStatue = RECYCLERVIEW_UP_LOADING_STATUE.LIST_IS_NULL; int lSize = mStringList.size(); int lI = lSize - 1; if (lI<0){ lI=0; } mViewHolderAdapter.notifyDataSetChanged(); } else { log("上拉 LIST_NOT_NULL"); mCurrentUpLoadingStatue = RECYCLERVIEW_UP_LOADING_STATUE.LIST_NOT_NULL; mViewHolderAdapter.notifyDataSetChanged(); } } }, 400); break; //没有 case NO_LOADING: break; // case CLICK_NO_DATA: //无数据点击 if (list.size() == 0) { mStringList.clear(); mViewHolderAdapter.notifyDataSetChanged(); //隐藏加载中 显示无数据页面 final ObjectAnimator lAlphaAnimation = ObjectAnimator.ofFloat(mLoadingNoDataLinearLayout, "alpha", 0f, 1f); lAlphaAnimation.setDuration(300); lAlphaAnimation.setInterpolator(new LinearInterpolator()); lAlphaAnimation.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { mLoadingNoDataLinearLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animator) { } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); if (mClickNoDataHidIngAndShowNoDataAnimator != null) { if (mClickNoDataHidIngAndShowNoDataAnimator.isRunning()) { mClickNoDataHidIngAndShowNoDataAnimator.cancel(); } } mClickNoDataHidIngAndShowNoDataAnimator = ObjectAnimator.ofFloat(mLoadingIngLinearLayout, "alpha", 1f, 0f); mClickNoDataHidIngAndShowNoDataAnimator.setDuration(300); mClickNoDataHidIngAndShowNoDataAnimator.setInterpolator(new LinearInterpolator()); mClickNoDataHidIngAndShowNoDataAnimator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { mLoadingIngLinearLayout.setVisibility(View.GONE); lAlphaAnimation.start(); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); mClickNoDataHidIngAndShowNoDataAnimator.start(); } else { //隐藏加载中 显示数据页面 if (mClickNoDataHidIngAndShowDataAnimator != null) { if (mClickNoDataHidIngAndShowDataAnimator.isRunning()) { mClickNoDataHidIngAndShowDataAnimator.cancel(); mClickNoDataHidIngAndShowDataAnimator = null; } } mStringList.clear(); mViewHolderAdapter.notifyDataSetChanged(); mStringList.addAll(list); mClickNoDataHidIngAndShowDataAnimator = ObjectAnimator.ofFloat(mLoadingIngLinearLayout, "alpha", 1f, 0f); mClickNoDataHidIngAndShowDataAnimator.setDuration(300); mClickNoDataHidIngAndShowDataAnimator.setInterpolator(new LinearInterpolator()); mClickNoDataHidIngAndShowDataAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { Float value = (Float) valueAnimator.getAnimatedValue(); mLoadingIngLinearLayout.setAlpha(value); if (value == 0) { if (mLoadingIngLinearLayout.getVisibility() == View.VISIBLE) { mLoadingIngLinearLayout.setVisibility(View.GONE); //刷新数据 mViewHolderAdapter.notifyDataSetChanged(); } } } }); mClickNoDataHidIngAndShowDataAnimator.start(); } break; case DEFAULT_LOADING: //第一次加载 mStringList.clear(); mStringList.addAll(list); if (mStringList.size() == 0) { //隐藏加载中 显示无数据页面 final ObjectAnimator lAlphaAnimation = ObjectAnimator.ofFloat(mLoadingNoDataLinearLayout, "alpha", 0f, 1f); lAlphaAnimation.setDuration(300); lAlphaAnimation.setInterpolator(new LinearInterpolator()); lAlphaAnimation.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { mLoadingNoDataLinearLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animator) { } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); ObjectAnimator lAlphaAnimation2 = ObjectAnimator.ofFloat(mLoadingIngLinearLayout, "alpha", 1f, 0f); lAlphaAnimation2.setDuration(300); lAlphaAnimation2.setInterpolator(new LinearInterpolator()); lAlphaAnimation2.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { mLoadingIngLinearLayout.setVisibility(View.GONE); lAlphaAnimation.start(); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); lAlphaAnimation2.start(); } else { switch (mCurrentShowDefaultType) { case NO_DATA: //隐藏无数据页面 显示数据 ObjectAnimator lAlphaAnimation2 = ObjectAnimator.ofFloat(mLoadingNoDataLinearLayout, "alpha", 1f, 0f); lAlphaAnimation2.setDuration(300); lAlphaAnimation2.setInterpolator(new LinearInterpolator()); lAlphaAnimation2.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { mLoadingNoDataLinearLayout.setVisibility(View.GONE); mViewHolderAdapter.notifyDataSetChanged(); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); lAlphaAnimation2.start(); break; case LOADING: //隐藏加载中 显示数据 ObjectAnimator lAlphaAnimation3 = ObjectAnimator.ofFloat(mLoadingIngLinearLayout, "alpha", 1f, 0f); lAlphaAnimation3.setDuration(300); lAlphaAnimation3.setInterpolator(new LinearInterpolator()); lAlphaAnimation3.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { mLoadingIngLinearLayout.setVisibility(View.GONE); mViewHolderAdapter.notifyDataSetChanged(); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); lAlphaAnimation3.start(); break; } } break; } } //更新加载更多的数据 /** * @param list * @param flag true 替换 false不替换 */ public void updateMoreDataList(final List<T> list, final boolean flag, List<Object> clist) { //更新加载标识 mIsLoading = false; int size = 0; log("隐藏加载中"); hidLoadingIngFucntion(); if (mStringList != null) { size = mStringList.size(); } else { mStringList = new ArrayList<>(); } if (flag) { mStringList = list; } else { if (list != null) { mStringList.addAll(list); } } if (clist == null || clist.size() == 0) { mCurrentUpLoadingStatue = RECYCLERVIEW_UP_LOADING_STATUE.LIST_IS_NULL; } else { mCurrentUpLoadingStatue = RECYCLERVIEW_UP_LOADING_STATUE.LIST_NOT_NULL; } if (mStringList == null || mStringList.size() == 0) { //显示无数据页面 log("显示无数据页面"); showLoadingNoDataFunction(); return; } else { log("隐藏无数据页面"); hidLoadingNoDataFunction(); } final int finalSize1 = size; mHandler.postDelayed(new Runnable() { @Override public void run() { log("刷新页面 " + finalSize1); mViewHolderAdapter.notifyItemRemoved(finalSize1); mViewHolderAdapter.notifyItemChanged(finalSize1); } }, 600); } public <T> void addLoadingMoreDataList(final List<T> list) { int size = 0; if (mStringList != null) { size = mStringList.size(); } //隐藏加载中 无数据页面 hidLoadingIngFucntion(); hidLoadingNoDataFunction(); if (list == null || list.size() == 0) { final int finalSize = size; mHandler.postDelayed(new Runnable() { @Override public void run() { //无数据标识 mCurrentUpLoadingStatue = RECYCLERVIEW_UP_LOADING_STATUE.LIST_IS_NULL; //更新 mViewHolderAdapter.notifyItemChanged(finalSize); } }, 600); } else { final int finalSize = size; mHandler.postDelayed(new Runnable() { @Override public void run() { //无数据标识 mCurrentUpLoadingStatue = RECYCLERVIEW_UP_LOADING_STATUE.LIST_NOT_NULL; //更新 mViewHolderAdapter.notifyItemChanged(finalSize); } }, 600); } } public void setRecyclerviewHeight(int flag) { if (mRecyclerView != null) { int lHeightPixels = mContext.getResources().getDisplayMetrics().heightPixels; if (flag < 0 || flag > lHeightPixels) { flag = lHeightPixels; } ViewGroup.LayoutParams lLayoutParams = mRecyclerView.getLayoutParams(); if (lLayoutParams != null) { lLayoutParams.height = flag; } } } public void setLoadingDataList(List<T> list) { setLoadingDataList(list,mCurrentShowDefaultType); } public void setLoadingDataList(List<T> list,SHOW_DEFAUTLE_PAGE_TYPE defautle_page_type) { mCurrentShowDefaultType = defautle_page_type; mIsLoading = false; //隐藏加载中 //closePullRefresh(); if (list == null) { list = new ArrayList<>(); } log("recy mNetLoadingStatue " + mNetLoadingStatue); switch (mNetLoadingStatue) { case PULL_LOADING: //下拉 //结束刷新状态 closePullRefresh(); if (list.size() == 0) { //显示无数据页面 ObjectAnimator lAlphaAnimation = ObjectAnimator.ofFloat(mLoadingNoDataLinearLayout, "alpha", 0f, 1f); lAlphaAnimation.setDuration(300); lAlphaAnimation.setInterpolator(new LinearInterpolator()); lAlphaAnimation.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { mLoadingNoDataLinearLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animator) { mStringList.clear(); mViewHolderAdapter.notifyDataSetChanged(); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); lAlphaAnimation.start(); } else { //刷新 final List<T> finalList = list; mHandler.postDelayed(new Runnable() { @Override public void run() { mStringList.clear(); mViewHolderAdapter.notifyDataSetChanged(); mStringList.addAll(finalList); mViewHolderAdapter.notifyDataSetChanged(); } }, 400); } break; case UP_LOADING: //上拉 int lSize = mStringList.size(); mStringList.addAll(list); if (list.size() == 0) { mCurrentUpLoadingStatue = RECYCLERVIEW_UP_LOADING_STATUE.LIST_IS_NULL; if (lSize == 0) { mViewHolderAdapter.notifyDataSetChanged(); } else { mViewHolderAdapter.notifyItemChanged(lSize); } } else { mCurrentUpLoadingStatue = RECYCLERVIEW_UP_LOADING_STATUE.LIST_NOT_NULL; if (lSize == 0) { mViewHolderAdapter.notifyDataSetChanged(); } else { mViewHolderAdapter.notifyItemChanged(lSize); } } break; //没有 case NO_LOADING: break; // case CLICK_NO_DATA: //无数据点击 if (list.size() == 0) { mStringList.clear(); mViewHolderAdapter.notifyDataSetChanged(); //隐藏加载中 显示无数据页面 final ObjectAnimator lAlphaAnimation = ObjectAnimator.ofFloat(mLoadingNoDataLinearLayout, "alpha", 0f, 1f); lAlphaAnimation.setDuration(300); lAlphaAnimation.setInterpolator(new LinearInterpolator()); lAlphaAnimation.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { mLoadingNoDataLinearLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animator) { } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); if (mClickNoDataHidIngAndShowNoDataAnimator != null) { if (mClickNoDataHidIngAndShowNoDataAnimator.isRunning()) { mClickNoDataHidIngAndShowNoDataAnimator.cancel(); } } mClickNoDataHidIngAndShowNoDataAnimator = ObjectAnimator.ofFloat(mLoadingIngLinearLayout, "alpha", 1f, 0f); mClickNoDataHidIngAndShowNoDataAnimator.setDuration(300); mClickNoDataHidIngAndShowNoDataAnimator.setInterpolator(new LinearInterpolator()); mClickNoDataHidIngAndShowNoDataAnimator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { mLoadingIngLinearLayout.setVisibility(View.GONE); lAlphaAnimation.start(); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); mClickNoDataHidIngAndShowNoDataAnimator.start(); } else { //隐藏加载中 显示数据页面 if (mClickNoDataHidIngAndShowDataAnimator != null) { if (mClickNoDataHidIngAndShowDataAnimator.isRunning()) { mClickNoDataHidIngAndShowDataAnimator.cancel(); mClickNoDataHidIngAndShowDataAnimator = null; } } mStringList.clear(); mViewHolderAdapter.notifyDataSetChanged(); mStringList.addAll(list); mClickNoDataHidIngAndShowDataAnimator = ObjectAnimator.ofFloat(mLoadingIngLinearLayout, "alpha", 1f, 0f); mClickNoDataHidIngAndShowDataAnimator.setDuration(300); mClickNoDataHidIngAndShowDataAnimator.setInterpolator(new LinearInterpolator()); mClickNoDataHidIngAndShowDataAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { Float value = (Float) valueAnimator.getAnimatedValue(); mLoadingIngLinearLayout.setAlpha(value); if (value == 0) { if (mLoadingIngLinearLayout.getVisibility() == View.VISIBLE) { mLoadingIngLinearLayout.setVisibility(View.GONE); //刷新数据 mViewHolderAdapter.notifyDataSetChanged(); } } } }); mClickNoDataHidIngAndShowDataAnimator.start(); } break; case DEFAULT_LOADING: //第一次加载 if (list.size() == 0) { //隐藏加载中 显示无数据页面 final ObjectAnimator lAlphaAnimation = ObjectAnimator.ofFloat(mLoadingNoDataLinearLayout, "alpha", 0f, 1f); lAlphaAnimation.setDuration(300); lAlphaAnimation.setInterpolator(new LinearInterpolator()); lAlphaAnimation.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { mLoadingNoDataLinearLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animator) { mStringList.clear(); mViewHolderAdapter.notifyDataSetChanged(); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); ObjectAnimator lAlphaAnimation2 = ObjectAnimator.ofFloat(mLoadingIngLinearLayout, "alpha", 1f, 0f); lAlphaAnimation2.setDuration(300); lAlphaAnimation2.setInterpolator(new LinearInterpolator()); lAlphaAnimation2.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { mLoadingIngLinearLayout.setVisibility(View.GONE); lAlphaAnimation.start(); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); lAlphaAnimation2.start(); } else { switch (mCurrentShowDefaultType) { case NO_DATA: if (mLoadingIngLinearLayout.getVisibility()== View.VISIBLE) { mLoadingIngLinearLayout.setVisibility(View.GONE); } //隐藏无数据页面 显示数据 ObjectAnimator lAlphaAnimation2 = ObjectAnimator.ofFloat(mLoadingNoDataLinearLayout, "alpha", 1f, 0f); lAlphaAnimation2.setDuration(300); lAlphaAnimation2.setInterpolator(new LinearInterpolator()); final List<T> finalList1 = list; lAlphaAnimation2.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { mLoadingNoDataLinearLayout.setVisibility(View.GONE); mStringList.clear(); mViewHolderAdapter.notifyDataSetChanged(); mStringList.addAll(finalList1); mViewHolderAdapter.notifyDataSetChanged(); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); lAlphaAnimation2.start(); break; case LOADING: if (mLoadingNoDataLinearLayout.getVisibility()== View.VISIBLE) { mLoadingNoDataLinearLayout.setVisibility(View.GONE); } //隐藏加载中 显示数据 ObjectAnimator lAlphaAnimation3 = ObjectAnimator.ofFloat(mLoadingIngLinearLayout, "alpha", 1f, 0f); lAlphaAnimation3.setDuration(300); lAlphaAnimation3.setInterpolator(new LinearInterpolator()); final List<T> finalList2 = list; lAlphaAnimation3.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { mLoadingIngLinearLayout.setVisibility(View.GONE); mStringList.clear(); mViewHolderAdapter.notifyDataSetChanged(); mStringList.addAll(finalList2); mViewHolderAdapter.notifyDataSetChanged(); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); lAlphaAnimation3.start(); break; } } break; } } //-------------------------------------------------------------------------------------------------- //上拉加载更多显示文字颜色 private int mLoadingMoreTextColor = Color.WHITE; public void setUpLoadingMoreTextColorFunction(int textColor) { mLoadingMoreTextColor = textColor; } //上拉加载更多显示背景颜色 private int mLoadingMoreBackGroundColor = Color.BLACK; public void setUpLoadingMoreBackGroundColor(int color) { mLoadingMoreBackGroundColor = color; } //-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- //下拉刷新显示文字颜色 private int mPullRefshTextColor = Color.WHITE; public void setPullRefshTextColorFunction(int textColor) { mLoadingMoreTextColor = textColor; if (mPullRefTextView != null) { mPullRefTextView.setTextColor(textColor); } } //下拉刷新显示背景颜色 private int mPullRefshBackGroundColor = Color.BLACK; public void setPullRefshBackGroundColor(int color) { mLoadingMoreBackGroundColor = color; if (mPullRefshLayout != null) { mPullRefshLayout.setBackgroundColor(color); } } //下拉刷新显示的图片 private Drawable mPullRefshDrawable = null; public void setPullRefshImageFunction(Drawable drawable) { mPullRefshDrawable = drawable; if (mPullRefImageView != null) { mPullRefImageView.setImageDrawable(drawable); } } private PULLREFSH_SHOW_VIEW_STATUE mCurrentPullRefshStatue = PULLREFSH_SHOW_VIEW_STATUE.PB_AND_TV; //下拉刷新模式 public enum PULLREFSH_SHOW_VIEW_STATUE { PB_AND_TV,//显示 加载进度显示文字 IV_AND_TV,//显示图片 加载进度显示文字 PB,//只显示加载进度圈 TV,//只显示加载文字 IV//只显示加载图片 } public void setPullRefshStatue(PULLREFSH_SHOW_VIEW_STATUE statue) { switch (statue) { case IV: if (mPullRefTextView != null) { mPullRefTextView.setVisibility(View.GONE); } if (mPullRefProgressBar != null) { mPullRefProgressBar.setVisibility(View.GONE); } if (mPullRefImageView != null) { mPullRefImageView.setVisibility(View.VISIBLE); } break; case PB: if (mPullRefTextView != null) { mPullRefTextView.setVisibility(View.GONE); } if (mPullRefProgressBar != null) { mPullRefProgressBar.setVisibility(View.VISIBLE); } if (mPullRefImageView != null) { mPullRefImageView.setVisibility(View.GONE); } break; case TV: if (mPullRefTextView != null) { mPullRefTextView.setVisibility(View.VISIBLE); } if (mPullRefProgressBar != null) { mPullRefProgressBar.setVisibility(View.GONE); } if (mPullRefImageView != null) { mPullRefImageView.setVisibility(View.GONE); } break; case PB_AND_TV: if (mPullRefProgressBar != null) { mPullRefProgressBar.setVisibility(View.VISIBLE); } if (mPullRefTextView != null) { mPullRefTextView.setVisibility(View.VISIBLE); } if (mPullRefImageView != null) { mPullRefImageView.setVisibility(View.GONE); } break; case IV_AND_TV: if (mPullRefProgressBar != null) { mPullRefProgressBar.setVisibility(View.GONE); } if (mPullRefTextView != null) { mPullRefTextView.setVisibility(View.VISIBLE); } if (mPullRefImageView != null) { mPullRefImageView.setVisibility(View.VISIBLE); } break; } } //-------------------------------------------------------------------------------------------------- //设置主背景的颜色 public void setMainBackgroundRelativeLayoutColor(int color) { if (mMainBackgroundRelativeLayout != null) { mMainBackgroundRelativeLayout.setBackgroundColor(color); } } //-------------------------------------------------------------------------------------------------- //加载无数据相关设置 //显示加载无数数据内容 public void showLoadingNoDataFunction() { if (mLoadingNoDataLinearLayout != null) { if (mLoadingIngLinearLayout.getVisibility() == View.VISIBLE) { //先隐藏加载中 //再显示无数据 final ObjectAnimator lAlphaAnimation2 = ObjectAnimator.ofFloat(mLoadingNoDataLinearLayout, "alpha", 0f, 1f); lAlphaAnimation2.setDuration(400); lAlphaAnimation2.setInterpolator(new LinearInterpolator()); lAlphaAnimation2.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { mLoadingNoDataLinearLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animator) { mLoadingNoDataLinearLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); ObjectAnimator lAlphaAnimation = ObjectAnimator.ofFloat(mLoadingIngLinearLayout, "alpha", 10f, 0); lAlphaAnimation.setDuration(400); lAlphaAnimation.setInterpolator(new LinearInterpolator()); lAlphaAnimation.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { mLoadingIngLinearLayout.setVisibility(View.GONE); lAlphaAnimation2.start(); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); lAlphaAnimation.start(); } else { Log.d("hid", "隐藏加载中 2"); ObjectAnimator lAlphaAnimation = ObjectAnimator.ofFloat(mLoadingNoDataLinearLayout, "alpha", 0f, 1f); lAlphaAnimation.setDuration(400); lAlphaAnimation.setInterpolator(new LinearInterpolator()); lAlphaAnimation.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { mLoadingNoDataLinearLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animator) { mLoadingNoDataLinearLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); lAlphaAnimation.start(); } } } //隐藏加载无数数据内容 public void hidLoadingNoDataFunction() { if (mLoadingNoDataLinearLayout != null && mLoadingNoDataLinearLayout.getVisibility() == View.VISIBLE && mLoadingNoDataLinearLayout.getAlpha() == 1) { Log.d("hid", "隐藏加载中 2"); ObjectAnimator lAlphaAnimation = ObjectAnimator.ofFloat(mLoadingNoDataLinearLayout, "alpha", 1f, 0f); lAlphaAnimation.setDuration(400); lAlphaAnimation.setInterpolator(new LinearInterpolator()); lAlphaAnimation.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { mLoadingNoDataLinearLayout.setAlpha(1f); mLoadingNoDataLinearLayout.setVisibility(View.GONE); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); lAlphaAnimation.start(); } } //点击加载数据事件 public View.OnClickListener mNoDataOnClickListener = new View.OnClickListener() { @Override public void onClick(View view) { //隐藏加载无数据 //显示加载中 final ObjectAnimator lAlphaAnimation1 = ObjectAnimator.ofFloat(mLoadingIngLinearLayout, "alpha", 0f, 1f); lAlphaAnimation1.setDuration(400); lAlphaAnimation1.setInterpolator(new LinearInterpolator()); lAlphaAnimation1.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { mLoadingIngLinearLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animator) { //更新标识 mNetLoadingStatue = NETLOADINGSTATE.CLICK_NO_DATA; //回调函数 if (mPullRecyclerViewLinserner != null) { mPullRecyclerViewLinserner.loadMoreData(); } } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); ObjectAnimator lAlphaAnimation = ObjectAnimator.ofFloat(mLoadingNoDataLinearLayout, "alpha", 1f, 0f); lAlphaAnimation.setDuration(200); lAlphaAnimation.setInterpolator(new LinearInterpolator()); lAlphaAnimation.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { mLoadingNoDataLinearLayout.setVisibility(View.GONE); lAlphaAnimation1.start(); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); lAlphaAnimation.start(); } }; //设置加载无数据文字 颜色 public void setLoadingNoDataTextColor(int color) { if (mLoadingNoDataTextView != null) { mLoadingNoDataTextView.setTextColor(color); } } //设置加载无数据文字 public void setLoadingNoDataText(String msg) { if (mLoadingNoDataTextView != null) { if (!TextUtils.isEmpty(msg)) { mLoadingNoDataTextView.setText(msg); } } } //-------------------------------------------------------------------------------------------------- //加载中相关设置 //显示加载中 public void showLoadingIngFucntion() { Log.d("hid", "显示加载中 1"); if (mLoadingIngLinearLayout != null && mLoadingIngLinearLayout.getVisibility() == View.GONE) { Log.d("hid", "隐藏加载中 2"); ObjectAnimator lAlphaAnimation = ObjectAnimator.ofFloat(mLoadingIngLinearLayout, "alpha", 0f, 1f); lAlphaAnimation.setDuration(400); lAlphaAnimation.setInterpolator(new LinearInterpolator()); lAlphaAnimation.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { mLoadingIngLinearLayout.setAlpha(0); mLoadingIngLinearLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animator) { mLoadingIngLinearLayout.setVisibility(View.VISIBLE); mLoadingIngLinearLayout.setAlpha(1f); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); lAlphaAnimation.start(); } } //隐藏加载中 public void hidLoadingIngFucntion() { Log.d("hid", "隐藏加载中 1"); if (mLoadingIngLinearLayout != null && mLoadingIngLinearLayout.getAlpha() == 1) { Log.d("hid", "隐藏加载中 2"); ObjectAnimator lAlphaAnimation = ObjectAnimator.ofFloat(mLoadingIngLinearLayout, "alpha", 1f, 0f); lAlphaAnimation.setDuration(400); lAlphaAnimation.setInterpolator(new LinearInterpolator()); lAlphaAnimation.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { mLoadingIngLinearLayout.setVisibility(View.GONE); mLoadingIngLinearLayout.setAlpha(1f); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); lAlphaAnimation.start(); } } //设置加载中文字颜色 //---------------------------------------------------------------------------- //设置索引相关 public void setShowIndexBar(QuickIndexBar.OnLetterChangeListener listener) { if (mQuickIndexBar != null && mQuickIndexBar.getVisibility() == View.GONE) { AlphaAnimation lAlphaAnimation = new AlphaAnimation(0f, 1f); lAlphaAnimation.setDuration(600); lAlphaAnimation.setInterpolator(new LinearInterpolator()); lAlphaAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { mQuickIndexBar.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); mQuickIndexBar.startAnimation(lAlphaAnimation); mQuickIndexBar.setOnLetterChangeListener(listener); } } public void setHidIndexBar() { if (mQuickIndexBar != null && mQuickIndexBar.getVisibility() == View.VISIBLE) { AlphaAnimation lAlphaAnimation = new AlphaAnimation(1f, 0f); lAlphaAnimation.setDuration(600); lAlphaAnimation.setInterpolator(new LinearInterpolator()); lAlphaAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { mQuickIndexBar.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { } }); mQuickIndexBar.startAnimation(lAlphaAnimation); } } //设置索引显示文字颜色 public void setQuickIndexBarTextColor(int color) { if (mQuickIndexBar != null) { mQuickIndexBar.settextColor(color); } } //按下进文字显示颜色 public void setQuickIndexBarPressTextColor(int color) { if (mQuickIndexBar != null) { mQuickIndexBar.setPressTextColor(color); } } public void setPullRecyclerViewOnItemClickLinserner(PullRecyclerViewOnItemClickLinserner linserner) { this.mPullRecyclerViewOnItemClickLinserner = linserner; } /** * 显示 */ public void setMainRecyclerviewShowFunction() { if (mMainRefreshView != null) { AlphaAnimation lAlphaAnimation = new AlphaAnimation(0f, 1f); lAlphaAnimation.setDuration(400); lAlphaAnimation.setInterpolator(new LinearInterpolator()); lAlphaAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { mMainRefreshView.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { mLoadingIngLinearLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); mMainRefreshView.startAnimation(lAlphaAnimation); } } /** * 设置索引的颜色 */ public void setQuickIndexBarBackGroundColor(int transparent) { if (mQuickIndexBar != null) { mQuickIndexBar.setBackgroundColor(transparent); } } /** * 将recyclerview 滑动到指定的位置 */ public void setRecyclerViewScrollTo(int i) { if (mRecyclerView != null) { mRecyclerView.scrollToPosition(i); } } }
16378f7a72c4ad287b5335b9ac286e9bcad35859
b0e3fe41276a6a875ad8c5f838c3496994760eb7
/ServidorRMI/src/BD/Conexao.java
b8d45e65cc6afc65693e5423916bf05098e82c88
[]
no_license
TiagoOlivv/client-and-server-with-rmi-communication
f540c62021167d2919020f6a33c4346c1ca93657
e4dfa59af8d0f540fd05e0416f46319a1a739d86
refs/heads/master
2020-04-30T06:37:19.038313
2019-04-13T22:52:12
2019-04-13T22:52:12
176,657,358
0
0
null
null
null
null
UTF-8
Java
false
false
962
java
package BD; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; public class Conexao { public Connection conect(){ try { System.out.println("Banco de dados conectado"); return DriverManager.getConnection("jdbc:postgresql://127.0.0.1:5432/rmi", "postgres","admin"); } catch (SQLException e) { System.out.println("Conexão falhada! Verifique o console de saída"); e.printStackTrace(); return null; } } public void registraDriver(){ try { Class.forName("org.postgresql.Driver"); } catch (ClassNotFoundException e) { System.out.println("Onde está o seu driver JDBC do PostgreSQL? " + "Inclua em sua biblioteca"); e.printStackTrace(); return; } System.out.println("\nPostgreSQL JDBC Driver registrado!"); } }
f3fc607e2ac9ee9b64e23a1cf429cd8a4b0b0e66
8d81f776e5e9d05508238e363a7510923bc796a1
/src/main/general/gui/GUIListSingleSelectionCenteredXY.java
f916e40972dafe7f1ab03fa2df8d5b98e7560565
[]
no_license
Itschotsch/BaschtelGame
b119839ab953eb3a70a4b1c6a69d6159d8773710
3fabc754123fcf3e480be295f514093cb1357454
refs/heads/master
2021-01-25T04:35:30.942305
2017-06-06T01:31:43
2017-06-06T01:31:43
93,451,007
0
0
null
2017-06-05T22:01:33
2017-06-05T22:01:33
null
UTF-8
Java
false
false
260
java
package main.general.gui; public class GUIListSingleSelectionCenteredXY extends GUIListSingleSelection { public GUIListSingleSelectionCenteredXY(float x, float y, float width, float height) { super(x - width / 2f, y - height / 2f, width, height); } }
ccc6e81109d0139ffd6259e94ca5653380a4c65a
87ce61c3a4171336d1c4e99dcf217ecbe0250d3d
/src/main/java/com/betterjr/modules/supplieroffer/data/OfferConstantCollentions.java
fac972e63f937339b9363324acad40ac0f7cdc7b
[]
no_license
Xuyp1023/scf-service
e2a92f0ce09f9508ff1f3e1f1b4486b106b531fa
d229c8f3fa46e897f53287c58a225e0a31ffb4f9
refs/heads/master
2021-05-15T13:08:44.375713
2017-10-20T08:36:58
2017-10-20T08:36:58
108,508,592
1
2
null
null
null
null
UTF-8
Java
false
false
311
java
package com.betterjr.modules.supplieroffer.data; public class OfferConstantCollentions { // 状态 0: 不可用 1 正常使用 public static final String OFFER_BUSIN_STATUS_NOEFFECTIVE = "0"; // 0: 不可用 public static final String OFFER_BUSIN_STATUS_EFFECTIVE = "1"; // 1 正常使用 }
2d083f6ec8d479a8f66e1b49129e231b17738103
2f57b85955893705ce9b012073f3fcd9d0828f21
/craigsListscraper/src/main/java/CraigsList.java
03bc20935ac4fbb54bf88963a9e6e09645955368
[]
no_license
izzyjr/ScrapersJava
3d4dcc8adf3c26cc6bda2d66e7efdb706c98e1b5
1847143a08c6d17717ebf583470b91eaadfb1ffd
refs/heads/master
2021-01-24T03:43:20.046430
2018-10-16T22:30:52
2018-10-16T22:30:52
122,902,779
1
0
null
null
null
null
UTF-8
Java
false
false
658
java
import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.html.HtmlPage; public class CraigsList { public static void main(String[] args) { String searchQuery = "Iphone 6s" ; WebClient client = new WebClient(); client.getOptions().setCssEnabled(false); client.getOptions().setJavaScriptEnabled(false); try { String searchUrl = "https://newyork.craigslist.org/search/sss?sort=rel&query=" + URLEncoder.encode(searchQuery, "UTF-8"; HtmlPage page = client.getPage(searchUrl); }catch(Exception e){ e.printStackTrace(); } } } }
1b1a7a4eec1a54d8b110c0c950ad3aa4ed76fef8
6a93f162a135bb53d965ca89736463b54342288e
/wechatspider/uiautoregister/src/main/java/com/common/volley/toolbox/Volley.java
ccaf21a0bc7f36b8505b6f3e57860379e8ca0a9e
[]
no_license
chenjiexu1010/autotesting
c0319d131969e554da22addcff72afb4fe4966ce
e82f42891e24d2e2d1f69e3abdbc0cd8a1455dcd
refs/heads/master
2021-03-17T16:27:30.662005
2020-04-23T03:18:29
2020-04-23T03:18:29
247,002,940
0
0
null
null
null
null
UTF-8
Java
false
false
2,893
java
/* * Copyright (C) 2012 The Android Open Source Project * * 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.common.volley.toolbox; import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.net.http.AndroidHttpClient; import android.os.Build; import com.common.volley.Network; import com.common.volley.RequestQueue; import java.io.File; public class Volley { /** Default on-disk cache directory. */ private static final String DEFAULT_CACHE_DIR = "volley"; /** * Creates a default instance of the worker pool and calls {@link RequestQueue#start()} on it. * * @param context A {@link Context} to use for creating the cache dir. * @param stack An {@link HttpStack} to use for the network, or null for default. * @return A started {@link RequestQueue} instance. */ public static RequestQueue newRequestQueue(Context context, HttpStack stack) { File cacheDir = new File(context.getCacheDir(), DEFAULT_CACHE_DIR); String userAgent = "volley/0"; try { String packageName = context.getPackageName(); PackageInfo info = context.getPackageManager().getPackageInfo(packageName, 0); userAgent = packageName + "/" + info.versionCode; } catch (NameNotFoundException e) { } if (stack == null) { if (Build.VERSION.SDK_INT >= 9) { stack = new HurlStack(); } else { // Prior to Gingerbread, HttpUrlConnection was unreliable. // See: http://android-developers.blogspot.com/2011/09/androids-http-clients.html stack = new HttpClientStack(AndroidHttpClient.newInstance(userAgent)); } } Network network = new BasicNetwork(stack); RequestQueue queue = new RequestQueue(new DiskBasedCache(cacheDir), network); queue.start(); return queue; } /** * Creates a default instance of the worker pool and calls {@link RequestQueue#start()} on it. * * @param context A {@link Context} to use for creating the cache dir. * @return A started {@link RequestQueue} instance. */ public static RequestQueue newRequestQueue(Context context) { return newRequestQueue(context, null); } }
73a8af86d71e600f1bf2bb32997492b1fe441420
0af8b92686a58eb0b64e319b22411432aca7a8f3
/large-multiproject/project68/src/test/java/org/gradle/test/performance68_2/Test68_129.java
44f9f3217b9a0f897394922b549af430d5388f1f
[]
no_license
gradle/performance-comparisons
b0d38db37c326e0ce271abebdb3c91769b860799
e53dc7182fafcf9fedf07920cbbea8b40ee4eef4
refs/heads/master
2023-08-14T19:24:39.164276
2022-11-24T05:18:33
2022-11-24T05:18:33
80,121,268
17
15
null
2022-09-30T08:04:35
2017-01-26T14:25:33
null
UTF-8
Java
false
false
292
java
package org.gradle.test.performance68_2; import static org.junit.Assert.*; public class Test68_129 { private final Production68_129 production = new Production68_129("value"); @org.junit.Test public void test() { assertEquals(production.getProperty(), "value"); } }
ced79f22ba30b95e9fada296a034a5663bbf141d
bb3b9380526af31f39cb6e71cbbba4e3c886c80d
/cellpay-sdk/src/main/java/com/cellcom/cellpay_sdk/helper/CellpayCheckOutInterface.java
f99318509fa36c549708967a264d1d5aa9fa87b2
[]
no_license
cellcom-nepal/cellpay-sdk
2d7ab770aa765bb9f80a3ae2e289d7459a8bd430
4514f2d46270668d6a4e5f7f4d6e4fcaae7ad654
refs/heads/master
2022-01-03T09:29:05.641467
2021-12-27T05:42:59
2021-12-27T05:42:59
231,575,984
0
0
null
null
null
null
UTF-8
Java
false
false
200
java
package com.cellcom.cellpay_sdk.helper; import com.cellcom.cellpay_sdk.api.Config; public interface CellpayCheckOutInterface { void show(); void show(Config config); void destroy(); }
a7fa5006ab592d19de397d4fbc89f61fd3d29ebe
59931fe6ad6e4a8d3b3e5457ae0978a8a6d3683e
/java-algo/src/main/java/com/c1games/terminal/simulation/units/Turret.java
bf82353e07d659e3ec57c91a32cd37ad36eb7175
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
muditg317/2021-Terminal
80ac971a20acca5398538a89331ef583b25730f5
7be6a157531576568a03fdef8f2574271228d648
refs/heads/master
2023-04-01T20:52:03.771507
2021-04-10T23:45:00
2021-04-10T23:45:00
341,638,215
0
0
null
null
null
null
UTF-8
Java
false
false
1,031
java
package com.c1games.terminal.simulation.units; import com.c1games.terminal.algo.Coords; import com.c1games.terminal.algo.PlayerId; import com.c1games.terminal.algo.map.Unit; import java.util.function.Function; public class Turret extends StructureUnit { private static final double startHealth = 60; private static final double range = 2.5; //max euclidean distance private static final double walkerDamage = 6; private static final double structureDamage = 0; Turret(Unit turret, Coords location) { super(turret.owner == PlayerId.Player2, turret.id, turret.unitInformation.startHealth.orElse(Turret.startHealth), turret.unitInformation.attackRange.orElse(Turret.range), turret.unitInformation.attackDamageWalker.orElse(Turret.walkerDamage), turret.unitInformation.attackDamageTower.orElse(Turret.structureDamage), location, turret.health, turret.upgraded); } @Override public boolean isInteractable(SimUnit simUnit) { return simUnit instanceof MobileUnit && simUnit.isEnemy() != this.isEnemy(); } }
ece2e1f760a64a9f9c952e78e0161f6432a12d9d
533721712ad0914139264b108c912e0f8e72cc32
/Day02/src/main/java/com/synechron/domain/Person.java
037b3437da4c62c072bc9da14c7479e8cea13337
[]
no_license
pskselvam/Sep-05-06-2019
494f3ee219beac2740c49f9fd81dc07eb85d1ac7
025bdbb54d81cb7e01d7bd273a21320fe675dee3
refs/heads/master
2020-07-21T03:10:55.443413
2019-09-06T08:13:10
2019-09-06T08:13:10
null
0
0
null
null
null
null
UTF-8
Java
false
false
932
java
package com.synechron.domain; import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.OneToMany; import javax.persistence.Table; @Entity @Table(name = "persons") public class Person { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; @Column(name = "name") private String name; @Column(name = "age") private int age; //@OneToMany(fetch = FetchType.LAZY, mappedBy = "person_id") //private List<Car> cars; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } }
31379c70c28eca642cf7e2bff98db4ad001db6d8
5cbe8869063ce8f1078974c47d49e08d4521eb52
/src/it/marteEngine/State.java
c2e6779bf166c9db00fe9ac76e12b79a228b514c
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
Flet/MarteEngine
10f99798651356869d57aa91de2cf4ac51324b4c
a2341398f909afeeb968d57493b8e72afd5a6b11
refs/heads/master
2021-01-16T20:50:41.917762
2012-03-18T19:46:35
2012-03-18T19:46:35
3,925,741
1
0
null
null
null
null
UTF-8
Java
false
false
255
java
package it.marteEngine; import org.newdawn.slick.GameContainer; import org.newdawn.slick.Graphics; public interface State { public void init(); public void update(GameContainer container, int delta); public void render(Graphics g); }
0ea69b7f1c30dc78d04399185dc978d9cc5c7322
5e427102d8e0fedfea123ba543918da68e220880
/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/tracer/ClientSpan.java
b963db2debf0078c468cfdb57d3d7accd4d864e7
[ "Apache-2.0" ]
permissive
aras112/opentelemetry-java-instrumentation
bef1c634cf0fd1a70eff848a6ee25fd52fead091
df004892f74852c689a5576e0703532c002a0361
refs/heads/main
2023-08-07T10:37:48.917978
2021-10-03T20:03:06
2021-10-04T18:58:48
412,537,338
0
0
Apache-2.0
2021-10-01T16:18:11
2021-10-01T16:18:10
null
UTF-8
Java
false
false
1,178
java
/* * Copyright The OpenTelemetry Authors * SPDX-License-Identifier: Apache-2.0 */ package io.opentelemetry.instrumentation.api.tracer; import io.opentelemetry.api.trace.Span; import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.SpanKey; import org.checkerframework.checker.nullness.qual.Nullable; /** * This class encapsulates the context key for storing the current {@link SpanKind#CLIENT} span in * the {@link Context}. */ public final class ClientSpan { /** Returns true when a {@link SpanKind#CLIENT} span is present in the passed {@code context}. */ public static boolean exists(Context context) { return fromContextOrNull(context) != null; } /** * Returns span of type {@link SpanKind#CLIENT} from the given context or {@code null} if not * found. */ @Nullable public static Span fromContextOrNull(Context context) { return SpanKey.ALL_CLIENTS.fromContextOrNull(context); } public static Context with(Context context, Span clientSpan) { return SpanKey.ALL_CLIENTS.storeInContext(context, clientSpan); } private ClientSpan() {} }
29ca1d6347f2daf9f255acc5cc127bdbf2cd431c
936b8f9e3f430209ea07a6012738040a9af0df41
/lib-core/src/main/java/com/hmw/lib/core/ui/loader/LoaderCreator.java
66e3405b351bb54b6e3790bdd13abbc3b5656307
[ "Apache-2.0" ]
permissive
hanmingwang/myecapp
7e729ad8e19fa33542fcfec9307052d59a3f72ea
3f52bd54e45ab5729ab36a8c58a6166c09409531
refs/heads/master
2020-03-19T02:56:02.741847
2018-06-04T14:57:20
2018-06-04T14:57:20
135,676,537
0
0
null
null
null
null
UTF-8
Java
false
false
1,618
java
package com.hmw.lib.core.ui.loader; import android.content.Context; import com.wang.avi.AVLoadingIndicatorView; import com.wang.avi.Indicator; import java.util.WeakHashMap; /** * Created by han on 2018/6/2. * 显示正在加载的旋转Dialog */ final class LoaderCreator { private static final WeakHashMap<String, Indicator> LOADING_MAP = new WeakHashMap<>(); static AVLoadingIndicatorView create(String type, Context context) { final AVLoadingIndicatorView avLoadingIndicatorView = new AVLoadingIndicatorView(context); if (LOADING_MAP.get(type) == null) { final Indicator indicator = getIndicator(type); LOADING_MAP.put(type, indicator); } avLoadingIndicatorView.setIndicator(LOADING_MAP.get(type)); return avLoadingIndicatorView; } private static Indicator getIndicator(String name) { if (name == null || name.isEmpty()) { return null; } final StringBuilder drawableClassName = new StringBuilder(); if (!name.contains(".")) { final String defaultPackageName = AVLoadingIndicatorView.class.getPackage().getName(); drawableClassName.append(defaultPackageName) .append(".indicators") .append("."); } drawableClassName.append(name); try { final Class<?> drawableClass = Class.forName(drawableClassName.toString()); return (Indicator) drawableClass.newInstance(); } catch (Exception e) { e.printStackTrace(); return null; } } }
3c8b534fa88ed0dac30c806f53cdb9fc0caa83f3
ec1afdf125e848ced736c2a8d884bcfff41ead7f
/src/main/java/com/utag/phase1/dao/PictureDaoImpl.java
ddb8175502df2af85735fdc1a8f9bb2685958082
[ "Apache-2.0" ]
permissive
Autumn-NJU/PhaseII
c02da5c2a385f8a6cb264f3ae0aa3cd73f1eaacd
76d0b01b5b49320ccef5bd4cffb2011d82af83cc
refs/heads/master
2021-04-15T13:18:32.759486
2018-10-17T03:02:12
2018-10-17T03:02:12
126,656,928
0
0
null
null
null
null
UTF-8
Java
false
false
3,953
java
package com.utag.phase1.dao; import com.utag.phase1.dao.DaoService.PictureDao; import com.utag.phase1.domain.Picture; import com.utag.phase1.util.FileTool; import com.utag.phase1.util.GsonTool; import org.springframework.stereotype.Repository; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @Repository public class PictureDaoImpl implements PictureDao { private static final String FILE_NAME = "pictures.json"; private static final String FOLDER_NAME = "src/main/resources/static/task/files/"; private ArrayList<Picture> init(){ List<String> pictureStrList = FileTool.readFile(FILE_NAME); ArrayList<Picture> pictureList = new ArrayList<>(); for(String str: pictureStrList){ pictureList.add(GsonTool.getBean(str, Picture.class)); } return pictureList; } @Override public boolean savePicture(int taskId, String worker, String pictureName) { Picture p = new Picture(taskId, worker, pictureName); String jsonStr = GsonTool.toJson(p); return FileTool.writeFile(FILE_NAME, jsonStr); } @Override public boolean tagPicture(String id) { ArrayList<Picture> list = init(); ArrayList<String> pictureStrList = new ArrayList<>(); int taskID = -1; Map<String, Double> map = new HashMap<>(); for(Picture p: list){ if(p.getId().equals(id)){ p.setTagged(true); taskID = p.getTaskID(); } String jsonStr = GsonTool.toJson(p); pictureStrList.add(jsonStr); } return taskID != -1 && FileTool.rewriteFile(FILE_NAME, pictureStrList); } @Override public List<String> listUntaggedPicture(int taskID, String worker) { List<String> list = new ArrayList<>(); ArrayList<Picture> pictureList = init(); for(Picture p: pictureList){ if(p.getTaskID() == taskID && p.getWorker().equals(worker) && !p.isTagged()) list.add(FOLDER_NAME + taskID + "/" + p.getImageID()); } return list; } @Override public List<String> listTaggedPicture(int taskId, String worker) { List<String> list = new ArrayList<>(); ArrayList<Picture> pictureList = init(); for(Picture p: pictureList){ if(p.getTaskID() == taskId && p.getWorker().equals(worker) && p.isTagged()) list.add(FOLDER_NAME + taskId + "/" + p.getImageID()); } return list; } @Override public List<String> listPictureName(int taskID) { return FileTool.listPictureName(taskID + ""); } @Override public boolean savePictureList(int taskID, String worker,List<String> nameList) { for(String name: nameList){ Picture picture = new Picture(taskID, name, worker); String str = GsonTool.toJson(picture); if(!FileTool.writeFile(FILE_NAME, str)) return false; } return true; } @Override public boolean deletePictureList(int taskID, String abandoner) { return false; } @Override public double calculateProcess(int taskID, String worker) { int sum = 0; List<String> list = new ArrayList<>(); ArrayList<Picture> pictureList = init(); for(Picture p: pictureList){ if(p.getTaskID() == taskID && p.getWorker().equals(worker)) sum++; } return sum * 1.0 / (listUntaggedPicture(taskID, worker).size() + listTaggedPicture(taskID, worker).size()); } @Override public boolean isTagged(int taskId, String worker, String imageId) { for(Picture p: init()){ if(p.getWorker().equals(worker) && p.getTaskID() == taskId && p.getImageID().equals(imageId)) return p.isTagged(); } return false; } }
8e67d8e0072a841f39e793e97153efa1d950734a
7b87ad269807540e557260933d667cdabd60f9eb
/BattlePets2.0/src/TeamVierAugen/Playables/AIPlayer.java
dab2f6ee3a8bd3dfcddd294ddaf8cbb8f0b55456
[]
no_license
lincolnsch99/BattlePets2.0
7b4dcd18c18b5a333ac739f4a4171f4efbd9e406
3e17e67c35b2b995e7cb51c89889d019dcb5331b
refs/heads/master
2020-09-14T08:49:03.089458
2020-02-10T02:54:58
2020-02-10T02:54:58
223,082,055
0
0
null
null
null
null
UTF-8
Java
false
false
658
java
/** * This class represents values for an AIPlayer. */ package TeamVierAugen.Playables; import TeamVierAugen.Skills.Skills; import java.util.ArrayList; import java.util.List; public class AIPlayer { private final int RANDOM_SEED = 5; private String name; private PlayerTypes type; public AIPlayer(String name, PlayerTypes type) { this.name = name; this.type = type; } /** * Gets the AI's name. * @return string name */ public String getName() { return name; } /** * Gets the AI's type. * @return playerType type */ public PlayerTypes getType() { return type; } }
31207674add0b370e687fa19faa599d6415201d8
a35a6a74ef97c991a5f017732f27ada99ce44d1f
/qy.times.manager/src/main/java/com/manager/entity/LoginRecord.java
181deb66a234659b0b31a4c7a233d17fc037a364
[]
no_license
zouzhiwu/qy-java
7d518df0d39e73b780d4cc931338c43cba4f5076
4be2ca43461358850d8a2cb8b0f46dea2bcba678
refs/heads/master
2020-05-23T13:23:37.326146
2019-05-16T01:53:18
2019-05-16T01:53:18
186,774,511
0
2
null
null
null
null
UTF-8
Java
false
false
480
java
package com.manager.entity; public class LoginRecord { private Integer id; private Long userId; private Integer createTime; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public Long getUserId() { return userId; } public void setUserId(Long userId) { this.userId = userId; } public Integer getCreateTime() { return createTime; } public void setCreateTime(Integer createTime) { this.createTime = createTime; } }
b7ccc843416a0053b4b3aae1388f7fd0aa037778
7d4c4f49de2985e8e4efb3ce88f2041c61ba325f
/mongodbapp/app/build/generated/not_namespaced_r_class_sources/debug/processDebugResources/r/android/support/fragment/R.java
d9f1a062d2493d96bc7cec0300c2d9522f14ef64
[]
no_license
jdoss003/awds
621089076eab9bb451565909a583ffca55ce3731
5d86a05a1af143a10dbd351eed42235a91816b23
refs/heads/app
2020-05-07T16:09:30.498243
2019-06-10T02:25:28
2019-06-10T02:29:05
180,668,126
0
0
null
2019-05-22T19:42:19
2019-04-10T21:41:46
C++
UTF-8
Java
false
false
10,194
java
/* AUTO-GENERATED FILE. DO NOT MODIFY. * * This class was automatically generated by the * gradle plugin from the resource data it found. It * should not be modified by hand. */ package android.support.fragment; public final class R { private R() {} public static final class attr { private attr() {} public static final int coordinatorLayoutStyle = 0x7f03006f; public static final int font = 0x7f030098; public static final int fontProviderAuthority = 0x7f03009a; public static final int fontProviderCerts = 0x7f03009b; public static final int fontProviderFetchStrategy = 0x7f03009c; public static final int fontProviderFetchTimeout = 0x7f03009d; public static final int fontProviderPackage = 0x7f03009e; public static final int fontProviderQuery = 0x7f03009f; public static final int fontStyle = 0x7f0300a0; public static final int fontWeight = 0x7f0300a1; public static final int keylines = 0x7f0300bb; public static final int layout_anchor = 0x7f0300be; public static final int layout_anchorGravity = 0x7f0300bf; public static final int layout_behavior = 0x7f0300c0; public static final int layout_dodgeInsetEdges = 0x7f0300ec; public static final int layout_insetEdge = 0x7f0300f5; public static final int layout_keyline = 0x7f0300f6; public static final int statusBarBackground = 0x7f030143; } public static final class bool { private bool() {} public static final int abc_action_bar_embed_tabs = 0x7f040000; } public static final class color { private color() {} public static final int notification_action_color_filter = 0x7f050049; public static final int notification_icon_bg_color = 0x7f05004a; public static final int ripple_material_light = 0x7f050055; public static final int secondary_text_default_material_light = 0x7f050057; } public static final class dimen { private dimen() {} public static final int compat_button_inset_horizontal_material = 0x7f06004b; public static final int compat_button_inset_vertical_material = 0x7f06004c; public static final int compat_button_padding_horizontal_material = 0x7f06004d; public static final int compat_button_padding_vertical_material = 0x7f06004e; public static final int compat_control_corner_material = 0x7f06004f; public static final int notification_action_icon_size = 0x7f060085; public static final int notification_action_text_size = 0x7f060086; public static final int notification_big_circle_margin = 0x7f060087; public static final int notification_content_margin_start = 0x7f060088; public static final int notification_large_icon_height = 0x7f060089; public static final int notification_large_icon_width = 0x7f06008a; public static final int notification_main_column_padding_top = 0x7f06008b; public static final int notification_media_narrow_margin = 0x7f06008c; public static final int notification_right_icon_size = 0x7f06008d; public static final int notification_right_side_padding_top = 0x7f06008e; public static final int notification_small_icon_background_padding = 0x7f06008f; public static final int notification_small_icon_size_as_large = 0x7f060090; public static final int notification_subtext_size = 0x7f060091; public static final int notification_top_pad = 0x7f060092; public static final int notification_top_pad_large_text = 0x7f060093; } public static final class drawable { private drawable() {} public static final int notification_action_background = 0x7f070065; public static final int notification_bg = 0x7f070066; public static final int notification_bg_low = 0x7f070067; public static final int notification_bg_low_normal = 0x7f070068; public static final int notification_bg_low_pressed = 0x7f070069; public static final int notification_bg_normal = 0x7f07006a; public static final int notification_bg_normal_pressed = 0x7f07006b; public static final int notification_icon_background = 0x7f07006c; public static final int notification_template_icon_bg = 0x7f07006d; public static final int notification_template_icon_low_bg = 0x7f07006e; public static final int notification_tile_bg = 0x7f07006f; public static final int notify_panel_notification_icon_bg = 0x7f070070; } public static final class id { private id() {} public static final int action_container = 0x7f08000e; public static final int action_divider = 0x7f080010; public static final int action_image = 0x7f080011; public static final int action_text = 0x7f080017; public static final int actions = 0x7f080018; public static final int async = 0x7f08001e; public static final int blocking = 0x7f080022; public static final int bottom = 0x7f080023; public static final int chronometer = 0x7f08002b; public static final int end = 0x7f08003f; public static final int forever = 0x7f08004b; public static final int icon = 0x7f080051; public static final int icon_group = 0x7f080052; public static final int info = 0x7f080055; public static final int italic = 0x7f080057; public static final int left = 0x7f08005a; public static final int line1 = 0x7f08005b; public static final int line3 = 0x7f08005c; public static final int none = 0x7f080067; public static final int normal = 0x7f080068; public static final int notification_background = 0x7f080069; public static final int notification_main_column = 0x7f08006a; public static final int notification_main_column_container = 0x7f08006b; public static final int right = 0x7f080076; public static final int right_icon = 0x7f080077; public static final int right_side = 0x7f080078; public static final int start = 0x7f08009d; public static final int tag_transition_group = 0x7f0800a2; public static final int text = 0x7f0800a3; public static final int text2 = 0x7f0800a4; public static final int time = 0x7f0800aa; public static final int title = 0x7f0800ab; public static final int top = 0x7f0800af; } public static final class integer { private integer() {} public static final int status_bar_notification_info_maxnum = 0x7f090009; } public static final class layout { private layout() {} public static final int notification_action = 0x7f0a002a; public static final int notification_action_tombstone = 0x7f0a002b; public static final int notification_template_custom_big = 0x7f0a0032; public static final int notification_template_icon_group = 0x7f0a0033; public static final int notification_template_part_chronometer = 0x7f0a0037; public static final int notification_template_part_time = 0x7f0a0038; } public static final class string { private string() {} public static final int status_bar_notification_info_overflow = 0x7f0c0029; } public static final class style { private style() {} public static final int TextAppearance_Compat_Notification = 0x7f0d00ed; public static final int TextAppearance_Compat_Notification_Info = 0x7f0d00ee; public static final int TextAppearance_Compat_Notification_Line2 = 0x7f0d00f0; public static final int TextAppearance_Compat_Notification_Time = 0x7f0d00f3; public static final int TextAppearance_Compat_Notification_Title = 0x7f0d00f5; public static final int Widget_Compat_NotificationActionContainer = 0x7f0d016b; public static final int Widget_Compat_NotificationActionText = 0x7f0d016c; public static final int Widget_Support_CoordinatorLayout = 0x7f0d0178; } public static final class styleable { private styleable() {} public static final int[] CoordinatorLayout = { 0x7f0300bb, 0x7f030143 }; public static final int CoordinatorLayout_keylines = 0; public static final int CoordinatorLayout_statusBarBackground = 1; public static final int[] CoordinatorLayout_Layout = { 0x10100b3, 0x7f0300be, 0x7f0300bf, 0x7f0300c0, 0x7f0300ec, 0x7f0300f5, 0x7f0300f6 }; public static final int CoordinatorLayout_Layout_android_layout_gravity = 0; public static final int CoordinatorLayout_Layout_layout_anchor = 1; public static final int CoordinatorLayout_Layout_layout_anchorGravity = 2; public static final int CoordinatorLayout_Layout_layout_behavior = 3; public static final int CoordinatorLayout_Layout_layout_dodgeInsetEdges = 4; public static final int CoordinatorLayout_Layout_layout_insetEdge = 5; public static final int CoordinatorLayout_Layout_layout_keyline = 6; public static final int[] FontFamily = { 0x7f03009a, 0x7f03009b, 0x7f03009c, 0x7f03009d, 0x7f03009e, 0x7f03009f }; public static final int FontFamily_fontProviderAuthority = 0; public static final int FontFamily_fontProviderCerts = 1; public static final int FontFamily_fontProviderFetchStrategy = 2; public static final int FontFamily_fontProviderFetchTimeout = 3; public static final int FontFamily_fontProviderPackage = 4; public static final int FontFamily_fontProviderQuery = 5; public static final int[] FontFamilyFont = { 0x1010532, 0x1010533, 0x101053f, 0x7f030098, 0x7f0300a0, 0x7f0300a1 }; public static final int FontFamilyFont_android_font = 0; public static final int FontFamilyFont_android_fontWeight = 1; public static final int FontFamilyFont_android_fontStyle = 2; public static final int FontFamilyFont_font = 3; public static final int FontFamilyFont_fontStyle = 4; public static final int FontFamilyFont_fontWeight = 5; } }
7adfd0a2e63a3c8111fff87b7dc34edf290b0a3d
0871fb7175c465103b7e35ee7d54b6a8a2af6b32
/app/src/main/java/com/datonicgroup/narrate/app/models/events/RemoteSyncUpdateEvent.java
61c65eb8fa92659b9cdb6e8e022660eee89b5bf7
[ "Apache-2.0" ]
permissive
saengowp/narrate-android
c29058a0444681bd5da32d05b7cf2360ff2fee3b
97c1b206130dc78c74712c76629b9171649c9225
refs/heads/master
2021-07-16T18:50:02.915550
2017-10-22T13:47:10
2017-10-22T13:47:10
107,793,918
0
0
null
2017-10-21T15:56:20
2017-10-21T15:56:20
null
UTF-8
Java
false
false
138
java
package com.datonicgroup.narrate.app.models.events; /** * Created by timothymiko on 1/14/16. */ public class RemoteSyncUpdateEvent { }
5bc518d6e8ec4d72240294fdac1489992625c0b4
5daf176c8047989f8411d05f57509c76d0f9353e
/app/src/main/java/app/com/willcallu/EasyPermissions.java
0d30ecfc5848b5ae68f12e4439e73c6efca18ca0
[]
no_license
kishansolanki124/WillCallU
8b7a21362d8616fd1ad8722d45dd7f8b0edef5f6
8cfa8b0fff9ad6cd211172b3a949d48b84f4acea
refs/heads/master
2022-02-18T13:58:36.153735
2022-01-27T09:52:44
2022-01-27T09:52:44
167,820,557
0
0
null
null
null
null
UTF-8
Java
false
false
17,033
java
package app.com.willcallu; import android.Manifest; import android.annotation.TargetApi; import android.app.Activity; import app.com.willcallu.R; import android.content.Context; import android.content.DialogInterface; import android.content.pm.PackageManager; import android.os.Build; import android.support.annotation.StringRes; import android.support.v4.app.ActivityCompat; import android.support.v4.app.Fragment; import android.support.v4.content.ContextCompat; import android.text.TextUtils; import android.util.Log; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; public class EasyPermissions { private static final String TAG = "EasyPermissions"; static long timeWhenRequestingStart; static Object object; private static PermissionDialog finalPermissionDialog = null; private static PermissionCallbacks callbacks; private static HashMap<String, String[]> permissionGroups; /** * Check if the calling context has a set of permissions. * * @param context the calling context. * @param perms one ore more permissions, such as {@code android.Manifest.permission.CAMERA}. * @return true if all permissions are already granted, false if at least one permission * is not yet granted. */ public static boolean hasPermissions(Context context, String... perms) { // Always return true for SDK < M, let the system deal with the permissions if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { Log.w(TAG, "hasPermissions: API version < M, returning true by default"); return true; } for (String perm : perms) { boolean hasPerm = (ContextCompat.checkSelfPermission(context, perm) == PackageManager.PERMISSION_GRANTED); if (!hasPerm) { return false; } } return true; } /** * Request a set of permissions, showing rationale if the system requests it. * * @param object Activity or Fragment requesting permissions. Should implement * {@link ActivityCompat.OnRequestPermissionsResultCallback} * or * @param rationale a message explaining why the application needs this set of permissions, will * be displayed if the user rejects the request the first time. * @param requestCode request code to track this request, must be < 256. * @param perms a set of permissions to be requested. */ public static void requestPermissions(final Object object, PermissionCallbacks callback, String rationale, final int requestCode, final String... perms) { requestPermissions(object, callback, rationale, android.R.string.ok, android.R.string.cancel, requestCode, perms); } /** * Request a set of permissions, showing rationale if the system requests it. * * @param obj Activity or Fragment requesting permissions. Should implement * {@link ActivityCompat.OnRequestPermissionsResultCallback} * or * @param rationale a message explaining why the application needs this set of permissions, will * be displayed if the user rejects the request the first time. * @param positiveButton custom text for positive button * @param negativeButton custom text for negative button * @param requestCode request code to track this request, must be < 256. * @param permission a set of permissions or permission.group to be requested. */ public static void requestPermissions(final Object obj, final PermissionCallbacks callback, String rationale, @StringRes int positiveButton, @StringRes int negativeButton, final int requestCode, final String... permission) { callbacks = callback; object = obj; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { // only for lower of M // PermissionCallbacks callbacks = (PermissionCallbacks) object; callbacks.onPermissionsGranted(requestCode, new ArrayList<>(Arrays.asList(permission))); return; } checkCallingObjectSuitability(object); // final PermissionCallbacks callbacks = (PermissionCallbacks) object; final String[] perms = getActualPermissions(object, permission); if (perms.length <= 0) { callbacks.onPermissionsGranted(requestCode, new ArrayList<String>(Arrays.asList(permission))); return; } boolean shouldShowRationale = false; for (String perm : perms) { shouldShowRationale = shouldShowRationale || shouldShowRequestPermissionRationale(object, perm); } if (shouldShowRationale) { if (!TextUtils.isEmpty(rationale)) { Log.i(TAG, "shouldShowRationale: "); finalPermissionDialog = new PermissionDialog(getActivity(object), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { executePermissionsRequest(object, perms, requestCode); finalPermissionDialog.dismiss(); } }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { callbacks.onPermissionsDenied(requestCode, Arrays.asList(perms)); finalPermissionDialog.dismiss(); } }, rationale, getActivity(object).getResources().getString(R.string.app_name)); // finalPermissionDialog.show(); } else { executePermissionsRequest(object, perms, requestCode); } } else { for (String perm : perms) { shouldShowRationale = shouldShowRationale || shouldShowRequestPermissionRationale(object, perm); } if (shouldShowRationale) { Log.d(TAG, "requestPermissions: show dialog"); } else { timeWhenRequestingStart = System.currentTimeMillis(); executePermissionsRequest(object, perms, requestCode); } } } private static String[] getActualPermissions(Object object, String[] permission) { initPermissionGroups(); ArrayList<String> permissionList = new ArrayList<>(); for (String indiPerm : permission) { if (permissionGroups.containsKey(indiPerm)) { String[] arr = permissionGroups.get(indiPerm); for (String s : arr) { if (!EasyPermissions.hasPermissions(getActivity(object), s)) { permissionList.add(s); } } } else { if (!EasyPermissions.hasPermissions(getActivity(object), indiPerm)) { permissionList.add(indiPerm); } } } Set<String> set = new LinkedHashSet<String>(permissionList); return set.toArray(new String[set.size()]); } private static void initPermissionGroups() { if (permissionGroups == null) { permissionGroups = new HashMap<String, String[]>(); permissionGroups.put(Manifest.permission_group.CALENDAR, new String[]{Manifest.permission.READ_CALENDAR, Manifest.permission.WRITE_CALENDAR}); permissionGroups.put(Manifest.permission_group.CAMERA, new String[]{Manifest.permission.CAMERA}); permissionGroups.put(Manifest.permission_group.CONTACTS, new String[]{Manifest.permission.READ_CONTACTS, Manifest.permission.WRITE_CONTACTS, Manifest.permission.GET_ACCOUNTS}); permissionGroups.put(Manifest.permission_group.LOCATION, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}); permissionGroups.put(Manifest.permission_group.MICROPHONE, new String[]{Manifest.permission.RECORD_AUDIO}); permissionGroups.put(Manifest.permission_group.PHONE, new String[]{Manifest.permission.READ_PHONE_STATE, Manifest.permission.CALL_PHONE, Manifest.permission.READ_CALL_LOG, Manifest.permission.WRITE_CALL_LOG, Manifest.permission.ADD_VOICEMAIL, Manifest.permission.USE_SIP, Manifest.permission.PROCESS_OUTGOING_CALLS}); permissionGroups.put(Manifest.permission_group.SENSORS, new String[]{Manifest.permission.BODY_SENSORS}); permissionGroups.put(Manifest.permission_group.SMS, new String[]{Manifest.permission.SEND_SMS, Manifest.permission.RECEIVE_SMS, Manifest.permission.READ_SMS, Manifest.permission.RECEIVE_WAP_PUSH, Manifest.permission.RECEIVE_MMS}); permissionGroups.put(Manifest.permission_group.STORAGE, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}); } } /** * Handle the result of a permission request, should be called from the calling Activity's * {@link ActivityCompat.OnRequestPermissionsResultCallback#onRequestPermissionsResult(int, String[], int[])} * method. * <p/> * If any permissions were granted or denied, the Activity will receive the appropriate * callbacks through {@link PermissionCallbacks} and methods annotated with * * @param requestCode requestCode argument to permission result callback. * @param permissions permissions argument to permission result callback. * @param grantResults grantResults argument to permission result callback. * @throws IllegalArgumentException if the calling Activity does not implement * {@link PermissionCallbacks}. */ public static void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { boolean isPermenantlyDisabled = false; // checkCallingObjectSuitability(object); // PermissionCallbacks callbacks = (PermissionCallbacks) object; // Make a collection of granted and denied permissions from the request. ArrayList<String> granted = new ArrayList<>(); ArrayList<String> denied = new ArrayList<>(); for (int i = 0; i < permissions.length; i++) { String perm = permissions[i]; if (grantResults[i] == PackageManager.PERMISSION_GRANTED) { granted.add(perm); } else { /**if deny then it will true and on never as me again it will return false * **/ boolean showRationale = shouldShowRequestPermissionRationale(object, perm); if (showRationale) { isPermenantlyDisabled = false; //deny // timeWhenRequestingStart = System.currentTimeMillis() - 2; } else { isPermenantlyDisabled = true; //never ask me again } denied.add(perm); // denied.add(perm); } } // Report granted permissions, if any. if (!granted.isEmpty() && denied.isEmpty()) { // Notify callbacks callbacks.onPermissionsGranted(requestCode, granted); } // Report denied permissions, if any. /*if (!denied.isEmpty()) { callbacks.onPermissionsDenied(requestCode, denied); }*/ //if 100% fail then check for whether timing else if (granted.isEmpty() && !denied.isEmpty() && isPermenantlyDisabled) { long diff = System.currentTimeMillis() - timeWhenRequestingStart; // if (diff < 350) { //means it is permenantly disabled callbacks.onPermissionsPermanentlyDeclined(requestCode, denied); // } Log.i("TAG", diff + ""); } // Report denied permissions, if any. if (!denied.isEmpty() && !isPermenantlyDisabled) { callbacks.onPermissionsDenied(requestCode, denied); } /*// If 100% successful, call annotated methods if (!granted.isEmpty() && denied.isEmpty()) { runAnnotatedMethods(object, requestCode); }*/ } @TargetApi(23) private static boolean shouldShowRequestPermissionRationale(Object object, String perm) { if (object instanceof Activity) { return ActivityCompat.shouldShowRequestPermissionRationale((Activity) object, perm); } else if (object instanceof Fragment) { return ((Fragment) object).shouldShowRequestPermissionRationale(perm); } else if (object instanceof android.app.Fragment) { return ((android.app.Fragment) object).shouldShowRequestPermissionRationale(perm); } else { return false; } } @TargetApi(23) private static void executePermissionsRequest(Object object, String[] perms, int requestCode) { checkCallingObjectSuitability(object); if (object instanceof Activity) { ActivityCompat.requestPermissions((Activity) object, perms, requestCode); } else if (object instanceof Fragment) { ((Fragment) object).requestPermissions(perms, requestCode); } else if (object instanceof android.app.Fragment) { ((android.app.Fragment) object).requestPermissions(perms, requestCode); } } @TargetApi(11) private static Activity getActivity(Object object) { if (object instanceof Activity) { return ((Activity) object); } else if (object instanceof Fragment) { return ((Fragment) object).getActivity(); } else if (object instanceof android.app.Fragment) { return ((android.app.Fragment) object).getActivity(); } else { return null; } } private static void checkCallingObjectSuitability(Object object) { // Make sure Object is an Activity or Fragment boolean isActivity = object instanceof Activity; boolean isSupportFragment = object instanceof Fragment; boolean isAppFragment = object instanceof android.app.Fragment; boolean isMinSdkM = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M; if (!(isSupportFragment || isActivity || (isAppFragment && isMinSdkM))) { if (isAppFragment) { throw new IllegalArgumentException( "Target SDK needs to be greater than 23 if caller is android.app.Fragment"); } else { throw new IllegalArgumentException("Caller must be an Activity or a Fragment."); } } /*// Make sure Object implements callbacks if (!(object instanceof PermissionCallbacks)) { throw new IllegalArgumentException("Caller must implement PermissionCallbacks."); }*/ } /*private static void runAnnotatedMethods(Object object, int requestCode) { Class clazz = object.getClass(); for (Method method : clazz.getDeclaredMethods()) { if (method.isAnnotationPresent(AfterPermissionGranted.class)) { // Check for annotated methods with matching request code. AfterPermissionGranted ann = method.getAnnotation(AfterPermissionGranted.class); if (ann.value() == requestCode) { // Method must be void so that we can invoke it if (method.getParameterTypes().length > 0) { throw new RuntimeException( "Cannot execute non-void method " + method.getName()); } try { // Make method accessible if private if (!method.isAccessible()) { method.setAccessible(true); } method.invoke(object); } catch (IllegalAccessException e) { Log.e(TAG, "runDefaultMethod:IllegalAccessException", e); } catch (InvocationTargetException e) { Log.e(TAG, "runDefaultMethod:InvocationTargetException", e); } } } } }*/ public interface PermissionCallbacks { void onPermissionsGranted(int requestCode, List<String> perms); void onPermissionsDenied(int requestCode, List<String> perms); void onPermissionsPermanentlyDeclined(int requestCode, List<String> perms); } }
5730cc898c8dcf364e213c52275d3db3bf075361
cb893f927e1cea8b7e86645e1f754ddeca9b40f9
/CodeUp/src/if_else/Soccer1.java
fef4951d4cbb8bd21f4f5b215a6c0f89efed789e
[]
no_license
CHOIHYOGIL/JAVA_PRACTICE
2de7f84f839f180adf91f14cfcf1da95268ffdb9
0528cebbb924cc022ee74ffd2490b2953bd5610b
refs/heads/master
2022-12-17T23:54:07.361187
2020-09-29T07:15:55
2020-09-29T07:15:55
289,222,437
0
0
null
null
null
null
UTF-8
Java
false
false
558
java
package if_else; import java.util.Scanner; public class Soccer1 { public static void main(String[] args) { Scanner scanner=new Scanner(System.in); int time; int first; int second; time=scanner.nextInt(); first=scanner.nextInt(); second=scanner.nextInt(); int rest=90-time; int total=0; if(rest%5==0) { total=rest/5+first; }else { total=rest/5+1+first; } if(total==second) { System.out.print("same"); }else if(total>second) { System.out.print("win"); }else { System.out.print("lose"); } } }
5abddb1cf7e000b28183de0b8eb2c075593e75f4
a545b8eaf3cf577a14a1afecf4019294560c657c
/src/test/java/io/jcervelin/familybase/templates/ParentTemplates.java
e17392fbfdfff32db8ecd4df16206f7fecfe2a7f
[]
no_license
jcervelin/family-base
acbeacba6f62c8a28e83084dbc621503ed2e2ad4
0aafba7661a88a8490f6f91317224f9677d936f7
refs/heads/master
2020-03-24T08:39:02.533964
2018-07-30T04:38:10
2018-07-30T04:38:10
142,602,788
0
0
null
null
null
null
UTF-8
Java
false
false
1,663
java
package io.jcervelin.familybase.templates; import br.com.six2six.fixturefactory.Fixture; import br.com.six2six.fixturefactory.Rule; import br.com.six2six.fixturefactory.loader.TemplateLoader; import io.jcervelin.familybase.domains.Child; import io.jcervelin.familybase.domains.Parent; import java.time.LocalDate; import static io.jcervelin.familybase.templates.ChildTemplates.CHILD_WITHOUT_DATE_OF_BIRTH; import static io.jcervelin.familybase.templates.ChildTemplates.VALID_CHILD; public class ParentTemplates implements TemplateLoader { public static final String VALID_PARENT = "Valid parent"; public static final String PARENT_WITHOUT_ID = "Parent without id"; public static final String PARENT_WITHOUT_DATE_OF_BIRTH = "Parent without date of birth"; @Override public void load() { Fixture.of(Parent.class).addTemplate(VALID_PARENT, new Rule() {{ add("id", 1L); add("title", "Mr."); add("firstName", "Antonius"); add("lastName", "Cervelin"); add("dateOfBirth", LocalDate.of(1950, 9, 12)); add("emailAddress", "[email protected]"); add("gender", "male"); add("secondName", null); add("children", has(2).of(Child.class, VALID_CHILD, CHILD_WITHOUT_DATE_OF_BIRTH)); }}); Fixture.of(Parent.class).addTemplate(PARENT_WITHOUT_ID).inherits(VALID_PARENT, new Rule() {{ add("id", null); }}); Fixture.of(Parent.class).addTemplate(PARENT_WITHOUT_DATE_OF_BIRTH).inherits(VALID_PARENT, new Rule() {{ add("id", 50L); add("dateOfBirth", null); }}); } }
b94cd00a438f295017a5322c20c3b450f9ce1ab8
56785ac290bd2b796bd5f90d2c76b97f8fb96a8b
/mHospital System/app/src/main/java/com/app/health/Main.java
51c170a56d232f6c8b5e133c23ea34f5b36651e7
[]
no_license
sutariyaashish022/mHospital
6630a4771b1a1b80eefc9ee6df41de2f0ef08321
a3202f69f889fbe48bb35da95798f472d1123e49
refs/heads/master
2022-12-23T07:50:16.897686
2020-10-01T20:39:13
2020-10-01T20:39:13
300,411,808
0
0
null
null
null
null
UTF-8
Java
false
false
3,200
java
package com.app.health; import android.content.DialogInterface; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.Toast; import com.marcoscg.fingerauth.FingerAuth; import com.marcoscg.fingerauth.FingerAuthDialog; import com.parse.ParseUser; public class Main extends AppCompatActivity { private Button login,sigup,admin; private ParseUser user; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); user = ParseUser.getCurrentUser(); if(user!=null){ new FingerAuthDialog(this) .setTitle("Sign in") .setCancelable(false) .setMaxFailedCount(3) // Number of attemps, default 3 .setPositiveButton("Login Again", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { // do something user.logOut(); Intent in = new Intent(Main.this,Login.class); startActivity(in); } }) .setOnFingerAuthListener(new FingerAuth.OnFingerAuthListener() { @Override public void onSuccess() { Toast.makeText(Main.this, "onSuccess", Toast.LENGTH_SHORT).show(); Intent in = new Intent(Main.this,MapsActivity.class); startActivity(in); } @Override public void onFailure() { Toast.makeText(Main.this, "onFailure", Toast.LENGTH_SHORT).show(); } @Override public void onError() { Toast.makeText(Main.this, "onError", Toast.LENGTH_SHORT).show(); } }) .show(); } login = (Button) findViewById(R.id.login); sigup = (Button) findViewById(R.id.signup); admin = (Button) findViewById(R.id.admin); login.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent in = new Intent(Main.this,Login.class); startActivity(in); } }); admin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent in = new Intent(Main.this,admin.class); startActivity(in); } }); sigup.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent in = new Intent(Main.this,Signup.class); startActivity(in); } }); } }
a4eea90cfa482ed6804de732473a04783f3a8170
30df5b79bdaeb4a0e5a123be5087bad4b00c4b54
/RadixSortString.java
c73d266284e71b3071331460a4bbd4baf1e09ab7
[]
no_license
AnshulPrasad2602/Types-of-sorting-techniques
dc418b82aa932080154ce2e55e35e0686811c1ec
835911e0e3cfed9edd195a2ca93c1bbe2d9757a6
refs/heads/master
2022-11-09T22:57:32.438000
2020-06-20T07:08:10
2020-06-20T07:08:10
272,764,140
0
0
null
null
null
null
UTF-8
Java
false
false
2,444
java
/* * 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 radixsort; /** * * @author ANSHUL */ public class RadixSortString { public static void radixSort (String[] arrString, int radix, int width) { for (int i = width - 1; i >= 0; i--) { radixSingleSort (arrString, i, radix); } } public static void radixSingleSort (String[] arrString, int position, int radix) { int numItems = arrString.length; int[] countArr = new int[radix]; for (String value : arrString) { countArr[getIndex(position, value)]++; } //Adjusting the count array for (int i = 1; i < radix; i++) { countArr[i] += countArr[i - 1]; } String[] temp = new String[numItems]; for (int i = numItems - 1; i >= 0; i--) { temp[--countArr[getIndex(position, arrString[i])]] = arrString[i]; } for (int i = 0; i < numItems; i++) { arrString[i] = temp[i]; } System.out.print("\nArray : "); for (int k = 0; k < arrString.length; k++) { System.out.print(" "+arrString[k]); } } public static int getIndex(int position, String value) { return value.charAt(position) - 'a'; } public static void main(String[] args) { // Scanner sc = new Scanner (System.in); // int size; // System.out.println("Enter size of array : "); // size = sc.nextInt(); // // String[] arr = new int[size]; // System.out.println("Enter the array : "); // for (int i = 0; i < arr.length; i++) // { // arr[i] = sc.nextInt(); // } //int[] arr = { 4725, 4586, 1330, 8792, 1594, 5729 }; String[] arrString = { "bcdef", "dbaqe", "abcde", "omadd", "bbbbb" }; radixSort(arrString, 26, 5); System.out.println("\nSorted array by 1 : "); for (int i = 0; i < arrString.length; i++) { System.out.print(" "+arrString[i]); } } }
19ff44f295e3a9f52b0f03c18344bffc2887434c
7f12ef982449c40b0039dd6e44e15eae92ad96f6
/StringMatchingAlgos/axg137230_Client.java
6808b5222913e14b82ce0a46da4e4b4af837d3ef
[]
no_license
abhishek182/DataStructuresAndAlgo
75e5753a5bb23097fd40f94008396aa87c69eb70
393a9dc355f133eb0a1cf05bfee2d4606ceae547
refs/heads/master
2020-05-03T02:53:20.086701
2014-12-21T00:16:44
2014-12-21T00:16:44
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,785
java
import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Scanner; /** * This class is the starting point of the program. It expects two command line * arguments. * * @author Abhishek Gupta (axg137230) and Manuj Singh (mxs135630) * */ public class axg137230_Client { /** * This holds the instance of the scanner used to read the file. */ private static Scanner scanner; /** * The main method reads the input file and search the given pattern in the * input text. * * @param args */ public static void main(String[] args) { // If command line argument given is less than two. if (args.length < 2) System.out.println("Not enough arguments.."); else { String pattern = args[0]; String inputFileName = args[1]; File inputFile = new File(inputFileName); try { scanner = new Scanner(inputFile); StringBuilder text = new StringBuilder(); // Constructing a single string of the content in the input // file, removing the new line. while (scanner.hasNext()) text.append(scanner.next()); // System.out.println(text); axg137230_StringMatching matching = new axg137230_StringMatching(pattern, text.toString()); long startTime = System.currentTimeMillis(); // Find shifts using naive algorithm. ArrayList<Integer> validShifts = (ArrayList<Integer>) matching .naive(); long endTime = System.currentTimeMillis(); // Print the number of shift and time taken by the naive // algorithm. System.out.print(validShifts.size() + " " + (endTime - startTime)); startTime = System.currentTimeMillis(); // Find shifts using Rabin Karp algorithm. validShifts = (ArrayList<Integer>) matching.rabinKarp(); endTime = System.currentTimeMillis(); // Print the time taken by the Rabin Karp algorithm. System.out.print(" " + (endTime - startTime)); startTime = System.currentTimeMillis(); // Find shifts using KMP algorithm. validShifts = (ArrayList<Integer>) matching.kmp(); endTime = System.currentTimeMillis(); // Print the time taken by the KMP algorithm. System.out.print(" " + (endTime - startTime)); startTime = System.currentTimeMillis(); // Find shifts using Boyer Moore algorithm. validShifts = (ArrayList<Integer>) matching.boyerMoore(); endTime = System.currentTimeMillis(); // Print the time taken by the Boyer Moore algorithm. System.out.print(" " + (endTime - startTime)); System.out.println(); // Printing the shifts only if the number of shifts is >= 20 if (validShifts.size() <= 20) for (Integer i : validShifts) { System.out.print(i + " "); } } catch (FileNotFoundException e) { e.printStackTrace(); } } } }
c243eacfde15c29ecfa061e87498ddc0bc7333a1
b00a2b523e9a4e5e215074b5e9db256b6454f2b0
/sample3/src/test/java/sample/ddd/bluedawnsolutions/domain/OrderTest.java
38bd742845b50f71e0a82bbf92cea6cfc89dff23
[]
no_license
kevinpotgieter/sample-DDD-root
7db2bb7fecb615a0ba7f8e01f255adb864d697f5
10366372beda0bd9635f63d54278d44bb70ff646
refs/heads/master
2021-01-01T17:05:25.614035
2016-11-01T17:18:29
2016-11-01T17:18:29
11,701,861
0
1
null
null
null
null
UTF-8
Java
false
false
2,122
java
package sample.ddd.bluedawnsolutions.domain; import com.google.common.collect.Lists; import org.junit.Before; import org.junit.Test; import sample.ddd.bluedawnsolutions.application.OrderingService; import sample.ddd.bluedawnsolutions.application.StandardOrderingService; import sample.ddd.bluedawnsolutions.services.ExternalSupplierService; import sample.ddd.bluedawnsolutions.services.NotificationService; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Mockito.*; public class OrderTest { private OrderingService orderingService; private ExternalSupplierService mockExternalSupplierService; private NotificationService mockNotificationService; @Before public void initialiseOrderingService() { mockExternalSupplierService = mock(ExternalSupplierService.class); mockNotificationService = mock(NotificationService.class); //mimick the autowiring behaviour that would occur normally. orderingService = new StandardOrderingService(mockExternalSupplierService, mockNotificationService); } @Test public void ensureThatWhenPlacingOrderThatCustomerIsNotifiedWhenStateIsOrdered() { Order order = new Order(); OrderItem item1 = new OrderItem(new Customer("[email protected]")); OrderItem item2 = new OrderItem(new Customer("[email protected]")); order.addOrderItem(item1); order.addOrderItem(item2); when(mockExternalSupplierService.placeOrder(any(Order.class))) .thenReturn(Lists.newArrayList(new SupplierOrderResponse(SupplierOrderState.ORDERED, item1), new SupplierOrderResponse(SupplierOrderState.PENDING, item2))); orderingService.placeOrderAndNotifyCustomer(order); assertThat(item1.getState(), is("ORDERED")); assertThat(item2.getState(), is("PENDING")); verify(mockExternalSupplierService).placeOrder(order); verify(mockNotificationService).sendEmail("[email protected]", "Your order has been ORDERED!"); } }
12c8b4d65b9a67f94c5077b77ac4e53cae44823a
dd89ba85ceb56a3df25be449088c492bfd6f7814
/collect/src/test/java/com/opengamma/collect/tuple/PairTest.java
126ac410e6545e3afd78997b5f0acd56e1ee1e4c
[ "Apache-2.0" ]
permissive
loredofilms1/OG-Commons
e163b56cddbdeaab89bf16211a750d6a479508f3
1d16971633d97c4464bea2c9653c4be915670f45
refs/heads/master
2020-05-20T23:10:50.216672
2014-12-17T12:29:37
2014-12-17T12:29:53
null
0
0
null
null
null
null
UTF-8
Java
false
false
4,302
java
/** * Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies * * Please see distribution for license. */ package com.opengamma.collect.tuple; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.opengamma.collect.TestHelper; /** * Test. */ @Test public class PairTest { //------------------------------------------------------------------------- @DataProvider(name = "factory") Object[][] data_factory() { return new Object[][] { {"A", "B"}, {"A", 200.2d}, }; } @Test(dataProvider = "factory") public void test_of_getters(Object first, Object second) { Pair<Object, Object> test = Pair.of(first, second); assertEquals(test.getFirst(), first); assertEquals(test.getSecond(), second); } @Test(dataProvider = "factory") public void test_sizeElements(Object first, Object second) { Pair<Object, Object> test = Pair.of(first, second); assertEquals(test.size(), 2); assertEquals(test.elements(), ImmutableList.of(first, second)); } @Test(dataProvider = "factory") public void test_toString(Object first, Object second) { Pair<Object, Object> test = Pair.of(first, second); String str = "[" + first + ", " + second + "]"; assertEquals(test.toString(), str); } @DataProvider(name = "factoryNull") Object[][] data_factoryNull() { return new Object[][] { {null, null}, {null, "B"}, {"A", null}, }; } @Test(dataProvider = "factoryNull", expectedExceptions = IllegalArgumentException.class) public void test_of_null(Object first, Object second) { Pair.of(first, second); } //------------------------------------------------------------------------- public void test_compareTo() { Pair<String, String> ab = Pair.of("A", "B"); Pair<String, String> ad = Pair.of("A", "D"); Pair<String, String> ba = Pair.of("B", "A"); assertTrue(ab.compareTo(ab) == 0); assertTrue(ab.compareTo(ad) < 0); assertTrue(ab.compareTo(ba) < 0); assertTrue(ad.compareTo(ab) > 0); assertTrue(ad.compareTo(ad) == 0); assertTrue(ad.compareTo(ba) < 0); assertTrue(ba.compareTo(ab) > 0); assertTrue(ba.compareTo(ad) > 0); assertTrue(ba.compareTo(ba) == 0); } @Test(expectedExceptions = ClassCastException.class) public void test_compareTo_notComparable() { Runnable notComparable = () -> {}; Pair<Runnable, String> test1 = Pair.of(notComparable, "A"); Pair<Runnable, String> test2 = Pair.of(notComparable, "B"); test1.compareTo(test2); } //------------------------------------------------------------------------- public void test_equals() { Pair<Integer, String> a = Pair.of(1, "Hello"); Pair<Integer, String> a2 = Pair.of(1, "Hello"); Pair<Integer, String> b = Pair.of(1, "Goodbye"); Pair<Integer, String> c = Pair.of(2, "Hello"); Pair<Integer, String> d = Pair.of(2, "Goodbye"); assertEquals(a.equals(a), true); assertEquals(a.equals(b), false); assertEquals(a.equals(c), false); assertEquals(a.equals(d), false); assertEquals(a.equals(a2), true); assertEquals(b.equals(a), false); assertEquals(b.equals(b), true); assertEquals(b.equals(c), false); assertEquals(b.equals(d), false); assertEquals(c.equals(a), false); assertEquals(c.equals(b), false); assertEquals(c.equals(c), true); assertEquals(c.equals(d), false); assertEquals(d.equals(a), false); assertEquals(d.equals(b), false); assertEquals(d.equals(c), false); assertEquals(d.equals(d), true); } public void test_equals_bad() { Pair<Integer, String> a = Pair.of(1, "Hello"); assertEquals(a.equals(null), false); assertEquals(a.equals(""), false); } public void test_hashCode() { Pair<Integer, String> a = Pair.of(1, "Hello"); assertEquals(a.hashCode(), a.hashCode()); } public void test_toString() { Pair<String, String> test = Pair.of("A", "B"); assertEquals("[A, B]", test.toString()); } public void coverage() { Pair<String, String> test = Pair.of("A", "B"); TestHelper.coverImmutableBean(test); } }
206395f56953b54f8f8d5ceac82132c708d7abd1
50038815ef10faa5932d12df02af5c654d997631
/src/main/java/com/huobi/designPatterns/factoryMode/OperationAdd.java
9f2f15ef10cd35618e050f5c5018b003df72e032
[]
no_license
wanyi007/java-basis
886b88847fe205999c8c7da640ef6e9bb9ffbb6f
5a158c124ee85c7d4a077ad6aec8f5900a61495e
refs/heads/master
2021-07-03T05:26:37.466730
2020-12-20T07:20:41
2020-12-20T07:20:41
207,129,461
2
0
null
null
null
null
UTF-8
Java
false
false
351
java
package com.huobi.designPatterns.factoryMode; /** * @author wanyi * @version V1.0 * @Package com.huobi.designPatterns * @date 2019-08-13 23:47 */ public class OperationAdd extends Operation_v1 { @Override public double GetResult() { double result = 0; result = getNumberA() + getNumberB(); return result; } }
066b3ba3827f3e15437f7abd7856bf7ee54bb81c
e313ac61275aa8189f829727252c3ed145aad209
/Lab03/Lab03_Bai04/app/src/main/java/com/example/lab03_bai04/LocaleHelper.java
ed693cf6767b884711dc9c73ebe8a81efc059227
[]
no_license
DalatCoder/lap-trinh-di-dong
b0d1eaf7db02fbfcb781f641334b457d1e6cc9c1
3a20853e2f5e767b62fa6ea9c5693db29e2aa549
refs/heads/main
2023-02-01T17:33:13.590866
2020-12-16T23:49:17
2020-12-16T23:49:17
302,788,220
0
1
null
null
null
null
UTF-8
Java
false
false
2,154
java
package com.example.lab03_bai04; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Configuration; import android.content.res.Resources; import android.preference.PreferenceManager; import java.util.Locale; public class LocaleHelper { private static final String SELECTED_LANGUAGE = "Locale.Helper.Selected.Language"; public static void onCreate(Context context) { String lang; if (getLanguage(context).isEmpty()) { lang = getPersistedData(context, Locale.getDefault().getLanguage()); } else { lang = getLanguage(context); } setLocale(context, lang); } public static void onCreate(Context context, String defaultLanguage) { String lang = getPersistedData(context, defaultLanguage); setLocale(context, lang); } public static String getLanguage(Context context) { return getPersistedData(context, Locale.getDefault().getLanguage()); } public static void setLocale(Context context, String language) { persist(context, language); updateResources(context, language); } private static String getPersistedData(Context context, String defaultLanguage) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); return preferences.getString(SELECTED_LANGUAGE, defaultLanguage); } private static void persist(Context context, String language) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = preferences.edit(); editor.putString(SELECTED_LANGUAGE, language); editor.apply(); } private static void updateResources(Context context, String language) { Locale locale = new Locale(language); Locale.setDefault(locale); Resources resources = context.getResources(); Configuration configuration = resources.getConfiguration(); configuration.locale = locale; resources.updateConfiguration(configuration, resources.getDisplayMetrics()); } }
f1378f3ee2055677c8182b2d6b505d95d86e2ac7
4936a2dae6dca6a9553f7bebeab28614908bea98
/app/src/main/java/com/example/zy/sagittarius/model/IVersion.java
affa2ce207eaa0fc7ce74e5ab0e5b00c739c1986
[]
no_license
zhaoxiansheng/Sagittarius
0e1fd09ee5dea129abf28f32c2b88e7ede2a5a1a
6afe1e499ccceb70e8320d0bdbb2ebb33f9bb18b
refs/heads/master
2021-05-23T05:08:52.567651
2018-12-11T06:50:48
2018-12-11T06:50:48
95,226,840
0
0
null
null
null
null
UTF-8
Java
false
false
684
java
package com.example.zy.sagittarius.model; /** * Created on 2017/9/21. * * @author zhaoy */ public interface IVersion { /** * 版本接口返回的值 * * @return 状态 */ String getStatus(); /** * 版本接口返回的值 * * @return latest */ String getLatest(); /** * 更新地址 * * @return 需要更新时的更新地址 */ String getUrl(); /** * 版本更新信息,都更新了什么 * * @return 更新信息 */ String getMsg(); /** * 检查版本 * @param versionName 当前版本号 */ void checkVersion(String versionName); }
e576d10df87fc991f68b875f510eb20ffdee3d82
3d11d1dff7d55840b5cfd9f5c316f5998e1d44ff
/app/src/main/java/com/example/muvindu/recyclerdemo/widgets/vizualizer.java
e144493cdb837ea4d8bad4fab6718c08c69f41a5
[]
no_license
rootm/android
c658e60703de4565ee4679e3b4a7ccd3a071f6b7
93354ac2a4b52ad0917f484ad0e8c317baf52d91
refs/heads/master
2021-01-20T06:36:17.207944
2017-07-10T16:25:33
2017-07-10T16:25:33
89,898,319
0
0
null
null
null
null
UTF-8
Java
false
false
2,659
java
package com.example.muvindu.recyclerdemo.widgets; /** * Created by Muvindu on 1/1/2017. */ import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; import android.util.AttributeSet; import android.util.TypedValue; import android.view.View; import java.util.Random; /** * a music visualizer sort of animation (with random data) */ public class vizualizer extends View { Random random = new Random(); Paint paint = new Paint(); private Runnable animateView = new Runnable() { @Override public void run() { //run every 150 ms postDelayed(this, 150); invalidate(); } }; public vizualizer(Context context) { super(context); new vizualizer(context, null); } public vizualizer(Context context, AttributeSet attrs) { super(context, attrs); //start runnable removeCallbacks(animateView); post(animateView); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); //set paint style, Style.FILL will fill the color, Style.STROKE will stroke the color paint.setStyle(Paint.Style.FILL); canvas.drawRect(getDimensionInPixel(0), getHeight() - (20 + random.nextInt((int) (getHeight() / 1.5f) - 19)), getDimensionInPixel(7), getHeight(), paint); canvas.drawRect(getDimensionInPixel(10), getHeight() - (20 + random.nextInt((int) (getHeight() / 1.5f) - 19)), getDimensionInPixel(17), getHeight(), paint); canvas.drawRect(getDimensionInPixel(20), getHeight() - (20 + random.nextInt((int) (getHeight() / 1.5f) - 19)), getDimensionInPixel(27), getHeight(), paint); } public void setColor(int color) { paint.setColor(color); invalidate(); } //get all dimensions in dp so that views behaves properly on different screen resolutions private int getDimensionInPixel(int dp) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, getResources().getDisplayMetrics()); } @Override protected void onWindowVisibilityChanged(int visibility) { super.onWindowVisibilityChanged(visibility); if (visibility == VISIBLE) { removeCallbacks(animateView); post(animateView); } else if (visibility == GONE) { removeCallbacks(animateView); } } }
11f676aa0a6b662b652ece68621d099befcc68ec
dcc363239ed8492ec30fe52f79acbc386ba9c01f
/ticTacToe/src/main/java/priidukull/factory/Factory.java
680d3585a4267f2d7ddb929cc3c48c3c91d39f68
[]
no_license
priidukull/java-tic-tac-toe
2eb2e6ad99ba0770662806870aa6f239c340036f
e6fb3703aeac20b0bdcef8162e507553594d78e7
refs/heads/master
2021-01-21T05:14:36.767672
2017-02-25T20:09:23
2017-02-25T20:09:23
83,159,296
0
0
null
null
null
null
UTF-8
Java
false
false
87
java
package priidukull.factory; public interface Factory { Object createInstance(); }
f9c78f753c53f076b685f70cb2c1becda2fc4f8a
793468313387415976aef3f8b55c27106111f1a4
/app/src/main/java/net/suntrans/ebuilding/fragment/din/LightFragment.java
c4fb5ff1d9e44e623aad8f5d76b23ae0da0835fc
[]
no_license
luping1994/Ebuilding
d2ae7c7cde7a12a4a067eea9211db71e7a50abfb
ffdc3e39d7347220d26212a71270ab772451c137
refs/heads/master
2021-01-01T18:06:03.548389
2018-04-30T00:41:11
2018-04-30T00:41:11
98,249,875
3
0
null
null
null
null
UTF-8
Java
false
false
11,396
java
package net.suntrans.ebuilding.fragment.din; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.CompoundButton; import android.widget.TextView; import com.trello.rxlifecycle.android.FragmentEvent; import com.trello.rxlifecycle.components.support.RxFragment; import net.suntrans.ebuilding.R; import net.suntrans.ebuilding.api.RetrofitHelper; import net.suntrans.ebuilding.bean.ControlEntity; import net.suntrans.ebuilding.bean.DeviceEntity; import net.suntrans.ebuilding.rx.BaseSubscriber; import net.suntrans.ebuilding.utils.ActivityUtils; import net.suntrans.ebuilding.utils.LogUtil; import net.suntrans.ebuilding.utils.UiUtils; import net.suntrans.ebuilding.views.LoadingDialog; import net.suntrans.ebuilding.views.SwitchButton; import java.util.ArrayList; import java.util.List; import rx.Observable; import rx.Subscriber; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers; import static android.R.attr.data; /** * Created by Looney on 2017/7/20. */ public class LightFragment extends RxFragment { private RecyclerView recyclerView; private List<DeviceEntity.ChannelInfo> datas; private Observable<ControlEntity> conOb; private LoadingDialog dialog; private LightAdapter adapter; private Observable<DeviceEntity> getDataObj; private SwipeRefreshLayout refreshLayout; private TextView tips; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_light, container, false); return view; } @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { datas = new ArrayList<>(); tips = (TextView) view.findViewById(R.id.tips); recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); adapter = new LightAdapter(); recyclerView.setAdapter(adapter); recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL)); refreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.refreshlayout); refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { getData(); } }); } private class LightAdapter extends RecyclerView.Adapter<LightAdapter.ViewHolder> { @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { return new ViewHolder(LayoutInflater.from(getContext()).inflate(R.layout.item_light, parent, false)); } @Override public void onBindViewHolder(ViewHolder holder, int position) { holder.setData(position); } @Override public int getItemCount() { return datas == null ? 0 : datas.size(); } class ViewHolder extends RecyclerView.ViewHolder { TextView name; TextView area; SwitchButton button; public void setData(int position) { button.setCheckedImmediately(datas.get(position).status.equals("1") ? true : false); name.setText(datas.get(position).name); area.setText(datas.get(position).area_name); } public ViewHolder(View itemView) { super(itemView); button = (SwitchButton) itemView.findViewById(R.id.checkbox); name = (TextView) itemView.findViewById(R.id.name); area = (TextView) itemView.findViewById(R.id.area); button.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { sendCmd(getAdapterPosition()); } }); } } } private void sendCmd(int position) { if (position == -1) { UiUtils.showToast("请不要频繁操作!"); return; } if (dialog == null) { dialog = new LoadingDialog(getActivity(), R.style.loading_dialog); dialog.setCancelable(false); } dialog.setWaitText("请稍后"); dialog.show(); conOb = null; conOb = RetrofitHelper.getApi().switchChannel(datas.get(position).id, datas.get(position).datapoint, datas.get(position).din, datas.get(position).status.equals("1") ? "0" : "1") .compose(this.<ControlEntity>bindUntilEvent(FragmentEvent.DESTROY_VIEW)) .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()); String order = datas.get(position).status.equals("1") ? "关" : "开"; LogUtil.i("发出命令:" + order); conOb.subscribe(new BaseSubscriber<ControlEntity>(getActivity()) { @Override public void onError(Throwable e) { super.onError(e); dialog.dismiss(); adapter.notifyDataSetChanged(); if (refreshLayout != null) { refreshLayout.setRefreshing(false); } } @Override public void onNext(ControlEntity data) { dialog.dismiss(); if (refreshLayout != null) { refreshLayout.setRefreshing(false); } if (data.code == 200) { LogUtil.i(data.data.toString()); for (int i = 0; i < datas.size(); i++) { if (datas.get(i).id.equals(data.data.id)) { datas.get(i).status = String.valueOf(data.data.status); } } } else if (data.code == 401) { ActivityUtils.showLoginOutDialogFragmentToActivity(getChildFragmentManager(), "Alert"); } else { UiUtils.showToast(data.msg); } adapter.notifyDataSetChanged(); } }); // .subscribe(new Subscriber<ControlEntity>() { // @Override // public void onCompleted() { // // } // // @Override // public void onError(Throwable e) { // e.printStackTrace(); // UiUtils.showToast("服务器错误"); // dialog.dismiss(); // // adapter.notifyDataSetChanged(); // if (refreshLayout!=null){ // refreshLayout.setRefreshing(false); // } // // } // // @Override // public void onNext(ControlEntity data) { // dialog.dismiss(); // if (refreshLayout!=null){ // refreshLayout.setRefreshing(false); // } // if (data.code == 200) { // LogUtil.i(data.data.toString()); // for (int i = 0; i < datas.size(); i++) { // if (datas.get(i).id.equals(data.data.id)) { // datas.get(i).status = String.valueOf(data.data.status); // } // } // } else if (data.code==401){ // ActivityUtils.showLoginOutDialogFragmentToActivity(getChildFragmentManager(), "Alert"); // // }else { // UiUtils.showToast(data.msg); // } // // adapter.notifyDataSetChanged(); // // } // }); } @Override public void onResume() { super.onResume(); getData(); } public void getData() { if (getDataObj == null) { getDataObj = RetrofitHelper.getApi().getAllDevice() .compose(this.<DeviceEntity>bindUntilEvent(FragmentEvent.DESTROY_VIEW)) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } getDataObj.subscribe(new BaseSubscriber<DeviceEntity>(getActivity()) { @Override public void onError(Throwable e) { super.onError(e); if (refreshLayout != null) { refreshLayout.setRefreshing(false); } } @Override public void onNext(DeviceEntity result) { if (refreshLayout != null) { refreshLayout.setRefreshing(false); } if (result.code == 200) { if (result != null) { datas.clear(); datas.addAll(result.data.lists); adapter.notifyDataSetChanged(); } if (datas.size() != 0) { recyclerView.setVisibility(View.VISIBLE); tips.setVisibility(View.GONE); } else { tips.setVisibility(View.VISIBLE); recyclerView.setVisibility(View.INVISIBLE); } } else { UiUtils.showToast(result.msg); } } }); // getDataObj.subscribe(new Subscriber<DeviceEntity>() { // @Override // public void onCompleted() { // // } // // @Override // public void onError(Throwable e) { // e.printStackTrace(); // if (refreshLayout != null) { // refreshLayout.setRefreshing(false); // } // } // // @Override // public void onNext(DeviceEntity result) { // if (refreshLayout != null) { // refreshLayout.setRefreshing(false); // } // if (result.code == 200) { // if (result != null) { // datas.clear(); // datas.addAll(result.data.lists); // adapter.notifyDataSetChanged(); // } // if (datas.size() != 0) { // recyclerView.setVisibility(View.VISIBLE); // tips.setVisibility(View.GONE); // // } else { // tips.setVisibility(View.VISIBLE); // recyclerView.setVisibility(View.INVISIBLE); // } // } else if (result.code == 401) { // ActivityUtils.showLoginOutDialogFragmentToActivity(getChildFragmentManager(), "Alert"); // // } else { // UiUtils.showToast(result.msg); // } // } // }); } }
1c5d4dcdd4ff9aae6fd68c071ee62be6e0b58190
9ee03047482c78de0dca7dccbf67394ea1df7e78
/workspace/3-site/src/main/java/gd/domain/recommendations/repository/query/QueryRelatedGamesBySingleGame.java
c5f7a01723a40d3c676df67312405ec3441c2477
[]
no_license
dinhani/gamediscovery
a3dc2fce6c637f5780ea1c75398762308d56fcfa
dbb758a1e88dc7a78df441899f79957a28d420c1
refs/heads/master
2021-01-22T21:38:39.620621
2018-05-06T07:48:56
2018-05-06T07:48:56
85,458,515
4
1
null
null
null
null
UTF-8
Java
false
false
13,075
java
package gd.domain.recommendations.repository.query; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import gd.domain.entities.entity.ConceptEntry; import gd.domain.entities.entity.gameplay.Duration; import gd.domain.entities.entity.gameplay.Genre; import gd.domain.entities.entity.gameplay.Graphics; import gd.domain.entities.entity.gameplay.Mechanics; import gd.domain.entities.entity.industry.Company; import gd.domain.entities.entity.industry.ContentCharacteristic; import gd.domain.entities.entity.industry.ContentClassification; import gd.domain.entities.entity.industry.Person; import gd.domain.entities.entity.industry.Platform; import gd.domain.entities.entity.industry.ReleaseYear; import gd.domain.entities.entity.plot.Atmosphere; import gd.domain.entities.entity.plot.Location; import gd.domain.entities.entity.plot.Organization; import gd.domain.entities.entity.plot.Period; import gd.domain.entities.entity.plot.Soundtrack; import gd.domain.entities.entity.plot.Theme; import gd.domain.entities.entity.plot.Vehicle; import gd.domain.entities.entity.plot.Weapon; import gd.domain.recommendations.entity.GraphSearch; import gd.domain.recommendations.entity.GraphSearchResult; import gd.domain.recommendations.repository.cache.GraphCache; import gd.infrastructure.enviroment.Environment; import gd.infrastructure.steriotype.GDQuery; import java.util.Collection; import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; import org.apache.commons.lang3.StringUtils; import org.apache.commons.math3.stat.Frequency; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; @GDQuery @Scope(value = "prototype") public class QueryRelatedGamesBySingleGame implements QueryRelatedGames { // ========================================================================= // SERVICES // ========================================================================= @Autowired private GraphCache graph; @Autowired private gd.infrastructure.math.Math math; @Autowired private Environment environment; // ========================================================================= // DATA // ========================================================================= private final Set<String> visitedNodes = Sets.newHashSet(); private final Frequency gameCategoriesFrequency = new Frequency(); // categoryUid, total private final Map<String, Double> gameCharacteristicsWeight = Maps.newHashMap(); // characteristicUid, relationship weight private final Map<String, Map<String, List<Double>>> relatedGamesRelationshipsWeight = Maps.newHashMap(); // gameUid, categoryUid, weight // ========================================================================= // EXECUTION // ========================================================================= @Override public Collection<GraphSearch> execute(String[] searchUids, String[] categoriesToUse) { // 1) get gameUid String gameUid = searchUids[0]; // 2) initialize categories Set<String> categoriesToUseSet = getCategoriesToUSe(categoriesToUse); // 3) initialize games characteristics calculateGameCharacteristicsWeights(gameUid); // 4) start calculation calculateRelevanceForNode(gameUid, categoriesToUseSet, 1); // 5) generate graph search GraphSearch graphSearch = generateGameSearch(gameUid); // return return Lists.newArrayList(graphSearch); } // ========================================================================= // STEP 2 - INITIALIZATION OF CATEGORIES // ========================================================================= private Set<String> getCategoriesToUSe(String[] categoriesToUse) { if (categoriesToUse == null || categoriesToUse.length == 0) { return chooseCategoriesToUseInRecommendations(); } else { return Sets.newHashSet(categoriesToUse); } } // ========================================================================= // STEP 3 - INITIALIZATION OF CHARACTERISTICS WEIGHT // ========================================================================= private void calculateGameCharacteristicsWeights(String gameUid) { Collection<String> neighbors = graph.getGraph().neighborsOf(gameUid); for (String neighborNode : neighbors) { double gameToCharacteristicWeight = 1 - graph.getGraph().getEdge(gameUid, neighborNode).getWeight(); gameCharacteristicsWeight.put(neighborNode, gameToCharacteristicWeight); } } // ========================================================================= // STEP 4 - RAW WEIGHTS SUM // ========================================================================= private void calculateRelevanceForNode(String nodeToVisit, Set<String> categoriesToUse, int currentDepthLevel) { // 1) mark current node as visited visitedNodes.add(nodeToVisit); // 2) extract node category and increment total of categories of current type String category = StringUtils.split(nodeToVisit, "-", 2)[0]; gameCategoriesFrequency.addValue(category); // 3) check if should use some category in the recommendations // "game" is always used if (!category.equals("game") && !categoriesToUse.contains(category)) { return; } // 4) calculate weight for current node and its neighbors Collection<String> neighbors = graph.getGraph().neighborsOf(nodeToVisit); for (String neighborNode : neighbors) { if (neighborNode.startsWith("game-")) { // calculate weight double calculatedWeightForNeighbor = calculateRelevanceForRelationship(nodeToVisit, neighborNode, currentDepthLevel); // add weights to list of calculate weights if (!relatedGamesRelationshipsWeight.containsKey(neighborNode)) { relatedGamesRelationshipsWeight.put(neighborNode, Maps.newHashMap()); } if (!relatedGamesRelationshipsWeight.get(neighborNode).containsKey(category)) { relatedGamesRelationshipsWeight.get(neighborNode).put(category, Lists.newArrayList()); } relatedGamesRelationshipsWeight.get(neighborNode).get(category).add(calculatedWeightForNeighbor); } } // 5) checks if already reached the maximum distance to visit if (currentDepthLevel == 2) { return; } // 6) visit neighbors nodes for (String neighbor : neighbors) { if (visitedNodes.contains(neighbor)) { continue; } calculateRelevanceForNode(neighbor, categoriesToUse, currentDepthLevel + 1); } } private double calculateRelevanceForRelationship(String sourceNode, String neighborNode, int currentDepthLevel) { double relationshipWeight = 1 - graph.getGraph().getEdge(sourceNode, neighborNode).getWeight(); double calculatedWeightForNeighbor = relationshipWeight / currentDepthLevel; calculatedWeightForNeighbor = calculatedWeightForNeighbor * (1 + gameCharacteristicsWeight.get(sourceNode)); return calculatedWeightForNeighbor; } // ========================================================================= // STEP 5 - TRANSFORMATION OF WEIGHTS // ========================================================================= private GraphSearch generateGameSearch(String searchUid) { // transform GraphSearch searchByGame = new GraphSearch(searchUid); // 1) calculate average and total weights for (Map.Entry<String, Map<String, List<Double>>> relatedGameWithRelationships : relatedGamesRelationshipsWeight.entrySet()) { // iterate categories Map<String, Double> relatedGamePartialWeights = Maps.newHashMap(); double totalWeight = 0; // transform partial weights into a single weight for (Map.Entry<String, List<Double>> categoryWithWeights : relatedGameWithRelationships.getValue().entrySet()) { String category = categoryWithWeights.getKey(); // calculate intersection weight long categoryFrequencyInSourceGame = gameCategoriesFrequency.getCount(category); // the number of times a category appear in the source game List<Double> categoryWeightsInRelationship = categoryWithWeights.getValue(); // all computed values between the source node and target node for the selected category double intersectionWeight = calculateIntersectionWeight(categoryFrequencyInSourceGame, categoryWeightsInRelationship); // update category weights relatedGamePartialWeights.put(category, intersectionWeight); totalWeight += intersectionWeight; } // add search result GraphSearchResult gameSearchResult = new GraphSearchResult(relatedGameWithRelationships.getKey(), totalWeight, relatedGamePartialWeights); searchByGame.addResult(gameSearchResult); } // 2) make searched game the most relevant searchByGame.addResult(searchUid, 100.0); // 3) order the results searchByGame.updateResultsOrder(); // 4) log results for analysis if (environment.isDevelopment()) { logSimilarGames(searchByGame); } // 5) invert weights making the largest weight the smallest double maxWeight = searchByGame.getResults().last().getWeight(); for (GraphSearchResult result : searchByGame.getResults()) { searchByGame.getResult(result.getGame()).setWeight(math.fitBetweenMinAndMax(result.getWeight(), maxWeight, 0)); } // force ordering searchByGame.updateResultsOrder(); return searchByGame; } private double calculateIntersectionWeight(long categoryFrequency, List<Double> categoryWeights) { double averageOfPartialWeights = categoryWeights.stream().mapToDouble(d -> d).average().getAsDouble(); double intersectionProportion = categoryWeights.size() / (categoryFrequency * 1.0); return averageOfPartialWeights * intersectionProportion; } // ========================================================================= // CATEGORIES CHOOSER // ========================================================================= private Set<String> chooseCategoriesToUseInRecommendations() { Set<Class<? extends ConceptEntry>> categories = Sets.newHashSet(Genre.class, Theme.class, Atmosphere.class, Mechanics.class, Graphics.class, Duration.class, // ContentCharacteristic.class, ContentClassification.class, // gd.domain.entities.entity.plot.Character.class, Weapon.class, Vehicle.class, Organization.class, Location.class, Period.class, Soundtrack.class, // Company.class, Person.class, Platform.class, ReleaseYear.class ); return categories.stream().map(c -> c.getSimpleName().toLowerCase()).collect(Collectors.toSet()); } // ===================================================================== // TRACING // ===================================================================== private void logSimilarGames(GraphSearch graphSearch) { // sort game results from the most to the least relevant Stream<GraphSearchResult> sortedResults = graphSearch.getResults().stream().sorted(Comparator.comparing(GraphSearchResult::getWeight).reversed()).limit(40); // print each relevant result for analysis System.out.print("\033[H\033[2J"); System.out.flush(); sortedResults.forEach( result -> { System.out.println("====================================="); System.out.format("%-60s | total = %.3f %n", result.getGame(), result.getWeight() * 100); for (Map.Entry<String, Double> partialWeight : result.getPartialWeights().entrySet().stream().sorted((e1, e2) -> -1 * e1.getValue().compareTo(e2.getValue())).collect(Collectors.toList())) { System.out.format("%-60s | %-30s = %.3f %n", result.getGame(), partialWeight.getKey(), partialWeight.getValue() * 100); } } ); } }
f7404699678969d5a2bb8d2fad1484b8d8c78cf8
7af401c3af9c00e4408f137bb306327c1c5419e0
/src-gen/org/mt/lic/eol/eventOrientedLanguage/GlobalSection.java
2d3ea10089454e1de3e7b1a21f18c679f9ed038b
[]
no_license
marcotinacci/Event-Oriented-Language
b7dd42d1a9f5b84e63a2ab36c1e339a6c65e9543
aae8dbd91b19d41f8927f2f6730aac078195e302
refs/heads/master
2021-01-01T18:55:33.236243
2011-07-25T20:03:54
2011-07-25T20:03:54
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,357
java
/** * <copyright> * </copyright> * */ package org.mt.lic.eol.eventOrientedLanguage; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EObject; /** * <!-- begin-user-doc --> * A representation of the model object '<em><b>Global Section</b></em>'. * <!-- end-user-doc --> * * <p> * The following features are supported: * <ul> * <li>{@link org.mt.lic.eol.eventOrientedLanguage.GlobalSection#getGlobals <em>Globals</em>}</li> * </ul> * </p> * * @see org.mt.lic.eol.eventOrientedLanguage.EventOrientedLanguagePackage#getGlobalSection() * @model * @generated */ public interface GlobalSection extends EObject { /** * Returns the value of the '<em><b>Globals</b></em>' containment reference list. * The list contents are of type {@link org.mt.lic.eol.eventOrientedLanguage.VariableDeclaration}. * <!-- begin-user-doc --> * <p> * If the meaning of the '<em>Globals</em>' containment reference list isn't clear, * there really should be more of a description here... * </p> * <!-- end-user-doc --> * @return the value of the '<em>Globals</em>' containment reference list. * @see org.mt.lic.eol.eventOrientedLanguage.EventOrientedLanguagePackage#getGlobalSection_Globals() * @model containment="true" * @generated */ EList<VariableDeclaration> getGlobals(); } // GlobalSection
43a5d4278b22812554b7548d24e15a96ca15e261
695fd9e50948b837bd4fc5599e56e649319d8a82
/java/19-07-10_rectangle_into_squares/src/main/java/kata/SqInRect.java
83173fb8535f330e2d4889a354bfb32236c49a92
[]
no_license
punchcafe/kata
eda582189b86988c3323dbf9a08f70e7843d95a0
ebce1260bb45b96a26c6f8195d3f7fe25a94b78b
refs/heads/master
2023-01-12T23:37:59.367264
2022-12-17T11:23:56
2022-12-17T11:23:56
250,609,599
0
0
null
2023-01-04T14:41:47
2020-03-27T18:09:52
JavaScript
UTF-8
Java
false
false
1,193
java
package kata; import java.util.*; class SqInRect{ public static ArrayList<Integer> sqInRect(int length, int width){ if( length == width ) return null; return splitRectangle(length, width); } private static ArrayList<Integer> splitRectangle(int length, int width){ if(length==width){ return extractDimensionToArrayList(length); } else { //make this a hashmap? //make this a get realtive dimensions int longer = width > length ? width : length; int shorter = width < length ? width : length; //this speaks for itself ArrayList<Integer> removedSquareDimension = extractDimensionToArrayList(shorter); //recur call on new rect dimensions splitNewRect int newLonger = longer - shorter; ArrayList<Integer> recursiveCall = splitRectangle(shorter, newLonger); // merge with return removedSquareDimensions + splitNewRect removedSquareDimension.addAll(recursiveCall); return removedSquareDimension; } } private static ArrayList<Integer> extractDimensionToArrayList(int length){ ArrayList<Integer> arrayList = new ArrayList<Integer>(); arrayList.add(length); return arrayList; } }
3cd20ccb51647a459c13aaf1176a459d9ae8a352
c71ac9f1fbd8dbd1a49216b2a1d5886ba5af0fca
/src/edu/utfpr/ct/util/ReplacerUtils.java
4af82c08479b888fb29a9f21c65d3b15fdef281f
[ "MIT" ]
permissive
Sandy4321/TheBeerGame
f3e31dcca38ca3d9e7235edac64a86caeb326962
93902e3f69b4ff207ee1813b964655c9a3f05ab1
refs/heads/master
2021-09-09T00:40:28.734522
2018-03-13T01:35:44
2018-03-13T01:35:44
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,653
java
/* * 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 edu.utfpr.ct.util; import java.util.HashMap; /** * * @author henrique */ public class ReplacerUtils { private static final HashMap<String, String> TUTORIAL_REPLACERS; static { TUTORIAL_REPLACERS = new HashMap<>(); TUTORIAL_REPLACERS.put("<var:player-name>", "<%=name%>"); TUTORIAL_REPLACERS.put("<var:player-producer>", "<span name=\"dlg_PRODUCER_name\">(***nome***)</span>"); TUTORIAL_REPLACERS.put("<var:player-distributor>", "<span name=\"dlg_DISTRIBUTOR_name\">(***nome***)</span>"); TUTORIAL_REPLACERS.put("<var:player-wholesaler>", "<span name=\"dlg_WHOLESALER_name\">(***nome***)</span>"); TUTORIAL_REPLACERS.put("<var:player-retailer>", "<span name=\"dlg_RETAILER_name\">(***nome***)</span>"); TUTORIAL_REPLACERS.put("<var:inf-duration>", "<span name=\"dlg_dur\">***</span>"); TUTORIAL_REPLACERS.put("<var:init-stock>", "<span name=\"dlg_istock\">***</span>"); TUTORIAL_REPLACERS.put("<var:init-incoming>", "<span name=\"dlg_incomming\">***</span>"); TUTORIAL_REPLACERS.put("<var:direct-client>", "<span name=\"dlg_client\">***</span>"); TUTORIAL_REPLACERS.put("<var:direct-supplier>", "<span name=\"dlg_supl\">***</span>"); TUTORIAL_REPLACERS.put("<var:stock-cost>", "<span name=\"dlg_stockcost\">***</span>"); TUTORIAL_REPLACERS.put("<var:missing-cost>", "<span name=\"dlg_misscost\">***</span>"); TUTORIAL_REPLACERS.put("<var:delivery-delay>", "<span name=\"dlg_delay\">***</span>"); TUTORIAL_REPLACERS.put("<structure:paragraph>", "<p>"); TUTORIAL_REPLACERS.put("<structure:end-paragraph>", "</p>"); TUTORIAL_REPLACERS.put("<structure:if-producer>", "<span id=\"dlg_b5_prod\">"); TUTORIAL_REPLACERS.put("<structure:if-not-producer>", "<span id=\"dlg_b5_notprod\">"); TUTORIAL_REPLACERS.put("<structure:end-if>", "</span>"); TUTORIAL_REPLACERS.put("<structure:page>", "<div name=\"text_tutorial\" class=\"mySlide\">"); TUTORIAL_REPLACERS.put("<structure:end-page>", "</div>"); } public static String tutorialReplace(String input){ String ret = input; if(input != null){ for(String key : TUTORIAL_REPLACERS.keySet()){ ret = ret.replace(key, TUTORIAL_REPLACERS.get(key)); } } return ret; } }
aa272e8928965d9e580aa13df43ab52b0bc2b4bd
5bdb09a2c43d794871a07d02a9a0959f7a290b1b
/spring/BE_Project1 MyBatis/src/main/java/T2454/Chandan_Bansal/BE_Project1/controller/DepartmentControllers.java
e829c1d92a5a8c26a632537e0743ee606eed3573
[]
no_license
chandan1602/Java_basics
f1d7a6aa0f372e4a581170d2c8c41d8f620f4a5c
f09313c160fb1ddb99580ab93230989914625c3a
refs/heads/master
2022-07-14T22:19:49.401682
2022-06-03T11:58:51
2022-06-03T11:58:51
195,409,757
0
0
null
null
null
null
UTF-8
Java
false
false
1,893
java
package T2454.Chandan_Bansal.BE_Project1.controller; import T2454.Chandan_Bansal.BE_Project1.entity.Department; import T2454.Chandan_Bansal.BE_Project1.service.DepartmentServices; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.util.List; @RestController @RequestMapping("/api/v1/department") public class DepartmentControllers { private final DepartmentServices departmentServices; public DepartmentControllers(DepartmentServices departmentServices) { this.departmentServices = departmentServices; } @GetMapping("") @ResponseBody public ResponseEntity<List<Department>> getDepartments() { List<Department> list = departmentServices.getAllDepartments(); return new ResponseEntity<List<Department>>(list, HttpStatus.OK); } @PostMapping("") @ResponseBody public ResponseEntity<Department> createDepartment( @RequestBody Department department) throws Exception { departmentServices.createDepartment(department); return new ResponseEntity<>(HttpStatus.CREATED); } @PutMapping("/{departmentId}") @ResponseBody public ResponseEntity<Department> updateDepartment( @RequestBody Department department, @PathVariable String departmentId ) { departmentServices.updateDepartmentById(department, departmentId); return new ResponseEntity<>(HttpStatus.ACCEPTED); } @DeleteMapping("/{departmentId}") @ResponseBody public ResponseEntity<Department> deleteDepartment( @PathVariable String departmentId ) { departmentServices.deleteDepartmentById(departmentId); return new ResponseEntity<Department>(HttpStatus.OK); } }
91ebe3a9e56e7a104418d9b0fca12593a65e9421
17adbe946a7f657c279556cd666839b19a46bad9
/modulo03/PaisCidade/src/main/java/br/com/br/dbc/paiscidade/paiscidade/entity/Estado.java
86b2ab8928617deb77df3ebd9de71792b8f40250
[]
no_license
jaquelinebonoto/EstagioVemSer
bfd4acce7ef6d00e2112b4d16b862dcf5761be88
48db9877fa84a87dc03bd35f9ffa45bf680cd534
refs/heads/master
2020-04-26T18:23:32.682456
2018-11-07T18:46:57
2018-11-07T18:46:57
173,743,623
0
0
null
null
null
null
UTF-8
Java
false
false
4,165
java
/* * 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 br.com.br.dbc.paiscidade.paiscidade.entity; import java.io.Serializable; import java.math.BigDecimal; import java.util.Collection; import javax.persistence.Basic; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.OneToMany; import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; /** * * @author jaqueline.bonoto */ @Entity @Table(name = "ESTADO") @XmlRootElement @NamedQueries({ @NamedQuery(name = "Estado.findAll", query = "SELECT e FROM Estado e") , @NamedQuery(name = "Estado.findByIdestado", query = "SELECT e FROM Estado e WHERE e.idestado = :idestado") , @NamedQuery(name = "Estado.findByNomeestado", query = "SELECT e FROM Estado e WHERE e.nomeestado = :nomeestado") , @NamedQuery(name = "Estado.findByEstadosigla", query = "SELECT e FROM Estado e WHERE e.estadosigla = :estadosigla")}) public class Estado implements Serializable { private static final long serialVersionUID = 1L; // @Max(value=?) @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation @Id @Basic(optional = false) @Column(name = "IDESTADO") @SequenceGenerator(name = "ESTADO_SEQ", sequenceName = "ESTADO_SEQ") @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ESTADO_SEQ") private Long idestado; @Basic(optional = false) @Column(name = "NOMEESTADO") private String nomeestado; @Column(name = "ESTADOSIGLA") private String estadosigla; @JoinColumn(name = "FK_IDPAIS", referencedColumnName = "IDPAIS") @ManyToOne private Pais fkIdpais; @OneToMany(mappedBy = "fkIdestado") private Collection<Cidade> cidadeCollection; public Estado() { } public Estado(Long idestado) { this.idestado = idestado; } public Estado(Long idestado, String nomeestado) { this.idestado = idestado; this.nomeestado = nomeestado; } public Long getIdestado() { return idestado; } public void setIdestado(Long idestado) { this.idestado = idestado; } public String getNomeestado() { return nomeestado; } public void setNomeestado(String nomeestado) { this.nomeestado = nomeestado; } public String getEstadosigla() { return estadosigla; } public void setEstadosigla(String estadosigla) { this.estadosigla = estadosigla; } public Pais getFkIdpais() { return fkIdpais; } public void setFkIdpais(Pais fkIdpais) { this.fkIdpais = fkIdpais; } @XmlTransient public Collection<Cidade> getCidadeCollection() { return cidadeCollection; } public void setCidadeCollection(Collection<Cidade> cidadeCollection) { this.cidadeCollection = cidadeCollection; } @Override public int hashCode() { int hash = 0; hash += (idestado != null ? idestado.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 Estado)) { return false; } Estado other = (Estado) object; if ((this.idestado == null && other.idestado != null) || (this.idestado != null && !this.idestado.equals(other.idestado))) { return false; } return true; } @Override public String toString() { return "br.com.br.dbc.paiscidade.paiscidade.entity.Estado[ idestado=" + idestado + " ]"; } }
196e0eed381cb04cfd310f8cfdafe62d74edcd95
8bcfe1b7edd93e30ee51b65f2f6bad6bc95bfdce
/shiro-example-chapter13/src/main/java/io/github/xyzc1988/shiro/chapter13/service/PasswordHelper.java
3cda48d0625c46977505186d437cc001078d8256
[]
no_license
xyzc1988/shiro-example
bd2d38518f86a135bb9cfedab658fda85ed27b13
7100186166eb18ec64b9399b8333c7ad781bfd23
refs/heads/master
2021-08-22T04:41:45.133264
2017-11-29T09:18:56
2017-11-29T09:18:56
84,457,555
0
0
null
null
null
null
UTF-8
Java
false
false
1,338
java
package io.github.xyzc1988.shiro.chapter13.service; import io.github.xyzc1988.shiro.chapter13.entity.User; import org.apache.shiro.crypto.RandomNumberGenerator; import org.apache.shiro.crypto.SecureRandomNumberGenerator; import org.apache.shiro.crypto.hash.SimpleHash; import org.apache.shiro.util.ByteSource; /** * <p>User: Zhang Kaitao * <p>Date: 14-1-28 * <p>Version: 1.0 */ public class PasswordHelper { private RandomNumberGenerator randomNumberGenerator = new SecureRandomNumberGenerator(); private String algorithmName = "md5"; private int hashIterations = 2; public void setRandomNumberGenerator(RandomNumberGenerator randomNumberGenerator) { this.randomNumberGenerator = randomNumberGenerator; } public void setAlgorithmName(String algorithmName) { this.algorithmName = algorithmName; } public void setHashIterations(int hashIterations) { this.hashIterations = hashIterations; } public void encryptPassword(User user) { user.setSalt(randomNumberGenerator.nextBytes().toHex()); String newPassword = new SimpleHash( algorithmName, user.getPassword(), ByteSource.Util.bytes(user.getCredentialsSalt()), hashIterations).toHex(); user.setPassword(newPassword); } }
c80f86310aa5d0f6e96a169c3f85281fe26b278b
4aa90348abcb2119011728dc067afd501f275374
/app/src/main/java/com/tencent/mm/plugin/appbrand/appcache/aa$a.java
ca7447faab36347d18b71df4d704d33d3efac1af
[]
no_license
jambestwick/HackWechat
0d4ceb2d79ccddb45004ca667e9a6a984a80f0f6
6a34899c8bfd50d19e5a5ec36a58218598172a6b
refs/heads/master
2022-01-27T12:48:43.446804
2021-12-29T10:36:30
2021-12-29T10:36:30
249,366,791
0
0
null
2020-03-23T07:48:32
2020-03-23T07:48:32
null
UTF-8
Java
false
false
3,762
java
package com.tencent.mm.plugin.appbrand.appcache; import android.net.Uri; import com.tencent.mm.bz.a; import com.tencent.mm.loader.stub.b; import com.tencent.mm.modelcdntran.g; import com.tencent.mm.modelcdntran.i; import com.tencent.mm.plugin.appbrand.p.h; import com.tencent.mm.pluginsdk.i.a.d.k; import com.tencent.mm.pluginsdk.i.a.d.l; import com.tencent.mm.sdk.platformtools.ak; import com.tencent.mm.sdk.platformtools.bh; import com.tencent.mm.sdk.platformtools.x; import java.util.ArrayList; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; final class aa$a { private aa$a() { } public final l a(aa$d com_tencent_mm_plugin_appbrand_appcache_aa_d) { String bZj = com_tencent_mm_plugin_appbrand_appcache_aa_d.bZj(); x.i("MicroMsg.AppBrand.CdnHttpsDownloadPerformer", "downloadUsingCDN, url %s", com_tencent_mm_plugin_appbrand_appcache_aa_d.iFI); try { ak akVar; final CountDownLatch countDownLatch = new CountDownLatch(1); final h hVar = new h(); final k aaa = com_tencent_mm_plugin_appbrand_appcache_aa_d.aaa(); final String str = aaa.vgd; final p$a com_tencent_mm_plugin_appbrand_appcache_p_a = com_tencent_mm_plugin_appbrand_appcache_aa_d.iFJ; if (com_tencent_mm_plugin_appbrand_appcache_aa_d.aaa().iFO) { akVar = new ak(a.cll().getLooper(), new ak.a(this) { final /* synthetic */ aa$a iFC; public final boolean uF() { g.MJ().kI(str); com_tencent_mm_plugin_appbrand_appcache_p_a.ZA(); b.deleteFile(aaa.getFilePath()); hVar.jRK = null; countDownLatch.countDown(); return false; } }, false); } else { akVar = null; } i.a 2 = new 2(this, com_tencent_mm_plugin_appbrand_appcache_aa_d, akVar, hVar, countDownLatch); i iVar = new i(); iVar.field_mediaId = str; iVar.field_fullpath = aaa.getFilePath(); iVar.htu = aaa.url; iVar.fLH = false; iVar.htt = 2; iVar.htv = (int) TimeUnit.MILLISECONDS.toSeconds((long) aaa.getConnectTimeout()); iVar.htw = (int) TimeUnit.MILLISECONDS.toSeconds((long) aaa.getReadTimeout()); iVar.field_fileType = com.tencent.mm.modelcdntran.b.hrV; String host = Uri.parse(iVar.htu).getHost(); if (!bh.ov(host)) { ArrayList arrayList = new ArrayList(); try { com.tencent.mm.kernel.g.Di().gPJ.hmV.getHostByName(host, arrayList); iVar.htx = new String[arrayList.size()]; arrayList.toArray(iVar.htx); } catch (Exception e) { x.e("MicroMsg.AppBrand.CdnHttpsDownloadPerformer", "cdn https getHostByName e = %s", e); } } g.MJ().b(iVar, -1); if (akVar != null) { long readTimeout = (long) aaa.getReadTimeout(); akVar.J(readTimeout, readTimeout); } try { countDownLatch.await(); return (l) hVar.jRK; } catch (Exception e2) { x.e("MicroMsg.AppBrand.CdnHttpsDownloadPerformer", "cdn https perform, urlKey %s semaphore await e = %s", bZj, e2); return null; } } catch (Exception e22) { x.e("MicroMsg.AppBrand.CdnHttpsDownloadPerformer", "cdn https perform urlKey %s exp %s", bZj, e22); return null; } } }
94eb8f7a2292997ed51f74092597592b9db9eea0
f76799b1f31d6625b16bdddafedb9e812fde800f
/app/src/main/java/com/example/petagram/MainActivity.java
10e3c20cce095663582ac1316247423689cc2e14
[]
no_license
CheloUY/MisMascotasConMenu
8db04ba2126f38e8cb7c136c50338d2d1a196417
386cdca7fc5e682e06c7788ae0357e78a3aa5bbe
refs/heads/master
2022-12-25T16:15:40.929567
2020-10-11T21:14:09
2020-10-11T21:14:09
303,214,593
1
0
null
null
null
null
UTF-8
Java
false
false
3,194
java
package com.example.petagram; import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; import androidx.viewpager.widget.ViewPager; import android.content.Intent; import android.os.Build; import android.os.Bundle; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import androidx.appcompat.widget.Toolbar; import com.example.petagram.adapter.PageAdapter; import com.example.petagram.vista.fragment.BlankFragment; import com.example.petagram.vista.fragment.RecyclerViewFragment; import com.google.android.material.tabs.TabLayout; import java.util.ArrayList; public class MainActivity extends AppCompatActivity { private Toolbar toolbar; private TabLayout tabLayaout; private ViewPager viewPager; @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); toolbar = (Toolbar) findViewById(R.id.toolbar); tabLayaout = (TabLayout) findViewById(R.id.tabLayout); viewPager = (ViewPager) findViewById(R.id.viewPager); setUpViewPager(); setToolBar(); if (toolbar != null){ setSupportActionBar(toolbar); } } @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu, menu); return super.onCreateOptionsMenu(menu); } @Override public boolean onOptionsItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.itemStrella: Intent intent = new Intent(MainActivity.this, MascotasFavoritas.class); startActivity(intent); return true; case R.id.contacto: Intent intentContacto = new Intent(MainActivity.this, Contacto.class); startActivity(intentContacto); return true; case R.id.acercaDe: Intent intentAcercaDe = new Intent(MainActivity.this, AcercaDe.class); startActivity(intentAcercaDe); return true; default: final boolean b = super.onOptionsItemSelected(item); return b; } } private ArrayList<Fragment> agregarFragments(){ ArrayList<Fragment> fragments = new ArrayList<>(); fragments.add(new RecyclerViewFragment()); fragments.add(new BlankFragment()); return fragments; } private void setUpViewPager(){ viewPager.setAdapter(new PageAdapter(getSupportFragmentManager(), agregarFragments())); tabLayaout.setupWithViewPager(viewPager); } public void setToolBar(){ Toolbar appBar = findViewById(R.id.appBar); setSupportActionBar(appBar); getSupportActionBar().setDisplayShowTitleEnabled(false); tabLayaout.getTabAt(0).setIcon(R.drawable.iconhouse); tabLayaout.getTabAt(1).setIcon(R.drawable.iconpug); } }
00b280d0b0517c632d5f72b78255b6f2fb4fc4ff
2c9e0541ed8a22bcdc81ae2f9610a118f62c4c4d
/harmony/tests/vts/vm/src/test/vm/jvms/classFile/attributes/annotation/annotationDefault/methodinfo12/annotation12p.java
1451c071eb60be850377dca0eafe05ea08ba9371
[ "Apache-2.0", "LicenseRef-scancode-generic-cla" ]
permissive
JetBrains/jdk8u_tests
774de7dffd513fd61458b4f7c26edd7924c7f1a5
263c74f1842954bae0b34ec3703ad35668b3ffa2
refs/heads/master
2023-08-07T17:57:58.511814
2017-03-20T08:13:25
2017-03-20T08:16:11
70,048,797
11
9
null
null
null
null
UTF-8
Java
false
false
1,403
java
/* Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable 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. */ /** * @author Maxim V. Makarov * @version $Revision: 1.1 $ */ package org.apache.harmony.vts.test.vm.jvms.classFile.attributes.annotation.annotationDefault.methodinfo12; import java.lang.annotation.*; import java.lang.reflect.*; public class annotation12p { public int test(String [] args) throws Exception { Class cl = Class.forName("org.apache.harmony.vts.test.vm.jvms.classFile.attributes.annotation.annotationDefault.methodinfo12.annotation12"); Object o = cl.getMethod("value", new Class[]{}).getDefaultValue(); if(((int [])o).length == 1) return 104; return 105; } public static void main(String [] args) throws Exception { System.exit((new annotation12p()).test(args)); } }
a8254db0ddd83ec6c2da7a1e6dc0af2b19a4c8b1
c96a84c9ad4993ea3eae5523c191f410aa6ac118
/src/br/com/wbotelhos/starting/exception/CommonException.java
a0cb0467133459d5ae7bb4526e0798065b618e72
[ "MIT" ]
permissive
faespsenar/vraptor-starting-project
7f4bb36e1b1a6cbc0c8bf3f72a977bcdff6d0055
f3764dc5e36aab5d0aa1ffaab25323d15e5768c7
refs/heads/master
2021-01-18T09:39:59.061910
2011-09-26T00:31:11
2011-09-26T00:31:11
null
0
0
null
null
null
null
UTF-8
Java
false
false
328
java
package br.com.wbotelhos.starting.exception; public class CommonException extends Exception { private static final long serialVersionUID = 5746751520999684832L; public CommonException(String mensagem) { super(mensagem); } public CommonException(String mensagem, Throwable e) { super(mensagem, e); } }
36b3a8d2d8e994d74efb332ed717dacadad9cf15
b89c4f90ed8f4e57cc37c17d4780cf1c720a3953
/app/src/main/java/com/sjz/zyl/appdemo/CrashHandler.java
23d1cb50aa25b8c42fed31f4e4887a001fcb60c3
[]
no_license
AllanJhon/xhz
416c3e3980cc590cbbaf8956330d66bcc1ce7aab
a8ce921a236369e1f43b1292ab762836e6c410c3
refs/heads/master
2021-05-08T14:40:37.948834
2018-02-19T13:19:51
2018-02-19T13:19:51
120,092,241
0
0
null
null
null
null
UTF-8
Java
false
false
5,177
java
/* * Copyright (c) 2014,KJFrameForAndroid Open Source Project,张涛. * * 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.sjz.zyl.appdemo; import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.os.Build; import org.kymjs.kjframe.ui.ViewInject; import org.kymjs.kjframe.utils.FileUtils; import org.kymjs.kjframe.utils.SystemTool; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.PrintWriter; import java.lang.Thread.UncaughtExceptionHandler; /** * UncaughtExceptionHandler:线程未捕获异常控制器是用来处理未捕获异常的。 如果程序出现了未捕获异常默认情况下则会出现强行关闭对话框 * 实现该接口并注册为程序中的默认未捕获异常处理 这样当未捕获异常发生时,就可以做些异常处理操作 例如:收集异常信息,发送错误报告 等。 * UncaughtException处理类,当程序发生Uncaught异常的时候,由该类来接管程序,并记录发送错误报告. <br> * * <b>创建时间</b> 2014-7-2 * * @author kymjs (https://www.kymjs.com/) */ public class CrashHandler implements UncaughtExceptionHandler { private final Context mContext; // log文件的后缀名 public static final String FILE_NAME_SUFFIX = "Xhz.log"; private static CrashHandler sInstance = null; private CrashHandler(Context cxt) { // 将当前实例设为系统默认的异常处理器 Thread.setDefaultUncaughtExceptionHandler(this); // 获取Context,方便内部使用 mContext = cxt; } public synchronized static CrashHandler create(Context cxt) { if (sInstance == null) { sInstance = new CrashHandler(cxt); } return sInstance; } /** * 这个是最关键的函数,当程序中有未被捕获的异常,系统将会自动调用#uncaughtException方法 * thread为出现未捕获异常的线程,ex为未捕获的异常,有了这个ex,我们就可以得到异常信息。 */ @Override public void uncaughtException(Thread thread, final Throwable ex) { // 导出异常信息到SD卡中 try { saveToSDCard(ex); ViewInject.longToast(ex.getMessage()); } catch (Exception e) { } // finally { // // ex.printStackTrace();// 调试时打印日志信息 // System.exit(0); // } } // public static void sendAppCrashReport(final Context context) { // ViewInject.create().getExitDialog(context, // "对不起,小屁孩发脾气了,我们会替你好好教训一下他的。", new OnClickListener() { // @Override // public void onClick(DialogInterface dialog, int which) { // System.exit(-table_frame_gray_xm); // } // }); // } private void saveToSDCard(Throwable ex) throws Exception { File file = FileUtils.getSaveFile(AppConfig.saveFolder, FILE_NAME_SUFFIX); boolean append = false; if (System.currentTimeMillis() - file.lastModified() > 5000) { append = true; } PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter( file, append))); // 导出发生异常的时间 pw.println(SystemTool.getDataTime("yyyy-MM-dd-HH-mm-ss")); // 导出手机信息 dumpPhoneInfo(pw); pw.println(); // 导出异常的调用栈信息 ex.printStackTrace(pw); pw.println(); pw.close(); } private void dumpPhoneInfo(PrintWriter pw) throws NameNotFoundException { // 应用的版本名称和版本号 PackageManager pm = mContext.getPackageManager(); PackageInfo pi = pm.getPackageInfo(mContext.getPackageName(), PackageManager.GET_ACTIVITIES); pw.print("App Version: "); pw.print(pi.versionName); pw.print('_'); pw.println(pi.versionCode); pw.println(); // android版本号 pw.print("OS Version: "); pw.print(Build.VERSION.RELEASE); pw.print("_"); pw.println(Build.VERSION.SDK_INT); pw.println(); // 手机制造商 pw.print("Vendor: "); pw.println(Build.MANUFACTURER); pw.println(); // 手机型号 pw.print("Model: "); pw.println(Build.MODEL); pw.println(); // cpu架构 pw.print("CPU ABI: "); pw.println(Build.CPU_ABI); pw.println(); } }
56dc9e5c772495f38a4107660db79123843225aa
3b34c8ecfa255e95c4595a04ce9480161426b67e
/app/src/main/java/com/ahmetmatematikci/broadcast/MainActivity.java
c0c239b3d537afba38a2f4f3865d0bc9be859fb8
[]
no_license
ahmetmatematikci/BroadCastv4
e7f0d54a89f94694c6efe47b42276b95f42be2b7
d086708f2b9ff6d8aecc2f40d044c6619b35a550
refs/heads/master
2021-01-09T05:45:27.890329
2017-02-03T12:15:16
2017-02-03T12:15:16
80,826,239
1
0
null
null
null
null
UTF-8
Java
false
false
1,146
java
package com.ahmetmatematikci.broadcast; import android.app.ListActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.ArrayAdapter; import android.widget.ListView; public class MainActivity extends ListActivity { String[] sayfalar = {"BroadCast", "Services", "WebTarayici","SMS", "Ses", "VideoOyantici"}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //setContentView(R.layout.activity_main); setListAdapter(new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, sayfalar)); } @Override protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); String sayfa = sayfalar[position]; Class gis ; try { gis = Class.forName("com.ahmetmatematikci.broadcast." + sayfa); Intent i = new Intent(MainActivity.this, gis); startActivity(i); } catch (ClassNotFoundException e) { e.printStackTrace(); } } }
fda797caaa3de591d7846f5bc8add8654ece4a27
fc160694094b89ab09e5c9a0f03db80437eabc93
/java-aiplatform/proto-google-cloud-aiplatform-v1/src/main/java/com/google/cloud/aiplatform/v1/ListModelDeploymentMonitoringJobsRequest.java
b18c91988cb4353b0b29816a0fc78f9b09e13642
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
googleapis/google-cloud-java
4f4d97a145e0310db142ecbc3340ce3a2a444e5e
6e23c3a406e19af410a1a1dd0d0487329875040e
refs/heads/main
2023-09-04T09:09:02.481897
2023-08-31T20:45:11
2023-08-31T20:45:11
26,181,278
1,122
685
Apache-2.0
2023-09-13T21:21:23
2014-11-04T17:57:16
Java
UTF-8
Java
false
false
47,233
java
/* * Copyright 2023 Google LLC * * 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 * * https://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. */ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/cloud/aiplatform/v1/job_service.proto package com.google.cloud.aiplatform.v1; /** * * * <pre> * Request message for * [JobService.ListModelDeploymentMonitoringJobs][google.cloud.aiplatform.v1.JobService.ListModelDeploymentMonitoringJobs]. * </pre> * * Protobuf type {@code google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest} */ public final class ListModelDeploymentMonitoringJobsRequest extends com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest) ListModelDeploymentMonitoringJobsRequestOrBuilder { private static final long serialVersionUID = 0L; // Use ListModelDeploymentMonitoringJobsRequest.newBuilder() to construct. private ListModelDeploymentMonitoringJobsRequest( com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { super(builder); } private ListModelDeploymentMonitoringJobsRequest() { parent_ = ""; filter_ = ""; pageToken_ = ""; } @java.lang.Override @SuppressWarnings({"unused"}) protected java.lang.Object newInstance(UnusedPrivateParameter unused) { return new ListModelDeploymentMonitoringJobsRequest(); } public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return com.google.cloud.aiplatform.v1.JobServiceProto .internal_static_google_cloud_aiplatform_v1_ListModelDeploymentMonitoringJobsRequest_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.cloud.aiplatform.v1.JobServiceProto .internal_static_google_cloud_aiplatform_v1_ListModelDeploymentMonitoringJobsRequest_fieldAccessorTable .ensureFieldAccessorsInitialized( com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest.class, com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest.Builder.class); } public static final int PARENT_FIELD_NUMBER = 1; @SuppressWarnings("serial") private volatile java.lang.Object parent_ = ""; /** * * * <pre> * Required. The parent of the ModelDeploymentMonitoringJob. * Format: `projects/{project}/locations/{location}` * </pre> * * <code> * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * </code> * * @return The parent. */ @java.lang.Override public java.lang.String getParent() { java.lang.Object ref = parent_; if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); parent_ = s; return s; } } /** * * * <pre> * Required. The parent of the ModelDeploymentMonitoringJob. * Format: `projects/{project}/locations/{location}` * </pre> * * <code> * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * </code> * * @return The bytes for parent. */ @java.lang.Override public com.google.protobuf.ByteString getParentBytes() { java.lang.Object ref = parent_; if (ref instanceof java.lang.String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); parent_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } public static final int FILTER_FIELD_NUMBER = 2; @SuppressWarnings("serial") private volatile java.lang.Object filter_ = ""; /** * * * <pre> * The standard list filter. * * Supported fields: * * * `display_name` supports `=`, `!=` comparisons, and `:` wildcard. * * `state` supports `=`, `!=` comparisons. * * `create_time` supports `=`, `!=`,`&lt;`, `&lt;=`,`&gt;`, `&gt;=` comparisons. * `create_time` must be in RFC 3339 format. * * `labels` supports general map functions that is: * `labels.key=value` - key:value equality * `labels.key:* - key existence * * Some examples of using the filter are: * * * `state="JOB_STATE_SUCCEEDED" AND display_name:"my_job_*"` * * `state!="JOB_STATE_FAILED" OR display_name="my_job"` * * `NOT display_name="my_job"` * * `create_time&gt;"2021-05-18T00:00:00Z"` * * `labels.keyA=valueA` * * `labels.keyB:*` * </pre> * * <code>string filter = 2;</code> * * @return The filter. */ @java.lang.Override public java.lang.String getFilter() { java.lang.Object ref = filter_; if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); filter_ = s; return s; } } /** * * * <pre> * The standard list filter. * * Supported fields: * * * `display_name` supports `=`, `!=` comparisons, and `:` wildcard. * * `state` supports `=`, `!=` comparisons. * * `create_time` supports `=`, `!=`,`&lt;`, `&lt;=`,`&gt;`, `&gt;=` comparisons. * `create_time` must be in RFC 3339 format. * * `labels` supports general map functions that is: * `labels.key=value` - key:value equality * `labels.key:* - key existence * * Some examples of using the filter are: * * * `state="JOB_STATE_SUCCEEDED" AND display_name:"my_job_*"` * * `state!="JOB_STATE_FAILED" OR display_name="my_job"` * * `NOT display_name="my_job"` * * `create_time&gt;"2021-05-18T00:00:00Z"` * * `labels.keyA=valueA` * * `labels.keyB:*` * </pre> * * <code>string filter = 2;</code> * * @return The bytes for filter. */ @java.lang.Override public com.google.protobuf.ByteString getFilterBytes() { java.lang.Object ref = filter_; if (ref instanceof java.lang.String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); filter_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } public static final int PAGE_SIZE_FIELD_NUMBER = 3; private int pageSize_ = 0; /** * * * <pre> * The standard list page size. * </pre> * * <code>int32 page_size = 3;</code> * * @return The pageSize. */ @java.lang.Override public int getPageSize() { return pageSize_; } public static final int PAGE_TOKEN_FIELD_NUMBER = 4; @SuppressWarnings("serial") private volatile java.lang.Object pageToken_ = ""; /** * * * <pre> * The standard list page token. * </pre> * * <code>string page_token = 4;</code> * * @return The pageToken. */ @java.lang.Override public java.lang.String getPageToken() { java.lang.Object ref = pageToken_; if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); pageToken_ = s; return s; } } /** * * * <pre> * The standard list page token. * </pre> * * <code>string page_token = 4;</code> * * @return The bytes for pageToken. */ @java.lang.Override public com.google.protobuf.ByteString getPageTokenBytes() { java.lang.Object ref = pageToken_; if (ref instanceof java.lang.String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); pageToken_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } public static final int READ_MASK_FIELD_NUMBER = 5; private com.google.protobuf.FieldMask readMask_; /** * * * <pre> * Mask specifying which fields to read * </pre> * * <code>.google.protobuf.FieldMask read_mask = 5;</code> * * @return Whether the readMask field is set. */ @java.lang.Override public boolean hasReadMask() { return readMask_ != null; } /** * * * <pre> * Mask specifying which fields to read * </pre> * * <code>.google.protobuf.FieldMask read_mask = 5;</code> * * @return The readMask. */ @java.lang.Override public com.google.protobuf.FieldMask getReadMask() { return readMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : readMask_; } /** * * * <pre> * Mask specifying which fields to read * </pre> * * <code>.google.protobuf.FieldMask read_mask = 5;</code> */ @java.lang.Override public com.google.protobuf.FieldMaskOrBuilder getReadMaskOrBuilder() { return readMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : readMask_; } private byte memoizedIsInitialized = -1; @java.lang.Override public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized == 1) return true; if (isInitialized == 0) return false; memoizedIsInitialized = 1; return true; } @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_); } if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(filter_)) { com.google.protobuf.GeneratedMessageV3.writeString(output, 2, filter_); } if (pageSize_ != 0) { output.writeInt32(3, pageSize_); } if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(pageToken_)) { com.google.protobuf.GeneratedMessageV3.writeString(output, 4, pageToken_); } if (readMask_ != null) { output.writeMessage(5, getReadMask()); } getUnknownFields().writeTo(output); } @java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_); } if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(filter_)) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, filter_); } if (pageSize_ != 0) { size += com.google.protobuf.CodedOutputStream.computeInt32Size(3, pageSize_); } if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(pageToken_)) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, pageToken_); } if (readMask_ != null) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(5, getReadMask()); } size += getUnknownFields().getSerializedSize(); memoizedSize = size; return size; } @java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest)) { return super.equals(obj); } com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest other = (com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest) obj; if (!getParent().equals(other.getParent())) return false; if (!getFilter().equals(other.getFilter())) return false; if (getPageSize() != other.getPageSize()) return false; if (!getPageToken().equals(other.getPageToken())) return false; if (hasReadMask() != other.hasReadMask()) return false; if (hasReadMask()) { if (!getReadMask().equals(other.getReadMask())) return false; } if (!getUnknownFields().equals(other.getUnknownFields())) return false; return true; } @java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + PARENT_FIELD_NUMBER; hash = (53 * hash) + getParent().hashCode(); hash = (37 * hash) + FILTER_FIELD_NUMBER; hash = (53 * hash) + getFilter().hashCode(); hash = (37 * hash) + PAGE_SIZE_FIELD_NUMBER; hash = (53 * hash) + getPageSize(); hash = (37 * hash) + PAGE_TOKEN_FIELD_NUMBER; hash = (53 * hash) + getPageToken().hashCode(); if (hasReadMask()) { hash = (37 * hash) + READ_MASK_FIELD_NUMBER; hash = (53 * hash) + getReadMask().hashCode(); } hash = (29 * hash) + getUnknownFields().hashCode(); memoizedHashCode = hash; return hash; } public static com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest parseFrom( java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } public static com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest parseFrom( java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } public static com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest parseFrom( com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } public static com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest parseFrom( com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } public static com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest parseFrom( byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } public static com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest parseFrom( byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } public static com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest parseFrom( java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); } public static com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3.parseWithIOException( PARSER, input, extensionRegistry); } public static com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); } public static com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( PARSER, input, extensionRegistry); } public static com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); } public static com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3.parseWithIOException( PARSER, input, extensionRegistry); } @java.lang.Override public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder() { return DEFAULT_INSTANCE.toBuilder(); } public static Builder newBuilder( com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest prototype) { return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); } @java.lang.Override public Builder toBuilder() { return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); } @java.lang.Override protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { Builder builder = new Builder(parent); return builder; } /** * * * <pre> * Request message for * [JobService.ListModelDeploymentMonitoringJobs][google.cloud.aiplatform.v1.JobService.ListModelDeploymentMonitoringJobs]. * </pre> * * Protobuf type {@code google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest} */ public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements // @@protoc_insertion_point(builder_implements:google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest) com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequestOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return com.google.cloud.aiplatform.v1.JobServiceProto .internal_static_google_cloud_aiplatform_v1_ListModelDeploymentMonitoringJobsRequest_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.cloud.aiplatform.v1.JobServiceProto .internal_static_google_cloud_aiplatform_v1_ListModelDeploymentMonitoringJobsRequest_fieldAccessorTable .ensureFieldAccessorsInitialized( com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest.class, com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest.Builder .class); } // Construct using // com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest.newBuilder() private Builder() {} private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { super(parent); } @java.lang.Override public Builder clear() { super.clear(); bitField0_ = 0; parent_ = ""; filter_ = ""; pageSize_ = 0; pageToken_ = ""; readMask_ = null; if (readMaskBuilder_ != null) { readMaskBuilder_.dispose(); readMaskBuilder_ = null; } return this; } @java.lang.Override public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { return com.google.cloud.aiplatform.v1.JobServiceProto .internal_static_google_cloud_aiplatform_v1_ListModelDeploymentMonitoringJobsRequest_descriptor; } @java.lang.Override public com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest getDefaultInstanceForType() { return com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest .getDefaultInstance(); } @java.lang.Override public com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest build() { com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; } @java.lang.Override public com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest buildPartial() { com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest result = new com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest(this); if (bitField0_ != 0) { buildPartial0(result); } onBuilt(); return result; } private void buildPartial0( com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest result) { int from_bitField0_ = bitField0_; if (((from_bitField0_ & 0x00000001) != 0)) { result.parent_ = parent_; } if (((from_bitField0_ & 0x00000002) != 0)) { result.filter_ = filter_; } if (((from_bitField0_ & 0x00000004) != 0)) { result.pageSize_ = pageSize_; } if (((from_bitField0_ & 0x00000008) != 0)) { result.pageToken_ = pageToken_; } if (((from_bitField0_ & 0x00000010) != 0)) { result.readMask_ = readMaskBuilder_ == null ? readMask_ : readMaskBuilder_.build(); } } @java.lang.Override public Builder clone() { return super.clone(); } @java.lang.Override public Builder setField( com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { return super.setField(field, value); } @java.lang.Override public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { return super.clearField(field); } @java.lang.Override public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { return super.clearOneof(oneof); } @java.lang.Override public Builder setRepeatedField( com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { return super.setRepeatedField(field, index, value); } @java.lang.Override public Builder addRepeatedField( com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { return super.addRepeatedField(field, value); } @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest) { return mergeFrom( (com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest) other); } else { super.mergeFrom(other); return this; } } public Builder mergeFrom( com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest other) { if (other == com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest .getDefaultInstance()) return this; if (!other.getParent().isEmpty()) { parent_ = other.parent_; bitField0_ |= 0x00000001; onChanged(); } if (!other.getFilter().isEmpty()) { filter_ = other.filter_; bitField0_ |= 0x00000002; onChanged(); } if (other.getPageSize() != 0) { setPageSize(other.getPageSize()); } if (!other.getPageToken().isEmpty()) { pageToken_ = other.pageToken_; bitField0_ |= 0x00000008; onChanged(); } if (other.hasReadMask()) { mergeReadMask(other.getReadMask()); } this.mergeUnknownFields(other.getUnknownFields()); onChanged(); return this; } @java.lang.Override public final boolean isInitialized() { return true; } @java.lang.Override public Builder mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } try { boolean done = false; while (!done) { int tag = input.readTag(); switch (tag) { case 0: done = true; break; case 10: { parent_ = input.readStringRequireUtf8(); bitField0_ |= 0x00000001; break; } // case 10 case 18: { filter_ = input.readStringRequireUtf8(); bitField0_ |= 0x00000002; break; } // case 18 case 24: { pageSize_ = input.readInt32(); bitField0_ |= 0x00000004; break; } // case 24 case 34: { pageToken_ = input.readStringRequireUtf8(); bitField0_ |= 0x00000008; break; } // case 34 case 42: { input.readMessage(getReadMaskFieldBuilder().getBuilder(), extensionRegistry); bitField0_ |= 0x00000010; break; } // case 42 default: { if (!super.parseUnknownField(input, extensionRegistry, tag)) { done = true; // was an endgroup tag } break; } // default: } // switch (tag) } // while (!done) } catch (com.google.protobuf.InvalidProtocolBufferException e) { throw e.unwrapIOException(); } finally { onChanged(); } // finally return this; } private int bitField0_; private java.lang.Object parent_ = ""; /** * * * <pre> * Required. The parent of the ModelDeploymentMonitoringJob. * Format: `projects/{project}/locations/{location}` * </pre> * * <code> * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * </code> * * @return The parent. */ public java.lang.String getParent() { java.lang.Object ref = parent_; if (!(ref instanceof java.lang.String)) { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); parent_ = s; return s; } else { return (java.lang.String) ref; } } /** * * * <pre> * Required. The parent of the ModelDeploymentMonitoringJob. * Format: `projects/{project}/locations/{location}` * </pre> * * <code> * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * </code> * * @return The bytes for parent. */ public com.google.protobuf.ByteString getParentBytes() { java.lang.Object ref = parent_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); parent_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } /** * * * <pre> * Required. The parent of the ModelDeploymentMonitoringJob. * Format: `projects/{project}/locations/{location}` * </pre> * * <code> * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * </code> * * @param value The parent to set. * @return This builder for chaining. */ public Builder setParent(java.lang.String value) { if (value == null) { throw new NullPointerException(); } parent_ = value; bitField0_ |= 0x00000001; onChanged(); return this; } /** * * * <pre> * Required. The parent of the ModelDeploymentMonitoringJob. * Format: `projects/{project}/locations/{location}` * </pre> * * <code> * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * </code> * * @return This builder for chaining. */ public Builder clearParent() { parent_ = getDefaultInstance().getParent(); bitField0_ = (bitField0_ & ~0x00000001); onChanged(); return this; } /** * * * <pre> * Required. The parent of the ModelDeploymentMonitoringJob. * Format: `projects/{project}/locations/{location}` * </pre> * * <code> * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * </code> * * @param value The bytes for parent to set. * @return This builder for chaining. */ public Builder setParentBytes(com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } checkByteStringIsUtf8(value); parent_ = value; bitField0_ |= 0x00000001; onChanged(); return this; } private java.lang.Object filter_ = ""; /** * * * <pre> * The standard list filter. * * Supported fields: * * * `display_name` supports `=`, `!=` comparisons, and `:` wildcard. * * `state` supports `=`, `!=` comparisons. * * `create_time` supports `=`, `!=`,`&lt;`, `&lt;=`,`&gt;`, `&gt;=` comparisons. * `create_time` must be in RFC 3339 format. * * `labels` supports general map functions that is: * `labels.key=value` - key:value equality * `labels.key:* - key existence * * Some examples of using the filter are: * * * `state="JOB_STATE_SUCCEEDED" AND display_name:"my_job_*"` * * `state!="JOB_STATE_FAILED" OR display_name="my_job"` * * `NOT display_name="my_job"` * * `create_time&gt;"2021-05-18T00:00:00Z"` * * `labels.keyA=valueA` * * `labels.keyB:*` * </pre> * * <code>string filter = 2;</code> * * @return The filter. */ public java.lang.String getFilter() { java.lang.Object ref = filter_; if (!(ref instanceof java.lang.String)) { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); filter_ = s; return s; } else { return (java.lang.String) ref; } } /** * * * <pre> * The standard list filter. * * Supported fields: * * * `display_name` supports `=`, `!=` comparisons, and `:` wildcard. * * `state` supports `=`, `!=` comparisons. * * `create_time` supports `=`, `!=`,`&lt;`, `&lt;=`,`&gt;`, `&gt;=` comparisons. * `create_time` must be in RFC 3339 format. * * `labels` supports general map functions that is: * `labels.key=value` - key:value equality * `labels.key:* - key existence * * Some examples of using the filter are: * * * `state="JOB_STATE_SUCCEEDED" AND display_name:"my_job_*"` * * `state!="JOB_STATE_FAILED" OR display_name="my_job"` * * `NOT display_name="my_job"` * * `create_time&gt;"2021-05-18T00:00:00Z"` * * `labels.keyA=valueA` * * `labels.keyB:*` * </pre> * * <code>string filter = 2;</code> * * @return The bytes for filter. */ public com.google.protobuf.ByteString getFilterBytes() { java.lang.Object ref = filter_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); filter_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } /** * * * <pre> * The standard list filter. * * Supported fields: * * * `display_name` supports `=`, `!=` comparisons, and `:` wildcard. * * `state` supports `=`, `!=` comparisons. * * `create_time` supports `=`, `!=`,`&lt;`, `&lt;=`,`&gt;`, `&gt;=` comparisons. * `create_time` must be in RFC 3339 format. * * `labels` supports general map functions that is: * `labels.key=value` - key:value equality * `labels.key:* - key existence * * Some examples of using the filter are: * * * `state="JOB_STATE_SUCCEEDED" AND display_name:"my_job_*"` * * `state!="JOB_STATE_FAILED" OR display_name="my_job"` * * `NOT display_name="my_job"` * * `create_time&gt;"2021-05-18T00:00:00Z"` * * `labels.keyA=valueA` * * `labels.keyB:*` * </pre> * * <code>string filter = 2;</code> * * @param value The filter to set. * @return This builder for chaining. */ public Builder setFilter(java.lang.String value) { if (value == null) { throw new NullPointerException(); } filter_ = value; bitField0_ |= 0x00000002; onChanged(); return this; } /** * * * <pre> * The standard list filter. * * Supported fields: * * * `display_name` supports `=`, `!=` comparisons, and `:` wildcard. * * `state` supports `=`, `!=` comparisons. * * `create_time` supports `=`, `!=`,`&lt;`, `&lt;=`,`&gt;`, `&gt;=` comparisons. * `create_time` must be in RFC 3339 format. * * `labels` supports general map functions that is: * `labels.key=value` - key:value equality * `labels.key:* - key existence * * Some examples of using the filter are: * * * `state="JOB_STATE_SUCCEEDED" AND display_name:"my_job_*"` * * `state!="JOB_STATE_FAILED" OR display_name="my_job"` * * `NOT display_name="my_job"` * * `create_time&gt;"2021-05-18T00:00:00Z"` * * `labels.keyA=valueA` * * `labels.keyB:*` * </pre> * * <code>string filter = 2;</code> * * @return This builder for chaining. */ public Builder clearFilter() { filter_ = getDefaultInstance().getFilter(); bitField0_ = (bitField0_ & ~0x00000002); onChanged(); return this; } /** * * * <pre> * The standard list filter. * * Supported fields: * * * `display_name` supports `=`, `!=` comparisons, and `:` wildcard. * * `state` supports `=`, `!=` comparisons. * * `create_time` supports `=`, `!=`,`&lt;`, `&lt;=`,`&gt;`, `&gt;=` comparisons. * `create_time` must be in RFC 3339 format. * * `labels` supports general map functions that is: * `labels.key=value` - key:value equality * `labels.key:* - key existence * * Some examples of using the filter are: * * * `state="JOB_STATE_SUCCEEDED" AND display_name:"my_job_*"` * * `state!="JOB_STATE_FAILED" OR display_name="my_job"` * * `NOT display_name="my_job"` * * `create_time&gt;"2021-05-18T00:00:00Z"` * * `labels.keyA=valueA` * * `labels.keyB:*` * </pre> * * <code>string filter = 2;</code> * * @param value The bytes for filter to set. * @return This builder for chaining. */ public Builder setFilterBytes(com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } checkByteStringIsUtf8(value); filter_ = value; bitField0_ |= 0x00000002; onChanged(); return this; } private int pageSize_; /** * * * <pre> * The standard list page size. * </pre> * * <code>int32 page_size = 3;</code> * * @return The pageSize. */ @java.lang.Override public int getPageSize() { return pageSize_; } /** * * * <pre> * The standard list page size. * </pre> * * <code>int32 page_size = 3;</code> * * @param value The pageSize to set. * @return This builder for chaining. */ public Builder setPageSize(int value) { pageSize_ = value; bitField0_ |= 0x00000004; onChanged(); return this; } /** * * * <pre> * The standard list page size. * </pre> * * <code>int32 page_size = 3;</code> * * @return This builder for chaining. */ public Builder clearPageSize() { bitField0_ = (bitField0_ & ~0x00000004); pageSize_ = 0; onChanged(); return this; } private java.lang.Object pageToken_ = ""; /** * * * <pre> * The standard list page token. * </pre> * * <code>string page_token = 4;</code> * * @return The pageToken. */ public java.lang.String getPageToken() { java.lang.Object ref = pageToken_; if (!(ref instanceof java.lang.String)) { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); pageToken_ = s; return s; } else { return (java.lang.String) ref; } } /** * * * <pre> * The standard list page token. * </pre> * * <code>string page_token = 4;</code> * * @return The bytes for pageToken. */ public com.google.protobuf.ByteString getPageTokenBytes() { java.lang.Object ref = pageToken_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); pageToken_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } /** * * * <pre> * The standard list page token. * </pre> * * <code>string page_token = 4;</code> * * @param value The pageToken to set. * @return This builder for chaining. */ public Builder setPageToken(java.lang.String value) { if (value == null) { throw new NullPointerException(); } pageToken_ = value; bitField0_ |= 0x00000008; onChanged(); return this; } /** * * * <pre> * The standard list page token. * </pre> * * <code>string page_token = 4;</code> * * @return This builder for chaining. */ public Builder clearPageToken() { pageToken_ = getDefaultInstance().getPageToken(); bitField0_ = (bitField0_ & ~0x00000008); onChanged(); return this; } /** * * * <pre> * The standard list page token. * </pre> * * <code>string page_token = 4;</code> * * @param value The bytes for pageToken to set. * @return This builder for chaining. */ public Builder setPageTokenBytes(com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } checkByteStringIsUtf8(value); pageToken_ = value; bitField0_ |= 0x00000008; onChanged(); return this; } private com.google.protobuf.FieldMask readMask_; private com.google.protobuf.SingleFieldBuilderV3< com.google.protobuf.FieldMask, com.google.protobuf.FieldMask.Builder, com.google.protobuf.FieldMaskOrBuilder> readMaskBuilder_; /** * * * <pre> * Mask specifying which fields to read * </pre> * * <code>.google.protobuf.FieldMask read_mask = 5;</code> * * @return Whether the readMask field is set. */ public boolean hasReadMask() { return ((bitField0_ & 0x00000010) != 0); } /** * * * <pre> * Mask specifying which fields to read * </pre> * * <code>.google.protobuf.FieldMask read_mask = 5;</code> * * @return The readMask. */ public com.google.protobuf.FieldMask getReadMask() { if (readMaskBuilder_ == null) { return readMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : readMask_; } else { return readMaskBuilder_.getMessage(); } } /** * * * <pre> * Mask specifying which fields to read * </pre> * * <code>.google.protobuf.FieldMask read_mask = 5;</code> */ public Builder setReadMask(com.google.protobuf.FieldMask value) { if (readMaskBuilder_ == null) { if (value == null) { throw new NullPointerException(); } readMask_ = value; } else { readMaskBuilder_.setMessage(value); } bitField0_ |= 0x00000010; onChanged(); return this; } /** * * * <pre> * Mask specifying which fields to read * </pre> * * <code>.google.protobuf.FieldMask read_mask = 5;</code> */ public Builder setReadMask(com.google.protobuf.FieldMask.Builder builderForValue) { if (readMaskBuilder_ == null) { readMask_ = builderForValue.build(); } else { readMaskBuilder_.setMessage(builderForValue.build()); } bitField0_ |= 0x00000010; onChanged(); return this; } /** * * * <pre> * Mask specifying which fields to read * </pre> * * <code>.google.protobuf.FieldMask read_mask = 5;</code> */ public Builder mergeReadMask(com.google.protobuf.FieldMask value) { if (readMaskBuilder_ == null) { if (((bitField0_ & 0x00000010) != 0) && readMask_ != null && readMask_ != com.google.protobuf.FieldMask.getDefaultInstance()) { getReadMaskBuilder().mergeFrom(value); } else { readMask_ = value; } } else { readMaskBuilder_.mergeFrom(value); } bitField0_ |= 0x00000010; onChanged(); return this; } /** * * * <pre> * Mask specifying which fields to read * </pre> * * <code>.google.protobuf.FieldMask read_mask = 5;</code> */ public Builder clearReadMask() { bitField0_ = (bitField0_ & ~0x00000010); readMask_ = null; if (readMaskBuilder_ != null) { readMaskBuilder_.dispose(); readMaskBuilder_ = null; } onChanged(); return this; } /** * * * <pre> * Mask specifying which fields to read * </pre> * * <code>.google.protobuf.FieldMask read_mask = 5;</code> */ public com.google.protobuf.FieldMask.Builder getReadMaskBuilder() { bitField0_ |= 0x00000010; onChanged(); return getReadMaskFieldBuilder().getBuilder(); } /** * * * <pre> * Mask specifying which fields to read * </pre> * * <code>.google.protobuf.FieldMask read_mask = 5;</code> */ public com.google.protobuf.FieldMaskOrBuilder getReadMaskOrBuilder() { if (readMaskBuilder_ != null) { return readMaskBuilder_.getMessageOrBuilder(); } else { return readMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : readMask_; } } /** * * * <pre> * Mask specifying which fields to read * </pre> * * <code>.google.protobuf.FieldMask read_mask = 5;</code> */ private com.google.protobuf.SingleFieldBuilderV3< com.google.protobuf.FieldMask, com.google.protobuf.FieldMask.Builder, com.google.protobuf.FieldMaskOrBuilder> getReadMaskFieldBuilder() { if (readMaskBuilder_ == null) { readMaskBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< com.google.protobuf.FieldMask, com.google.protobuf.FieldMask.Builder, com.google.protobuf.FieldMaskOrBuilder>( getReadMask(), getParentForChildren(), isClean()); readMask_ = null; } return readMaskBuilder_; } @java.lang.Override public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); } @java.lang.Override public final Builder mergeUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { return super.mergeUnknownFields(unknownFields); } // @@protoc_insertion_point(builder_scope:google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest) } // @@protoc_insertion_point(class_scope:google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest) private static final com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest DEFAULT_INSTANCE; static { DEFAULT_INSTANCE = new com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest(); } public static com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest getDefaultInstance() { return DEFAULT_INSTANCE; } private static final com.google.protobuf.Parser<ListModelDeploymentMonitoringJobsRequest> PARSER = new com.google.protobuf.AbstractParser<ListModelDeploymentMonitoringJobsRequest>() { @java.lang.Override public ListModelDeploymentMonitoringJobsRequest parsePartialFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { Builder builder = newBuilder(); try { builder.mergeFrom(input, extensionRegistry); } catch (com.google.protobuf.InvalidProtocolBufferException e) { throw e.setUnfinishedMessage(builder.buildPartial()); } catch (com.google.protobuf.UninitializedMessageException e) { throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); } catch (java.io.IOException e) { throw new com.google.protobuf.InvalidProtocolBufferException(e) .setUnfinishedMessage(builder.buildPartial()); } return builder.buildPartial(); } }; public static com.google.protobuf.Parser<ListModelDeploymentMonitoringJobsRequest> parser() { return PARSER; } @java.lang.Override public com.google.protobuf.Parser<ListModelDeploymentMonitoringJobsRequest> getParserForType() { return PARSER; } @java.lang.Override public com.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest getDefaultInstanceForType() { return DEFAULT_INSTANCE; } }
b3ab59d6959029edadbf7f0f587d2cb168fe607e
54556275ca0ad0fb4850b92e5921725da73e3473
/src/com/google/common/collect/RegularImmutableSortedMap.java
aff27d5ed278c417cd581863321d6989f1e07aa0
[]
no_license
xSke/CoreServer
f7ea539617c08e4bd2206f8fa3c13c58dfb76d30
d3655412008da22b58f031f4e7f08a6f6940bf46
refs/heads/master
2020-03-19T02:33:15.256865
2018-05-31T22:00:17
2018-05-31T22:00:17
135,638,686
0
0
null
null
null
null
UTF-8
Java
false
false
4,317
java
/* * Decompiled with CFR 0_129. * * Could not load the following classes: * javax.annotation.Nullable */ package com.google.common.collect; import com.google.common.annotations.GwtCompatible; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableAsList; import com.google.common.collect.ImmutableCollection; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMapEntrySet; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.Maps; import com.google.common.collect.RegularImmutableSortedSet; import com.google.common.collect.UnmodifiableIterator; import java.util.Collection; import java.util.Comparator; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.NavigableMap; import java.util.NavigableSet; import java.util.Set; import javax.annotation.Nullable; @GwtCompatible(emulated=true) final class RegularImmutableSortedMap<K, V> extends ImmutableSortedMap<K, V> { private final transient RegularImmutableSortedSet<K> keySet; private final transient ImmutableList<V> valueList; RegularImmutableSortedMap(RegularImmutableSortedSet<K> keySet, ImmutableList<V> valueList) { this.keySet = keySet; this.valueList = valueList; } RegularImmutableSortedMap(RegularImmutableSortedSet<K> keySet, ImmutableList<V> valueList, ImmutableSortedMap<K, V> descendingMap) { super(descendingMap); this.keySet = keySet; this.valueList = valueList; } @Override ImmutableSet<Map.Entry<K, V>> createEntrySet() { return new EntrySet(); } @Override public ImmutableSortedSet<K> keySet() { return this.keySet; } @Override public ImmutableCollection<V> values() { return this.valueList; } @Override public V get(@Nullable Object key) { int index = this.keySet.indexOf(key); return index == -1 ? null : (V)this.valueList.get(index); } private ImmutableSortedMap<K, V> getSubMap(int fromIndex, int toIndex) { if (fromIndex == 0 && toIndex == this.size()) { return this; } if (fromIndex == toIndex) { return RegularImmutableSortedMap.emptyMap(this.comparator()); } return RegularImmutableSortedMap.from(this.keySet.getSubSet(fromIndex, toIndex), this.valueList.subList(fromIndex, toIndex)); } @Override public ImmutableSortedMap<K, V> headMap(K toKey, boolean inclusive) { return this.getSubMap(0, this.keySet.headIndex(Preconditions.checkNotNull(toKey), inclusive)); } @Override public ImmutableSortedMap<K, V> tailMap(K fromKey, boolean inclusive) { return this.getSubMap(this.keySet.tailIndex(Preconditions.checkNotNull(fromKey), inclusive), this.size()); } @Override ImmutableSortedMap<K, V> createDescendingMap() { return new RegularImmutableSortedMap<K, V>((RegularImmutableSortedSet)this.keySet.descendingSet(), this.valueList.reverse(), this); } private class EntrySet extends ImmutableMapEntrySet<K, V> { private EntrySet() { } @Override public UnmodifiableIterator<Map.Entry<K, V>> iterator() { return this.asList().iterator(); } @Override ImmutableList<Map.Entry<K, V>> createAsList() { return new ImmutableAsList<Map.Entry<K, V>>(){ private final ImmutableList<K> keyList; { this.keyList = RegularImmutableSortedMap.this.keySet().asList(); } @Override public Map.Entry<K, V> get(int index) { return Maps.immutableEntry(this.keyList.get(index), RegularImmutableSortedMap.this.valueList.get(index)); } @Override ImmutableCollection<Map.Entry<K, V>> delegateCollection() { return EntrySet.this; } }; } @Override ImmutableMap<K, V> map() { return RegularImmutableSortedMap.this; } } }
44ec664ca88bc58fe3268fb47da2ceff217e572e
712cc04c10f79c7d4c379b1d116d77281f49d885
/core/src/no/dkit/android/ludum/core/game/ai/behaviors/single/OffsetArriveDistanced.java
84b7a5e8032077ef6e1da0527f9c1638c662fa1d
[]
no_license
thecocce/ludum-engine
c2712ee72ff29c3839e349e8d99f227639a3f963
13dec9a49f9d28fcbb0379d8830175d93f9ef40b
refs/heads/master
2020-12-25T12:47:50.964944
2015-08-21T17:38:51
2015-08-21T17:38:51
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,409
java
package no.dkit.android.ludum.core.game.ai.behaviors.single; import com.badlogic.gdx.math.Vector2; import no.dkit.android.ludum.core.game.Config; import no.dkit.android.ludum.core.game.model.body.agent.AgentBody; public class OffsetArriveDistanced extends SingleBehavior { private AgentBody target; protected int num_steps; Vector2 force = new Vector2(); Vector2 offsetVector = new Vector2(); float offset; float dist; float speed; public OffsetArriveDistanced(AgentBody target, float activeDistance, float influence, int steps, float offset) { super(activeDistance, influence); this.target = target; this.num_steps = steps; this.offset = offset; } public Vector2 calculate(AgentBody veh) { if (veh.getBody() == null) return NO_VECTOR; offsetVector.set(veh.position).sub(target.position); offsetVector.nor().scl(this.offset); force.set(target.position).sub(veh.position).add(offsetVector); dist = force.len(); if (dist > getActiveDistance()) return NO_VECTOR; if (dist < Config.EPSILON) return NO_VECTOR; speed = (dist * num_steps) / num_steps; if (speed > veh.getMaxSpeed()) speed = veh.getMaxSpeed(); force.scl(speed / dist); force.sub(veh.getBody().getLinearVelocity()); force.scl(getInfluence()); return force; } }
cfaaee0dbf8f1663a903cc6ccbc446863001273f
a66c5b01a4197ffab758145a1f62280430afd18a
/image_pps/common/com/gaopin/entity/SystemRoleAction.java
844a4c6fade5a3833efdc68c3c20deba57f76b20
[]
no_license
shawnwz/image_portal_springmvc
2b29a5353bcfcf05b64835b7f2746d6312656d00
72182259c1b55f82ddca19700bfc85aec58bbde4
refs/heads/master
2021-09-03T13:28:26.701563
2018-01-09T11:01:36
2018-01-09T11:01:36
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,762
java
/* This file SystemRoleAction.java is part of image_pps . * Copyright © 2015 Gaopin Images. All rights reserved. * This software, including documentation, is protected by copyright controlled by Gaopin Images. All rights are reserved. * Copying, including reproducing, storing, adapting or translating, any or all of this material requires the prior written consent of Gaopin Images. * This material also contains confidential information which may not be disclosed to others without the prior written consent of Gaopin Images. * */ package com.gaopin.entity; import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; /** * SystemRoleAction entity. @author MyEclipse Persistence Tools */ @Entity @Table(name = "system_role_action") public class SystemRoleAction implements java.io.Serializable { // Fields private Integer id; private Integer roleId; private Integer actionId; private Integer creator; private Integer modifier; private Date createTime; private Date updateTime; // Constructors /** default constructor */ public SystemRoleAction() { } /** full constructor */ public SystemRoleAction(Integer roleId, Integer actionId, Integer creator, Integer modifier, Date createTime, Date updateTime) { this.roleId = roleId; this.actionId = actionId; this.creator = creator; this.modifier = modifier; this.createTime = createTime; this.updateTime = updateTime; } // Property accessors @Id @GeneratedValue @Column(name = "id", unique = true, nullable = false) public Integer getId() { return this.id; } public void setId(Integer id) { this.id = id; } @Column(name = "role_id") public Integer getRoleId() { return this.roleId; } public void setRoleId(Integer roleId) { this.roleId = roleId; } @Column(name = "action_id") public Integer getActionId() { return this.actionId; } public void setActionId(Integer actionId) { this.actionId = actionId; } @Column(name = "creator") public Integer getCreator() { return this.creator; } public void setCreator(Integer creator) { this.creator = creator; } @Column(name = "modifier") public Integer getModifier() { return this.modifier; } public void setModifier(Integer modifier) { this.modifier = modifier; } @Column(name = "create_time", length = 0) public Date getCreateTime() { return this.createTime; } public void setCreateTime(Date createTime) { this.createTime = createTime; } @Column(name = "update_time", length = 0) public Date getUpdateTime() { return this.updateTime; } public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; } }
435bcfd60a680b3baed67e7e4eba7208c0ca2c98
45515dd9363185ecbe8bd5a03af6d3ece64013a2
/AssignmentOne/src/com/iu/achilles/FunctionalSample.java
fe311b6d877b87b4731ab9665e73fb08ceb6ef83
[]
no_license
brajaram/applied-algorithms
3f5ab992b3a78de6ca466c8c8c381c3eac045e27
0ac3deed0d6af33417d5edca59e82db98c525e48
refs/heads/master
2021-01-23T19:11:18.998667
2017-11-10T16:19:25
2017-11-10T16:19:25
102,809,217
0
0
null
null
null
null
UTF-8
Java
false
false
417
java
package com.iu.achilles; import java.util.function.Consumer; public class FunctionalSample { public void functionOne(String a, Consumer<String> function) { function.accept(a); } public static void printOne(String s) { System.out.println(s); } public static void main(String[] args) { FunctionalSample obj = new FunctionalSample(); obj.functionOne("hello", FunctionalSample::printOne); } }
170a76054508c50d5da2d64967672bee653d2b4d
93924d068e2a1e3bcdb71ddfd02dc2d54e4e693e
/sivareddy/LargestAndSmallestInArray.java
989416476fb825e07be6b4d1f504ceb189bf2840
[]
no_license
anvesh1891/babai4
89379ca1a68f2ace8575b084f62471db8e657046
c2dfb0f405cd6c841ad9ebf829b9d1c1ddc74421
refs/heads/master
2021-07-07T19:55:27.387161
2019-01-10T09:49:37
2019-01-10T09:49:37
133,390,290
0
1
null
null
null
null
UTF-8
Java
false
false
523
java
package Sample; //TC:O(n).O(logn) not possible for this. public class LargestAndSmallestInArray { public static void findLargestAndSmallest(int[] arr) { int min=arr[0],max=arr[0]; for(int i=1;i<arr.length;i++) { if(min>arr[i]) min=arr[i]; if(max<arr[i]) max=arr[i]; } System.out.println("Smallest element is:"+min); System.out.println("Largest element is:"+max); } public static void main(String[] args) { int[] arr= {1,2345353,-3232,4224523,-35353535}; findLargestAndSmallest(arr); } }
5036c31e7344de453e3442db601566cdbea858ed
2fbaf7af42a7ff19f6d62588106306ecdbfe0766
/NewsServer/src/test/java/com/stackroute/newsapp/controller/NewsControllerTest.java
eff2794bd041a6672dd6a27eebf4a59411a23775
[]
no_license
guttamogain/NewAPP
c56052c90a879d59dd80cc7819aeded830d7ae4b
86484bc1c5096010f8fd2ee2631ca4627eef59f6
refs/heads/master
2020-04-18T12:49:53.112306
2019-02-25T05:55:12
2019-02-25T05:55:12
167,545,527
0
0
null
null
null
null
UTF-8
Java
false
false
6,110
java
package com.stackroute.newsapp.controller; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import java.util.ArrayList; import java.util.List; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import com.fasterxml.jackson.databind.ObjectMapper; import com.stackroute.newsapp.domain.News; import com.stackroute.newsapp.service.NewsService; @WebMvcTest(NewsController.class) public class NewsControllerTest { private MockMvc newsMockMVC; @Mock private NewsService newsService; @InjectMocks NewsController newsController; private List<News> newsSet = new ArrayList<>(); private News news = new News(109876, "author", "title", "description", "url", "urlToImage", "publishedAt", "content", "username"); @Before public void setUp(){ MockitoAnnotations.initMocks(this); newsMockMVC = MockMvcBuilders.standaloneSetup(newsController).build(); news = new News(109876, "author", "title", "description", "url", "urlToImage", "publishedAt", "content", "username"); News news1 = new News(9876, "author", "title1", "description", "url", "urlToImage", "publishedAt", "content", "username"); newsSet.add(news1); News news2 = new News(8765, "author", "title2", "description", "url", "urlToImage", "publishedAt", "content", "username"); News news3 = new News(7654, "author", "title3", "description", "url", "urlToImage", "publishedAt", "content", "username"); News news4 = new News(6543, "author", "title4", "description", "url", "urlToImage", "publishedAt", "content", "username"); News news5 = new News(5432, "author", "title5", "description", "url", "urlToImage", "publishedAt", "content", "username"); //For user3: eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1c2VyMyIsImlhdCI6MTU0ODk0NDMyNX0.DfoA735TswtFG-IXrvuajm18JIfFg4iXINsqa3XvDrI //For admin: eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiIsImlhdCI6MTU0ODk0NjE5N30.Kz6vHWBPp5mIpwtVxBm2YoyVeYX4x3qqvicWN536Uqc newsSet.add(news2); newsSet.add(news3); newsSet.add(news4); newsSet.add(news5); } private static String asJsonString(final Object obj) { try { return new ObjectMapper().writeValueAsString(obj); } catch (Exception e) { throw new RuntimeException(e); } } @Test public void saveNewsTest() throws Exception{ when(newsService.saveNews(news)).thenReturn(true); String token = "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1c2VyMyIsImlhdCI6MTU0ODk0NDMyNX0.DfoA735TswtFG-IXrvuajm18JIfFg4iXINsqa3XvDrI"; newsMockMVC.perform(post("/api/v1/newsservice/news").header("authorization", "Bearer " + token) .contentType(MediaType.APPLICATION_JSON).content(asJsonString(news))) .andExpect(status().isOk()).andDo(print()); verify(newsService, times(1)).saveNews(Mockito.any(News.class)); verifyNoMoreInteractions(newsService); } @Test public void updateNewsTest() throws Exception{ when(newsService.updateNews(Mockito.anyInt(), Mockito.any(News.class))).thenReturn(news); when(newsService.getNewsIdByUsernameAndTitle(Mockito.anyString(), Mockito.anyString())).thenReturn(123); String token = "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1c2VyMyIsImlhdCI6MTU0ODk0NDMyNX0.DfoA735TswtFG-IXrvuajm18JIfFg4iXINsqa3XvDrI"; newsMockMVC.perform(put("/api/v1/newsservice/news/title").header("authorization", "Bearer " + token) .contentType(MediaType.APPLICATION_JSON).content(asJsonString(news))) .andExpect(status().isOk()).andDo(print()); verify(newsService, times(1)).updateNews(Mockito.anyInt(), Mockito.any(News.class)); } @Test public void deleteNewsTest() throws Exception{ when(newsService.deleteNews(Mockito.anyInt())).thenReturn(true); String token = "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1c2VyMyIsImlhdCI6MTU0ODk0NDMyNX0.DfoA735TswtFG-IXrvuajm18JIfFg4iXINsqa3XvDrI"; newsMockMVC.perform(delete("/api/v1/newsservice/news/title").header("authorization", "Bearer " + token) .contentType(MediaType.APPLICATION_JSON).content(asJsonString(news))) .andExpect(status().isOk()).andDo(print()); verify(newsService, times(1)).deleteNews((Mockito.anyInt())); } @Test public void fetchNewsTest() throws Exception{ when(newsService.getNews(Mockito.anyString())).thenReturn(newsSet); String token = "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1c2VyMyIsImlhdCI6MTU0ODk0NDMyNX0.DfoA735TswtFG-IXrvuajm18JIfFg4iXINsqa3XvDrI"; newsMockMVC.perform(get("/api/v1/newsservice/news").header("authorization", "Bearer " + token) .contentType(MediaType.APPLICATION_JSON).content(asJsonString(news))) .andExpect(status().isOk()).andDo(print()); verify(newsService, times(1)).getNews(Mockito.anyString()); } @Test public void fetchNewsTestForExternal() throws Exception{ when(newsService.getNews(Mockito.anyString())).thenReturn(newsSet); String token = "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1c2VyMyIsImlhdCI6MTU0ODk0NDMyNX0.DfoA735TswtFG-IXrvuajm18JIfFg4iXINsqa3XvDrI"; newsMockMVC.perform(get("/api/v1/newsservice/news/external").header("authorization", "Bearer " + token) .contentType(MediaType.APPLICATION_JSON).content(asJsonString(news))) .andExpect(status().isOk()).andDo(print()); verify(newsService, times(1)).getNews(Mockito.anyString()); } }
0a88147072c1c6d39cda6e591161faaac1ae6577
3a8ce5ea32fe07cab693780f590ee72b20d9ff23
/src/model/bo/SinhVienBO.java
1c6d06d6ce4b618a51f8110845ff109b496ab262
[]
no_license
tuvietvan210694/jsp-servlet-sinhvien
d4bfad7220086a783eeca69bfe56e3277d7e4143
cd022d633c0550e12b7baba77ce385215ed6b353
refs/heads/master
2020-05-27T15:01:15.468609
2019-05-26T11:05:29
2019-05-26T11:05:29
188,672,381
0
0
null
null
null
null
UTF-8
Java
false
false
1,256
java
package model.bo; import java.util.ArrayList; import model.bean.SinhVien; import model.dao.SinhVienDAO; /** * SinhVienBO.java * * Version 1.0 * * Date: Jan 19, 2015 * * Copyright * * Modification Logs: * DATE AUTHOR DESCRIPTION * ----------------------------------------------------------------------- * Jan 19, 2015 DaiLV2 Create */ public class SinhVienBO { SinhVienDAO sinhVienDAO = new SinhVienDAO(); public ArrayList<SinhVien> getListSinhVien() { return sinhVienDAO.getListSinhVien(); } public ArrayList<SinhVien> getListSinhVien(String maKhoa) { return sinhVienDAO.getListSinhVien(maKhoa); } public void themSinhVien(String msv, String hoTen, String gioiTinh, String maKhoa) { sinhVienDAO.themSinhVien(msv, hoTen, gioiTinh, maKhoa); } public SinhVien getThongTinSinhVien(String msv) { return sinhVienDAO.getThongTinSinhVien(msv); } public void suaSinhVien(String msv, String hoTen, String gioiTinh, String maKhoa) { sinhVienDAO.suaSinhVien(msv, hoTen, gioiTinh, maKhoa); } public void xoaSinhVien(String msv) { sinhVienDAO.xoaSinhVien(msv); } public ArrayList<SinhVien> getListSinhViens(String ten) { return sinhVienDAO.getListSinhViens(ten); } }
9bd9e9e549a0a877a802b8a0f3209412f72d9f69
4578f89e7ac6ee5f37ae456248845aa7f2bef86d
/Tasks/src/giohji/tasks/model/TasksAdapter.java
ec646d564979112a6f1f3afe585d39130170aa12
[]
no_license
giohji/Tasks
9d4f5628c07b160b10f6d01151a54b7f418e4bd5
5ffde35f296bda02a8d1f411decafb99b48b6015
refs/heads/master
2021-01-01T16:00:06.974224
2011-11-02T14:40:13
2011-11-02T14:40:13
2,695,454
0
0
null
null
null
null
UTF-8
Java
false
false
29,306
java
package giohji.tasks.model; import giohji.tasks.auth.TasksLogin; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringWriter; import java.io.Writer; import java.net.URL; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import oauth.signpost.OAuthConsumer; import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer; import oauth.signpost.exception.OAuthCommunicationException; import oauth.signpost.exception.OAuthExpectationFailedException; import oauth.signpost.exception.OAuthMessageSignerException; import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpDelete; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPut; import org.apache.http.client.params.HttpClientParams; import org.apache.http.entity.BufferedHttpEntity; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.params.BasicHttpParams; import org.apache.http.params.HttpParams; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.util.Log; /** * Class used to make API calls to the Google Data API to request for Tasks feeds. */ public final class TasksAdapter { /** The TAG. */ private static final String TAG = "TasksAdapter"; /** The Constant BASE_URL. */ private static final String BASE_URL = "https://www.googleapis.com/tasks/v1"; /** The Constant GET_TASK_LISTS. */ private static final String GET_TASK_LISTS = "/users/@me/lists"; /** The Constant GET_TASK_PREFIX. */ private static final String LISTS_PREFIX = "/lists/"; /** The Constant GET_TASK_SUFIX. */ private static final String GET_TASK_SUFIX = "/tasks"; /** The Constant GET_TASK_SUFIX. */ private static final String MOVE_TASK_SUFIX = "/move"; /** The Constant CLEAR_COMPLETED_SUFIX. */ private static final String CLEAR_COMPLETED_SUFIX = "/clear"; /** The Http Response code OK. */ private static final int CODE_OK = 200; /** The Http Response code NO_CONTENT. */ private static final int CODE_NO_CONTENT = 204; /** The location field in the redirect Header. */ private static final String LOCATION = "location"; /** The app secret */ private String mSecret; /** The access token */ private String mToken; /** The singleton. */ private static TasksAdapter singleton; public static void initialize(final String secret, final String token) { synchronized (TasksAdapter.class) { singleton = new TasksAdapter(secret, token); } } /** * Gets the adapter. * * @return the adapter */ public static TasksAdapter getAdapter() { synchronized (TasksAdapter.class) { return singleton; } } /** * Instantiates a new tasks adapter. Private Method used by Singleton */ private TasksAdapter(final String secret, final String token) { mSecret = secret; mToken = token; } /** * Gets all TasksList from the calendar/tasks user account stored in SimpleSettingsManager. * @return * an ArrayList containing all user TasksList. */ public List<TaskList> getTaskList() { final OAuthConsumer consumer = new CommonsHttpOAuthConsumer(TasksLogin.CONSUMER_KEY, TasksLogin.CONSUMER_SECRET); setAuthToken(consumer); List<TaskList> taskLists = null; try { URL url = new URL(BASE_URL + GET_TASK_LISTS); //Set redirect parameter to false so we can // handle the redirection and re-sign the request final HttpParams params = new BasicHttpParams(); HttpClientParams.setRedirecting(params, false); Header locationHeader; HttpResponse response; do { final HttpGet req = new HttpGet(url.toString()); req.setParams(params); // Sign the request with the authenticated token consumer.sign(req); // Send the request final HttpClient httpClient = new DefaultHttpClient(); response = httpClient.execute(req); //Google tasks redirects and appends a gsessionid query string //so we need to re-sign the request. locationHeader = response.getFirstHeader(LOCATION); if (locationHeader != null) { url = new URL(locationHeader.getValue()); } } while (locationHeader != null); final HttpEntity entity = response.getEntity(); final BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity); final InputStream input = bufHttpEntity.getContent(); final String taskListsStream = convertStreamToString(input); input.close(); //we need to parse the response and store it in the model. Log.d("GET_TASK_LISTS", taskListsStream); taskLists = parseTaskLists(taskListsStream); } catch (IOException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } catch (OAuthExpectationFailedException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } catch (OAuthCommunicationException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } catch (OAuthMessageSignerException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } return taskLists; } /** * Parses the user taskLists. * * @param userPhotosJSON * the Input Stream with the user photo list. */ private List<TaskList> parseTaskLists(final String taskListsJSON) { JSONObject rawObject; final ArrayList<TaskList> taskLists = new ArrayList<TaskList>(); try { rawObject = new JSONObject(taskListsJSON); final JSONArray entryArray = rawObject.getJSONArray("items"); for (int i = 0; i < entryArray.length(); i++) { final JSONObject taskListObject = entryArray.getJSONObject(i); final TaskList taskList = new TaskList( taskListObject.getString("id"), taskListObject.getString("title"), taskListObject.getString("selfLink") ); taskLists.add(taskList); } } catch (JSONException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } return taskLists; } /** * Gets all tasks in the TaskList with taskListId. * @param taskListId * the TaskList id. * @return * an ArrayList with all the tasks from the TaskList with taskListId */ public List<Task> getTasks(final String taskListId) { List<Task> tasks = null; final OAuthConsumer consumer = new CommonsHttpOAuthConsumer( TasksLogin.CONSUMER_KEY, TasksLogin.CONSUMER_SECRET); setAuthToken(consumer); try { URL url = new URL(BASE_URL + LISTS_PREFIX + taskListId + GET_TASK_SUFIX); final HttpParams params = new BasicHttpParams(); HttpClientParams.setRedirecting(params, false); Header locationHeader; HttpResponse response; do { final HttpGet req = new HttpGet(url.toString()); //Set redirect parameter to false so we can // handle the redirection and re-sign the request req.setParams(params); // Sign the request with the authenticated token consumer.sign(req); // Send the request final HttpClient httpClient = new DefaultHttpClient(); response = httpClient.execute(req); //Google tasks redirects and appends a gsessionid query string //so we need to re-sign the request. locationHeader = response.getFirstHeader(LOCATION); if (locationHeader != null) { url = new URL(locationHeader.getValue()); } } while (locationHeader != null); final HttpEntity entity = response.getEntity(); final BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity); final InputStream input = bufHttpEntity.getContent(); final String tasksStream = convertStreamToString(input); input.close(); Log.d("GetTasks:", tasksStream); tasks = parseTasks(tasksStream); } catch (IOException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } catch (OAuthExpectationFailedException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } catch (OAuthCommunicationException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } catch (OAuthMessageSignerException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } return tasks; } /** * Parses the tasks. * * @param tasksJSON * the Input Stream with all the tasks. */ private List<Task> parseTasks(final String tasksJSON) { JSONObject rawObject; final ArrayList<Task> tasks = new ArrayList<Task>(); try { rawObject = new JSONObject(tasksJSON); if (rawObject.has("items")) { final JSONArray entryArray = rawObject.getJSONArray("items"); for (int i = 0; i < entryArray.length(); i++) { final JSONObject taskObject = entryArray.getJSONObject(i); final Task task = new Task( taskObject.getString("id"), taskObject.getString("title"), DateParsingUtil.parseDate(taskObject.optString("updated", null)), taskObject.getString("selfLink"), taskObject.optString("parent", null), taskObject.optString("position", null), taskObject.optString("notes", null), taskObject.getString("status"), DateParsingUtil.parseDate(taskObject.optString("due", null)), DateParsingUtil.parseDate(taskObject.optString("completed", null)), taskObject.optBoolean("deleted", false), taskObject.optBoolean("hidden", false)); tasks.add(task); } } } catch (JSONException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } return tasks; } /** * Clear all completed tasks from the TaskList with taskListId. * @param taskListId * the TaskList id. * @return * true if the TaskList was cleared successfully. */ public Boolean clearCompleted(final String taskListId) { Boolean cleared = false; final OAuthConsumer consumer = new CommonsHttpOAuthConsumer( TasksLogin.CONSUMER_KEY, TasksLogin.CONSUMER_SECRET); setAuthToken(consumer); try { URL url = new URL(BASE_URL + LISTS_PREFIX + taskListId + CLEAR_COMPLETED_SUFIX); final HttpParams params = new BasicHttpParams(); HttpClientParams.setRedirecting(params, false); Header locationHeader; HttpResponse response; do { final HttpPost req = new HttpPost(url.toString()); //Set redirect parameter to false so we can // handle the redirection and re-sign the request req.setParams(params); // Sign the request with the authenticated token consumer.sign(req); // Send the request final HttpClient httpClient = new DefaultHttpClient(); response = httpClient.execute(req); //Google tasks redirects and appends a gsessionid query string //so we need to re-sign the request. locationHeader = response.getFirstHeader(LOCATION); if (locationHeader != null) { url = new URL(locationHeader.getValue()); } } while (locationHeader != null); if (response.getStatusLine().getStatusCode() == CODE_OK || response.getStatusLine().getStatusCode() == CODE_NO_CONTENT) { cleared = true; } } catch (IOException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } catch (OAuthExpectationFailedException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } catch (OAuthCommunicationException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } catch (OAuthMessageSignerException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } return cleared; } /** * Delete the task with the taskSelfLink. * @param taskSelfLink * the task selfLink * @return * true if the task was deleted successfully */ public Boolean deleteTask(final String taskSelfLink) { Boolean deleted = false; final OAuthConsumer consumer = new CommonsHttpOAuthConsumer( TasksLogin.CONSUMER_KEY, TasksLogin.CONSUMER_SECRET); setAuthToken(consumer); try { URL url = new URL(taskSelfLink); final HttpParams params = new BasicHttpParams(); HttpClientParams.setRedirecting(params, false); Header locationHeader; HttpResponse response; do { final HttpDelete req = new HttpDelete(url.toString()); //Set redirect parameter to false so we can // handle the redirection and re-sign the request req.setParams(params); // Sign the request with the authenticated token consumer.sign(req); // Send the request final HttpClient httpClient = new DefaultHttpClient(); response = httpClient.execute(req); //Google tasks redirects and appends a gsessionid query string //so we need to re-sign the request. locationHeader = response.getFirstHeader(LOCATION); if (locationHeader != null) { url = new URL(locationHeader.getValue()); } } while (locationHeader != null); if (response.getStatusLine().getStatusCode() == CODE_OK || response.getStatusLine().getStatusCode() == CODE_NO_CONTENT) { deleted = true; } } catch (IOException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } catch (OAuthExpectationFailedException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } catch (OAuthCommunicationException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } catch (OAuthMessageSignerException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } return deleted; } /** * Move the task with selfLink=targetTaskLink to the parent with id=parentTaskLink and * and after the task with id=previousTaskLink. * @param targetTaskLink * The selfLink of the Task to be moved. * @param parentTaskId * The id of the parent Task, the Task will be moved to the root if parentTaskLink * is null. * @param previousTaskId * The id of the previous Task, the Task will be moved to the first position if * previousTaskId is null. * @return * true is the Task was moved successfully. */ public Boolean moveTask( final String targetTaskLink, final String parentTaskId, final String previousTaskId) { Boolean moved = false; final OAuthConsumer consumer = new CommonsHttpOAuthConsumer( TasksLogin.CONSUMER_KEY, TasksLogin.CONSUMER_SECRET); setAuthToken(consumer); String parameters = ""; Boolean firstParam = true; if (parentTaskId != null || previousTaskId != null) { parameters = "?"; if (parentTaskId != null) { firstParam = false; parameters = parameters.concat("parent=" + parentTaskId); } if (previousTaskId != null) { if (firstParam) { parameters = parameters.concat("previous=" + previousTaskId); } else { parameters = parameters.concat("&previous=" + previousTaskId); } } } try { URL url = new URL(targetTaskLink + MOVE_TASK_SUFIX + parameters); final HttpParams params = new BasicHttpParams(); HttpClientParams.setRedirecting(params, false); Header locationHeader; HttpResponse response; do { final HttpPost req = new HttpPost(url.toString()); //Set redirect parameter to false so we can // handle the redirection and re-sign the request req.setParams(params); // Sign the request with the authenticated token consumer.sign(req); // Send the request final HttpClient httpClient = new DefaultHttpClient(); response = httpClient.execute(req); //Google tasks redirects and appends a gsessionid query string //so we need to re-sign the request. locationHeader = response.getFirstHeader(LOCATION); if (locationHeader != null) { url = new URL(locationHeader.getValue()); } } while (locationHeader != null); if (response.getStatusLine().getStatusCode() == CODE_OK || response.getStatusLine().getStatusCode() == CODE_NO_CONTENT) { moved = true; } } catch (IOException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } catch (OAuthExpectationFailedException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } catch (OAuthCommunicationException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } catch (OAuthMessageSignerException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } return moved; } /** * Updates the modifications in the task. * @param task * the modified task to be updated. * @return * true if the update was successful. */ public Boolean updateTask(final Task task) { Boolean updated = false; final OAuthConsumer consumer = new CommonsHttpOAuthConsumer( TasksLogin.CONSUMER_KEY, TasksLogin.CONSUMER_SECRET); setAuthToken(consumer); try { URL url = new URL(task.getSelfLink()); final HttpParams params = new BasicHttpParams(); HttpClientParams.setRedirecting(params, false); Header locationHeader; HttpResponse response; //create the JSON request body to update the Task final StringEntity stringEntity = new StringEntity(task.getJSONObject().toString(), "UTF-8"); do { final HttpPut req = new HttpPut(url.toString()); //Set redirect parameter to false so we can // handle the redirection and re-sign the request req.setParams(params); //set the request body req.setEntity(stringEntity); //set the content type header to JSON format req.addHeader("Content-Type", "application/json"); // Sign the request with the authenticated token consumer.sign(req); // Send the request final HttpClient httpClient = new DefaultHttpClient(); response = httpClient.execute(req); //Google tasks redirects and appends a gsessionid query string //so we need to re-sign the request. locationHeader = response.getFirstHeader(LOCATION); if (locationHeader != null) { url = new URL(locationHeader.getValue()); } } while (locationHeader != null); if (response.getStatusLine().getStatusCode() == CODE_OK || response.getStatusLine().getStatusCode() == CODE_NO_CONTENT) { updated = true; } final HttpEntity entity = response.getEntity(); final BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity); final InputStream input = bufHttpEntity.getContent(); final String taskListsStream = convertStreamToString(input); input.close(); Log.d("UPDATE_TASK", taskListsStream); } catch (IOException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } catch (OAuthExpectationFailedException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } catch (OAuthCommunicationException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } catch (OAuthMessageSignerException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } catch (JSONException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } return updated; } /** * Creates a task in the specified taskListId. * @param title * the title of the new task. * @param notes * the notes of the new task. * @param due * the deadline of the new task. * @param taskListId * the taskListId to add the task. * @param parentTaskId * the parent of the new task (if null the task will be created in the root). * @param previousTaskId * the previous task of the new task (if null the task will be the first in its parent). * @return */ public Boolean createTask( final String title, final String notes, final Date due, final String taskListId, final String parentTaskId, final String previousTaskId) { Boolean created = false; final OAuthConsumer consumer = new CommonsHttpOAuthConsumer( TasksLogin.CONSUMER_KEY, TasksLogin.CONSUMER_SECRET); setAuthToken(consumer); String parameters = ""; Boolean firstParam = true; if (parentTaskId != null || previousTaskId != null) { parameters = "?"; if (parentTaskId != null) { firstParam = false; parameters = parameters.concat("parent=" + parentTaskId); } if (previousTaskId != null) { if (firstParam) { parameters = parameters.concat("previous=" + previousTaskId); } else { parameters = parameters.concat("&previous=" + previousTaskId); } } } try { URL url = new URL(BASE_URL + LISTS_PREFIX + taskListId + GET_TASK_SUFIX + parameters); Log.d("CREATE_TASK", url.toString()); final HttpParams params = new BasicHttpParams(); HttpClientParams.setRedirecting(params, false); Header locationHeader; HttpResponse response; //creating the JSONObject to build the request body. final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); final JSONObject taskJSON = new JSONObject(); taskJSON.put("title", title); if (notes != null) { taskJSON.put("notes", notes); } if (due != null) { taskJSON.put("due", sdf.format(due)); } //create the JSON request body to update the Task final StringEntity stringEntity = new StringEntity(taskJSON.toString(), "UTF-8"); do { final HttpPost req = new HttpPost(url.toString()); //Set redirect parameter to false so we can // handle the redirection and re-sign the request req.setParams(params); //set the request body req.setEntity(stringEntity); //set the content type header to JSON format req.addHeader("Content-Type", "application/json"); // Sign the request with the authenticated token consumer.sign(req); // Send the request final HttpClient httpClient = new DefaultHttpClient(); response = httpClient.execute(req); //Google tasks redirects and appends a gsessionid query string //so we need to re-sign the request. locationHeader = response.getFirstHeader(LOCATION); if (locationHeader != null) { url = new URL(locationHeader.getValue()); } } while (locationHeader != null); if (response.getStatusLine().getStatusCode() == CODE_OK || response.getStatusLine().getStatusCode() == CODE_NO_CONTENT) { created = true; } final HttpEntity entity = response.getEntity(); final BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity); final InputStream input = bufHttpEntity.getContent(); final String taskListsStream = convertStreamToString(input); input.close(); Log.d("UPDATE_TASK", taskListsStream); } catch (IOException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } catch (OAuthExpectationFailedException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } catch (OAuthCommunicationException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } catch (OAuthMessageSignerException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } catch (JSONException e) { Log.e(TAG, e.getClass().getName() + e.getMessage()); } return created; } /** * Sets the auth token. */ private void setAuthToken(final OAuthConsumer consumer) { consumer.setTokenWithSecret(mToken, mSecret); } /** * Convert stream to string. * * @param inputStream * the Input Stream * @return the string * @throws IOException * Signals that an I/O exception has occurred. */ public String convertStreamToString(final InputStream inputStream) throws IOException { String convertedString = ""; /* * To convert the InputStream to String we use the Reader.read(char[] buffer) method. We * iterate until the Reader return -1 which means there's no more data to read. We use the * StringWriter class to produce the string. */ if (inputStream != null) { final Writer writer = new StringWriter(); final char[] buffer = new char[1024]; try { final Reader reader = new BufferedReader( new InputStreamReader(inputStream, "UTF-8")); int charNo = reader.read(buffer); while (charNo != -1) { writer.write(buffer, 0, charNo); charNo = reader.read(buffer); } } finally { inputStream.close(); } convertedString = writer.toString(); } return convertedString; } }
35627fa2de731694f28d74455929cdf027d79703
2d472124f7af68bf63700eeeab82b32c2ea730df
/4_10/src/www/bittech/Interview.java
5d57454237790cb930373f7f9a9173f3428060b2
[]
no_license
Celine-lzl/java
094756331e94f1ba874d37bd854a0940430ac8b0
46c729dd7465f0ba3da0237f82470a04b5479777
refs/heads/master
2022-07-08T07:48:30.579817
2019-09-13T10:59:11
2019-09-13T10:59:11
173,115,411
0
0
null
2022-06-21T01:38:05
2019-02-28T13:18:08
Java
UTF-8
Java
false
false
4,391
java
package www.bittech; public class Interview { public static class ListNode { int val; ListNode next; ListNode(int x) { val = x; } } private static class Solution { public ListNode removeElements(ListNode head, int val) { ListNode result = null; // 结果链表,没有结点 ListNode last = null; // 记录结果链表的最后一个结点 ListNode cur = head; while (cur != null) { ListNode next = cur.next; if (cur.val != val) { // 把 cur 结点尾插到 result 链表上 // 尾插 cur.next = null; if (result == null) { result = cur; } else { last.next = cur; } // 尾插结束 // 更新结果链表的最后一个结点 last = cur; } cur = next; } return result; } public ListNode removeElements2(ListNode head, int val) { if (head == null) { return null; } ListNode cur = head; while (cur.next != null) { if (cur.next.val != val) { cur = cur.next; } else { cur.next = cur.next.next; } } if (head.val == val) { return head.next; } else { return head; } } } public ListNode reverseList(ListNode head) { ListNode result = null; // 结果链表 ListNode cur = head; while (cur != null) { ListNode next = cur.next; cur.next = result; result = cur; cur = next; } return result; } public ListNode mergeTwoLists(ListNode l1, ListNode l2) { if (l1 == null) { return l2; } if (l2 == null) { return l1; } ListNode cur1 = l1; ListNode cur2 = l2; ListNode result = null; // 结果链表的第一个结点 ListNode last = null; // 记录结果链表的最后一个结点 while (cur1 != null && cur2 != null) { if (cur1.val <= cur2.val) { // 1. 让 cur1 可以在运行后执行 原 cur1 的下一个结点 // 2. 让 cur1 尾插到 [result, last] 链表上 // 3. 更新 last ListNode next = cur1.next; // 把 cur1 尾插到 result 上 cur1.next = null; if (result == null) { // result 链表中没有结点 result = cur1; } else { // result 链表中有结点 last.next = cur1; } last = cur1; // 更新最后一个结点记录 cur1 = next; } else { ListNode next = cur2.next; // 把 cur2 尾插到 result 上 cur2.next = null; if (result == null) { result = cur2; } else { last.next = cur2; } last = cur2; cur2 = next; } } if (cur1 != null) { last.next = cur1; } if (cur2 != null) { last.next = cur2; } return result; } public static void main(String[] args) { ListNode n1 = new ListNode(1); ListNode n2 = new ListNode(2); ListNode n3 = new ListNode(6); ListNode n4 = new ListNode(3); ListNode n5 = new ListNode(4); ListNode n6 = new ListNode(5); ListNode n7 = new ListNode(6); n1.next = n2; n2.next = n3; n3.next = n4; n4.next = n5; n5.next = n6; n6.next = n7; n7.next = null; Solution solution = new Solution(); ListNode result = solution.removeElements(n1, 6); ListNode cur = result; while (cur != null) { System.out.println(cur.val); cur = cur.next; } } }
b8e2ec2e9117ac990d2715f5c46196e21099701b
e6490e35633674c9ee2db2657c6aee223b4e21c6
/app/src/main/java/br/com/cpmh/plus/logistical/StorageOrdersFragment.java
10e19328a7ad1c21f003fc791526061086beea4e
[]
no_license
DiegoSouzadeAndrade/cpmh-android-cpmhplus-client
e0713c620c97e5284a1474c6478588462e97c5eb
836fa5885d098edb234b3331dd28d4e3f32266d7
refs/heads/master
2021-05-25T17:18:51.358712
2020-04-07T15:44:41
2020-04-07T15:44:41
253,839,867
0
0
null
null
null
null
UTF-8
Java
false
false
2,890
java
package br.com.cpmh.plus.logistical; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.google.firebase.firestore.EventListener; import com.google.firebase.firestore.FirebaseFirestore; import com.google.firebase.firestore.FirebaseFirestoreException; import com.google.firebase.firestore.Query; import com.google.firebase.firestore.QueryDocumentSnapshot; import com.google.firebase.firestore.QuerySnapshot; import java.util.ArrayList; import java.util.List; import br.com.cpmh.plus.R; import br.com.cpmh.plus.sales.orders.Order; /** * A simple {@link Fragment} subclass. */ public class StorageOrdersFragment extends Fragment implements EventListener<QuerySnapshot> { private static final String TAG = "StorageOrdersFragment"; private FirebaseFirestore firestore; private List<Order> orderList; private StorageOrdersAdapter storageOrdersAdapter; private RecyclerView recyclerView; public StorageOrdersFragment() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_storage_orders, container, false); } public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); firestore = FirebaseFirestore.getInstance(); orderList = new ArrayList<>(); storageOrdersAdapter = new StorageOrdersAdapter(orderList); recyclerView = view.findViewById(R.id.recycler_view); recyclerView.setAdapter(storageOrdersAdapter); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); retrieveOrders(); } public void retrieveOrders() { firestore.collection("orders").whereEqualTo("finished",false).whereEqualTo("stage","Logistica").addSnapshotListener(this); } @Override public void onEvent(@javax.annotation.Nullable QuerySnapshot snapshot, @javax.annotation.Nullable FirebaseFirestoreException exception) { if (exception != null) { Log.w(TAG, "Listen failed.", exception); return; } else { for (QueryDocumentSnapshot documentSnapshot : snapshot) { orderList.add(documentSnapshot.toObject(Order.class)); } storageOrdersAdapter.notifyDataSetChanged(); } } }
e90dd4cf445d0c710188be7af75afee96444f836
7da0c35a466eddce3c66c0a3504cf5422b729641
/SLSessionBean/ejbModule/com/hcl/LCalculator.java
be39fb41b5f58071713e012583421e4be9c1e08d
[]
no_license
manishik/MyWS
344c44b5a326efad934c1a9d4cce66c27b75aa8f
6f7ae6f465ab03ac624c0a87253c6662ae8b5a7a
refs/heads/master
2020-12-29T18:45:38.927782
2020-01-14T23:11:06
2020-01-14T23:11:06
54,737,957
1
0
null
null
null
null
UTF-8
Java
false
false
114
java
package com.hcl; import javax.ejb.Local; @Local public interface LCalculator { public int add(int a,int b); }
66d2f78755b0e72b722545f79bbd31cde5e1c583
7d95e6fa948fec6a6bba801e5cf19be46cba6dc4
/src/algorithm1/asdaa.java
8701aee01f66d2adcc1afb5c908f62bd3b4f953b
[]
no_license
13120269250/Algorithm
397a648559d9162676f05111912a343ba35af340
b96fc931adfa603f0b7723db54c39ced8d0c3ea4
refs/heads/master
2021-09-03T21:19:40.651620
2018-01-12T03:14:26
2018-01-12T03:14:26
null
0
0
null
null
null
null
UTF-8
Java
false
false
611
java
package algorithm1; public class asdaa { public static void main(String[] args) { // TODO Auto-generated method stub System.out.println(numDistinct("abcbbbbc","abc")); } public static int numDistinct(String S, String T) { if (S.length() == 0) { return T.length() == 0 ? 1 : 0; } if (T.length() == 0) { return 1; } int cnt = 0; for (int i = 0; i < S.length(); i++) { if (S.charAt(i) == T.charAt(0)) { cnt += numDistinct(S.substring(i + 1), T.substring(1)); } } return cnt; } }
05056573549ab696a3022d668086a8a4e33118e8
af554a16be1cf436bc98cbff71e31bda28e66a18
/src/test/java/com/techproed/Question05.java
74c0304c223cb956d657298bcdb7959288d97edb
[]
no_license
nildembay/SeleniumOfiiceMaven
01f1f714f346acd2eee11a9c7fda5b6c27837b56
2854eec7d967d564c7087484229fc2ec36b6c53a
refs/heads/master
2023-02-03T07:44:01.399740
2020-12-20T21:30:35
2020-12-20T21:30:35
320,924,261
0
0
null
null
null
null
UTF-8
Java
false
false
1,058
java
package com.techproed; /* Google'a gidelim LOgosunun görünüp görünmediğini assert edelim */ import io.github.bonigarcia.wdm.WebDriverManager; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; public class Question05 { static WebDriver driver; @BeforeClass public static void setUp() { WebDriverManager.chromedriver().setup(); driver = new ChromeDriver(); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); } @Test public void test1() { driver.get("https://www.google.com"); WebElement logo=driver.findElement(By.id("hplogo")); Assert.assertTrue(logo.isDisplayed()); } @AfterClass public static void tearDown(){ driver.quit(); } }
892eee36c2785bee0d867a313265ae3e8ff14406
26d4ae226b14dac096f8fea572e5798319424fc2
/unsupported_project/RailwayBookingHelper/src/railwaybookinghelper/RailwayBookingHelper.java
d59aa8c9a39a61ec524886c53bc42b5d5e26e720
[]
no_license
jasperyen/java-examples
cf1722f1dcf5b6751a0278cc64d7f6389c775efc
ca37ee5515c8a6f70d489381223f4f94c5e8571f
refs/heads/master
2021-01-20T00:36:37.497207
2018-11-06T18:09:41
2018-11-06T18:09:41
89,157,271
0
0
null
null
null
null
UTF-8
Java
false
false
1,429
java
/* * 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 railwaybookinghelper; import static java.lang.System.out; import java.util.Scanner; /** * * @author Jasper */ public class RailwayBookingHelper { public static void main(String[] args) { //getManyImg(); RailwayDemo(); } static void RailwayDemo(){ Scanner console = new Scanner(System.in); while(true) { out.println("Please choose(0 to End) : 1.預約定票 2.定時搜尋剩餘車票"); switch (console.nextInt()){ case 0 : break; case 1 : TicketByNo ticketbyno = new TicketByNo(); break; case 2 : out.println("Unfinished :(\n"); break; default : continue; } break; } } static void getManyImg(){ try { //大量抓取驗證碼 getImg g = new getImg(); } catch (Exception ex) { ex.printStackTrace(); } } }
e7233c3a7307332f718bbe0f780c877d215ab68a
c35e2275cb42520c4d659c9cd057db2fbde89c2e
/src/main/java/com/java/web/solutionhub/config/jwt/service/CustomUserDetailService.java
3ddb8029284b9943d27bb69951a8c5e4600ac2c8
[]
no_license
SecuritySolutionHub/BackEnd
9bf00b5b2b280e9dad2d2ec1a56256c2e1cdf91e
7a291f7159c9be673e1e7cb2ebf845b7cb7d31fb
refs/heads/main
2023-08-22T13:04:21.964478
2021-10-04T16:45:13
2021-10-04T16:45:13
367,581,101
0
0
null
2021-10-04T16:45:14
2021-05-15T08:41:44
CSS
UTF-8
Java
false
false
832
java
package com.java.web.solutionhub.config.jwt.service; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.stereotype.Service; import com.java.web.solutionhub.member.repository.MemberRepository; import lombok.RequiredArgsConstructor; @Service @RequiredArgsConstructor public class CustomUserDetailService implements UserDetailsService{ private final MemberRepository memberRepository; @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { return (UserDetails) memberRepository.findByUserId(username) .orElseThrow(() -> new UsernameNotFoundException("Can't find user")); } }
25f4c3be06fe60aadef676dc2c9e39732aa28b42
6343948bce78fe90d1bae6391c33e460ad5c6de9
/23_Shop/src/com/shop/service/ProdPicsService.java
b1f0b8c3a28c4c2c986c2f201884f0172c9d45f1
[]
no_license
collinchou/FFF
f189017db66244e68538c7162237245819ff4c16
6a860530ec58cbc8f26f242b9f9758835e15aa60
refs/heads/main
2023-07-13T21:45:31.715864
2021-08-21T15:01:29
2021-08-21T15:01:29
null
0
0
null
null
null
null
UTF-8
Java
false
false
871
java
package com.shop.service; import java.util.List; import com.shop.dao.ProdPicsDAO; import com.shop.daoImpl.ProdPicsDAOImpl; import com.shop.model.ProdPics; public class ProdPicsService { private ProdPicsDAO dao; public ProdPicsService() { dao = new ProdPicsDAOImpl(); } public ProdPics addProdPic(int prod_id, byte[] prod_pic) { ProdPics prodPics = new ProdPics(); prodPics.setProd_id(prod_id); prodPics.setProd_pic(prod_pic); dao.add(prodPics); return prodPics; }; public ProdPics updateProdPic(int prod_id, byte[] prod_pic) { ProdPics prodPics = new ProdPics(); prodPics.setProd_id(prod_id); prodPics.setProd_pic(prod_pic); dao.update(prodPics); return prodPics; }; public void deleteProdPic(int id) { dao.delete(id); }; public List<ProdPics> getAllProdPicByProdID(int id){ return dao.findByProdID(id); }; }
803c28271a2004c1d8058698bb8991bec67d68e0
f21dbe2d66922fe6e6e5ac7d644ed15caceae83b
/src/main/java/tiy/invictus/ResponseError.java
1867e1743d0c7b75d8cabaf99c517b29eba6d48e
[]
no_license
TIY-Hackathon-Invictus/eventContactUpdatedWithJSON
68e68c17df21c3d180c7c78b15892a2cae78f7e4
a4ef0de7b94de29c345315073acb5055ea4a7e4f
refs/heads/master
2021-01-18T19:40:12.254287
2016-10-03T12:41:05
2016-10-03T12:41:05
69,618,152
0
2
null
2016-10-01T15:40:04
2016-09-30T00:12:55
Java
UTF-8
Java
false
false
373
java
package tiy.invictus; /** * Created by Brice on 10/2/16. */ public class ResponseError implements Response{ public String message; public ResponseError(String message) { this.message = message; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } }
0da4793c79f3aa9e4cbbfd946967e8474d9d01a9
17123dd5bb8430f15db1c65e47ead96e8d754133
/src/myClass/City.java
3889eb664d262b2b9280d27ab759f4628788cb09
[]
no_license
Aresix/AirlineReservationSystem
8387fb4350b165490aa83e85f4457fde4340336e
9700b471f8e19fc81f1d31519b16cf434885eab6
refs/heads/master
2023-02-12T00:55:49.662297
2021-01-10T15:04:59
2021-01-10T15:04:59
328,119,838
0
0
null
null
null
null
UTF-8
Java
false
false
617
java
package myClass; public class City { private String name; private String country; // 所属国家 public City(String name, String country) { this.name=name; this.country=country; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getCountry() { return country; } public void setCountry(String country) { this.country = country; } public void getCity(){ System.out.println("当前访问城市:\t国家: "+country+"\t城市:"+name); } }
13b1396e41a07bab6bc1ad6928f8fa087d83d983
e95cefbdbe49e167569e051727823e2aa35f1d2d
/app/src/main/java/com/digimamad/model/Comments.java
e6cab0839ff83c1b1a81bb3f1d77b9f6c7de92b1
[]
no_license
mmahditalachi/DigiMamad
375a4cf811dc46c2a1d9510e9447f1f9ed10f59f
2aecc9aa9a0ffb897318944ea355ed42fce29544
refs/heads/master
2020-05-22T04:56:06.031681
2019-05-20T12:39:19
2019-05-20T12:39:19
186,226,170
0
0
null
null
null
null
UTF-8
Java
false
false
1,149
java
package com.digimamad.model; public class Comments { private String username; private String text; private int product_id; private int like; private int dislike; public Comments(String username, String text, int product_id, int like, int dislike) { this.username = username; this.text = text; this.product_id = product_id; this.like = like; this.dislike = dislike; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getText() { return text; } public void setText(String text) { this.text = text; } public int getProduct_id() { return product_id; } public void setProduct_id(int product_id) { this.product_id = product_id; } public int getLike() { return like; } public void setLike(int like) { this.like = like; } public int getDislike() { return dislike; } public void setDislike(int dislike) { this.dislike = dislike; } }
423a63f53157c5b26ca049a9112bf46e696ef867
65a8a2fbf780519c55e3c0199a318ea4a71a7eef
/src/main/java/com/baeldung/springsoap/gen/Country.java
6ddde984c8596736aabda8005c42471a0e003967
[]
no_license
ganeshnayanajith/producing-web-service
a4bc9958df68e7978e1715d138b5cadf2e32e984
5e221f5ec6e27cde1cea250775a377a0423f60ca
refs/heads/master
2021-01-07T06:25:27.298557
2020-02-19T11:35:15
2020-02-19T11:35:15
241,606,090
0
0
null
null
null
null
UTF-8
Java
false
false
3,408
java
// // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. // Generated on: 2020.02.12 at 02:50:04 PM IST // package com.baeldung.springsoap.gen; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; /** * <p>Java class for country complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType name="country"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/> * &lt;element name="population" type="{http://www.w3.org/2001/XMLSchema}int"/> * &lt;element name="capital" type="{http://www.w3.org/2001/XMLSchema}string"/> * &lt;element name="currency" type="{http://www.baeldung.com/springsoap/gen}currency"/> * &lt;/sequence> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "country", propOrder = { "name", "population", "capital", "currency" }) public class Country { @XmlElement(required = true) protected String name; protected int population; @XmlElement(required = true) protected String capital; @XmlElement(required = true) protected Currency currency; /** * Gets the value of the name property. * * @return * possible object is * {@link String } * */ public String getName() { return name; } /** * Sets the value of the name property. * * @param value * allowed object is * {@link String } * */ public void setName(String value) { this.name = value; } /** * Gets the value of the population property. * */ public int getPopulation() { return population; } /** * Sets the value of the population property. * */ public void setPopulation(int value) { this.population = value; } /** * Gets the value of the capital property. * * @return * possible object is * {@link String } * */ public String getCapital() { return capital; } /** * Sets the value of the capital property. * * @param value * allowed object is * {@link String } * */ public void setCapital(String value) { this.capital = value; } /** * Gets the value of the currency property. * * @return * possible object is * {@link Currency } * */ public Currency getCurrency() { return currency; } /** * Sets the value of the currency property. * * @param value * allowed object is * {@link Currency } * */ public void setCurrency(Currency value) { this.currency = value; } }
735e4a46f69469d665e35be0b9e3e71bb5a50543
2b7d5785b7fd044b10847aca3406129112a355f6
/csms-frk/src/main/java/com/cosmos/pageobject/em/pages/BasePage.java
0aac3cdff86ab1de85ec221b047428c19a0d335f
[]
no_license
sudhakarvsoft/cosmos-framework
66fb64db5d289b81569ad881cf3f335a8b7d373a
863c81aa668171eb86dea015107953aa568bf851
refs/heads/master
2020-04-09T12:03:41.555055
2018-07-11T12:20:07
2018-07-11T12:20:07
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,251
java
package com.cosmos.pageobject.em.pages; import static com.cosmos.util.WaitUtils.waitUntilElementVisible; import org.openqa.selenium.TimeoutException; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.PageFactory; import com.cosmos.pageobject.em.pages.pagefactory.WebDriverAwareDecorator; import com.cosmos.webdriver.manager.IDriverManager; import ru.yandex.qatools.htmlelements.loader.decorator.HtmlElementLocatorFactory; public abstract class BasePage { protected final IDriverManager driverManager; public BasePage(IDriverManager driverManager) { this.driverManager = driverManager; PageFactory .initElements(new WebDriverAwareDecorator (new HtmlElementLocatorFactory(driverManager.getDriver()), driverManager.getDriver()), this); } public boolean isAt() { return isAt(5); } public boolean isAt(long timeout) { boolean isAt; try { waitUntilElementVisible(getPagePresenceValidatingWebElement(), driverManager.getDriver(), timeout); isAt = true; } catch (TimeoutException exception) { isAt = false; } return isAt; } protected abstract WebElement getPagePresenceValidatingWebElement(); }
db9ec9a80298281c8c7fc3ba10c6dfab5ab83b96
b9861a0fc815b77551d81010fa890ef44e9ba1cc
/common/src/main/java/com/hwp/common/db/DynamicDataSource.java
0f153a38e88a0fb73e4ed2238fdc9294ec924b4e
[]
no_license
happyjianguo/hwp
6dbc5223bb19534ac9d61b3eae8009038be4e1aa
6bf80e34f3363f48af039e92931fbf3c22daae50
refs/heads/master
2022-12-01T01:57:04.680195
2020-08-09T00:20:00
2020-08-09T00:20:00
null
0
0
null
null
null
null
UTF-8
Java
false
false
399
java
package com.hwp.common.db; import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; public class DynamicDataSource extends AbstractRoutingDataSource { @Override protected Object determineCurrentLookupKey() { // TODO Auto-generated method stub String handlerString = CustomerContextHolder.getServiceDataSource(); return handlerString; } }
d35f27abcffc4e6d0fd3619acd1a48ea5a89e276
8af1164bac943cef64e41bae312223c3c0e38114
/results-java/JetBrains--intellij-community/a1b92cd0432ead884507bc49f602d75586053568/after/GroovyUtils.java
4d92b37ba47c6bfcb0e07d5a541b6b045d10cd9a
[]
no_license
fracz/refactor-extractor
3ae45c97cc63f26d5cb8b92003b12f74cc9973a9
dd5e82bfcc376e74a99e18c2bf54c95676914272
refs/heads/master
2021-01-19T06:50:08.211003
2018-11-30T13:00:57
2018-11-30T13:00:57
87,353,478
0
0
null
null
null
null
UTF-8
Java
false
false
4,412
java
/* * Copyright 2000-2007 JetBrains s.r.o. * 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.jetbrains.plugins.groovy.util; import com.intellij.openapi.module.Module; import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiClassType; import com.intellij.util.ArrayUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.groovy.GroovyFileType; import java.io.File; import java.io.FilenameFilter; import java.util.*; import java.util.regex.Pattern; /** * @author ilyas */ public abstract class GroovyUtils { /** * @param dir * @return true if current file is VCS auxiliary directory */ public static boolean isVersionControlSysDir(final VirtualFile dir) { if (!dir.isDirectory()) { return false; } final String name = dir.getName().toLowerCase(); return ".svn".equals(name) || "_svn".equals(name) || ".cvs".equals(name) || "_cvs".equals(name); } /** * @param file * @return true if current file is true groovy file */ public static boolean isGroovyFileOrDirectory(final @NotNull VirtualFile file) { return isGroovyFile(file) || file.isDirectory(); } public static boolean isGroovyFile(VirtualFile file) { return GroovyFileType.GROOVY_FILE_TYPE.getDefaultExtension().equals(file.getExtension()); } /** * @param module Module to get content root * @return VirtualFile corresponding to content root */ @NotNull public static String[] getModuleRootUrls(@NotNull final Module module) { VirtualFile[] roots = ModuleRootManager.getInstance(module).getSourceRoots(); if (roots.length == 0) { return ArrayUtil.EMPTY_STRING_ARRAY; } String[] urls = new String[roots.length]; int i = 0; for (VirtualFile root : roots) { urls[i++] = root.getUrl(); } return urls; } public static File[] getFilesInDirectoryByPattern(String dirPath, final String patternString) { File distDir = new File(dirPath); return distDir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { Pattern pattern = Pattern.compile(patternString); return pattern.matcher(name).matches(); } }); } public static <E> List<E> flatten(Collection<List<E>> lists) { List<E> result = new ArrayList<E>(); for (List<E> list : lists) { result.addAll(list); } return result; } /* * Finds all super classes recursively; may return the same types twice */ public static Iterable<PsiClass> findAllSupers(final PsiClass psiClass, final HashSet<PsiClassType> visitedSupers) { return new Iterable<PsiClass>() { public Iterator<PsiClass> iterator() { return new Iterator<PsiClass>() { int i = 0; Set<PsiClass> set = new HashSet<PsiClass>(); PsiClass current = psiClass; public boolean hasNext() { if (i < current.getSuperTypes().length) return true; if (set.contains(current)) set.remove(current); final Iterator<PsiClass> classIterator = set.iterator(); if (classIterator.hasNext()) { current = classIterator.next(); } else return false; i = 0; return current.getSuperTypes().length != 0 || hasNext(); } public PsiClass next() { final PsiClassType superType; PsiClass superClass; superType = current.getSuperTypes()[i++]; superClass = superType.resolve(); if (superClass == null) return null; if (!set.contains(superClass)) set.add(superClass); return superClass; } public void remove() { throw new IllegalStateException("cannot.be.called"); } }; } }; } }
51fcbac5e66bf391b149696231024bb8bdd9f665
e2397631ebdae212d953e68a216528f9b233ede7
/buymesth-back/src/main/java/com/buymesth/app/controllers/ProductController.java
05f57f09f51caf1aba557b7c7ceccbad190c6554
[ "MIT" ]
permissive
jfbernal92/buymesth
23d69b28a0813582ec22d0a2c8f8c837a6a50563
2629548bbe8da3c91d935761478e6dbed03aebf4
refs/heads/master
2022-12-24T01:54:23.846693
2019-10-30T18:49:45
2019-10-30T18:49:45
192,288,560
1
0
MIT
2022-12-09T06:37:43
2019-06-17T06:34:22
CSS
UTF-8
Java
false
false
4,860
java
package com.buymesth.app.controllers; import com.buymesth.app.dtos.ProductDto; import com.buymesth.app.dtos.ProductFilter; import com.buymesth.app.services.ProductService; import com.buymesth.app.utils.PageDto; import com.buymesth.app.utils.routes.RestRoutes; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.hateoas.Link; import org.springframework.hateoas.Resource; import org.springframework.hateoas.mvc.ControllerLinkBuilder; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.util.List; import java.util.Map; import java.util.stream.Collectors; import static com.buymesth.app.utils.routes.RestRoutes.Product.*; @Validated @RestController @CrossOrigin(value = "*", maxAge = 3600) @RequestMapping(RestRoutes.Product.URL) public class ProductController { private ResourceGenerator resGen; private ProductService productService; @Autowired public ProductController(@Lazy ResourceGenerator resGen, @Lazy ProductService productService) { this.resGen = resGen; this.productService = productService; } @GetMapping @PreAuthorize(value = "hasAnyAuthority('USER')") @ApiImplicitParams({ @ApiImplicitParam(name = "page", dataType = "integer", paramType = "query", value = "Results page you want to retrieve (0..N)"), @ApiImplicitParam(name = "size", dataType = "integer", paramType = "query", value = "Number of records per page."), @ApiImplicitParam(name = "sort", allowMultiple = true, dataType = "string", paramType = "query", value = "Sorting criteria in the format: property,[asc|desc]. " + "Default sort order is ascending.") }) public Resource<PageDto<Resource<ProductDto>>> getProducts(Pageable pageable) { Page<ProductDto> products = productService.getProducts(pageable); List<Resource<ProductDto>> list = products.stream().map(resGen::getProductResource).collect(Collectors.toList()); Resource<PageDto<Resource<ProductDto>>> resource = new Resource<>(PageDto.of(list, products.getTotalElements(), products.getNumberOfElements())); Link link = ControllerLinkBuilder.linkTo(ControllerLinkBuilder.methodOn(this.getClass()).getProducts(pageable)).withRel("all").expand(); resource.add(link); return resource; } @PreAuthorize(value = "hasAnyAuthority('USER')") @GetMapping(PRODUCT) public ResponseEntity<ProductDto> getProduct(@PathVariable(name = "id") Long id) { return productService.getProduct(id).map(ResponseEntity::ok).orElse(ResponseEntity.notFound().build()); } @PreAuthorize(value = "hasAnyAuthority('ADMIN')") @PostMapping @ApiOperation(value = "", notes = "You can create some products at the same time. If you use an existing ID then it will be updated.") public ResponseEntity<Resource<PageDto<Resource<ProductDto>>>> createProduct(@Valid @RequestBody List<ProductDto> productDtos) { return productService.createProduct(productDtos).map(l -> resGen.getProductsResource(l, (long) l.size(), l.size())).map(ResponseEntity::ok).orElse(ResponseEntity.badRequest().build()); } @PreAuthorize(value = "hasAnyAuthority('ADMIN')") @PutMapping(PRODUCT) public ResponseEntity<ProductDto> ediProduct(@PathVariable(name = "id") Long id, @Valid @RequestBody ProductDto productDto) { productDto.setIdProduct(id); return productService.editProduct(productDto).map(ResponseEntity::ok).orElse(ResponseEntity.notFound().build()); } @PreAuthorize(value = "hasAnyAuthority('ADMIN')") @DeleteMapping(PRODUCT) public ResponseEntity deleteProduct(@PathVariable(name = "id") Long id) { productService.deleteProduct(id); return ResponseEntity.noContent().build(); } @PreAuthorize(value = "hasAnyAuthority('USER')") @GetMapping(SEARCH) public List<Resource<ProductDto>> searchProducts(@Valid ProductFilter filter) { return productService.searchProducts(filter).stream().map(resGen::getProductResource).collect(Collectors.toList()); } @PreAuthorize(value = "hasAnyAuthority('ADMIN')") @GetMapping(PRODUCT_BY_CATEGORY) public ResponseEntity<Map<String, Integer>> countProductByCategory() { return ResponseEntity.ok(productService.countProductsByCategory()); } }
fc08743b65a3b1415236b75bfe653bfd772fc9ae
cea9770f3af93c447bc25ce71b145070741b4624
/week5/Count-Primes/woo.java
9a97cf50750985b3d20fc399df038db7a2c9eb06
[]
no_license
push-harder-than-yesterday/algorithm
19377bccf4986949b5053f5dbb6efd6528fc2f70
271a8d4273c5fdf8c83d3626755200126ab48913
refs/heads/master
2023-01-12T12:40:56.226012
2020-11-11T09:55:15
2020-11-11T09:55:15
292,226,094
3
6
null
2020-11-14T08:02:31
2020-09-02T08:35:40
Java
UTF-8
Java
false
false
880
java
package week5.CountPrimes; /** * created by victory_woo on 2020/10/08 */ public class woo { public static void main(String[] args) { System.out.println(countPrimes(10)); System.out.println(countPrimes(0)); System.out.println(countPrimes(1)); System.out.println(countPrimes(2)); System.out.println(countPrimes(3)); } // n보다 작아야 하는데, n보다 작거나 같은 조건으로 찾고 있었음.. public static int countPrimes(int n) { if (n == 0 || n == 1) return 0; boolean[] check = new boolean[n + 1]; for (int i = 2; i <= n; i++) { if (check[i]) continue; for (int j = i + i; j <= n; j += i) check[j] = true; } int count = 0; for (int i = 2; i < n; i++) { if (!check[i]) count++; } return count; } }
35220a0612e70c48fafbe1311902a32f7bc630ca
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/10/10_947464379423a02059c5089bcb2fe378280ac488/TaskSelectionDialog/10_947464379423a02059c5089bcb2fe378280ac488_TaskSelectionDialog_s.java
67232b10e9287dc5aa9b1ca5f5b34954b64c4ea7
[]
no_license
zhongxingyu/Seer
48e7e5197624d7afa94d23f849f8ea2075bcaec0
c11a3109fdfca9be337e509ecb2c085b60076213
refs/heads/master
2023-07-06T12:48:55.516692
2023-06-22T07:55:56
2023-06-22T07:55:56
259,613,157
6
2
null
2023-06-22T07:55:57
2020-04-28T11:07:49
null
UTF-8
Java
false
false
23,412
java
/******************************************************************************* * Copyright (c) 2004, 2007 Mylyn project committers and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.eclipse.mylyn.internal.tasks.ui.actions; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.ActionContributionItem; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.layout.GridLayoutFactory; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.window.Window; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.mylyn.internal.tasks.core.TaskList; import org.eclipse.mylyn.internal.tasks.ui.TaskListColorsAndFonts; import org.eclipse.mylyn.internal.tasks.ui.TaskSearchPage; import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; import org.eclipse.mylyn.internal.tasks.ui.views.TaskActivationHistory; import org.eclipse.mylyn.internal.tasks.ui.views.TaskDetailLabelProvider; import org.eclipse.mylyn.internal.tasks.ui.views.TaskElementLabelProvider; import org.eclipse.mylyn.internal.tasks.ui.views.TaskListFilteredTree; import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView; import org.eclipse.mylyn.internal.tasks.ui.workingsets.TaskWorkingSetUpdater; import org.eclipse.mylyn.internal.tasks.ui.workingsets.WorkingSetLabelComparator; import org.eclipse.mylyn.tasks.core.AbstractTask; import org.eclipse.mylyn.tasks.core.AbstractTaskContainer; import org.eclipse.search.internal.ui.SearchDialog; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IMemento; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkingSet; import org.eclipse.ui.IWorkingSetManager; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.FilteredItemsSelectionDialog; import org.eclipse.ui.dialogs.IWorkingSetEditWizard; import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog; import org.eclipse.ui.dialogs.SearchPattern; import org.eclipse.ui.forms.events.HyperlinkAdapter; import org.eclipse.ui.forms.events.HyperlinkEvent; import org.eclipse.ui.forms.widgets.ImageHyperlink; /** * @author Willian Mitsuda * @author Mik Kersten * @author Eugene Kuleshov * @author Shawn Minto */ public class TaskSelectionDialog extends FilteredItemsSelectionDialog { private class DeselectWorkingSetAction extends Action { public DeselectWorkingSetAction() { super("&Deselect Working Set", IAction.AS_PUSH_BUTTON); } @Override public void run() { setSelectedWorkingSet(null); } } private class EditWorkingSetAction extends Action { public EditWorkingSetAction() { super("&Edit Active Working Set...", IAction.AS_PUSH_BUTTON); } @Override public void run() { IWorkingSetEditWizard wizard = PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSetEditWizard( selectedWorkingSet); if (wizard != null) { WizardDialog dlg = new WizardDialog(getShell(), wizard); dlg.open(); } } } private class FilterWorkingSetAction extends Action { private final IWorkingSet workingSet; public FilterWorkingSetAction(IWorkingSet workingSet, int shortcutKeyNumber) { super("", IAction.AS_RADIO_BUTTON); this.workingSet = workingSet; if (shortcutKeyNumber >= 1 && shortcutKeyNumber <= 9) { setText("&" + String.valueOf(shortcutKeyNumber) + " " + workingSet.getLabel()); } else { setText(workingSet.getLabel()); } setImageDescriptor(workingSet.getImageDescriptor()); } @Override public void run() { setSelectedWorkingSet(workingSet); } } private class SelectWorkingSetAction extends Action { public SelectWorkingSetAction() { super("Select &Working Set...", IAction.AS_PUSH_BUTTON); } @Override public void run() { IWorkingSetSelectionDialog dlg = PlatformUI.getWorkbench() .getWorkingSetManager() .createWorkingSetSelectionDialog(getShell(), false, new String[] { TaskWorkingSetUpdater.ID_TASK_WORKING_SET }); if (selectedWorkingSet != null) { dlg.setSelection(new IWorkingSet[] { selectedWorkingSet }); } if (dlg.open() == Window.OK) { IWorkingSet[] selection = dlg.getSelection(); if (selection.length == 0) { setSelectedWorkingSet(null); } else { setSelectedWorkingSet(selection[0]); } } } } private class ShowCompletedTasksAction extends Action { public ShowCompletedTasksAction() { super("Show &Completed Tasks", IAction.AS_CHECK_BOX); } @Override public void run() { showCompletedTasks = isChecked(); applyFilter(); } } private class TaskHistoryItemsComparator implements Comparator<Object> { Map<AbstractTask, Integer> positionByTask = new HashMap<AbstractTask, Integer>(); public TaskHistoryItemsComparator(List<AbstractTask> history) { for (int i = 0; i < history.size(); i++) { positionByTask.put(history.get(i), i); } } public int compare(Object o1, Object o2) { Integer p1 = positionByTask.get(o1); Integer p2 = positionByTask.get(o2); if (p1 != null && p2 != null) { return p2.compareTo(p1); } return labelProvider.getText(o1).compareTo(labelProvider.getText(o2)); } } /** * Integrates {@link FilteredItemsSelectionDialog} history management with Mylyn's task list activation history * <p> * Due to {@link SelectionHistory} use of memento-based history storage, many methods are overridden */ private class TaskSelectionHistory extends SelectionHistory { @Override public synchronized void accessed(Object object) { history.add((AbstractTask) object); } @Override public synchronized boolean contains(Object object) { return history.contains(object); } @Override public synchronized Object[] getHistoryItems() { return history.toArray(); } @Override public synchronized boolean isEmpty() { return history.isEmpty(); } @Override public void load(IMemento memento) { // do nothing because tasklist history handles this } @Override public synchronized boolean remove(Object object) { return history.remove(object); } @Override protected Object restoreItemFromMemento(IMemento memento) { // do nothing because tasklist history handles this return null; } @Override public void save(IMemento memento) { // do nothing because tasklist history handles this } @Override protected void storeItemToMemento(Object item, IMemento memento) { // do nothing because tasklist history handles this } } /** * Supports filtering of completed tasks. */ private class TasksFilter extends ItemsFilter { private Set<AbstractTask> allTasksFromWorkingSets; /** * Stores the task containers from selected working set; empty, which can come from no working set selection or * working set with no task containers selected, means no filtering */ private final Set<AbstractTaskContainer> elements; private final boolean showCompletedTasks; public TasksFilter(boolean showCompletedTasks, IWorkingSet selectedWorkingSet) { super(new SearchPattern()); // Little hack to force always a match inside any part of task text patternMatcher.setPattern("*" + patternMatcher.getPattern()); this.showCompletedTasks = showCompletedTasks; elements = new HashSet<AbstractTaskContainer>(); if (selectedWorkingSet != null) { for (IAdaptable adaptable : selectedWorkingSet.getElements()) { AbstractTaskContainer container = (AbstractTaskContainer) adaptable.getAdapter(AbstractTaskContainer.class); if (container != null) { elements.add(container); } } } } @Override public boolean equalsFilter(ItemsFilter filter) { if (!super.equalsFilter(filter)) { return false; } if (filter instanceof TasksFilter) { TasksFilter tasksFilter = (TasksFilter) filter; if (showCompletedTasks != tasksFilter.showCompletedTasks) { return false; } return elements.equals(tasksFilter.elements); } return true; } @Override public boolean isConsistentItem(Object item) { return item instanceof AbstractTask; } @Override public boolean isSubFilter(ItemsFilter filter) { if (!super.isSubFilter(filter)) { return false; } if (filter instanceof TasksFilter) { TasksFilter tasksFilter = (TasksFilter) filter; if (!showCompletedTasks && tasksFilter.showCompletedTasks) { return false; } if (elements.isEmpty()) { return true; } if (tasksFilter.elements.isEmpty()) { return false; } return elements.containsAll(tasksFilter.elements); } return true; } @Override public boolean matchItem(Object item) { if (!(item instanceof AbstractTask)) { return false; } if (!showCompletedTasks && ((AbstractTask) item).isCompleted()) { return false; } if (!elements.isEmpty()) { if (allTasksFromWorkingSets == null) { populateTasksFromWorkingSets(); } if (!allTasksFromWorkingSets.contains(item)) { return false; } } return matches(labelProvider.getText(item)); } private void populateTasksFromWorkingSets() { allTasksFromWorkingSets = new HashSet<AbstractTask>(1000); for (AbstractTaskContainer container : elements) { allTasksFromWorkingSets.addAll(container.getChildren()); } } } private static final int SEARCH_ID = IDialogConstants.CLIENT_ID + 1; private static final int CREATE_ID = SEARCH_ID + 1; private static final String IS_USING_WINDOW_WORKING_SET_SETTING = "IsUsingWindowWorkingSet"; private static final String OPEN_IN_BROWSER_SETTING = "OpenInBrowser"; private static final String SHOW_COMPLETED_TASKS_SETTING = "ShowCompletedTasks"; private static final String TASK_SELECTION_DIALOG_SECTION = "TaskSelectionDialogSection"; private static final String WORKING_SET_NAME_SETTING = "WorkingSetName"; /** * Caches all tasks; populated at first access */ private Set<AbstractTask> allTasks; private Button createTaskButton; /** * Mylyn's task activation history */ private final List<AbstractTask> history; private final TaskHistoryItemsComparator itemsComparator; private final TaskElementLabelProvider labelProvider; private boolean needsCreateTask; private boolean openInBrowser; private Button openInBrowserCheck; /** * Set of filtered working sets */ private IWorkingSet selectedWorkingSet; private boolean showCompletedTasks; private final ShowCompletedTasksAction showCompletedTasksAction; private boolean showExtendedOpeningOptions; /** * Caches the window working set */ private final IWorkingSet windowWorkingSet; /** * Refilters if the current working set content has changed */ private final IPropertyChangeListener workingSetListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE)) { if (event.getNewValue().equals(selectedWorkingSet)) { applyFilter(); } } } }; public TaskSelectionDialog(Shell parent) { super(parent); TaskActivationHistory taskActivationHistory = TasksUiPlugin.getTaskListManager().getTaskActivationHistory(); this.history = new ArrayList<AbstractTask>(taskActivationHistory.getPreviousTasks()); this.itemsComparator = new TaskHistoryItemsComparator(this.history); this.needsCreateTask = true; this.labelProvider = new TaskElementLabelProvider(false); this.showCompletedTasksAction = new ShowCompletedTasksAction(); setSelectionHistory(new TaskSelectionHistory()); setListLabelProvider(labelProvider); // setListLabelProvider(new DecoratingLabelProvider(labelProvider, PlatformUI.getWorkbench() // .getDecoratorManager() // .getLabelDecorator())); setDetailsLabelProvider(new TaskDetailLabelProvider()); setSeparatorLabel(TaskListView.LABEL_VIEW + " matches"); // If there is a text selection, use it as the initial filter IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); ISelection selection = window.getSelectionService().getSelection(); if (selection instanceof ITextSelection) { // Get only get first line String text = ((ITextSelection) selection).getText(); int n = text.indexOf('\n'); if (n > -1) { text.substring(0, n); } setInitialPattern(text); } windowWorkingSet = window.getActivePage().getAggregateWorkingSet(); selectedWorkingSet = windowWorkingSet; PlatformUI.getWorkbench().getWorkingSetManager().addPropertyChangeListener(workingSetListener); } @Override public boolean close() { PlatformUI.getWorkbench().getWorkingSetManager().removePropertyChangeListener(workingSetListener); if (openInBrowserCheck != null) { openInBrowser = openInBrowserCheck.getSelection(); } return super.close(); } @Override protected Control createButtonBar(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 0; // create layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // create help control if needed if (isHelpAvailable()) { createHelpControl(composite); } if (needsCreateTask) { createTaskButton = createButton(composite, CREATE_ID, "New Task...", true); createTaskButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // ignore } public void widgetSelected(SelectionEvent e) { close(); new NewTaskAction().run(); } }); } Label filler = new Label(composite, SWT.NONE); filler.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); layout.numColumns++; super.createButtonsForButtonBar(composite); // cancel button return composite; } @Override protected Control createExtendedContentArea(Composite parent) { if (!showExtendedOpeningOptions) { return null; } Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(GridLayoutFactory.swtDefaults().margins(0, 5).create()); composite.setLayoutData(GridDataFactory.fillDefaults().create()); openInBrowserCheck = new Button(composite, SWT.CHECK); openInBrowserCheck.setText("Open with &Browser"); openInBrowserCheck.setSelection(openInBrowser); ImageHyperlink openHyperlink = new ImageHyperlink(composite, SWT.NONE); openHyperlink.setText(TaskListFilteredTree.LABEL_SEARCH); openHyperlink.setForeground(TaskListColorsAndFonts.COLOR_HYPERLINK_WIDGET); openHyperlink.setUnderlined(true); openHyperlink.addHyperlinkListener(new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { getShell().close(); new SearchDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), TaskSearchPage.ID).open(); } }); return composite; } @Override protected ItemsFilter createFilter() { return new TasksFilter(showCompletedTasks, selectedWorkingSet); } @Override protected void fillContentProvider(AbstractContentProvider contentProvider, ItemsFilter itemsFilter, IProgressMonitor progressMonitor) throws CoreException { progressMonitor.beginTask("Search for tasks", 100); if (allTasks == null) { allTasks = new HashSet<AbstractTask>(); TaskList taskList = TasksUiPlugin.getTaskListManager().getTaskList(); allTasks.addAll(taskList.getAllTasks()); } progressMonitor.worked(10); SubProgressMonitor subMonitor = new SubProgressMonitor(progressMonitor, 90); subMonitor.beginTask("Scanning tasks", allTasks.size()); for (AbstractTask task : allTasks) { contentProvider.add(task, itemsFilter); subMonitor.worked(1); } subMonitor.done(); progressMonitor.done(); } @Override protected void fillViewMenu(IMenuManager menuManager) { super.fillViewMenu(menuManager); menuManager.add(showCompletedTasksAction); menuManager.add(new Separator()); // Fill existing tasks working sets menuManager.add(new SelectWorkingSetAction()); final DeselectWorkingSetAction deselectAction = new DeselectWorkingSetAction(); menuManager.add(deselectAction); final EditWorkingSetAction editAction = new EditWorkingSetAction(); menuManager.add(editAction); menuManager.add(new Separator("lruActions")); final FilterWorkingSetAction windowWorkingSetAction = new FilterWorkingSetAction(windowWorkingSet, 1); menuManager.add(windowWorkingSetAction); menuManager.addMenuListener(new IMenuListener() { private final List<ActionContributionItem> lruActions = new ArrayList<ActionContributionItem>(); public void menuAboutToShow(IMenuManager manager) { deselectAction.setEnabled(selectedWorkingSet != null); editAction.setEnabled(selectedWorkingSet != null && selectedWorkingSet.isEditable()); // Remove previous LRU actions for (ActionContributionItem action : lruActions) { manager.remove(action); } lruActions.clear(); // Adds actual LRU actions IWorkingSet[] workingSets = PlatformUI.getWorkbench().getWorkingSetManager().getRecentWorkingSets(); Arrays.sort(workingSets, new WorkingSetLabelComparator()); int count = 2; for (IWorkingSet workingSet : workingSets) { if (workingSet.getId().equalsIgnoreCase(TaskWorkingSetUpdater.ID_TASK_WORKING_SET)) { IAction action = new FilterWorkingSetAction(workingSet, count++); if (workingSet.equals(selectedWorkingSet)) { action.setChecked(true); } ActionContributionItem ci = new ActionContributionItem(action); lruActions.add(ci); manager.appendToGroup("lruActions", ci); } } windowWorkingSetAction.setChecked(windowWorkingSet.equals(selectedWorkingSet)); } }); } @Override protected IDialogSettings getDialogSettings() { IDialogSettings settings = TasksUiPlugin.getDefault().getDialogSettings(); IDialogSettings section = settings.getSection(TASK_SELECTION_DIALOG_SECTION); if (section == null) { section = settings.addNewSection(TASK_SELECTION_DIALOG_SECTION); section.put(OPEN_IN_BROWSER_SETTING, false); section.put(SHOW_COMPLETED_TASKS_SETTING, true); section.put(IS_USING_WINDOW_WORKING_SET_SETTING, true); section.put(WORKING_SET_NAME_SETTING, ""); } return section; } @Override public String getElementName(Object item) { return labelProvider.getText(item); } /** * Sort tasks by summary */ @SuppressWarnings("unchecked") @Override protected Comparator getItemsComparator() { return itemsComparator; } public boolean getOpenInBrowser() { return openInBrowser; } public boolean getShowExtendedOpeningOptions() { return showExtendedOpeningOptions; } public boolean needsCreateTask() { return needsCreateTask; } @Override protected void restoreDialog(IDialogSettings settings) { openInBrowser = settings.getBoolean(OPEN_IN_BROWSER_SETTING); showCompletedTasks = settings.getBoolean(SHOW_COMPLETED_TASKS_SETTING); showCompletedTasksAction.setChecked(showCompletedTasks); boolean isUsingWindowWorkingSet = settings.getBoolean(IS_USING_WINDOW_WORKING_SET_SETTING); if (isUsingWindowWorkingSet) { selectedWorkingSet = windowWorkingSet; } else { String workingSetName = settings.get(WORKING_SET_NAME_SETTING); if (workingSetName != null) { selectedWorkingSet = PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(workingSetName); } } super.restoreDialog(settings); } public void setNeedsCreateTask(boolean value) { needsCreateTask = value; } public void setOpenInBrowser(boolean openInBrowser) { this.openInBrowser = openInBrowser; } /** * All working set filter changes should be made through this method; ensures proper history handling and triggers * refiltering */ private void setSelectedWorkingSet(IWorkingSet workingSet) { selectedWorkingSet = workingSet; if (workingSet != null) { PlatformUI.getWorkbench().getWorkingSetManager().addRecentWorkingSet(workingSet); } applyFilter(); } public void setShowExtendedOpeningOptions(boolean showExtendedOpeningOptions) { this.showExtendedOpeningOptions = showExtendedOpeningOptions; } @Override protected void storeDialog(IDialogSettings settings) { settings.put(OPEN_IN_BROWSER_SETTING, openInBrowser); settings.put(SHOW_COMPLETED_TASKS_SETTING, showCompletedTasks); settings.put(IS_USING_WINDOW_WORKING_SET_SETTING, selectedWorkingSet == windowWorkingSet); if (selectedWorkingSet == null) { settings.put(WORKING_SET_NAME_SETTING, ""); } else { settings.put(WORKING_SET_NAME_SETTING, selectedWorkingSet.getName()); } super.storeDialog(settings); } @Override protected IStatus validateItem(Object item) { if (item instanceof AbstractTask) { return Status.OK_STATUS; } return new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Selected item is not a task"); } }
fb6bda27295fdedb21be27800438ab20b698b9f1
f0df0eec63d8720663cc6f769d83ebb4031e56a3
/src/main/java/spring/DBUtil.java
d9b3edb14a05b26c7149d77c3fd61ff281d53ac8
[]
no_license
liurenyou/Spring
cd9f095b30a953ac09efd13a927f7244dd878bb5
59fc5c05fb1a66bf8cd616cae9ba23903b079537
refs/heads/master
2020-03-17T14:38:05.271488
2018-05-16T03:13:15
2018-05-16T03:13:15
133,680,489
0
0
null
null
null
null
UTF-8
Java
false
false
928
java
package spring; import java.io.Serializable; public class DBUtil implements Serializable { private static final long serialVersionUID = 1L; private String driverClass; private String url; private String userName; private String password; public String getDriverClass() { return driverClass; } public void setDriverClass(String driverClass) { this.driverClass = driverClass; } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } @Override public String toString() { return "DBUtil [driverClass=" + driverClass + ", url=" + url + ", userName=" + userName + ", password=" + password + "]"; } }
090f2da1459e34f0e4d667abc7a4c38b84bccdce
bda49fb96ea12034bf5663d39ceea943d50657b3
/src/seng271/group8/ludo/graphics/IEasing.java
6a237a1f8869c7a71722fde99a3863a93ee5b86b
[]
no_license
hrky/LudoGame
4f114f9bab2a5897480564a52ca157349831e234
b50a057c322edd4121407deb3de79bbde8c00254
refs/heads/master
2020-04-24T02:23:26.788075
2015-02-01T19:40:22
2015-02-01T19:40:22
30,136,469
1
0
null
null
null
null
UTF-8
Java
false
false
257
java
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package seng271.group8.ludo.graphics; /** * * @author alastair */ public interface IEasing { public float tic(float t, float b, float c, float d); }
65e1bd6794b6112b5562777b4465a78b95e3da92
d9017ff594120c4d8bc38f8ef4b31843b7be1c28
/app/server/appsmith-server/src/main/java/com/appsmith/server/authentication/handlers/ce/AuthenticationEntryPointCE.java
d5d108064bc195c542a79f14856c7e42133d0be2
[ "Apache-2.0" ]
permissive
reachtokish/appsmith
979ccee42ffda132284d0f161bcc369f1212172b
46e368afa9776b13d8cb177f1a9f8a89c119afb4
refs/heads/release
2023-01-02T08:42:14.096088
2022-08-22T12:15:03
2022-08-22T12:15:03
301,500,835
1
0
Apache-2.0
2020-10-06T06:23:17
2020-10-05T18:19:19
null
UTF-8
Java
false
false
1,353
java
package com.appsmith.server.authentication.handlers.ce; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; import org.springframework.http.server.reactive.ServerHttpResponse; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.server.ServerAuthenticationEntryPoint; import org.springframework.web.server.ServerWebExchange; import reactor.core.publisher.Mono; /** * This class returns 401 unauthorized for all unauthenticated requests that require authentication. The client will * redirect to the login page when it receives this response header. * <p> * This class is invoked via the ExceptionHandlingSpec configured in the `SecurityConfig.configure()` function. * In future, we can append to this response object to return other custom headers as required for any unauthenticated * requests. */ @Slf4j public class AuthenticationEntryPointCE implements ServerAuthenticationEntryPoint { @Override public Mono<Void> commence(ServerWebExchange exchange, AuthenticationException e) { // In the custom authenticationEntryPoint. Returning unauthorized from here return Mono.fromRunnable(() -> { ServerHttpResponse response = exchange.getResponse(); response.setStatusCode(HttpStatus.UNAUTHORIZED); }); } }
d7ecca2cb0c37307f2493bded278b43bb399c2b9
8bd4cd295806cb42af7bac6120f376e6a4e4f288
/com/google/android/gms/maps/model/TileOverlay.java
ada77995202eac0aefb82ae6cec13a35bb3fd128
[]
no_license
awestlake87/dapath
74d95d27854bc75b5d26456621d45eae79d5995b
8e83688c9ec6ab9d5b0def17e9dc5b2c6896ea0b
refs/heads/master
2020-03-13T10:40:49.896330
2018-04-26T02:22:12
2018-04-26T02:22:12
131,088,145
0
0
null
null
null
null
UTF-8
Java
false
false
2,576
java
package com.google.android.gms.maps.model; import android.os.RemoteException; import com.google.android.gms.internal.hm; import com.google.android.gms.maps.model.internal.C0422h; public final class TileOverlay { private final C0422h abc; public TileOverlay(C0422h delegate) { this.abc = (C0422h) hm.m1232f(delegate); } public void clearTileCache() { try { this.abc.clearTileCache(); } catch (RemoteException e) { throw new RuntimeRemoteException(e); } } public boolean equals(Object other) { if (!(other instanceof TileOverlay)) { return false; } try { return this.abc.mo2238a(((TileOverlay) other).abc); } catch (RemoteException e) { throw new RuntimeRemoteException(e); } } public boolean getFadeIn() { try { return this.abc.getFadeIn(); } catch (RemoteException e) { throw new RuntimeRemoteException(e); } } public String getId() { try { return this.abc.getId(); } catch (RemoteException e) { throw new RuntimeRemoteException(e); } } public float getZIndex() { try { return this.abc.getZIndex(); } catch (RemoteException e) { throw new RuntimeRemoteException(e); } } public int hashCode() { try { return this.abc.hashCodeRemote(); } catch (RemoteException e) { throw new RuntimeRemoteException(e); } } public boolean isVisible() { try { return this.abc.isVisible(); } catch (RemoteException e) { throw new RuntimeRemoteException(e); } } public void remove() { try { this.abc.remove(); } catch (RemoteException e) { throw new RuntimeRemoteException(e); } } public void setFadeIn(boolean fadeIn) { try { this.abc.setFadeIn(fadeIn); } catch (RemoteException e) { throw new RuntimeRemoteException(e); } } public void setVisible(boolean visible) { try { this.abc.setVisible(visible); } catch (RemoteException e) { throw new RuntimeRemoteException(e); } } public void setZIndex(float zIndex) { try { this.abc.setZIndex(zIndex); } catch (RemoteException e) { throw new RuntimeRemoteException(e); } } }
cad2f281379f5c392ade1bafde313dc96482c834
69a63af520efc14feae102c386bb185b4b6101c8
/JalForce/app/src/main/java/com/ssvtech/jalforce1/Dailydelivery.java
3526f111b5c10c7ed7cc1c0a9e988457ba67c6a2
[]
no_license
srinathvangari/AndroidAquaProject
fc3379965df89a68b6e65cb27f26678f0080e906
80caa3201fa834d48ecc38652c1bcd524ae84ba7
refs/heads/master
2021-06-24T15:12:13.637919
2019-09-08T15:12:17
2019-09-08T15:12:17
207,130,385
0
0
null
null
null
null
UTF-8
Java
false
false
2,975
java
package com.ssvtech.jalforce1; public class Dailydelivery { private Integer id; // private Date trans_date; private Integer customerId; private Integer returnCanCount; private Integer deliveredCanCount; private Integer employeeId; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getCustFirstName() { return custFirstName; } public void setCustFirstName(String custFirstName) { this.custFirstName = custFirstName; } private String custFirstName; public String getCustLastName() { return custLastName; } public void setCustLastName(String custLastName) { this.custLastName = custLastName; } public String getEmpFirstName() { return empFirstName; } public void setEmpFirstName(String empFirstName) { this.empFirstName = empFirstName; } public String getEmpLastName() { return empLastName; } public void setEmpLastName(String empLastName) { this.empLastName = empLastName; } public String getRouteAddress() { return routeAddress; } public void setRouteAddress(String routeAddress) { this.routeAddress = routeAddress; } public String getCustAddress() { return custAddress; } public void setCustAddress(String custAddress) { this.custAddress = custAddress; } public String getCustMobileNo() { return custMobileNo; } public void setCustMobileNo(String custMobileNo) { this.custMobileNo = custMobileNo; } public String getEmpMobileNo() { return empMobileNo; } public void setEmpMobileNo(String empMobileNo) { this.empMobileNo = empMobileNo; } private String custLastName; private String empFirstName; private String empLastName; private String routeAddress; private String custAddress; private String custMobileNo; private String empMobileNo; /* public Date getTrans_date() { return trans_date; } public void setTrans_date(Date trans_date) { this.trans_date = trans_date; }*/ public Integer getCustomerId() { return customerId; } public void setCustomerId(Integer customerId) { this.customerId = customerId; } public Integer getReturnCanCount() { return returnCanCount; } public void setReturnCanCount(Integer returnCanCount) { this.returnCanCount = returnCanCount; } public Integer getDeliveredCanCount() { return deliveredCanCount; } public void setDeliveredCanCount(Integer deliveredCanCount) { this.deliveredCanCount = deliveredCanCount; } public Integer getEmployeeId() { return employeeId; } public void setEmployeeId(Integer employeeId) { this.employeeId = employeeId; } }
001594b0cdf09e8632cecd2b653e2b6ec3932122
b8b38238ac0ed2cd829451a45a8e33559718762f
/BMS/src/test/Test1.java
952ea66aa4ad19caed0d5b9dd263551f4ef606ba
[]
no_license
kgcnjzym/203007U2
2c9d6790854727d06e78219fc186d056e6dcdc30
ad92468dd76056b93bae6f8376fa87ddf6ca0ea2
refs/heads/master
2023-02-09T19:50:50.072495
2021-01-07T02:31:46
2021-01-07T02:31:46
310,059,311
0
1
null
null
null
null
UTF-8
Java
false
false
954
java
package test; import com.xt.entity.Book; import com.xt.service.OrderService; import com.xt.service.impl.OrderServiceImpl; import java.util.ArrayList; import java.util.List; /** * 订单测试 * @author 杨卫兵 * @version V1.00 * @date 2020/11/20 09:33 * @since V1.00 */ public class Test1 { public static void main(String[] args) { OrderService service=new OrderServiceImpl(); List<Book> books=new ArrayList<>(); Book bk=new Book(); bk.setId(1); bk.setCount(2); books.add(bk); bk=new Book(); bk.setId(3); bk.setCount(1); books.add(bk); bk=new Book(); bk.setId(12); bk.setCount(1); books.add(bk); try{ int ret=service.addOrder(1,books); System.out.println("添加成功,订单编号:"+ret); } catch (RuntimeException ex){ System.out.println(ex); } } }
fd921d186100deb671d3a3434e6d4f60152af32a
275a7d99e7e22e22796e8cdc3d626eee8b361fe2
/carp_mobile_sensing/example/android/app/src/main/java/dk/cachet/carp/carpmobilesensingexample/MainActivity.java
80fe9aaa918fda2f8a0b19b2b2f520e97bfd77ce
[ "MIT" ]
permissive
askmetoo/carp.sensing-flutter
61680961a53e350d9f3e6b4f6b821e1ca4b136ee
5de36216bb22b12b3112677616a7de242ff0bcdb
refs/heads/master
2022-11-21T10:59:03.506184
2020-07-17T12:29:13
2020-07-17T12:29:13
null
0
0
null
null
null
null
UTF-8
Java
false
false
158
java
package dk.cachet.carp.carpmobilesensingexample; import io.flutter.embedding.android.FlutterActivity; public class MainActivity extends FlutterActivity { }
fc05433a24d3ea469b1c630e633a829ac449cfc1
e2d71e452f3e1477ad330d264eb7b544542911f1
/src/main/java/com/gustavoweb/cursomc/repositories/ItemPedidoRepository.java
2069654c2cc9c1d2aae3671af173363d5ad5f083
[]
no_license
gustavoMoraiss/cursomc
cec6a9d84ad6d80425d51333b16ae01010da20a7
30684e7717fd2129ce9ff5923792b30569758f28
refs/heads/master
2023-03-30T05:37:09.019944
2021-04-10T19:35:19
2021-04-10T19:35:19
348,553,976
0
0
null
null
null
null
UTF-8
Java
false
false
307
java
package com.gustavoweb.cursomc.repositories; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; import com.gustavoweb.cursomc.domain.ItemPedido; @Repository public interface ItemPedidoRepository extends JpaRepository<ItemPedido, Integer> { }
f2d33e95ecd4970be81deb5509d15ec2c3e3e070
f97c673fb49bddeb605d9931392f2757a27d1a12
/stats-utils-base/src/main/java/com/pervasivecode/utils/stats/histogram/Histogram.java
d949c962f70fcae522940540e092fa9a6bdb86fb
[ "Apache-2.0" ]
permissive
JamieFlournoy/java-stats-utils
10eb9dedc97d14b0f4b6e6c017e91b59f126872a
bb3460bc97e6b0171a8e1b44a6ae7d9c02617c5b
refs/heads/master
2020-04-06T08:26:07.346806
2019-02-20T03:15:51
2019-02-20T03:15:51
157,304,522
0
0
null
null
null
null
UTF-8
Java
false
false
1,942
java
package com.pervasivecode.utils.stats.histogram; /** * This is a data structure that holds frequency counts of values for use in a histogram. Since a * histogram shows the number values within specified ranges, the structure only stores counts all * values in each range. * <p> * "Buckets" (the ranges of counted values) are identified by an inclusive upper bound value. Values * from negative infinity (or the equivalent in the given type) through the lowest upper bound value * go into the first bucket; values greater than the highest upper bound value and up to positive * infinity (or the equivalent) go in the last bucket. * <p> * Example: A Histogram of String values has 5 buckets, with upper bound values of "Apple", "Hewlett * Packard", "Sun", and "Wang" (the last bucket never has an upper bound value, so there is no fifth * upper bound value). * <p> * In this example histogram, here is how elements would be counted: * <ul> * <li>A value "Acorn" would have gone in the first bucket since it's less-than-or-equal-to * "Apple".</li> * <li>If the second bucket has counted 5 values, that means that there must have been five values * counted that were greater than "Apple" and less-than-or-equal-to "Hewlett Packard".</li> * <li>A value "Tandem" would have gone in the fourth bucket since it's greater than "Sun" but less * than or equal to "Wang".</li> * <li>"Zenith" would go in the last (5th) bucket, since it's greater than the last * upper-bound-value, "Wang".</li> * </ul> * * @param <T> The type of value that is being counted. * @see BucketingSystem */ public interface Histogram<T> extends BucketingSystem<T> { /** * Get the number of elements that were counted in the specified bucket. The first bucket has an * index of 0. * * @param index The bucket number to examine. * @return The count of values in the specified bucket. */ public long countInBucket(int index); }
d663f9c60b062a37b5529aa8890e7e5187553274
1b233c50da4c3f79e1021463fa42ed3e4c763005
/backend-user/src/main/java/pl/jcw/demo/microservices/user/BackendUserApplication.java
d78514aa6298eff2f50a754d99cec565144daca1
[ "Apache-2.0" ]
permissive
juliusz-cwiakalski/demo-microservices
9243566d716a26ecb265e8caa0fb9d3b5cb8d020
86b1eee029e5d3fd5a3bd43c297c7a3c74333a12
refs/heads/main
2023-03-13T05:05:13.171290
2021-03-02T14:55:40
2021-03-02T14:55:40
343,776,392
0
0
null
null
null
null
UTF-8
Java
false
false
333
java
package pl.jcw.demo.microservices.user; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class BackendUserApplication { public static void main(String[] args) { SpringApplication.run(BackendUserApplication.class, args); } }
72d4962a0357c7823cd1593059f0277ee601e0f3
9bd29dc00a259184035eda2358b776539f675b20
/bus-micro-service/saga-orchestration/src/main/java/com/shaun/microserive/sagaorchestration/infrastructure/config/CamelConfig.java
118d93996625589281522c9d128e807721cdb3a9
[]
no_license
ShaunChow/shaun-spring-cloud
82de39c1ed7044b3e20339f1b2b1dfec044b2f04
2a228ba53e961079fc13a1d9c5d0559e34edfbab
refs/heads/master
2021-05-18T23:52:03.171580
2021-01-24T15:33:05
2021-01-24T15:33:05
251,484,192
0
0
null
null
null
null
UTF-8
Java
false
false
493
java
package com.shaun.microserive.sagaorchestration.infrastructure.config; import org.apache.camel.CamelContext; import org.apache.camel.impl.saga.InMemorySagaService; import org.springframework.context.annotation.Configuration; @Configuration public class CamelConfig { final CamelContext camelContext; public CamelConfig(CamelContext camelContext) throws Exception { this.camelContext = camelContext; this.camelContext.addService(new InMemorySagaService()); } }
43ed48ce40fe0969deb82b0ee778623f56b6cc13
b02ca92629b9a63fcf1fc6f6faf91c0369564c4e
/app/src/main/java/com/ziran/meiliao/constant/AppConstant.java
5fc0fbcc7b24afa647f003f9a961439c114a014f
[]
no_license
sengeiou/meiliao2
e10a202589f281a884688e550cb1a3bdcdca3fc6
7c23870b5876b46a7d61fea117c7db0ae846df90
refs/heads/master
2022-11-17T21:21:11.680666
2020-07-08T02:20:22
2020-07-08T02:20:22
null
0
0
null
null
null
null
UTF-8
Java
false
false
10,225
java
package com.ziran.meiliao.constant; /** * author 吴祖清 * create 2017/3/31 10 * des 基本常量 * <p> * updateAuthor * updateDate * updateDes */ public interface AppConstant { String URL = "http://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1512405681970&di=8224522cd94a416d9af9dc0be1b97a3a" + "&imgtype=0&src=http%3A%2F%2Fimg1.3lian.com%2F2015%2Fa1%2F105%2Fd%2F40.jpg"; // String URL = "http://pic30.nipic.com/20130624/7447430_170433987002_2.jpg"; /** * 保存主页面的底部Tab选择索引 */ String HOME_CURRENT_TAB_POSITION = "HOME_CURRENT_TAB_POSITION"; /** * 用户信息编辑来源(1 编辑用户昵称, 2 编辑email) */ String KEY_EDIT_USERINFO_FROM = "KEY_EDIT_USERINFO_FROM"; /** * 下载的来源 */ String DOWN_ALBUM = "downAlbum"; /** * 下载的来源 */ String DOWN_COURSE = "downCourse"; /** * 当前播放的音乐对象 */ String KEY_MUSIC = "music"; /** * 缓存在数据库中的首页减压馆推荐的id */ long CACHE_PAGE_MAIN_JYG_RECOMMEND = 100L; /** * 缓存在数据库中的首页减压馆分类栏目的id */ long CACHE_PAGE_MAIN_JYG_CATEGORY = 1000L; /** * 缓存在数据库中的首页减压馆分类栏目详情的id */ long CACHE_PAGE_MAIN_JYG_CATEGORY_DETAIL = 10000L; /** * 缓存在数据库中的首页数据库直播的id */ long CACHE_PAGE_MAIN_SJK_ZHIBO = 110L; /** * 缓存在数据库中的首页我的界面预告的id */ long CACHE_PAGE_MAIN_ME_TRAILER = 130L; /** * 缓存在数据库中的首页数据库活动的id */ long CACHE_PAGE_MAIN_SJK_ACT = 120L; /** * 缓存在数据库中的历史课程列表的id */ long CACHE_PAGE_HISTORY_COURSE = 140L; /** * 缓存在数据库中的官方消息的id */ long CACHE_PAGE_ME_MESSAGE = 245L; /** * 当前是否是练习中状态 */ String UPDATE_ENROL_ACTIVITY = "refreshAct"; String UPDATE_COLLECT_ACTIVITY = "updateCollect"; java.lang.String VERSION_CODE = "VERSION_CODE"; /** * author 吴祖清 * create 2017/3/31 10 * des 偏好设置常量与Intent 和 Bundle 传参 常量 RxBus tag 常量 * <p> * updateAuthor * updateDate * updateDes */ interface SPKey { String TOKEN = "accessToken"; String R_TOKEN = "r_accessToken"; String PHONE = "phone"; String USERID = "USERID"; String EXTRAS_URL = "url"; String ALBUM_ID = "albumId"; String COURSE_ID = "courseId"; String MESSAGE_PUSH = "MESSAGE_PUSH"; String EXERCISE_NUMBER = "EXERCISE_NUMBER"; String PLAY_MODE = "PLAY_MODE"; String WIFI_DOWNLOAD_SWITCH = "WIFI_DOWNLOAD_SWITCH"; String SYSTEM_VERSION = "system_version"; String SHOW_JYG_FRAGMENT_PLAY = "showplay"; String PLAY_CURRENT_DATA = "PLAY_CURRENT_DATA"; String PLAY_DATA = "loadData"; String FIRST_SHOW_PUSH_TIPS = "FIRST_SHOW_PUSH_TIPS"; String COURSE_FRIST_TIPS = "COURSE_FRIST_TIPS"; String NOTIFY_LIAN_XI = "NOTIFY_LIAN_XI"; String ALBUM_FLAG = "ALBUM_FLAG"; } interface RXTag { String PLAY_STATE = "PLAY_STATE"; /** * 是否显示底部动作栏 */ String FITNESS_BACK = "FITNESS_BACK"; /** * 当前音频播放界面的音乐的播放进度 */ String MUSIC_PLAY_UPDATE_POSITION = "MUSIC_PLAY_UPDATE_POSITION"; /** * 当前练习界面音乐的播放进度 */ String EXERCISE_PLAY_UPDATE_POSITION = "EXERCISE_PLAY_UPDATE_POSITION"; /** * 设置当前播放视频的路径 */ String VIDEO_PATH = "viedoPath"; /** * 设置当前播放视频的路径 */ String UPDATE_TITLE = "updataTitle"; String UPDATE_MEMBER="updataMember"; String UPDATE_COLLECT = "updateCollect"; String DELETE_UPDATE = "deleteUpdate"; String CLOSE_VIEW = "closeView"; String UMENG_MSG = "UMessage"; String UMENG_MSG_CLICK = "UMessageClick"; String SEND = "send"; String USER_COUNT = "userCount"; String PUSH = "push"; String UPDATE_TRAILER = "updateTrailer"; String TRAILER_WEB_ACTIVITY_DATA = "TrailerWebActivityData"; String DELETE = "delete"; String CLOSE = "close"; String UPDATE_SEL = "updateSel"; String SHOW_DIALOG = "showDialog"; String ON_WEB_PAY = "onWebPay"; String EDIT_USER_INFO = "EDIT_USER_INFO"; String UPDATE_USER = "UPDATE_USER"; String UPDATE_OTHERUSER = "UPDATE_OTHERUSER"; String NETWORK_CHANGE_STATE = "netWorkState"; String REQ_BUY_COURSE = "REQ_BUY_COURSE"; String REQ_BUY_COURSE_FINISH = "REQ_BUY_COURSE_FINISH"; String LIVE_OVER = "LIVE_OVER"; String USER_TICK = "USER_TICK"; String GIVE_GIFT = "GIVE_GIFT"; String GIVE_GIFT1 = "GIVE_GIFT1"; String GIVE_GIFT2 = "GIVE_GIFT2"; String BALANCE = "balance"; String GIVE_ALBUM = "GIVE_ALBUM"; String ALBUM_COUNT_DOWN_TIME = "ALBUM_COUNT_DOWN_TIME"; String PLAYER_END = "PLAYER_END"; String POPUW_SET_TIME_DISMISS = "POPUW_SET_TIME_DISMISS"; String UNBIND_BANK = "UNBIND_BANK"; String SUBSCRIBE_AUDIO_TAG = "SUBSCRIBE_AUDIO_TAG"; int SUBSCRIBE_AUDIO_TAG_POST_COMMENT = 0x6e21; int SUBSCRIBE_AUDIO_TAG_POST_PRAISE_COMMENT = 0x6e22; String CATEGORY_MORE_CLICK = "CATEGORY_MORE_CLICK"; String MAIN_HOME_MORE_CLICK = "MAIN_HOME_MORE_CLICK"; String SJKZHUANLAN_MORE_CLICK = "SJKZHUANLAN_MORE_CLICK"; String DELETE_NOTES = "DELETE_NOTES"; String HOME_MUSIC_PLANE_SHOW_OR_HIDE = "HOME_MUSIC_PLANE_SHOW_OR_HIDE"; String EXERCISE_PLAY = "EXERCISE_PLAY"; String SUBSCRIBE_COMMENT_FRAGMENT_SHOW_OR_HIDE = "SUBSCRIBE_COMMENT_FRAGMENT_SHOW_OR_HIDE"; String AUDIO_ID = "audioId"; String SWITCH_FRAGMENT = "SWITCH_FRAGMENT"; String HOME_UPDATE = "HOME_UPDATE"; String SUBSCRIBE_UPDATE = "SUBSCRIBE_UPDATE"; String BIG_IN_TAG = "BIG_IN_TAG"; String SUBMIT_USER_MSG = "SUBMIT_USER_MSG"; String PRACTICE_CAN_SCROLL = "PRACTICE_CAN_SCROLL"; String CONFERENCE_GET_CONFERENCE = "CONFERENCE_GET_CONFERENCE"; String GET_GAIN_SPREAD = "GET_GAIN_SPREAD"; String BIND_VIEWPAGER_UTIL = "BIND_VIEWPAGER_UTIL"; String WORKSHOPS_MAIN_TOP_BAR_SHOW_HIDE = "WORKSHOPS_MAIN_TOP_BAR_SHOW_HIDE"; String BASE_ITEM_VIEW_CLICK_ID = "BASE_ITEM_VIEW_CLICK_ID"; String CROWD_FUNDING_CHOOSE_DATA = "CROWD_FUNDING_CHOOSE_DATA"; String CHANGE_VIDEO_PLAY_STATE = "CHANGE_VIDEO_PLAY_STATE"; String CITY_DATA = "CITY_DATA"; String USER_TEMPLATE = "USER_TEMPLATE"; String IMAGE_RESULT = "image"; String SUBMIT_CROWD_FUNDING_MSG = "SUBMIT_CROWD_FUNDING_MSG"; String PREVIEW_CLOSE = "PREVIEW_CLOSE"; String MPS_COMPLETION = "MPS_COMPLETION"; String UPDATE_STUDY_FINISH = "UPDATE_STUDY_FINISH"; String REFUND_RESULT = "REFUND_RESULT"; String ZL_BUY_SUCESS = "ZL_BUY_SUCESS"; String MUSIC_BUY_SUCESS = "MUSIC_BUY_SUCESS"; } interface ExtraKey { String ALBUM_GAIN = "ALBUM_GAIN"; String EXTRAS_TITLE = "title"; String COLUMN_ID = "columnId"; String SUBSCRIPTION_ID = "subscriptionId"; String TARGET_ID = "targetId"; String ALBUM_TITLE = "ALBUM_TITLE"; /** * 当前编辑用户个人资料的内容 */ String KEY_CONTENT = "KEY_CONTENT"; String LIVE_STREAMING = "liveStreaming"; String M_VIDEO_PATH = "videoPath"; String VIDEO_TITLE = "title"; String FROM_TYPE = "FROM_TYPE"; String FROM_CONDITION = "FROM_CONDITION"; String FROM_ID = "_ID"; String DEVICE_TOKEN = "deviceToken"; String BALANCE = "BALANCE"; String IS_LOAD_DETAIL = "IS_LOAD_DETAIL"; String AUTHOR_DATA = "AUTHOR_DATA"; String CARD_NO = "bankCardNo"; String BANK_INFO = "BANK_INFO"; String BANK_LIST = "BANK_LIST"; String ZHUANLAN_PAY_DATA = "ZHUANLAN_PAY_DATA"; String BEAN = "bean"; String UNREAD_COUNT = "UNREAD_COUNT"; String TARGET_KEY = "TARGET_KEY"; // String COMMON_ID = "COMMON_ID"; String EXTRAS_DATA = "EXTRAS_DATA"; String EXTRAS_ZHIBO = "EXTRAS_ZHIBO"; String EXTRAS_DATA_NEEDED = "EXTRAS_DATA_NEEDED"; String COUNT_DOWN_STOP = "COUNT_DOWN_STOP"; String CLEAR_FILTER = "CLEAR_FILTER"; String FROM_CAN_CLOSE = "FROM_CAN_CLOSE"; } interface CollectCourse{ String ITEM_TYPE_ACTIVITY = "activity"; String ITEM_TYPE_CROWD_FUND = "crowdFunds"; String ITEM_TYPE_TEAM = "missionBuilts"; String ITEM_TYPE_TEACHER = "famousTeachers"; } interface TeamDetail { int TYPE_DAY = 1; int TYPE_NORMAL = 2; int ICON_TYPE_ADDRESS = 1; int ICON_TYPE_RITE = 2; int ICON_TYPE_HOURSE = 3; int ICON_TYPE_HOTEL = 4; } interface SearchId { int WHAT_FROM_TYPE_CROWD_FUNDING_PROJECT_MSG = 10; int WHAT_FROM_TYPE_CROWD_FUNDING_PROJECT_MSG_AVATAR = 12; int WHAT_FROM_TYPE_CROWD_FUNDING_USED_INPUT_MSG = 11; int WHAT_TOPIC = 1; int WHAT_TEACHER = 2; int WHAT_HOME_TEACHER_LIST = 3; String TYPE_FORM_TOPIC = "TYPE_FORM_TOPIC"; String TYPE_FORM_TEACHER = "TYPE_FORM_TEACHER"; String TYPE_FORM_HOME_TEACHER_LIST = "TYPE_FORM_HOME_TEACHER_LIST"; int RESULT_TEAM = 1114; int RESULT_TEACHER = 1115; int RESULT_XIANG_GUAN = 1118; int RESULT_EMPTY = 1119; int RESULT_CROWD_FUNDING = 1113; int RESULT_ALBUM = 1110; int RESULT_COURSE = 1111; int RESULT_ACTIVITY = 1112; } }
[ "s66225303" ]
s66225303
036ef3f89cb10c74232d24b80eb2c6a1f075e351
568a97f8791e6409382a6a63f50ffe1bb7d2563b
/src/PracticePrograms/MyFavoritePoem.java
5ed1d17d0bc55649c86c683d347a3eb4d34c8868
[]
no_license
kaezhar97/Big-Java-Book-Practice
cec8ece617a4a17410fa8b5614753410c03cc8ed
a1b573bfb729f7b84676faa130ff8c5f79684307
refs/heads/master
2021-07-02T18:25:58.626606
2017-09-13T22:33:14
2017-09-13T22:33:14
103,315,773
0
0
null
null
null
null
UTF-8
Java
false
false
1,507
java
/* * 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 PracticePrograms; /** * * @author Octavio */ public class MyFavoritePoem { public static void main (String args[]) { System.out.println("Invictus"); System.out.println("by William Ernest Henley\n"); System.out.println("Out of the night that covers me,"); System.out.println(" Black as the pit from pole to pole,"); System.out.println("I thank whatever gods may be"); System.out.println(" For my unconquerable soul.\n"); System.out.println("In the fell clutch of circumstance"); System.out.println(" I have not winced nor cried aloud."); System.out.println("Under the bludgeonings of chance"); System.out.println(" My head is bloody, but unbowed.\n"); System.out.println("Beyond this place of wrath and tears"); System.out.println(" Looms but the Horror of the shade,"); System.out.println("And yet the menace of the years"); System.out.println(" Finds and shall find me unafraid.\n"); System.out.println("It matters not how strait the gate,"); System.out.println(" How charged with punishments the scroll,"); System.out.println("I am the master of my fate,"); System.out.println(" I am the captain of my soul."); } }