blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
410
content_id
stringlengths
40
40
detected_licenses
sequencelengths
0
51
license_type
stringclasses
2 values
repo_name
stringlengths
5
132
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
80
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
5.85k
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
131 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
9.45M
extension
stringclasses
32 values
content
stringlengths
3
9.45M
authors
sequencelengths
1
1
author_id
stringlengths
0
313
d82b1dba2a954ce91ad1347f0de324efd8c9a668
4a3648bc8c5b05f5126d43a64177896e181dfd23
/parent/service-api-zb-impl/src/main/java/com/eason/api/zb/cache/ZbTUserPersonal.java
28cb94491aacdfa022d6fd4c2ba2262d14f9d6e8
[]
no_license
jayfeihe/myhost
7fa09711858c6d48b4b8df3d1c8f068f2fc5029e
f02817d80ca42a8581c48348bcf1dc6a3b894816
refs/heads/master
2020-06-24T15:45:49.111585
2018-07-05T06:15:18
2018-07-05T06:15:18
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,968
java
package com.eason.api.zb.cache; import com.eason.api.zb.model.GeneratedValue; import org.springframework.data.annotation.Id; import org.springframework.data.mongodb.core.index.CompoundIndex; import org.springframework.data.mongodb.core.index.CompoundIndexes; import org.springframework.data.mongodb.core.mapping.Document; import java.io.Serializable; import java.util.Date; @Document(collection = "zb_t_user_personal") @CompoundIndexes({ @CompoundIndex(name = "zb_user_id_index", def = "{'zbId': 1, 'userId': -1}") }) public class ZbTUserPersonal implements Serializable { private static final long serialVersionUID = 1L; @GeneratedValue @Id private int id; private Integer zbId; private Integer userId; private Date startTime; private Integer activityTime; private Date inviteTime; //邀请时间 private Date bookTime; public ZbTUserPersonal() { } public int getId() { return id; } public void setId(int id) { this.id = id; } public Integer getUserId() { return userId; } public void setUserId(Integer userId) { this.userId = userId; } public Integer getZbId() { return zbId; } public void setZbId(Integer zbId) { this.zbId = zbId; } public Integer getActivityTime() { return this.activityTime; } public void setActivityTime(Integer activityTime) { this.activityTime = activityTime; } public Date getInviteTime() { return inviteTime; } public void setInviteTime(Date inviteTime) { this.inviteTime = inviteTime; } public Date getStartTime() { return this.startTime; } public void setStartTime(Date startTime) { this.startTime = startTime; } public Date getBookTime() { return bookTime; } public void setBookTime(Date bookTime) { this.bookTime = bookTime; } }
bfaa89efbb7f47081d43403025161b556ed556cf
3ef55e152decb43bdd90e3de821ffea1a2ec8f75
/large/module0890_public/src/java/module0890_public/a/IFoo1.java
669371b460bac5b6549c328642f67aeb6bb14958
[ "BSD-3-Clause" ]
permissive
salesforce/bazel-ls-demo-project
5cc6ef749d65d6626080f3a94239b6a509ef145a
948ed278f87338edd7e40af68b8690ae4f73ebf0
refs/heads/master
2023-06-24T08:06:06.084651
2023-03-14T11:54:29
2023-03-14T11:54:29
241,489,944
0
5
BSD-3-Clause
2023-03-27T11:28:14
2020-02-18T23:30:47
Java
UTF-8
Java
false
false
810
java
package module0890_public.a; import java.util.zip.*; import javax.annotation.processing.*; import javax.lang.model.*; /** * Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut * labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. * Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. * * @see java.awt.datatransfer.DataFlavor * @see java.beans.beancontext.BeanContext * @see java.io.File */ @SuppressWarnings("all") public interface IFoo1<Z> extends module0890_public.a.IFoo0<Z> { java.rmi.Remote f0 = null; java.nio.file.FileStore f1 = null; java.sql.Array f2 = null; String getName(); void setName(String s); Z get(); void set(Z e); }
9a7e94be8bd85e36649b412ee8eea2184d6d60e4
78b3c85eb518ebfeb4437c3e0ac3b541364b9a82
/springcloud-consumer/src/main/java/com/xiao/springcloudconsumer/SpringcloudConsumerApplication.java
30d0c9a079884dd7b47be2f1ec7238d642d3c7d5
[]
no_license
xiaowangjun/springcloud
2cfcf8c35a29e9185581c00ec0804676bafce012
c1e23ea89169a183ba9894d40700309130d2fadf
refs/heads/master
2022-11-24T15:59:45.482185
2019-10-10T10:02:41
2019-10-10T10:02:41
179,222,445
0
0
null
null
null
null
UTF-8
Java
false
false
748
java
package com.xiao.springcloudconsumer; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.netflix.feign.EnableFeignClients; import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients @EnableHystrixDashboard @EnableCircuitBreaker public class SpringcloudConsumerApplication { public static void main(String[] args) { SpringApplication.run(SpringcloudConsumerApplication.class, args); } }
8ba7ecb25fc1ce6dee9fec642216a609272d3237
6012ab2cd878c3d427a751243d83b72d1f9e755e
/spreader-task-register/src/com/nali/spreader/words/IDGenerator.java
0c0143c65cef699133dac90881639c2742130ebe
[]
no_license
heiheisoftware/spreader
50c0c79025fa369ca21352e891707cf8f8dd3cd4
bfb95a8c77a1f65d97664805081ffc33351e98f4
refs/heads/master
2020-06-10T19:46:21.433789
2014-12-27T05:08:31
2014-12-27T05:08:31
null
0
0
null
null
null
null
UTF-8
Java
false
false
4,094
java
package com.nali.spreader.words; import java.util.Random; public class IDGenerator { private static Random random=new Random(); //110102 YYYYMMDD 888 X //地址码 出生日期码 顺序码(奇数男性,偶数女性) 校验码 private static final int[] weights = new int[] {7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2,1}; private static char check(int[] nums) { int sum=0; for (int i = 0; i < nums.length; i++) { sum += nums[i] * weights[i]; } int rltInt = (12 - (sum%11)) % 11; return rltInt==10 ? 'X' : (char)(rltInt+'0'); } /** * @param idCode 18位身份证 */ public static Integer getAreaCode(String idCode) { return Integer.valueOf(idCode.substring(0, 6)); } /** * @param idCode 18位身份证 */ public static Integer getYear(String idCode) { return Integer.valueOf(idCode.substring(6, 10)); } /** * @param idCode 18位身份证 */ public static Integer getMonth(String idCode) { return Integer.valueOf(idCode.substring(10, 12)); } /** * @param idCode 18位身份证 */ public static Integer getDate(String idCode) { return Integer.valueOf(idCode.substring(12, 14)); } /** * @param idCode 18位身份证 */ public static Boolean isMale(String idCode) { return Integer.valueOf(idCode.substring(14, 17)) % 2 == 1; } /** * 15位转18位 */ public static String tran15(String old) { if(old.length()!=15) { throw new IllegalArgumentException("id's length does not equal 15:" + old); } int[] nums = new int[17]; fill(Integer.parseInt(old.substring(0, 6)), nums, 5, 6); fill(19, nums, 7, 2); fill(Integer.parseInt(old.substring(6)), nums, 16, 9); return generate(nums); } /** * @return 统一返回18位身份证 */ public static String checkedId(String rawId) throws IllegalArgumentException { String id; if(rawId.length()==18) { if(rawId.charAt(17)=='x') { id = rawId.substring(0, 17) + 'X'; } else { id = rawId; } } else if(rawId.length()==15) { id = tran15(rawId); } else { throw new IllegalArgumentException("id's length does not equal 15 or 18:" + rawId); } Integer month = getMonth(id); if(month>12||month==0) { throw new IllegalArgumentException("illegal month:" + rawId); } Integer date = getDate(id); if(date>31||date==0) { throw new IllegalArgumentException("illegal month:" + rawId); } if(rawId.length()==18) { int[] numArray = new int[17]; fill(Integer.parseInt(id.substring(0, 9)), numArray, 8, 9); fill(Integer.parseInt(id.substring(9, 17)), numArray, 16, 8); char checkChar = check(numArray); if(checkChar!=id.charAt(17)) { throw new IllegalArgumentException("illegal checkChar:" + rawId); } } return id; } public static String generate(int areaCode, int year, int month, int date, boolean maleGender) { if(maleGender) { return generate(areaCode, year, month, date, random.nextInt(500) * 2 + 1); } else { return generate(areaCode, year, month, date, random.nextInt(499) * 2 + 2); } } public static String generate(int areaCode, int year, int month, int date, int seq) { int[] nums = new int[17]; fill(areaCode, nums, 5, 6); fill(year, nums, 9, 4); fill(month, nums, 11, 2); fill(date, nums, 13, 2); fill(seq, nums, 16, 3); return generate(nums); } private static String generate(int[] nums) { char checkCode = check(nums); char[] chars = new char[18]; for (int i = 0; i < 17; i++) { chars[i] = (char) (nums[i] + '0'); } chars[17] = checkCode; return new String(chars); } private static void fill(int number, int[] numArray, int endPos, int length) { if(length-1 > endPos) { throw new IllegalArgumentException("length-1 > endPos"); } for (int i = endPos; ; i--) { numArray[i] = number%10; number/=10; if(number==0) { break; } if(i==0) { throw new IllegalArgumentException("number[" + number + "] is longer than the length:" + length); } } } }
52db6dc92048c82559fe1696c563d1374ffe56fc
83e81c25b1f74f88ed0f723afc5d3f83e7d05da8
/packages/SimAppDialog/src/com/android/simappdialog/InstallCarrierAppActivity.java
a4b2e24af71cbc79d9890d8ca3e930d30b1715bc
[ "Apache-2.0", "LicenseRef-scancode-unicode" ]
permissive
Ankits-lab/frameworks_base
8a63f39a79965c87a84e80550926327dcafb40b7
150a9240e5a11cd5ebc9bb0832ce30e9c23f376a
refs/heads/main
2023-02-06T03:57:44.893590
2020-11-14T09:13:40
2020-11-14T09:13:40
null
0
0
null
null
null
null
UTF-8
Java
false
false
3,786
java
/* * Copyright (C) 2018 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.android.simappdialog; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.sysprop.SetupWizardProperties; import android.text.TextUtils; import android.view.View; import android.widget.Button; import android.widget.TextView; import com.android.setupwizardlib.util.WizardManagerHelper; /** * Activity that gives a user the choice to download the SIM app or defer until a later time * * Will finish with result {@link #DEFER_RESULT} on defer button press or {@link #DOWNLOAD_RESULT} * if the download button is pressed * * Can display the carrier app name if its passed into the intent with key * {@link #BUNDLE_KEY_CARRIER_NAME} */ public class InstallCarrierAppActivity extends Activity implements View.OnClickListener { /** * Key for the carrier app name that will be displayed as the app to download. If unset, a * default description will be used */ public static final String BUNDLE_KEY_CARRIER_NAME = "carrier_name"; /** Result code when the defer button is pressed */ public static final int DEFER_RESULT = 1; /** Result code when the download button is pressed */ public static final int DOWNLOAD_RESULT = 2; @Override protected void onCreate(Bundle icicle) { // Setup theme for aosp/pixel setTheme( WizardManagerHelper.getThemeRes( SetupWizardProperties.theme().orElse(""), R.style.SuwThemeGlif_Light ) ); super.onCreate(icicle); setContentView(R.layout.install_carrier_app_activity); Button notNowButton = findViewById(R.id.skip_button); notNowButton.setOnClickListener(this); Button downloadButton = findViewById(R.id.download_button); downloadButton.setOnClickListener(this); // Show/hide illo depending on whether one was provided in a resource overlay boolean showIllo = getResources().getBoolean(R.bool.show_sim_app_dialog_illo); View illoContainer = findViewById(R.id.illo_container); illoContainer.setVisibility(showIllo ? View.VISIBLE : View.GONE); // Include carrier name in description text if its present in the intent Intent intent = getIntent(); if (intent != null) { String carrierName = intent.getStringExtra(BUNDLE_KEY_CARRIER_NAME); if (!TextUtils.isEmpty(carrierName)) { TextView subtitle = findViewById(R.id.install_carrier_app_description); subtitle.setText(getString(R.string.install_carrier_app_description, carrierName)); } } } @Override public void onClick(View v) { switch (v.getId()) { case R.id.skip_button: finish(DEFER_RESULT); break; case R.id.download_button: finish(DOWNLOAD_RESULT); break; } } private void finish(int resultCode) { setResult(resultCode); finish(); } }
75661acd8c9404226a5a15e26ae5d732db8ca365
30f1f0f62d5127deb774ff9d4deb16b070905d1f
/src/com/uahoy/campaign/util/GetStackElements.java
cb0b10215f17508d4dc53701aec49c885e51e67f
[]
no_license
vivekdhakre/campaign-page
9429118b2b3f0d31cf75864fbc2e4c35f0cf4f28
b91fb390fff709e75f1285cf324734b0db742889
refs/heads/master
2020-12-30T14:45:15.711153
2017-07-03T06:51:59
2017-07-03T06:51:59
91,084,518
0
0
null
null
null
null
UTF-8
Java
false
false
374
java
package com.uahoy.campaign.util; public class GetStackElements { public static String getRootCause(Exception e, String className) { for (StackTraceElement element : e.getStackTrace()) { if (element.getClassName().equals(className)) { return "Exception : " + e + " at " + element; } } return null; } }
4cc9469c03f762f9c9e6d2da8aeb5dcd440b9771
419dc8af02e1b128acb0fd0fc444918cfb12751f
/app/src/main/java/com/rcpt/mvp/module/TestRecordModule.java
5c560260e9b9ae1a99fe3fa66d5a5fdd9c1d03f1
[]
no_license
jieyuchongliang/RCPT
e9f7258b1ca9ec6cdf688bafb43c5fd2c201371a
931c4ccfbcf8f123f4f2152ea36b61121d5337da
refs/heads/master
2021-01-15T12:59:25.001619
2017-08-08T07:27:38
2017-08-08T07:27:38
99,663,470
0
0
null
null
null
null
UTF-8
Java
false
false
1,857
java
package com.rcpt.mvp.module; import android.content.Context; import com.rcpt.base.HttpResult; import com.rcpt.base.mvp.OnDataGetCallback; import com.rcpt.bean.TestRecordListBean; import com.rcpt.http.ProgressSubscriber; import com.rcpt.http.RequestImpl; import com.rcpt.http.RetrofitManager; import com.rcpt.http.api.ApiClient; import java.util.List; /** * Created by 860617003 on 2017/5/25. */ public class TestRecordModule { private boolean isEnd; private List<TestRecordListBean.CompanyFavoritesBean> mListData; public void requestTestRecordList(Context context, String userId, int pageNum, final OnDataGetCallback<List<TestRecordListBean.CompanyFavoritesBean>> callback) { RetrofitManager.toSubscribe( ApiClient.getApiService().getTestRecordList(userId, pageNum) , new ProgressSubscriber<HttpResult<TestRecordListBean>>(context, new RequestImpl<HttpResult<TestRecordListBean>>() { @Override public void onNext(HttpResult<TestRecordListBean> result) { TestRecordListBean data = result.getData(); if (data != null) { if (mListData == null) { mListData = data.getCompanyFavorites(); } else { mListData.addAll(data.getCompanyFavorites()); } isEnd = !data.isIsNext(); } callback.onSuccessResult(mListData); } }) ); } public boolean isEnd() { return isEnd; } public List<TestRecordListBean.CompanyFavoritesBean> getListData() { return mListData; } }
0985150961b631393c4944c0454cc164a9c86d34
e8e72feb13b6833d6ffe19729db0f057d5f2d122
/hc-device-service/src/main/java/com/hc/device/config/PageHelperConfig.java
dde54676be92eb3e1a1186815c1e962f6cc086f8
[]
no_license
Huali23/device-service
019aac811c08a6556b24c779c47369cbe67d264d
3e06ce33569f2239da230f1846772581a5fd91cb
refs/heads/master
2023-04-05T16:16:22.137762
2021-04-13T09:47:21
2021-04-13T09:47:21
351,003,441
0
0
null
null
null
null
UTF-8
Java
false
false
835
java
package com.hc.device.config; import com.github.pagehelper.PageHelper; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import java.util.Properties; @Configuration public class PageHelperConfig { @Bean public PageHelper pageHelper() { PageHelper pageHelper = new PageHelper(); Properties properties = new Properties(); properties.setProperty("offsetAsPageNum", "true"); properties.setProperty("rowBoundsWithCount", "true"); properties.setProperty("pageSizeZero", "true");//pageSize=0,查询全部 properties.setProperty("reasonable", "true"); properties.setProperty("dialect", "mysql"); // 配置mysql数据库的方言 pageHelper.setProperties(properties); return pageHelper; } }
4bd63bbcd35bc4aeedf8b45c4e7fd340544d284f
db0b1d5e0f34d588b268f0f7765db3e747021560
/Math/baekjoon_2292.java
16eb542b0be13ddc0677506379208859eff9b3ab
[]
no_license
yelimi/algorithm
ea597be60029165641930fe88655fda3114b0a3f
45df05867024dcddc3dc9c4e3cf88c3aea4592f8
refs/heads/master
2022-06-21T23:39:01.922874
2022-05-29T16:48:37
2022-05-29T16:48:37
225,543,322
0
0
null
null
null
null
UTF-8
Java
false
false
522
java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main{ public static void main(String[] args) throws IOException { // TODO Auto-generated method stub BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int sum = 1; int index = 0; while(true) { sum = sum + (6 * index); if(sum >= n) { System.out.print(index + 1); break; } index++; } } }
5a45c027e133441d09482617976e6febd791cbfb
2bead5b7f8175f95b6fe2054d938e9813d01fcae
/src/main/java/io/github/elytra/concrete/annotation/field/Optional.java
13b9b30cd2442f6a7c2948e6db501ab74d51e586
[ "MIT" ]
permissive
darkevilmac/Concrete
d36dcf5a806c303943c9a59a5ec3c5e2b01a7a62
214ff2211448b551d79c1b6062a1e980de778878
refs/heads/1.10.2
2021-01-16T17:48:46.170401
2017-10-25T07:29:08
2017-10-25T07:29:08
90,093,053
0
1
null
2017-06-16T01:34:09
2017-05-03T01:01:21
Java
UTF-8
Java
false
false
578
java
package io.github.elytra.concrete.annotation.field; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Specifies a Message field as optional, meaning it may be null. This will * incur a cost of one boolean, with the same bitfield optimization as normal * booleans. Null Message fields are normally an error. */ @Documented @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) public @interface Optional {}
c8bb6526d05fcbb81cb63750cecceac0ba291757
a98e00126f575e5c5a291496bbe3af73523bbbd3
/odf-template-engine/odtprocessor/src/main/java/cz/jalasoft/template/engine/odt/OdtTemplateEngine.java
05ec76fd9d6c5af6e20206e06290f420ef53ed47
[]
no_license
jalasoft/java-learning
70f5cd280cffec583943f495c20edd186c9afba5
e09813261ddcab88311e911df277dd51ad8276dc
refs/heads/master
2022-12-27T10:24:20.244320
2020-08-06T08:55:06
2020-08-06T08:55:06
252,143,897
0
0
null
2022-11-16T09:58:55
2020-04-01T10:32:14
Java
UTF-8
Java
false
false
2,609
java
package cz.jalasoft.template.engine.odt; import cz.jalasoft.template.engine.DataModel; import cz.jalasoft.template.engine.Document; import cz.jalasoft.template.engine.TemplateCompilationException; import cz.jalasoft.template.engine.TemplateEngine; import cz.jalasoft.template.engine.TemplateSource; import cz.jalasoft.template.engine.odt.expression.ExpressionEvaluator; import cz.jalasoft.template.engine.odt.visitor.AnnotationResolvingContentVisitor; import cz.jalasoft.template.engine.odt.visitor.ConditionalSubTreeContentVisitor; import cz.jalasoft.template.engine.odt.visitor.DomBuildingContentVisitor; import cz.jalasoft.template.engine.odt.visitor.InterpolationResolvingContentVisitor; import org.odftoolkit.odfdom.doc.OdfDocument; import org.odftoolkit.odfdom.doc.OdfTextDocument; import org.odftoolkit.odfdom.dom.element.office.OfficeTextElement; import java.io.ByteArrayOutputStream; public final class OdtTemplateEngine implements TemplateEngine { public Document compile(TemplateSource source, DataModel model) throws TemplateCompilationException { try (OdfTextDocument document = (OdfTextDocument) OdfDocument.loadDocument(source.input())) { return compile(document, model); } catch (Exception exc) { throw new TemplateCompilationException(exc); } } private Document compile(OdfTextDocument document, DataModel model) throws Exception { ExpressionEvaluator resolver = new ExpressionEvaluator(model); domModificationIteration(document, new InterpolationResolvingContentVisitor(document.getContentDom(), resolver)); domModificationIteration(document, new AnnotationResolvingContentVisitor(document.getContentDom(), resolver)); domModificationIteration(document, new ConditionalSubTreeContentVisitor(document.getContentDom(), resolver)); ByteArrayOutputStream s = new ByteArrayOutputStream(); document.save(s); return new Document(s.toByteArray()); } private void domModificationIteration(OdfTextDocument document, DomBuildingContentVisitor visitor) throws Exception { constructNewDom(document, visitor); replaceContent(document, visitor); } private void constructNewDom(OdfTextDocument document, DomBuildingContentVisitor visitor) throws Exception { OfficeTextElement root = document.getContentRoot(); new ContentWalker(root).walk(visitor); } private void replaceContent(OdfTextDocument document, DomBuildingContentVisitor visitor) throws Exception { OfficeTextElement root = document.getContentRoot(); while(root.hasChildNodes()) { root.removeChild(root.getFirstChild()); } visitor.content().forEach(p -> root.insert(p, 0)); } }
b58afa4bd01c6e347e03c2637bc864c8d7092fbc
9fa1566e9f0c88816d54c2b26ffcb15cba4b1729
/test/words/WordTest.java
f9dcf57f065ba5c637185909219dd87e1efd5cba
[]
no_license
iworourke/Words
dc70f59de43b3c6e9d5215410265b6c42e96470e
f923cc8c6b70dd4e73057e0f887becf1ac0fbf78
refs/heads/master
2021-01-10T10:28:55.976245
2016-01-19T20:48:49
2016-01-19T20:48:49
48,661,940
0
0
null
null
null
null
UTF-8
Java
false
false
3,933
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 words; import org.junit.After; import org.junit.Before; import org.junit.Test; import static org.junit.Assert.*; /** * * @author iworourke */ public class WordTest { private Word word1, word2, word3; private PhoneticRepresentation pr1, pr2, pr3; private String busText = "B AH S"; private String mudText = "M AH D"; private String dogText = "D AO G"; @Before public void setUp() { pr1 = new PhoneticRepresentation(busText); pr2 = new PhoneticRepresentation(mudText); pr3 = new PhoneticRepresentation(dogText); word1 = new Word("bus", pr1); word2 = new Word("mud", pr2); word3 = new Word("dog", pr3); } @After public void tearDown() { System.out.println("Running tear down..."); } /** * Test of isLiteralMatch method, of class Word. */ @Test public void testConventionalSpellingMatches() { Word instance, candidate; boolean expResult, result; System.out.println("isLiteralMatch"); instance = new Word(word1); candidate = new Word(word1); expResult = true; result = instance.conventionalSpellingMatches(candidate); assertEquals(expResult, result); candidate = new Word(word3); expResult = false; result = instance.conventionalSpellingMatches(candidate); assertEquals(expResult, result); } /** * Test of isPhoneticMatch method, of class Word. */ @Test public void testPhoneticSpellingMatches() { Word candidate, instance; boolean expResult, result; System.out.println("isPhoneticMatch"); instance = new Word(word1); candidate = new Word(word1); expResult = true; result = instance.phoneticSpellingMatches(candidate); assertEquals(expResult, result); candidate = new Word(word3); expResult = false; result = instance.phoneticSpellingMatches(candidate); assertEquals(expResult, result); } /** * Test of hashCode method, of class Word. */ @Test public void testHashCode() { System.out.println("hashCode"); Word instance1 = new Word(word1); Word instance2 = new Word(word1); int result1 = instance1.hashCode(); int result2 = instance2.hashCode(); assertEquals(result1, result2); } /** * Test of equals method, of class Word. */ @Test public void testEquals() { System.out.println("equals"); Object other = new Word(word1); Word instance = new Word(word1); boolean expResult = true; boolean result = instance.equals(other); assertEquals(expResult, result); other = new Word(word3); expResult = false; result = instance.equals(other); assertEquals(expResult, result); } /** * Test of printWord method, of class Word. */ @Test public void testPrintWord() { System.out.println("printWord"); Word instance = new Word(word1); boolean thrown = false; try { instance.printConventionalSpelling(); } catch(Exception e) { thrown = true; } assertFalse(thrown); } /** * Test of compareTo method, of class Word. */ @Test public void testCompareTo() { System.out.println("compareTo"); Word o = new Word(word1); Word instance = new Word(word1); int expResult = 0; int result = instance.compareTo(o); assertEquals(expResult, result); } }
9f569281f83fb6fb78626a6244aef29c4266ce4c
732182a102a07211f7c1106a1b8f409323e607e0
/robot/src/lx/gs/task/msg/CClearFamTask.java
4e9b035390a0414f962fdde4a06227d69777bcfc
[]
no_license
BanyLee/QYZ_Server
a67df7e7b4ec021d0aaa41cfc7f3bd8c7f1af3da
0eeb0eb70e9e9a1a06306ba4f08267af142957de
refs/heads/master
2021-09-13T22:32:27.563172
2018-05-05T09:20:55
2018-05-05T09:20:55
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,452
java
package lx.gs.task.msg; import com.goldhuman.Common.Marshal.OctetsStream; import com.goldhuman.Common.Marshal.MarshalException; // {{{ RPCGEN_IMPORT_BEGIN // {{{ DO NOT EDIT THIS abstract class __CClearFamTask__ extends xio.Protocol { } /** 一键清环,使用元宝完成前十环任务,不用去家族提交,当天完成已经超过十环,不能一键清 */ // DO NOT EDIT THIS }}} // RPCGEN_IMPORT_END }}} public class CClearFamTask extends __CClearFamTask__ { @Override protected void process() { // protocol handle } // {{{ RPCGEN_DEFINE_BEGIN // {{{ DO NOT EDIT THIS public static final int PROTOCOL_TYPE = 6563815; public int getType() { return 6563815; } public CClearFamTask() { } public final boolean _validator_() { return true; } public OctetsStream marshal(OctetsStream _os_) { return _os_; } public OctetsStream unmarshal(OctetsStream _os_) throws MarshalException { return _os_; } public boolean equals(Object _o1_) { if (_o1_ == this) return true; if (_o1_ instanceof CClearFamTask) { return true; } return false; } public int hashCode() { int _h_ = 0; return _h_; } public String toString() { StringBuilder _sb_ = new StringBuilder(); _sb_.append("("); _sb_.append(")"); return _sb_.toString(); } public int compareTo(CClearFamTask _o_) { if (_o_ == this) return 0; int _c_ = 0; return _c_; } // DO NOT EDIT THIS }}} // RPCGEN_DEFINE_END }}} }
ba29e9eddbe45a3e76472380951cd3aa57b0c23a
4ca4c49a6148a5b49279c6edd9eccf5861bdcb63
/android/app/src/main/java/com/ajaybhatia/hello_flutter/MainActivity.java
92b1013c437db6e97c5d39e74ecd2bec402f50b4
[]
no_license
ajaybhatia/hello-flutter
722b552cb834839f8058426aac33f8dae5bae1d0
4dfaee502ffb2caa306625a5bb227f836b8ea9f8
refs/heads/master
2022-11-27T16:11:59.605919
2020-08-07T02:07:17
2020-08-07T02:07:17
285,714,439
0
0
null
null
null
null
UTF-8
Java
false
false
147
java
package com.ajaybhatia.hello_flutter; import io.flutter.embedding.android.FlutterActivity; public class MainActivity extends FlutterActivity { }
0ef11bf45c6cec2a408d9d01599479da8a66f96a
2736eb6f6a15547529f760d9c0fcd72fa6314b02
/app/src/main/java/com/cursoandroid/meusconvidados/views/PresentFragment.java
8112ac2e537ed26b2453fac759ee4a4b5dc36cb5
[]
no_license
regisgomesr/Gerenciador-de-Convidados---Aplicativo-Android
37354cb888568de2e6249ddf05f4132a195c52f4
a2b3eeaa0f5b5e6548eb27e9f24840c77838f398
refs/heads/master
2022-02-13T12:36:03.056296
2019-07-21T18:29:34
2019-07-21T18:29:34
198,085,913
0
0
null
null
null
null
UTF-8
Java
false
false
3,220
java
package com.cursoandroid.meusconvidados.views; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; 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.Toast; import com.cursoandroid.meusconvidados.R; import com.cursoandroid.meusconvidados.adapter.GuestListAdapter; import com.cursoandroid.meusconvidados.business.GuestBusiness; import com.cursoandroid.meusconvidados.constants.GuestConstants; import com.cursoandroid.meusconvidados.entities.GuestEntity; import com.cursoandroid.meusconvidados.listener.OnGuestListenerInteractionListener; import java.util.List; public class PresentFragment extends Fragment { private ViewHolder mViewHolder = new ViewHolder(); private GuestBusiness mGuestBusiness; private OnGuestListenerInteractionListener mOnGuestListenerInteractionListener; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_present, container, false); Context context = view.getContext(); // Obter Recycler this.mViewHolder.mRecyclerAllPresent = view.findViewById(R.id.recycler_all_present); this.mGuestBusiness = new GuestBusiness(context); this.mOnGuestListenerInteractionListener = new OnGuestListenerInteractionListener() { @Override public void onListClick(int id) { // Abrir activity de formulario Bundle bundle = new Bundle(); bundle.putInt(GuestConstants.BundleConstants.GUEST_ID, id); Intent intent = new Intent(getContext(), GuestFormActivity.class); intent.putExtras(bundle); startActivity(intent); } @Override public void onDeleteClick(int id) { mGuestBusiness.remove(id); mGuestBusiness.remove(id); Toast.makeText(getContext(), R.string.convidado_removido_sucesso, Toast.LENGTH_LONG).show(); loadGuests(); } }; // Definir um layout this.mViewHolder.mRecyclerAllPresent.setLayoutManager(new LinearLayoutManager(context)); return view; } @Override public void onResume() { super.onResume(); this.loadGuests(); } private void loadGuests() { List<GuestEntity> guestEntityList = this.mGuestBusiness.getPresent(); // Definir um adapter GuestListAdapter guestListAdapter = new GuestListAdapter(guestEntityList, this.mOnGuestListenerInteractionListener); this.mViewHolder.mRecyclerAllPresent.setAdapter(guestListAdapter); guestListAdapter.notifyDataSetChanged(); } private static class ViewHolder { RecyclerView mRecyclerAllPresent; } }
d6a248af380da6e3757c258e066eb3227afda7f7
841f218b3b6b4e65a461b92fa0102a78911baff8
/src/com/zls/model/PageBean.java
a293f0b66ec3976a7612535735ece5bebcf1544d
[]
no_license
zhonglunsheng/Rbpsx
c678643d9a71769b9c3b65e7c19dcd4f33df676a
28c4361e8dd06e512963dbc669bb7c3f1fbf638b
refs/heads/master
2021-09-04T03:12:00.834634
2018-01-15T04:33:36
2018-01-15T04:33:36
104,758,989
1
0
null
null
null
null
GB18030
Java
false
false
535
java
package com.zls.model; public class PageBean { private int page; // 第几页 private int rows; // 每页记录数 @SuppressWarnings("unused") private int start; // 起始页 public PageBean(int page, int rows) { super(); this.page = page; this.rows = rows; } public int getPage() { return page; } public void setPage(int page) { this.page = page; } public int getRows() { return rows; } public void setRows(int rows) { this.rows = rows; } public int getStart() { return (page-1)*rows; } }
7edb05db4a96afc24f243fc65335a290e55033ac
9aebb5150f0aaa70ad91f3b44bba70ce65e7a344
/src/main/java/Spel.java
b371e2d514e47b6f42c8ed15d46a4d608778bc1a
[]
no_license
einbergisak/2019-voice-game
995a32847600c90b3b559e076ac0aceeeb3ddfa3
694455d3d8861a707fb35911777e6b3737433029
refs/heads/main
2023-03-02T15:52:35.758788
2021-02-11T16:06:17
2021-02-11T16:06:17
338,048,620
0
0
null
null
null
null
UTF-8
Java
false
false
23,345
java
import javax.imageio.ImageIO; import javax.swing.*; import java.awt.*; import java.awt.image.BufferedImage; import java.io.*; import java.nio.charset.StandardCharsets; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Locale; class Spel { static class BildMedProp { final BufferedImage bild; final String prop; BildMedProp(BufferedImage bild, String bildproportioner) { this.bild = bild; this.prop = bildproportioner; } } static Land land; static boolean flaggrev, namnrev, flaggtyprev, huvudstadrev, formrev, saAvsluta = false; private static int antalLanderVisade = 0; private static double andelKorrekt, tid; private static BufferedImage unknownFlagBild, avslutaBild, villAvslutaBild; private static boolean spelRedanKlart = false, uppdaterad = false; static ArrayList<BildMedProp> bmpList; static { try { unknownFlagBild = ImageIO.read(new File(Konstanter.path + "bilder\\unknownflag.png")); avslutaBild = ImageIO.read(new File(Konstanter.path + "bilder\\closewindow.jpg")); villAvslutaBild = ImageIO.read(new File(Konstanter.path + "bilder\\villavsluta" + ".jpg")); } catch (IOException e) { e.printStackTrace(); } } final static int SG_ENKEL = 0, SG_MEDEL = 1, SG_SVAR = 2, SG_OVERDRIVET_SVAR = 3; static int svarighetsgrad, antalFargerVisade = 0; static double antalFel = 0, antalKorrekt = 0; static private BildMedProp bmp1, bmp2, bmp3; static ArrayList<Land> landArray; private static double silhuettRot; static String senasteFelsvar = "", varldsdel = ""; static void visaNyttLand() { spelRedanKlart = false; Logik.redanKorrekta = new ArrayList<>(); formrev = false; flaggtyprev = false; flaggrev = false; namnrev = false; huvudstadrev = false; antalFargerVisade = 0; land = landArray.get(antalLanderVisade); if (svarighetsgrad == SG_ENKEL) { huvudstadrev = true; formrev = true; flaggtyprev = true; flaggrev = true; } else if (svarighetsgrad == SG_MEDEL || svarighetsgrad == SG_SVAR) { flaggtyprev = true; } if (svarighetsgrad != SG_ENKEL) { if (svarighetsgrad == SG_OVERDRIVET_SVAR) { //Vinkeln slumpas här för att den inte ska uppdateras varje gång spelet uppdaterar det som visas. // 2 pi radianer = 360 grader. silhuettRot = Math.random() * 2 * Math.PI; } ArrayList<BufferedImage> liknandeFlaggor; ArrayList<String> flaggProportioner; ArrayList<Land> allaLand = Konstanter.europaArray; liknandeFlaggor = new ArrayList<>(); Collections.shuffle(allaLand); flaggProportioner = new ArrayList<>(); String tidigareNamn = ""; String tidigareProp = ""; for (int i = 0; true; i++) { // System.out.println("Jämför " + allaLand.get(i).namn + " med " + land.namn); boolean approved = false; //För "SG_MEDEL" behöver inte flaggorna vara av samma typ. if (!tidigareNamn.equals(allaLand.get(i).namn)) { if (svarighetsgrad == SG_MEDEL && allaLand.get(i) != land) { approved = true; tidigareNamn = allaLand.get(i).namn; tidigareProp = allaLand.get(i).flaggProp; } else if (svarighetsgrad != SG_MEDEL && allaLand.get(i) != land) { if ((land.flaggtyp == Konstanter.FLAGGTYP_SOLIDTRIVAGRAT || land.flaggtyp == Konstanter.FLAGGTYP_SOLIDTRILODRAT || land.flaggtyp == Konstanter.FLAGGTYP_TRIKOLOR) && (allaLand.get(i).flaggtyp == Konstanter.FLAGGTYP_SOLIDTRIVAGRAT || allaLand.get(i).flaggtyp == Konstanter.FLAGGTYP_SOLIDTRILODRAT || allaLand.get(i).flaggtyp == Konstanter.FLAGGTYP_TRIKOLOR)) { if (!land.flaggProp.equals(allaLand.get(i).flaggProp)) { if (liknandeFlaggor.size() == 1) { if (!tidigareProp.equals(allaLand.get(i).flaggProp)) { approved = true; } } else { approved = true; tidigareNamn = allaLand.get(i).namn; tidigareProp = allaLand.get(i).flaggProp; } } } else if (allaLand.get(i).flaggtyp == land.flaggtyp) { approved = true; tidigareNamn = allaLand.get(i).namn; tidigareProp = allaLand.get(i).flaggProp; } } } if (approved && svarighetsgrad != SG_MEDEL) { liknandeFlaggor.add(allaLand.get(i).flaggBilderArray.get(0)); flaggProportioner.add(allaLand.get(i).flaggProp); System.out.println("Tillagd!!"); if (liknandeFlaggor.size() == 2) { System.out.println("BREAK"); break; } } else if (approved) { liknandeFlaggor.add(allaLand.get(i).flaggBilderArray.get(allaLand.get(i).flaggBilderArray.size() - 1)); flaggProportioner.add(allaLand.get(i).flaggProp); System.out.println("Tillagd!!"); if (liknandeFlaggor.size() == 2) { System.out.println("BREAK"); break; } } } if (svarighetsgrad != SG_MEDEL) { liknandeFlaggor.add(land.flaggBilderArray.get(0)); } else { liknandeFlaggor.add(land.flaggBilderArray.get(land.flaggBilderArray.size() - 1)); } flaggProportioner.add(land.flaggProp); bmp1 = new BildMedProp(liknandeFlaggor.get(0), flaggProportioner.get(0)); bmp2 = new BildMedProp(liknandeFlaggor.get(1), flaggProportioner.get(1)); bmp3 = new BildMedProp(liknandeFlaggor.get(2), flaggProportioner.get(2)); bmpList = new ArrayList<BildMedProp>() {{ add(bmp1); add(bmp2); add(bmp3); }}; Collections.shuffle(bmpList); } antalLanderVisade += 1; System.out.println("Nytt land förbereds..."); Main.rita.repaint(); System.out.println("Nytt land visas."); } public static class Rita extends JComponent { @Override protected void paintComponent(Graphics g2) { Graphics2D g = (Graphics2D) g2; if (saAvsluta) { g.drawImage(villAvslutaBild, 1640, 0, this); } else { g.drawImage(avslutaBild, 1830, 0, this); } if (antalFel == 0) { andelKorrekt = 100.00; } else { andelKorrekt = (antalKorrekt * 100) / (antalFel + antalKorrekt); } if (!Frame.iHuvudmeny && !spelRedanKlart) { DecimalFormat nF = new DecimalFormat("#.00"); g.setFont(new Font(Font.SANS_SERIF, Font.ITALIC, 32)); if (antalKorrekt == 0) { g.drawString("Andel korrekta svar: 0,00%", 15, 35); } else if (antalFel == 0 && antalKorrekt >= 1) { g.drawString("Andel korrekta svar: 100,00%", 15, 35); } else { g.drawString("Andel korrekta svar: " + nF.format(andelKorrekt) + "%", 15, 35); } g.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 26)); g.drawString("Land " + antalLanderVisade + " av " + landArray.size(), 15, 65); g.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 26)); g.setColor(Color.red); g.drawString(senasteFelsvar, 15, 500); g.setColor(Color.black); g.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 50)); if (namnrev) { g.drawString("Namn: " + land.namn, 800, 700); } else { g.drawString("Namn: ?", 800, 700); } g.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 30)); if (huvudstadrev) { g.drawString("Huvudstad: " + land.huvudstad, 800, 750); } else { g.drawString("Huvudstad: ?", 800, 750); } if (svarighetsgrad == SG_ENKEL) { g.drawImage(land.silhuett, 800, 250, this); g.drawImage(land.flaggBilderArray.get(land.flaggFargerArray.size()), 1500, 40, this); } else if (svarighetsgrad == SG_MEDEL) { g.drawImage(land.silhuett, 800, 250, this); if (!formrev) { System.out.println("visar tre olika flaggor"); g.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 24)); g.drawString("Vilken flagga är rätt?", 1545, 35); g.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 20)); g.drawString("1 (" + bmpList.get(0).prop + ")", 1400, 150); g.drawImage(bmpList.get(0).bild, 1500, 50, this); g.drawString("2 (" + bmpList.get(1).prop + ")", 1400, 380); g.drawImage(bmpList.get(1).bild, 1500, 280, this); g.drawString("3 (" + bmpList.get(2).prop + ")", 1400, 610); g.drawImage(bmpList.get(2).bild, 1500, 510, this); } else { g.drawImage(land.flaggBilderArray.get(land.flaggFargerArray.size()), 1500, 40, this); g.drawString("Flaggan färdig.", 1500, 270); } } else if (svarighetsgrad == SG_SVAR) { g.drawImage(land.silhuett, 800, 250, this); if (!formrev) { System.out.println("visar tre olika flaggor"); g.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 24)); g.drawString("Vilken flagga är rätt?", 1545, 35); g.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 20)); g.drawString("1 (" + bmpList.get(0).prop + ")", 1400, 150); g.drawImage(bmpList.get(0).bild, 1500, 50, this); g.drawString("2 (" + bmpList.get(1).prop + ")", 1400, 380); g.drawImage(bmpList.get(1).bild, 1500, 280, this); g.drawString("3 (" + bmpList.get(2).prop + ")", 1400, 610); g.drawImage(bmpList.get(2).bild, 1500, 510, this); } else if (!flaggrev) { g.drawImage(land.flaggBilderArray.get(antalFargerVisade), 1500, 40, this); g.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 25)); g.drawString("Säg färgen som hör till fält " + (antalFargerVisade + 1), 1500, 270); } else { g.drawImage(land.flaggBilderArray.get(land.flaggFargerArray.size()), 1500, 40, this); g.drawString("Flaggan färdig.", 1500, 270); } } else if (svarighetsgrad == SG_OVERDRIVET_SVAR) { //Får ut absolutbeloppet för sinus och cosinus för den tidigare slumpade vinkeln. // Ger alltså alltid ett positivt värde. double sin = Math.abs(Math.sin(silhuettRot)), cos = Math.abs(Math.cos(silhuettRot)); //Skapar variabler med värden för bildens höjd/bredd före och efter rotationen double bredd = land.silhuett.getWidth(), hojd = land.silhuett.getHeight(); int nyBredd = (int) Math.floor(bredd * cos + hojd * sin), nyHojd = (int) Math.floor(hojd * cos + bredd * sin); //Skapar bilden som ska roteras (bi) och en Graphics2D (utöver "g" som redan finns). //Allt som denna Graphics2D kommer att rita (bilden "bi") kommer att roteras. //Det behövs en separat Graphics2D (utöver "g") för att inte rotera ALLT som ska visas. BufferedImage bi = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() .getDefaultConfiguration().createCompatibleImage(nyBredd, nyHojd, Transparency.TRANSLUCENT); Graphics2D g3 = bi.createGraphics(); //Ser till så att bildens "bounds", d.v.s. upptagningsområde flyttas till rätt ställe efter rotation. g3.translate((nyBredd - bredd) / 2, (nyHojd - hojd) / 2); //Roterar bilden g3.rotate(silhuettRot, bredd / 2, hojd / 2); g3.drawRenderedImage(land.silhuett, null); g3.dispose(); //Ritar den roterate bilden g.drawImage(bi, 800, 250, this); if (flaggtyprev) { if (!formrev) { System.out.println("visar tre olika flaggor"); g.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 24)); g.drawString("Vilken flagga är rätt?", 1545, 35); g.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 20)); g.drawString("1 (" + bmpList.get(0).prop + ")", 1400, 150); g.drawImage(bmpList.get(0).bild, 1500, 50, this); g.drawString("2 (" + bmpList.get(1).prop + ")", 1400, 380); g.drawImage(bmpList.get(1).bild, 1500, 280, this); g.drawString("3 (" + bmpList.get(2).prop + ")", 1400, 610); g.drawImage(bmpList.get(2).bild, 1500, 510, this); } else if (!flaggrev) { g.drawImage(land.flaggBilderArray.get(antalFargerVisade), 1500, 40, this); g.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 25)); g.drawString("Säg färgen som hör till fält " + (antalFargerVisade + 1), 1500, 270); } else { g.drawImage(land.flaggBilderArray.get(land.flaggFargerArray.size()), 1500, 40, this); g.drawString("Flaggan färdig.", 1500, 270); } } else { g.drawImage(unknownFlagBild, 1500, 40, this); } } //Om allt är gissat. if ((svarighetsgrad == SG_ENKEL && namnrev) || ((svarighetsgrad == SG_MEDEL || svarighetsgrad == SG_SVAR) && namnrev && huvudstadrev && flaggrev) || (svarighetsgrad == SG_OVERDRIVET_SVAR && namnrev && huvudstadrev && flaggrev)) { if (antalLanderVisade == landArray.size() && !uppdaterad) { uppdaterad = true; Main.rita.repaint(); } else if (uppdaterad) { spelRedanKlart = true; tid = Tid.tidSomPasserat(); if (landArray == Konstanter.blandadArray) { sparaHighscore(0); } else if (landArray == Konstanter.nordArray) { sparaHighscore(1); } else if (landArray == Konstanter.sydArray) { sparaHighscore(2); } else if (landArray == Konstanter.vastArray) { sparaHighscore(3); } else if (landArray == Konstanter.ostArray) { sparaHighscore(4); } Main.f.dispose(); System.exit(0); } else { System.out.println("Landet gissades korrekt"); Logik.tidigare.add(land); Taligenkanning.nyssKorrekt = true; visaNyttLand(); } } } } } private static void sparaHighscore(int varldsdel) { File rekordFil; String vd; String sgrad; switch (varldsdel) { case 0: vd = "Blandad"; break; case 1: vd = "Nordeuropa"; break; case 2: vd = "Sydeuropa"; break; case 3: vd = "Västeuropa"; break; case 4: vd = "Östeuropa"; break; default: vd = "[error]"; break; } switch (svarighetsgrad) { case 0: sgrad = "enkelt"; break; case 1: sgrad = "medel"; break; case 2: sgrad = "svårt"; break; case 3: sgrad = "överdrivet svårt"; break; default: sgrad = "[error]"; break; } rekordFil = (new File(Konstanter.path + "highscores\\" + vd + svarighetsgrad + ".txt")); NumberFormat nf = NumberFormat.getNumberInstance(Locale.GERMAN); DecimalFormat nF = (DecimalFormat) nf; nF.setMaximumFractionDigits(2); ArrayList<String> highscore; String rektid; double highScoreDouble; highscore = hittaHighscore(rekordFil); if (highscore.size() == 0) { highScoreDouble = 0; } else { highScoreDouble = Double.parseDouble(highscore.get(0)); } int min; double s; String namn; min = (int) Math.floor(tid / 60); s = tid % 60; String tiden = ""; if (min == 0) { tiden += nF.format(s) + " s"; } else { tiden += min + " min " + nF.format(s) + " s"; } if (andelKorrekt > highScoreDouble) { System.out.println("Nytt highscore " + nF.format(andelKorrekt)); namn = JOptionPane.showInputDialog(Main.f, nF.format(andelKorrekt) + "% på '" + vd + " " + sgrad + "' med tiden " + tiden + " är nytt rekord!\nVänligen ange ditt namn:"); } else if (andelKorrekt == highScoreDouble) { if (tid < Double.parseDouble(highscore.get(2))) { System.out.println("Nytt highscore " + nF.format(andelKorrekt)); namn = JOptionPane.showInputDialog(Main.f, nF.format(andelKorrekt) + "% på '" + vd + " " + sgrad + "' med tiden " + tiden + " är nytt rekord!\nVänligen ange ditt namn:"); } else { min = (int) Math.floor(Double.parseDouble(highscore.get(2)) / 60); s = Double.parseDouble(highscore.get(2)) % 60; rektid = "" + min + " min " + nF.format(s) + " s"; namn = JOptionPane.showInputDialog(Main.f, "Spelet färdigt. Ditt resultat: " + nF.format(andelKorrekt) + "% på '" + vd + " " + sgrad + "' med tiden " + tiden + ".\nHighscore: " + highscore.get(0) + "% av " + highscore.get(1) + " med tiden " + rektid + "\nVänligen ange ditt namn:"); } } else { min = (int) Math.floor(Double.parseDouble(highscore.get(2)) / 60); s = Double.parseDouble(highscore.get(2)) % 60; rektid = "" + min + " min " + nF.format(s) + " s"; namn = JOptionPane.showInputDialog(Main.f, "Spelet färdigt. Ditt resultat: " + nF.format(andelKorrekt) + "% på '" + vd + " " + sgrad + "' med tiden " + tiden + ".\nHighscore: " + highscore.get(0) + "% av " + highscore.get(1) + " med tiden " + rektid + "\nVänligen ange ditt namn:"); } if (namn.equals("")) { namn = "anonym"; } if (namn.contains("-")) { namn = namn.replaceAll("-", "_"); } try { String andelKorrektString = nF.format(andelKorrekt).replaceAll(",", "."); BufferedWriter output = new BufferedWriter(new FileWriter(rekordFil, true)); output.newLine(); output.append(andelKorrektString).append("-").append(namn).append("-").append(String.valueOf(tid)); output.close(); } catch (IOException ex1) { System.out.print("ERROR "); } System.out.println("Spel.sparaHighscore 3"); } static ArrayList<String> hittaHighscore(File rekordFil) { if (!rekordFil.exists()) { try (FileOutputStream skriv = new FileOutputStream(rekordFil)) { String s = ""; skriv.write(s.getBytes()); skriv.flush(); } catch (IOException e) { System.out.println("Fel vid rekordlagring."); } } double highScore = 0; ArrayList<String> c; ArrayList<String> hs = new ArrayList<>(); try { BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(rekordFil), StandardCharsets.ISO_8859_1)); String line = reader.readLine(); while (line != null) // när en rad finns i textdokumentet. { try { c = new ArrayList<>(); Collections.addAll(c, line.trim().split("-")); double score = Double.parseDouble(c.get(0)); // en rad i taget i form av double double tid = Double.parseDouble(c.get(2)); if (score > highScore || (score == highScore && tid < Double.parseDouble(hs.get(2)))) { hs = c; hs.set(0, hs.get(0).replace(".", ",")); highScore = score; } } catch (NumberFormatException e1) { System.err.println("ignorerar ogiltigt resultat: '" + line + "'"); } line = reader.readLine(); } reader.close(); } catch (IOException ex) { System.err.println("Det gick inte att läsa filen: " + rekordFil.getPath()); } return hs; } }
853760ba50f63d7ab65aa74981261760b41fcd77
8ea87becad2893858b71388ff98d9cffa7dcd833
/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4518Test.java
e5446422ee9074ec4ab06679bf12aaa983fb3024
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "LicenseRef-scancode-unknown", "CDDL-1.0", "BSD-3-Clause", "LicenseRef-scancode-proprietary-license", "AFL-3.0", "MIT-0", "AFL-2.1", "MIT" ]
permissive
ehossack-aws/activemq
0e04ce1d73c07a0cc3cac6c59fc95d6ce2728f45
67256c61b1560127e3a56ba9dede61cad3001f4a
refs/heads/main
2023-09-06T06:42:11.600762
2021-11-10T17:56:04
2021-11-10T17:56:04
337,473,970
1
2
Apache-2.0
2021-11-19T03:39:56
2021-02-09T16:56:55
Java
UTF-8
Java
false
false
5,013
java
/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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.apache.activemq.bugs; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.Destination; import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.advisory.AdvisorySupport; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.region.policy.DeadLetterStrategy; import org.apache.activemq.broker.region.policy.IndividualDeadLetterStrategy; import org.apache.activemq.broker.region.policy.PolicyEntry; import org.apache.activemq.broker.region.policy.PolicyMap; import org.junit.After; import org.junit.Before; import org.junit.Test; public class AMQ4518Test { private BrokerService brokerService; private String connectionUri; @Before public void setup() throws Exception { brokerService = new BrokerService(); connectionUri = brokerService.addConnector("tcp://localhost:0").getPublishableConnectString(); // Configure Dead Letter Strategy DeadLetterStrategy strategy = new IndividualDeadLetterStrategy(); ((IndividualDeadLetterStrategy)strategy).setUseQueueForQueueMessages(true); ((IndividualDeadLetterStrategy)strategy).setQueuePrefix("DLQ."); strategy.setProcessNonPersistent(false); strategy.setProcessExpired(false); // Add policy and individual DLQ strategy PolicyEntry policy = new PolicyEntry(); policy.setTimeBeforeDispatchStarts(3000); policy.setDeadLetterStrategy(strategy); PolicyMap pMap = new PolicyMap(); pMap.setDefaultEntry(policy); brokerService.setDestinationPolicy(pMap); brokerService.setPersistent(false); brokerService.start(); } @After public void stop() throws Exception { brokerService.stop(); } @Test(timeout=360000) public void test() throws Exception { final ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(connectionUri); final AtomicBoolean advised = new AtomicBoolean(false); Connection connection = cf.createConnection(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination dlqDestination = session.createTopic(AdvisorySupport.EXPIRED_QUEUE_MESSAGES_TOPIC_PREFIX + ">"); MessageConsumer consumer = session.createConsumer(dlqDestination); consumer.setMessageListener(new MessageListener() { @Override public void onMessage(Message message) { advised.set(true); } }); connection.start(); ExecutorService service = Executors.newSingleThreadExecutor(); service.execute(new Runnable() { @Override public void run() { try { ActiveMQConnection connection = (ActiveMQConnection) cf.createConnection(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination destination = session.createTemporaryQueue(); MessageProducer producer = session.createProducer(destination); producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); producer.setTimeToLive(400); producer.send(session.createTextMessage()); producer.send(session.createTextMessage()); TimeUnit.MILLISECONDS.sleep(500); connection.close(); } catch (Exception e) { } } }); service.shutdown(); assertTrue(service.awaitTermination(1, TimeUnit.MINUTES)); assertFalse("Should not get any Advisories for Expired Messages", advised.get()); } }
74d7403b49ba9c94a2e9eedca360c0a55923318d
bd50af2e1dbefafa37afcee0a0d9fae2b2b89cf4
/StudentManage/src/dto/StudentDTO.java
4f39e6aa0c7daba4fe40a4aafa69b845f67c44da
[]
no_license
whjin5804/KHacademy
f33c584ed66c4f9d9632b297a454b583946a877a
0e70c5f2614355fee64ef4bdf5c9916c339767c1
refs/heads/master
2023-03-09T11:09:56.692186
2021-02-26T06:00:32
2021-02-26T06:00:32
325,142,992
0
0
null
null
null
null
UTF-8
Java
false
false
874
java
package dto; public class StudentDTO { private String stuNum; private String name; private int age; private String major; private String birthday; private String gender; public void setStuNum(String stuNum) { this.stuNum = stuNum; } public String getStuNum() { return stuNum; } public void setName(String name) { this.name = name; } public String getName() { return name; } public void setAge(int age) { this.age = age; } public int getAge() { return age; } public void setMajor(String major) { this.major = major; } public String getMajor() { return major; } public void setBirthday(String birthday) { this.birthday = birthday; } public String getBirthday() { return birthday; } public void setGender(String gender) { this.gender = gender; } public String getGender() { return gender; } }
69a57b637adf7ec09fb253cf255967a9f01fd996
b471ff5c883738d30891ed603f97c48a2d0f4e53
/src/main/java/com/towianski/chainfilters/ChainFilterOfMaxFolderCount.java
35cd6edc8ba741ff0a834e109726118a6e586da1
[]
no_license
stant/jfileprocessorRest
e32e283ba8c2f3ebe3e53e2ecf2db225a08da989
26b4f36b375841efa6d12447e5b12905855212d8
refs/heads/master
2021-03-30T23:46:35.597557
2021-02-06T22:00:27
2021-02-06T22:00:27
125,122,154
7
1
null
null
null
null
UTF-8
Java
false
false
1,786
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 com.towianski.chainfilters; import com.towianski.jfileprocessor.JFileFinder; import com.towianski.utils.MyLogger; import java.nio.file.Path; import java.nio.file.attribute.BasicFileAttributes; /** * * @author Stan Towianski - June 2017 */ public class ChainFilterOfMaxFolderCount implements FilterChainFilter { private static final MyLogger logger = MyLogger.getLogger( ChainFilterOfMaxFolderCount.class.getName() ); long maxFolderCount; public ChainFilterOfMaxFolderCount() { //logger.info( "new ChainFilterOfMaxFolderCount()" ); } public ChainFilterOfMaxFolderCount( String startingFolder, String maxFolderCount ) { this.maxFolderCount = Long.parseLong( maxFolderCount ) - 1; logger.info( "Long.parseLong( maxFolderCount ) =" + this.maxFolderCount ); } // These must be the same parms for all filters that get used. // First check is do we show this folder? public Boolean accept( Path fpath, BasicFileAttributes attr, ChainFilterArgs chainFilterArgs, JFileFinder jFileFinder ) { // logger.info( "for path =" + fpath + " chainFilterArgs.getNumFolderMatches() =" + chainFilterArgs.getNumFolderMatches() ); if ( chainFilterArgs.getNumFolderMatches() >= maxFolderCount ) { // logger.info( "STOP for path =" + fpath + " chainFilterArgs.getNumFolderMatches() =" + chainFilterArgs.getNumFolderMatches() ); jFileFinder.cancelSearch(); } return true; } }
eb05fc14962d09d263c354e658ce5bc2c043559d
f23f54ea1ecc4de1a9593fb7659213f87296a9fd
/EurekaServer-ha-2/src/main/java/com/qyw/cloud/EurekaServerHa2Application.java
3e1ffc3c2902e7bfaa93a67e0438b7064da94376
[]
no_license
qywian/springCloud
0b660715b48bf7f2a618ea840a2a2cdd8a415f4e
37d5e900e62a6a660584bd83f44c07aa3d237b22
refs/heads/master
2021-01-20T04:55:37.974598
2017-09-01T13:44:52
2017-09-01T13:44:52
101,395,749
1
0
null
null
null
null
UTF-8
Java
false
false
1,310
java
/** * @Title: [EurekaServerApplication.java] * @Package: [com.qyw.cloud] * @author: [YanweiQin] * @CreateDate: [8/24/2017 05:34 PM] * @UpdateUser: [YanweiQin] * @UpdateDate: [8/24/2017 05:34 PM] * @UpdateRemark: [说明本次修改内容] * @Description: [TODO(用一句话描述该文件做什么)] * @version: [V1.0] */ package com.qyw.cloud; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; /** * @ClassName: EurekaServerApplication * @author: [YanweiQin] * @CreateDate: [8/24/2017 05:34 PM] * @UpdateUser: [YanweiQin] * @UpdateDate: [8/24/2017 05:34 PM] * @UpdateRemark: [说明本次修改内容] * @Description: [TODO(用一句话描述该文件做什么)] * @version: [V1.0] */ @EnableEurekaServer @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class}) public class EurekaServerHa2Application { public static void main(String[] args) { SpringApplication.run(EurekaServerHa2Application.class, args); } }
218e403f2e143afb4b34f0fdc0ad03f33af7ee9f
56f1764085282b61add1b5beb0f277749e7a6470
/BobRossPaint/src/paint/RectangleManipulatorStrategy.java
3835d5081ffabba94beb482be3139f82176936bc
[ "MIT" ]
permissive
JathavanS/BobRossPaint
0f49f9c025ab338ede719e403345edb413a4bca2
78f8c7641f45e570ab79624bd3a2a03d03e5327f
refs/heads/master
2023-04-04T06:00:00.455758
2020-02-21T06:18:56
2020-02-21T06:18:56
242,050,915
0
0
null
null
null
null
UTF-8
Java
false
false
2,420
java
package paint; import javafx.scene.input.MouseEvent; import paint.PaintPanel; import paint.Point; import paint.Rectangle; import paint.ShapeManipulatorStrategy; public class RectangleManipulatorStrategy implements ShapeManipulatorStrategy{ private Point anchorPoint; private Rectangle rectangle; /** * Handle mouse input from the user, and pass this to the PaintPanel specified * @param paintPanel The PaintPanel calling this * @param event The MouseEvent this is called using */ @Override public void handle(PaintPanel paintPanel, MouseEvent event) { if (event.getEventType() == MouseEvent.MOUSE_PRESSED) { handleMousePressed(paintPanel, event); } else if (event.getEventType() == MouseEvent.MOUSE_DRAGGED) { handleMouseDragged(paintPanel, event); } else if (event.getEventType() == MouseEvent.MOUSE_RELEASED) { handleMouseReleased(paintPanel, event); } } /** * When the user presses the mouse, create a new Rectangle * @param paintPanel The PaintPanel calling this * @param event The MouseEvent this is called using */ private void handleMousePressed(PaintPanel paintPanel, MouseEvent event) { int x = (int) event.getX(); int y = (int) event.getY(); this.anchorPoint = new Point(x, y); this.rectangle = new Rectangle(x, y, 0, 0, paintPanel.getFilled()); paintPanel.getPaintModel().addDrawingCommand(this.rectangle); paintPanel.repaint(); // CHANGE THIS!!!! } /** * When the user drags the mouse, update the Rectangle * @param paintPanel The PaintPanel calling this * @param event The MouseEvent this is called using */ private void handleMouseDragged(PaintPanel paintPanel, MouseEvent event) { if (this.rectangle != null) { Point point = new Point((int) event.getX(), (int) event.getY()); this.rectangle.setCorners(this.anchorPoint, point); } paintPanel.repaint(); // CHANGE THIS!!!! } /** * When the user releases the mouse, add the Rectangle to the PaintModel * @param paintPanel The PaintPanel calling this * @param event The MouseEvent this is called using */ private void handleMouseReleased(PaintPanel paintPanel, MouseEvent event) { if (this.rectangle != null) { Point point = new Point((int) event.getX(), (int) event.getY()); this.rectangle.setCorners(this.anchorPoint, point); this.rectangle = null; } } }
94ef658e5ff748b79fb2d83a9f236746f4ecce54
cd8b284ecf978282a3a34b272322001c58649496
/app/src/main/java/tr/bcxip/hummingbird/SearchFragment.java
8cd21f9700f7852df106cda226c1f765c4c408b3
[ "Apache-2.0" ]
permissive
hhy5277/Hummingbird-for-Android
dc64dbb2a8ed4273f2dc62c04731803796097b02
9dfdcdefad9b6e3e6ccb7f897609c00f4216528f
refs/heads/master
2020-05-13T05:26:55.392010
2015-06-20T17:05:57
2015-06-20T17:10:20
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,943
java
package tr.bcxip.hummingbird; import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; /** * Created by Hikari on 10/24/14. */ public class SearchFragment extends Fragment { private static final String TAG = "SEARCH FRAGMENT"; public static final String TAG_SEARCH_FRAGMENT = "search_fragment"; public static final String ARG_SEARCH_TYPE = "search_type"; public static final String ARG_QUERY = "query"; public static final String SEARCH_TYPE_GENERAL = "search_type_general"; public static final String SEARCH_TYPE_LIBRARY = "search_type_library"; Context context; View rootView; String SEARCH_TYPE; String QUERY; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); context = getActivity(); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rootView = inflater.inflate(R.layout.fragment_search, null); Bundle args = getArguments(); if (args != null) { SEARCH_TYPE = args.getString(ARG_SEARCH_TYPE); QUERY = args.getString(ARG_QUERY); } if (SEARCH_TYPE == null || SEARCH_TYPE.equals("") || SEARCH_TYPE.trim().equals("")) { Log.e(TAG, "No search type was passed; Nothing to do..."); return new View(context); } if (QUERY == null || QUERY.equals("") || QUERY.trim().equals("")) { Log.e(TAG, "No search query was passed; Can't do any kind of search"); return new View(context); } TextView text = (TextView) rootView.findViewById(R.id.search_query); text.setText(QUERY); return rootView; } }
03ca0f03bc08b10ad7a17da3f567b793e95b4d10
73e5e4208b9d78bfb14639a4ded2d5dc3b711e83
/src/main/java/com/bm/lpb/domain/User.java
900848dd985539ffea5bed96a16fd83d269f1805
[]
no_license
bachnej/ldp
23e9a9fce74d36a04b540ea3297c8d11f256ec1f
70135ffb8228c9dac29f0171acd55e9726241869
refs/heads/master
2021-06-07T09:20:38.308794
2017-07-23T19:17:15
2017-07-23T19:17:15
98,087,591
0
1
null
2020-09-18T07:18:16
2017-07-23T09:27:34
Java
UTF-8
Java
false
false
5,714
java
package com.bm.lpb.domain; import com.bm.lpb.config.Constants; import com.fasterxml.jackson.annotation.JsonIgnore; import org.apache.commons.lang3.StringUtils; import org.hibernate.annotations.BatchSize; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import org.hibernate.validator.constraints.Email; import org.springframework.data.elasticsearch.annotations.Document; import javax.persistence.*; import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; import java.io.Serializable; import java.util.HashSet; import java.util.Locale; import java.util.Objects; import java.util.Set; import java.time.Instant; /** * A user. */ @Entity @Table(name = "jhi_user") @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) @Document(indexName = "user") public class User extends AbstractAuditingEntity implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @NotNull @Pattern(regexp = Constants.LOGIN_REGEX) @Size(min = 1, max = 100) @Column(length = 100, unique = true, nullable = false) private String login; @JsonIgnore @NotNull @Size(min = 60, max = 60) @Column(name = "password_hash",length = 60) private String password; @Size(max = 50) @Column(name = "first_name", length = 50) private String firstName; @Size(max = 50) @Column(name = "last_name", length = 50) private String lastName; @Email @Size(min = 5, max = 100) @Column(length = 100, unique = true) private String email; @NotNull @Column(nullable = false) private boolean activated = false; @Size(min = 2, max = 5) @Column(name = "lang_key", length = 5) private String langKey; @Size(max = 256) @Column(name = "image_url", length = 256) private String imageUrl; @Size(max = 20) @Column(name = "activation_key", length = 20) @JsonIgnore private String activationKey; @Size(max = 20) @Column(name = "reset_key", length = 20) @JsonIgnore private String resetKey; @Column(name = "reset_date") private Instant resetDate = null; @JsonIgnore @ManyToMany @JoinTable( name = "jhi_user_authority", joinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "id")}, inverseJoinColumns = {@JoinColumn(name = "authority_name", referencedColumnName = "name")}) @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) @BatchSize(size = 20) private Set<Authority> authorities = new HashSet<>(); public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getLogin() { return login; } //Lowercase the login before saving it in database public void setLogin(String login) { this.login = StringUtils.lowerCase(login, Locale.ENGLISH); } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getImageUrl() { return imageUrl; } public void setImageUrl(String imageUrl) { this.imageUrl = imageUrl; } public boolean getActivated() { return activated; } public void setActivated(boolean activated) { this.activated = activated; } public String getActivationKey() { return activationKey; } public void setActivationKey(String activationKey) { this.activationKey = activationKey; } public String getResetKey() { return resetKey; } public void setResetKey(String resetKey) { this.resetKey = resetKey; } public Instant getResetDate() { return resetDate; } public void setResetDate(Instant resetDate) { this.resetDate = resetDate; } public String getLangKey() { return langKey; } public void setLangKey(String langKey) { this.langKey = langKey; } public Set<Authority> getAuthorities() { return authorities; } public void setAuthorities(Set<Authority> authorities) { this.authorities = authorities; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } User user = (User) o; return !(user.getId() == null || getId() == null) && Objects.equals(getId(), user.getId()); } @Override public int hashCode() { return Objects.hashCode(getId()); } @Override public String toString() { return "User{" + "login='" + login + '\'' + ", firstName='" + firstName + '\'' + ", lastName='" + lastName + '\'' + ", email='" + email + '\'' + ", imageUrl='" + imageUrl + '\'' + ", activated='" + activated + '\'' + ", langKey='" + langKey + '\'' + ", activationKey='" + activationKey + '\'' + "}"; } }
f360641034a790acb29b65bca6838268a4c17f4c
30236f2f91a96f2d1e491867cf5bc63df72f65c0
/spring-demo-one/src/com/luv2code/springdemo/SetterDemoApp.java
ba91c5156e5ebf0d82e43178ba78911eb5f2a609
[]
no_license
svwoodhouse/SpringFramework
7578c4bd047649118ec96f691e430d3bf998e6ad
2642bdf7d422446e14550baf180132f9836a0571
refs/heads/master
2020-08-20T15:20:39.517656
2019-10-25T14:48:20
2019-10-25T14:48:20
216,037,953
0
0
null
null
null
null
UTF-8
Java
false
false
760
java
package com.luv2code.springdemo; import org.springframework.context.support.ClassPathXmlApplicationContext; public class SetterDemoApp { public static void main(String[] args) { // Load Spring Configuration file ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); // Retrieve the bean from Spring Container CricketCoach theCoach = context.getBean("myCricketCoach", CricketCoach.class); // Call methods on the bean System.out.println(theCoach.getDailyWorkout()); System.out.println(theCoach.getDailyFortune()); System.out.println(theCoach.getEmailAddress()); System.out.println(theCoach.getTeam()); // Close the context context.close(); } }
[ "Sydnee@LAPTOP-LADAT234" ]
Sydnee@LAPTOP-LADAT234
701fcf94a08a36967f854cc7439ba8c054f27d5c
4627d514d6664526f58fbe3cac830a54679749cd
/results/cling/time-org.joda.time.chrono.ISOChronology-org.joda.time.chrono.AssembledChronology-10/org/joda/time/chrono/ISOChronology_ESTest.java
58ce75aabb0618137760887c60eeefab090f7f7a
[]
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
3,712
java
/* * Tue Mar 03 16:50:29 GMT 2020 */ package org.joda.time.chrono; import org.junit.Test; import static org.junit.Assert.*; import static org.evosuite.shaded.org.mockito.Mockito.*; import static org.evosuite.runtime.EvoAssertions.*; import org.evosuite.runtime.EvoRunner; import org.evosuite.runtime.EvoRunnerParameters; import org.evosuite.runtime.ViolatedAssumptionAnswer; import org.joda.time.Chronology; import org.joda.time.DateMidnight; import org.joda.time.DateTimeZone; import org.joda.time.IllegalFieldValueException; import org.joda.time.chrono.BuddhistChronology; import org.joda.time.chrono.EthiopicChronology; import org.joda.time.chrono.ISOChronology; import org.joda.time.chrono.StrictChronology; import org.joda.time.chrono.ZonedChronology; import org.junit.runner.RunWith; @RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, separateClassLoader = false, useJEE = true) public class ISOChronology_ESTest extends ISOChronology_ESTest_scaffolding { @Test(timeout = 4000) public void test0() throws Throwable { DateTimeZone dateTimeZone0 = DateTimeZone.forOffsetMillis(68); BuddhistChronology buddhistChronology0 = BuddhistChronology.getInstance(dateTimeZone0); ZonedChronology.getInstance(buddhistChronology0, dateTimeZone0); ISOChronology iSOChronology0 = ISOChronology.getInstance(dateTimeZone0); try { iSOChronology0.getDateTimeMillis(1, 68, 3117, 3117, 1, (-2297), (-2297)); fail("Expecting exception: IllegalFieldValueException"); } catch(IllegalFieldValueException e) { // // Value 3117 for hourOfDay must be in the range [0,23] // verifyException("org.joda.time.field.FieldUtils", e); } } @Test(timeout = 4000) public void test1() throws Throwable { EthiopicChronology ethiopicChronology0 = EthiopicChronology.getInstance(); StrictChronology.getInstance(ethiopicChronology0); DateMidnight dateMidnight0 = new DateMidnight(1, 1, 1); assertEquals((-62135597972000L), dateMidnight0.getMillis()); } @Test(timeout = 4000) public void test2() throws Throwable { EthiopicChronology ethiopicChronology0 = EthiopicChronology.getInstance(); StrictChronology.getInstance(ethiopicChronology0); ISOChronology iSOChronology0 = ISOChronology.getInstance((DateTimeZone) null); assertNotNull(iSOChronology0); } @Test(timeout = 4000) public void test3() throws Throwable { DateTimeZone dateTimeZone0 = DateTimeZone.forOffsetMillis(3145); BuddhistChronology buddhistChronology0 = BuddhistChronology.getInstance(dateTimeZone0); try { buddhistChronology0.getDateTimeMillis(3145, 0, (-1285), 1); fail("Expecting exception: IllegalFieldValueException"); } catch(IllegalFieldValueException e) { // // Value 0 for monthOfYear must be in the range [1,12] // verifyException("org.joda.time.field.FieldUtils", e); } } @Test(timeout = 4000) public void test4() throws Throwable { ISOChronology iSOChronology0 = ISOChronology.getInstanceUTC(); DateTimeZone dateTimeZone0 = mock(DateTimeZone.class, new ViolatedAssumptionAnswer()); doReturn("", "", "").when(dateTimeZone0).getID(); doReturn("", "", "", "", "").when(dateTimeZone0).toString(); Chronology chronology0 = iSOChronology0.withZone(dateTimeZone0); assertNotNull(chronology0); long long0 = iSOChronology0.getDateTimeMillis((-1755L), 6, 6, 6, 6); assertEquals((-64433994L), long0); assertNotSame(iSOChronology0, chronology0); } }
5255b9954ada6ca9b21a8cf30455cf2c8eaed69f
0520bcc56cc6c2540274b52f6bf436bd3d6791a0
/src/main/java/com/threedsoft/inventory/service/InventoryServiceByItem.java
deed86a8805f53bd6a164e33a9a21734e96e7dd2
[]
no_license
knpillutla/inventory
cd8346d8cb14d72b0dff318bcee87ce23ba9d995
782b654af39c87a518236f0463ae62bef810bd2f
refs/heads/master
2020-03-30T02:59:47.697395
2018-11-12T03:49:56
2018-11-12T03:49:56
148,157,767
0
0
null
null
null
null
UTF-8
Java
false
false
5,187
java
package com.threedsoft.inventory.service; import java.util.ArrayList; import java.util.List; import java.util.Optional; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.domain.Example; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.stereotype.Service; import com.threedsoft.inventory.db.Inventory; import com.threedsoft.inventory.dto.requests.InventoryAllocationRequestDTO; import com.threedsoft.inventory.dto.requests.InventorySearchRequestDTO; import com.threedsoft.inventory.dto.requests.InventoryUpdateRequestDTO; import com.threedsoft.inventory.dto.responses.InventoryResourceDTO; import com.threedsoft.inventory.exception.InsufficientInventoryException; import com.threedsoft.inventory.exception.InventoryException; import lombok.extern.slf4j.Slf4j; @Service @Slf4j public class InventoryServiceByItem extends InventoryServiceImpl { private static final Logger logger = LoggerFactory.getLogger(InventoryServiceByItem.class); @Override public List<Inventory> getInventoryToBeAllocated(InventoryAllocationRequestDTO invnAllocationRequest) throws InsufficientInventoryException{ List<Inventory> invnEntityList = null; invnEntityList = inventoryDAO.findByBusNameAndLocnNbrAndItemBrcd(invnAllocationRequest.getBusName(), invnAllocationRequest.getLocnNbr(), invnAllocationRequest.getItemBrcd(), InventoryStatus.AVAILABLE.getStatCode()); int totalQtyReserved = 0; int qtyToBeReserved = invnAllocationRequest.getQty(); List<Inventory> reservedEntityList = new ArrayList(); if(invnEntityList == null) return reservedEntityList; for(Inventory invn : invnEntityList) { int qtyReserved = 0; if(invn.getQty()-qtyToBeReserved<=0) { reservedEntityList.add(invn); qtyReserved = invn.getQty(); }else { qtyReserved = qtyToBeReserved; // create new inventory record for the reserved inventory Inventory newInventory = new Inventory(); newInventory.setLocnBrcd(invn.getLocnBrcd()); newInventory.setItemBrcd(invn.getItemBrcd()); newInventory.setQty(qtyReserved); invn.setBusName(invn.getBusName()); invn.setBusUnit(invn.getBusUnit()); invn.setLocnNbr(invn.getLocnNbr()); invn.setIlpn(invn.getIlpn()); invn.setPackageNbr(invn.getPackageNbr()); reservedEntityList.add(newInventory); // update available qty for the current locn/item invn.setQty(invn.getQty()-qtyReserved); reservedEntityList.add(invn); break; } totalQtyReserved = totalQtyReserved + qtyReserved; qtyToBeReserved = qtyToBeReserved - qtyReserved; } // there is not enough quantity availabile in Active to reserve, throw exception or trigger replenishment if(qtyToBeReserved>0){ throw new InsufficientInventoryException("Not Enough Quantity To Reserve for Item:" + invnAllocationRequest.toString()); } return reservedEntityList; } public List<InventoryResourceDTO> findByBusNameAndLocnNbr(String busName, Integer locnNbr) { PageRequest pageRequest = new PageRequest(0, 20); List<Inventory> invnEntityList = inventoryDAO.findByBusNameAndLocnNbr(busName, locnNbr, pageRequest); List<InventoryResourceDTO> inventoryDTOList = new ArrayList(); for(Inventory invnEntity : invnEntityList) { inventoryDTOList.add(inventoryDTOConverter.getInventoryDTO(invnEntity)); } return inventoryDTOList; } @Override public InventoryResourceDTO updateInventory(InventoryUpdateRequestDTO invnUpdateReq) throws InventoryException{ Optional<Inventory> optionalInventoryEntity = inventoryDAO.findById(invnUpdateReq.getId()); if(optionalInventoryEntity.isPresent()) { Inventory invnEntity = optionalInventoryEntity.get(); invnEntity.setLocnBrcd(invnUpdateReq.getLocnBrcd()); invnEntity.setItemBrcd(invnUpdateReq.getItemBrcd()); invnEntity.setQty(invnUpdateReq.getQty()); invnEntity.setIlpn(invnUpdateReq.getIlpn()); invnEntity.setTrackByLPN(invnUpdateReq.getTrackByLPN()); invnEntity.setLocked(invnUpdateReq.getLocked()); Inventory savedInvnEntity = inventoryDAO.save(invnEntity); return inventoryDTOConverter.getInventoryDTO(savedInvnEntity); } return null; } @Override public InventoryResourceDTO deleteInventory(Long id) throws InventoryException{ Optional<Inventory> optionalInventoryEntity = inventoryDAO.findById(id); if(optionalInventoryEntity.isPresent()) { Inventory invnEntity = optionalInventoryEntity.get(); inventoryDAO.delete(invnEntity); return inventoryDTOConverter.getInventoryDTO(invnEntity); } return null; } @Override public List<InventoryResourceDTO> searchInventory(InventorySearchRequestDTO invnSearchReq) throws InventoryException{ PageRequest pageRequest = new PageRequest(0, 50); Inventory searchInventory = inventoryDTOConverter.getInventoryEntityForSearch(invnSearchReq); Page<Inventory> invnEntityPage = inventoryDAO.findAll(Example.of(searchInventory), pageRequest); List<InventoryResourceDTO> inventoryDTOList = new ArrayList(); for(Inventory invnEntity : invnEntityPage) { inventoryDTOList.add(inventoryDTOConverter.getInventoryDTO(invnEntity)); } return inventoryDTOList; } }
01736c3756713ddbf5c4aab2a2d7c91b01bb09bc
1f0cb0b6f4c74ff706254baf5b028bc9417615f9
/spring-micro-repositories/spring-micro-repositories-mysql/spring-micro-repositories-mysql-modules_1/spring-micro-repositories-mysql-patient_1/src/main/java/org/example/spring/repositories/mysql/patient/table/po/TPatientTeamMealCheckItem.java
7fe1041c35f1ac2cc84f084c430ccf635bd6ee43
[]
no_license
yuan50697105/spring-build-project-1
af448da5e3676a99c22aaaca6de4fb9e8ea55811
967fc586637146d8ab3f80bd518ed50bf70dae90
refs/heads/master
2022-07-22T13:45:00.442964
2021-06-03T02:53:19
2021-06-03T02:53:19
359,333,990
0
0
null
null
null
null
UTF-8
Java
false
false
1,705
java
package org.example.spring.repositories.mysql.patient.table.po; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import org.example.spring.plugins.mybatis.entity.po.IBaseEntity; import java.io.Serializable; /** * t_patient_team_meal_check_item */ @ApiModel(value = "org-example-spring-infrastructures-mysql-patient-table-po-TPatientTeamMealCheckItem") @Data @EqualsAndHashCode(callSuper = true) @AllArgsConstructor @NoArgsConstructor public class TPatientTeamMealCheckItem extends IBaseEntity implements Serializable { private static final long serialVersionUID = 1L; /** * patientId */ @ApiModelProperty(value = "patientId") private Long teamId; /** * mealId */ @ApiModelProperty(value = "mealId") private Long mealId; /** * teamMealId */ @ApiModelProperty(value = "teamMealId") private Long teamMealId; /** * feeItemId */ @ApiModelProperty(value = "feeItemId") private Long feeItemId; /** * teamFeeItemId */ @ApiModelProperty(value = "teamFeeItemId") private Long teamFeeItemId; /** * checkItemId */ @ApiModelProperty(value = "checkItemId") private String checkItemId; /** * checkItemCode */ @ApiModelProperty(value = "checkItemCode") private String checkItemCode; /** * checkItemName */ @ApiModelProperty(value = "checkItemName") private String checkItemName; /** * source */ @ApiModelProperty(value = "source") private String source; }
5ac357402d3dffc9b124f50eef5bf85f2253c7d1
c92d185c3130646de86ecc4d02d8f49cde3bfb28
/src/test/java/com/gmail/justisroot/broker/IntegerBroker.java
1b67252b0536fd09eae609cba32921008449d43d
[ "MIT" ]
permissive
CyberFlameGO/BrokerAPI
c175d2f3641ba06c3675d201671e1443e2df1555
15f6ff4b01f00da1c876a2bfb396662786cb2690
refs/heads/master
2023-06-19T10:12:09.508738
2021-07-21T08:38:16
2021-07-21T08:38:16
null
0
0
null
null
null
null
UTF-8
Java
false
false
795
java
/* * * BrokerAPI Copyright 2020 Justis Root * * This program is distributed under the terms of the GNU Lesser General Public License * */ package com.gmail.justisroot.broker; import java.util.UUID; /** * @author Justis R * */ public class IntegerBroker extends MockBroker { public static final String ID = "IntegerBroker"; @Override public String getId() { return ID; } @Override public boolean handlesPurchases(UUID playerID, UUID worldID, String object) { try { Integer.parseInt(object); return true; } catch (NumberFormatException e) { } return false; } @Override public boolean handlesSales(UUID playerID, UUID worldID, String object) { try { Integer.parseInt(object); return true; } catch (NumberFormatException e) { } return false; } }
3572f01e04c6e5658f10ea4add6b568b64600155
082e26b011e30dc62a62fae95f375e4f87d9e99c
/docs/weixin_7.0.4_source/反编译源码/反混淆后/src/main/java/com/tencent/rtmp/TXLivePlayer.java
4c6e77e65dd8d7a6c91a25388ff223f0f3b8027f
[]
no_license
xsren/AndroidReverseNotes
9631a5aabc031006e795a112b7ac756a8edd4385
9202c276fe9f04a978e4e08b08e42645d97ca94b
refs/heads/master
2021-04-07T22:50:51.072197
2019-07-16T02:24:43
2019-07-16T02:24:43
null
0
0
null
null
null
null
UTF-8
Java
false
false
27,802
java
package com.tencent.rtmp; import android.content.Context; import android.graphics.Bitmap; import android.os.Build; import android.os.Build.VERSION; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.text.TextUtils; import android.view.Surface; import android.view.TextureView; import com.tencent.liteav.C17787g; import com.tencent.liteav.C25666p; import com.tencent.liteav.C37368j; import com.tencent.liteav.C37368j.C0963a; import com.tencent.liteav.C45110n; import com.tencent.liteav.C8832o; import com.tencent.liteav.basic.datareport.C8795a; import com.tencent.liteav.basic.datareport.TXCDRApi; import com.tencent.liteav.basic.log.TXCLog; import com.tencent.liteav.basic.p140d.C0946a; import com.tencent.liteav.basic.util.TXCCommonUtil; import com.tencent.matrix.trace.core.AppMethodBeat; import com.tencent.rtmp.p1423ui.TXCloudVideoView; import com.tencent.ttpic.util.VideoMaterialUtil; import com.tencent.ugc.TXRecordCommon.ITXVideoRecordListener; import com.tencent.view.C31128d; import java.util.Iterator; import java.util.Vector; public class TXLivePlayer implements C0946a { public static final int PLAY_TYPE_LIVE_FLV = 1; public static final int PLAY_TYPE_LIVE_RTMP = 0; public static final int PLAY_TYPE_LIVE_RTMP_ACC = 5; public static final int PLAY_TYPE_LOCAL_VIDEO = 6; public static final int PLAY_TYPE_VOD_FLV = 2; public static final int PLAY_TYPE_VOD_HLS = 3; public static final int PLAY_TYPE_VOD_MP4 = 4; public static final String TAG = "TXLivePlayer"; private ITXAudioRawDataListener mAudioRawDataListener; private int mAudioRoute = 0; private boolean mAutoPlay = true; private Vector<String> mCallFuncBeforeStartPlay = new Vector(); private TXLivePlayConfig mConfig; private Context mContext; private int mCurrentPlayType = -1; private boolean mEnableHWDec = false; private boolean mIsNeedClearLastImg = true; private boolean mIsShiftPlaying; private long mLastReportTime = 0; private ITXLivePlayListener mListener; private String mLivePlayUrl; private boolean mMute = false; private String mPlayUrl = ""; private C45110n mPlayer; private long mProgressStartTime; private float mRate = 1.0f; private int mRenderMode; private int mRenderRotation; private boolean mSnapshotRunning = false; private Surface mSurface; private int mSurfaceHeight; private int mSurfaceWidth; private TXCloudVideoView mTXCloudVideoView; private C37368j mTimeShiftUtil; private ITXVideoRawDataListener mVideoRawDataListener = null; public interface ITXAudioRawDataListener { void onAudioInfoChanged(int i, int i2, int i3); void onPcmDataAvailable(byte[] bArr, long j); } public interface ITXSnapshotListener { void onSnapshot(Bitmap bitmap); } /* renamed from: com.tencent.rtmp.TXLivePlayer$1 */ class C364141 implements C0963a { C364141() { } public void onLiveTime(long j) { AppMethodBeat.m2504i(65990); TXLivePlayer.this.mProgressStartTime = j; if (TXLivePlayer.this.mPlayer != null) { TXLivePlayer.this.mPlayer.mo67329g(); } AppMethodBeat.m2505o(65990); } } public interface ITXVideoRawDataListener { void onVideoRawDataAvailable(byte[] bArr, int i, int i2, int i3); } public TXLivePlayer(Context context) { AppMethodBeat.m2504i(65938); TXCLog.init(); this.mListener = null; this.mContext = context.getApplicationContext(); AppMethodBeat.m2505o(65938); } public void setConfig(TXLivePlayConfig tXLivePlayConfig) { AppMethodBeat.m2504i(65939); TXCLog.m15675d(TAG, "liteav_api setConfig ".concat(String.valueOf(this))); this.mConfig = tXLivePlayConfig; if (this.mConfig == null) { this.mConfig = new TXLivePlayConfig(); } if (this.mPlayer != null) { C17787g h = this.mPlayer.mo72894h(); if (h == null) { h = new C17787g(); } h.f4172a = this.mConfig.mCacheTime; h.f4178g = this.mConfig.mAutoAdjustCacheTime; h.f4174c = this.mConfig.mMinAutoAdjustCacheTime; h.f4173b = this.mConfig.mMaxAutoAdjustCacheTime; h.f4175d = this.mConfig.mVideoBlockThreshold; h.f4176e = this.mConfig.mConnectRetryCount; h.f4177f = this.mConfig.mConnectRetryInterval; h.f4179h = this.mConfig.mEnableAec; h.f4181j = this.mConfig.mEnableNearestIP; h.f4183l = this.mConfig.mRtmpChannelType; h.f4180i = this.mEnableHWDec; h.f4184m = this.mConfig.mCacheFolderPath; h.f4185n = this.mConfig.mMaxCacheItems; h.f4182k = this.mConfig.mEnableMessage; h.f4186o = this.mConfig.mHeaders; this.mPlayer.mo67315a(h); } String str = "setConfig:" + this.mConfig.mCacheTime + VideoMaterialUtil.FRAMES_ID_SEPARATOR_3D + this.mConfig.mAutoAdjustCacheTime + VideoMaterialUtil.FRAMES_ID_SEPARATOR_3D + this.mConfig.mMinAutoAdjustCacheTime + VideoMaterialUtil.FRAMES_ID_SEPARATOR_3D + this.mConfig.mMaxAutoAdjustCacheTime; if (this.mPlayUrl == null || this.mPlayUrl.length() <= 0) { this.mCallFuncBeforeStartPlay.add(str); AppMethodBeat.m2505o(65939); return; } TXCDRApi.reportEvent40003(this.mPlayUrl, C8795a.f2493S, 0, str, ""); AppMethodBeat.m2505o(65939); } public void setPlayerView(TXCloudVideoView tXCloudVideoView) { AppMethodBeat.m2504i(65940); TXCLog.m15675d(TAG, "liteav_api setPlayerView old view : " + this.mTXCloudVideoView + ", new view : " + tXCloudVideoView + ", " + this); this.mTXCloudVideoView = tXCloudVideoView; if (this.mPlayer != null) { this.mPlayer.mo67318a(tXCloudVideoView); } AppMethodBeat.m2505o(65940); } public void setSurface(Surface surface) { AppMethodBeat.m2504i(65941); TXCLog.m15675d(TAG, "liteav_api setSurface old : " + this.mSurface + ", new : " + surface + ", " + this); this.mSurface = surface; if (this.mPlayer != null) { this.mPlayer.mo67314a(this.mSurface); } AppMethodBeat.m2505o(65941); } public void setSurfaceSize(int i, int i2) { AppMethodBeat.m2504i(65942); this.mSurfaceWidth = i; this.mSurfaceHeight = i2; if (this.mPlayer != null) { this.mPlayer.mo67312a(i, i2); } AppMethodBeat.m2505o(65942); } public int startPlay(String str, int i) { AppMethodBeat.m2504i(65943); TXCLog.m15675d(TAG, "liteav_api startPlay ".concat(String.valueOf(this))); if (TextUtils.isEmpty(str)) { TXCLog.m15676e(TAG, "start play error when url is empty ".concat(String.valueOf(this))); AppMethodBeat.m2505o(65943); return -1; } if (!TextUtils.isEmpty(this.mPlayUrl) && isPlaying()) { if (this.mPlayUrl.equalsIgnoreCase(str)) { TXCLog.m15676e(TAG, "start play error when new url is the same with old url ".concat(String.valueOf(this))); AppMethodBeat.m2505o(65943); return -1; } TXCLog.m15679w(TAG, " stop old play when new url is not the same with old url ".concat(String.valueOf(this))); if (this.mPlayer != null) { this.mPlayer.mo67309a(false); } this.mPlayUrl = ""; } TXCDRApi.initCrashReport(this.mContext); TXCLog.m15675d(TAG, "==========================================================================================================================================================="); TXCLog.m15675d(TAG, "==========================================================================================================================================================="); TXCLog.m15675d(TAG, "===== StartPlay url = " + str + " playType = " + i + " SDKVersion = " + TXCCommonUtil.getSDKID() + " , " + TXCCommonUtil.getSDKVersionStr() + " ======"); TXCLog.m15675d(TAG, "==========================================================================================================================================================="); TXCLog.m15675d(TAG, "==========================================================================================================================================================="); if (this.mCurrentPlayType == -1 || this.mCurrentPlayType != i) { this.mPlayer = C25666p.m40716a(this.mContext, i); } this.mCurrentPlayType = i; if (this.mPlayer == null) { AppMethodBeat.m2505o(65943); return -2; } this.mPlayUrl = checkPlayUrl(str, i); setConfig(this.mConfig); if (this.mTXCloudVideoView != null) { this.mTXCloudVideoView.clearLog(); this.mTXCloudVideoView.setVisibility(0); } this.mPlayer.mo67318a(this.mTXCloudVideoView); this.mPlayer.mo72891a((C0946a) this); this.mPlayer.mo72892c(this.mAutoPlay); if (this.mSurface != null) { this.mPlayer.mo67314a(this.mSurface); this.mPlayer.mo67312a(this.mSurfaceWidth, this.mSurfaceHeight); } this.mPlayer.mo67308a(this.mPlayUrl, i); this.mPlayer.mo67323b(this.mMute); this.mPlayer.mo72890a(this.mRate); this.mPlayer.mo67322b(this.mRenderRotation); this.mPlayer.mo67311a(this.mRenderMode); setAudioRoute(this.mAudioRoute); this.mPlayer.mo67317a(this.mAudioRawDataListener); setVideoRawDataListener(this.mVideoRawDataListener); if (this.mPlayer.mo67328f()) { this.mLivePlayUrl = this.mPlayUrl; this.mProgressStartTime = this.mTimeShiftUtil != null ? this.mTimeShiftUtil.mo60179a() : 0; if (this.mProgressStartTime > 0) { this.mPlayer.mo67329g(); } } Iterator it = this.mCallFuncBeforeStartPlay.iterator(); while (it.hasNext()) { TXCDRApi.reportEvent40003(this.mPlayUrl, C8795a.f2493S, 0, (String) it.next(), ""); } this.mCallFuncBeforeStartPlay.clear(); TXCDRApi.reportEvent40003(this.mPlayUrl, C8795a.f2493S, 0, "startPlay:".concat(String.valueOf(i)), ""); AppMethodBeat.m2505o(65943); return 0; } public int switchStream(String str) { AppMethodBeat.m2504i(65944); if (this.mPlayer != null) { int a = this.mPlayer.mo67307a(str); AppMethodBeat.m2505o(65944); return a; } AppMethodBeat.m2505o(65944); return -1; } public int stopPlay(boolean z) { AppMethodBeat.m2504i(65945); TXCLog.m15675d(TAG, "liteav_api stopPlay " + z + ", " + this); if (this.mPlayUrl != null && this.mPlayUrl.length() > 0) { TXCDRApi.reportEvent40003(this.mPlayUrl, C8795a.f2493S, 0, "stopPlay", ""); } if (z && this.mTXCloudVideoView != null) { this.mTXCloudVideoView.setVisibility(8); } if (this.mPlayer != null) { this.mPlayer.mo67309a(z); } this.mPlayUrl = ""; this.mProgressStartTime = 0; this.mTimeShiftUtil = null; this.mIsShiftPlaying = false; AppMethodBeat.m2505o(65945); return 0; } public boolean isPlaying() { AppMethodBeat.m2504i(65946); if (this.mPlayer != null) { boolean c = this.mPlayer.mo67325c(); AppMethodBeat.m2505o(65946); return c; } AppMethodBeat.m2505o(65946); return false; } public void pause() { AppMethodBeat.m2504i(65947); TXCLog.m15675d(TAG, "liteav_api pause ".concat(String.valueOf(this))); if (this.mPlayer != null) { TXCLog.m15679w(TAG, "pause play"); this.mPlayer.mo67310a(); } if (this.mPlayUrl != null && this.mPlayUrl.length() > 0) { TXCDRApi.reportEvent40003(this.mPlayUrl, C8795a.f2493S, 0, "pause", ""); } AppMethodBeat.m2505o(65947); } public void resume() { AppMethodBeat.m2504i(65948); TXCLog.m15675d(TAG, "liteav_api resume ".concat(String.valueOf(this))); if (this.mPlayer != null) { TXCLog.m15679w(TAG, "resume play"); this.mPlayer.mo67321b(); setAudioRoute(this.mAudioRoute); } if (this.mPlayUrl != null && this.mPlayUrl.length() > 0) { TXCDRApi.reportEvent40003(this.mPlayUrl, C8795a.f2493S, 0, "resume", ""); } AppMethodBeat.m2505o(65948); } public void seek(int i) { AppMethodBeat.m2504i(65949); TXCLog.m15675d(TAG, "liteav_api "); if (this.mPlayer != null) { if (this.mPlayer.mo67328f() || this.mIsShiftPlaying) { CharSequence a = this.mTimeShiftUtil != null ? this.mTimeShiftUtil.mo60180a((long) i) : ""; if (!TextUtils.isEmpty(a)) { this.mIsShiftPlaying = startPlay(a, 3) == 0; if (this.mIsShiftPlaying) { this.mProgressStartTime = (long) (i * 1000); AppMethodBeat.m2505o(65949); return; } } else if (this.mListener != null) { this.mListener.onPlayEvent(TXLiveConstants.PLAY_ERR_NET_DISCONNECT, new Bundle()); } AppMethodBeat.m2505o(65949); return; } this.mPlayer.mo72893e(i); } AppMethodBeat.m2505o(65949); } public int prepareLiveSeek(String str, int i) { AppMethodBeat.m2504i(65950); TXCLog.m15675d(TAG, "liteav_api prepareLiveSeek ".concat(String.valueOf(this))); if (this.mTimeShiftUtil == null) { this.mTimeShiftUtil = new C37368j(this.mContext); } if (this.mTimeShiftUtil != null) { int a = this.mTimeShiftUtil.mo60178a(this.mPlayUrl, str, i, new C364141()); AppMethodBeat.m2505o(65950); return a; } AppMethodBeat.m2505o(65950); return -1; } public int resumeLive() { AppMethodBeat.m2504i(65951); TXCLog.m15675d(TAG, "liteav_api resumeLive ".concat(String.valueOf(this))); if (this.mIsShiftPlaying) { this.mIsShiftPlaying = false; int startPlay = startPlay(this.mLivePlayUrl, 1); AppMethodBeat.m2505o(65951); return startPlay; } AppMethodBeat.m2505o(65951); return -1; } public void setPlayListener(ITXLivePlayListener iTXLivePlayListener) { AppMethodBeat.m2504i(65952); TXCLog.m15675d(TAG, "liteav_api setPlayListener ".concat(String.valueOf(this))); this.mListener = iTXLivePlayListener; AppMethodBeat.m2505o(65952); } public void setVideoRecordListener(ITXVideoRecordListener iTXVideoRecordListener) { AppMethodBeat.m2504i(65953); TXCLog.m15675d(TAG, "liteav_api setVideoRecordListener"); if (this.mPlayer != null) { this.mPlayer.mo67319a(iTXVideoRecordListener); } AppMethodBeat.m2505o(65953); } public int startRecord(int i) { AppMethodBeat.m2504i(65954); TXCLog.m15675d(TAG, "liteav_api startRecord ".concat(String.valueOf(this))); if (VERSION.SDK_INT < 18) { TXCLog.m15676e(TAG, "API levl is too low (record need 18, current is" + VERSION.SDK_INT + ")"); AppMethodBeat.m2505o(65954); return -3; } else if (!isPlaying()) { TXCLog.m15676e(TAG, "startRecord: there is no playing stream"); AppMethodBeat.m2505o(65954); return -1; } else if (this.mPlayer != null) { int c = this.mPlayer.mo67324c(i); AppMethodBeat.m2505o(65954); return c; } else { AppMethodBeat.m2505o(65954); return -1; } } public int stopRecord() { AppMethodBeat.m2504i(65955); TXCLog.m15675d(TAG, "liteav_api stopRecord ".concat(String.valueOf(this))); if (this.mPlayer != null) { int e = this.mPlayer.mo67327e(); AppMethodBeat.m2505o(65955); return e; } AppMethodBeat.m2505o(65955); return -1; } public void setRenderMode(int i) { AppMethodBeat.m2504i(65956); TXCLog.m15675d(TAG, "liteav_api setRenderMode ".concat(String.valueOf(i))); this.mRenderMode = i; if (this.mPlayer != null) { this.mPlayer.mo67311a(i); } AppMethodBeat.m2505o(65956); } public void setRenderRotation(int i) { AppMethodBeat.m2504i(65957); TXCLog.m15675d(TAG, "liteav_api setRenderRotation ".concat(String.valueOf(i))); this.mRenderRotation = i; if (this.mPlayer != null) { this.mPlayer.mo67322b(i); } AppMethodBeat.m2505o(65957); } public boolean enableHardwareDecode(boolean z) { AppMethodBeat.m2504i(65958); TXCLog.m15675d(TAG, "liteav_api enableHardwareDecode ".concat(String.valueOf(z))); if (z) { if (VERSION.SDK_INT < 18) { TXCLog.m15676e("HardwareDecode", "enableHardwareDecode failed, android system build.version = " + VERSION.SDK_INT + ", the minimum build.version should be 18(android 4.3 or later)"); AppMethodBeat.m2505o(65958); return false; } else if (isAVCDecBlacklistDevices()) { TXCLog.m15676e("HardwareDecode", "enableHardwareDecode failed, MANUFACTURER = " + Build.MANUFACTURER + ", MODEL" + Build.MODEL); AppMethodBeat.m2505o(65958); return false; } } this.mEnableHWDec = z; if (this.mPlayer != null) { C17787g h = this.mPlayer.mo72894h(); if (h == null) { h = new C17787g(); } h.f4180i = this.mEnableHWDec; this.mPlayer.mo67315a(h); } AppMethodBeat.m2505o(65958); return true; } public void setMute(boolean z) { AppMethodBeat.m2504i(65959); TXCLog.m15675d(TAG, "liteav_api setMute ".concat(String.valueOf(z))); this.mMute = z; if (this.mPlayer != null) { this.mPlayer.mo67323b(z); } if (this.mPlayUrl == null || this.mPlayUrl.length() <= 0) { this.mCallFuncBeforeStartPlay.add("setMute:".concat(String.valueOf(z))); AppMethodBeat.m2505o(65959); return; } TXCDRApi.reportEvent40003(this.mPlayUrl, C8795a.f2493S, 0, "setMute:".concat(String.valueOf(z)), ""); AppMethodBeat.m2505o(65959); } public void setAutoPlay(boolean z) { AppMethodBeat.m2504i(65960); TXCLog.m15675d(TAG, "liteav_api setAutoPlay ".concat(String.valueOf(z))); this.mAutoPlay = z; AppMethodBeat.m2505o(65960); } public void setRate(float f) { AppMethodBeat.m2504i(65961); TXCLog.m15675d(TAG, "liteav_api setRate ".concat(String.valueOf(f))); this.mRate = f; if (this.mPlayer != null) { this.mPlayer.mo72890a(f); } AppMethodBeat.m2505o(65961); } public void setAudioRoute(int i) { AppMethodBeat.m2504i(65962); TXCLog.m15675d(TAG, "liteav_api setAudioRoute ".concat(String.valueOf(i))); this.mAudioRoute = i; if (this.mPlayer != null) { this.mPlayer.mo67313a(this.mContext, this.mAudioRoute); } AppMethodBeat.m2505o(65962); } public void onNotifyEvent(int i, Bundle bundle) { AppMethodBeat.m2504i(65963); long j; if (i == 15001) { if (this.mTXCloudVideoView != null) { this.mTXCloudVideoView.setLogText(bundle, null, 0); } if (this.mListener != null) { this.mListener.onNetStatus(bundle); AppMethodBeat.m2505o(65963); return; } } else if (i == TXLiveConstants.PLAY_EVT_PLAY_PROGRESS) { j = ((long) bundle.getInt(TXLiveConstants.EVT_PLAY_PROGRESS_MS)) + this.mProgressStartTime; if (j > 0) { bundle.putInt(TXLiveConstants.EVT_PLAY_PROGRESS, (int) (j / 1000)); bundle.putInt(TXLiveConstants.EVT_PLAY_PROGRESS_MS, (int) j); if (this.mListener != null) { this.mListener.onPlayEvent(i, bundle); } } AppMethodBeat.m2505o(65963); return; } else { if (this.mTXCloudVideoView != null) { this.mTXCloudVideoView.setLogText(null, bundle, i); } if (this.mListener != null) { this.mListener.onPlayEvent(i, bundle); } j = System.currentTimeMillis(); if (i == TXLiveConstants.PUSH_ERR_VIDEO_ENCODE_FAIL) { if (j - this.mLastReportTime < 5000) { AppMethodBeat.m2505o(65963); return; } this.mLastReportTime = j; } if (!(i == TXLiveConstants.PLAY_EVT_PLAY_PROGRESS || i == 2012 || this.mPlayUrl == null || this.mPlayUrl.length() <= 0)) { String string = bundle.getString(TXLiveConstants.EVT_DESCRIPTION); String str = this.mPlayUrl; int i2 = C8795a.f2494T; if (string == null) { string = ""; } TXCDRApi.reportEvent40003(str, i2, i, string, ""); } } AppMethodBeat.m2505o(65963); } public boolean addVideoRawData(byte[] bArr) { AppMethodBeat.m2504i(65964); TXCLog.m15675d(TAG, "liteav_api addVideoRawData ".concat(String.valueOf(bArr))); if (this.mPlayUrl == null || this.mPlayUrl.isEmpty()) { AppMethodBeat.m2505o(65964); return false; } else if (this.mEnableHWDec) { TXLog.m71029e(TAG, "can not addVideoRawData because of hw decode has set!"); AppMethodBeat.m2505o(65964); return false; } else if (this.mPlayer == null) { TXCLog.m15676e(TAG, "player hasn't created or not instanceof live player"); AppMethodBeat.m2505o(65964); return false; } else { this.mPlayer.mo67320a(bArr); AppMethodBeat.m2505o(65964); return true; } } public void setVideoRawDataListener(final ITXVideoRawDataListener iTXVideoRawDataListener) { AppMethodBeat.m2504i(65965); TXCLog.m15675d(TAG, "liteav_api setVideoRawDataListener ".concat(String.valueOf(iTXVideoRawDataListener))); this.mVideoRawDataListener = iTXVideoRawDataListener; if (this.mPlayer == null) { AppMethodBeat.m2505o(65965); } else if (iTXVideoRawDataListener != null) { this.mPlayer.mo67316a(new C8832o() { public void onVideoRawDataAvailable(byte[] bArr, int i, int i2, int i3) { AppMethodBeat.m2504i(65594); iTXVideoRawDataListener.onVideoRawDataAvailable(bArr, i, i2, i3); AppMethodBeat.m2505o(65594); } }); AppMethodBeat.m2505o(65965); } else { this.mPlayer.mo67316a(null); AppMethodBeat.m2505o(65965); } } public void snapshot(ITXSnapshotListener iTXSnapshotListener) { AppMethodBeat.m2504i(65966); TXCLog.m15675d(TAG, "liteav_api snapshot ".concat(String.valueOf(iTXSnapshotListener))); if (this.mSnapshotRunning || iTXSnapshotListener == null) { AppMethodBeat.m2505o(65966); return; } TextureView d; this.mSnapshotRunning = true; if (this.mPlayer != null) { d = this.mPlayer.mo67326d(); } else { d = null; } if (d != null) { Bitmap bitmap; try { bitmap = d.getBitmap(); } catch (OutOfMemoryError e) { bitmap = null; } if (bitmap != null) { int i = 0; Bitmap createBitmap = Bitmap.createBitmap(bitmap, 0, i, bitmap.getWidth(), bitmap.getHeight(), d.getTransform(null), true); bitmap.recycle(); bitmap = createBitmap; } postBitmapToMainThread(iTXSnapshotListener, bitmap); AppMethodBeat.m2505o(65966); return; } this.mSnapshotRunning = false; AppMethodBeat.m2505o(65966); } public void setAudioRawDataListener(ITXAudioRawDataListener iTXAudioRawDataListener) { AppMethodBeat.m2504i(65967); TXCLog.m15675d(TAG, "liteav_api setAudioRawDataListener ".concat(String.valueOf(iTXAudioRawDataListener))); this.mAudioRawDataListener = iTXAudioRawDataListener; if (this.mPlayer != null) { this.mPlayer.mo67317a(iTXAudioRawDataListener); } AppMethodBeat.m2505o(65967); } private boolean isAVCDecBlacklistDevices() { AppMethodBeat.m2504i(65968); if (Build.MANUFACTURER.equalsIgnoreCase("HUAWEI") && Build.MODEL.equalsIgnoreCase("Che2-TL00")) { AppMethodBeat.m2505o(65968); return true; } AppMethodBeat.m2505o(65968); return false; } private String checkPlayUrl(String str, int i) { AppMethodBeat.m2504i(65969); if (i != 6) { try { byte[] bytes = str.getBytes("UTF-8"); StringBuilder stringBuilder = new StringBuilder(bytes.length); int i2 = 0; while (i2 < bytes.length) { int i3 = bytes[i2] < (byte) 0 ? bytes[i2] + 256 : bytes[i2]; if (i3 <= 32 || i3 >= C31128d.MIC_SketchMark || i3 == 34 || i3 == 37 || i3 == 60 || i3 == 62 || i3 == 91 || i3 == 125 || i3 == 92 || i3 == 93 || i3 == 94 || i3 == 96 || i3 == 123 || i3 == 124) { stringBuilder.append(String.format("%%%02X", new Object[]{Integer.valueOf(i3)})); } else { stringBuilder.append((char) i3); } i2++; } str = stringBuilder.toString(); } catch (Exception e) { } } String trim = str.trim(); AppMethodBeat.m2505o(65969); return trim; } private void postBitmapToMainThread(final ITXSnapshotListener iTXSnapshotListener, final Bitmap bitmap) { AppMethodBeat.m2504i(65970); if (iTXSnapshotListener == null) { AppMethodBeat.m2505o(65970); return; } new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { AppMethodBeat.m2504i(65608); if (iTXSnapshotListener != null) { iTXSnapshotListener.onSnapshot(bitmap); } TXLivePlayer.this.mSnapshotRunning = false; AppMethodBeat.m2505o(65608); } }); AppMethodBeat.m2505o(65970); } }
d5dbd5db58322a3951683e49a03f9ed272989c4f
a7d40bd0085bfe46d12887295e7b4d68453acd05
/app/src/main/java/com/imrainbow/myappportfolio/MainActivity.java
e2a47e0ce0c0b4381eadae6939c9f753bfa452ef
[]
no_license
vclub/MyAppPortfolio
c02c1adf215046d1aa875a5f6eb5061166f15ef5
695910ab3bfc2706134e92ca78f1b084ca2b32e0
refs/heads/master
2020-04-14T14:59:57.521398
2015-09-23T13:40:49
2015-09-23T13:40:49
38,828,323
0
0
null
null
null
null
UTF-8
Java
false
false
1,390
java
package com.imrainbow.myappportfolio; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.Toast; public class MainActivity extends AppCompatActivity implements View.OnClickListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); findViewById(R.id.btnSpotifyStreamer).setOnClickListener(this); findViewById(R.id.btnScoresApp).setOnClickListener(this); findViewById(R.id.btnLibraryApp).setOnClickListener(this); findViewById(R.id.btnBuildItBigger).setOnClickListener(this); findViewById(R.id.btnBaconReader).setOnClickListener(this); findViewById(R.id.btnCapstone).setOnClickListener(this); } @Override public void onClick(View v) { switch (v.getId()){ case R.id.btnCapstone: Toast.makeText(this,"This button will launch my capstone app!", Toast.LENGTH_SHORT).show(); break; default: if (v instanceof Button){ Toast.makeText(this, ((Button) v).getText() + " click", Toast.LENGTH_SHORT).show(); } break; } } }
573123737d559532406bb3e05ed2014d79fb7b6c
bdb5d205d56ef9e0f523be1c3fd683400f7057a5
/app/src/main/java/com/tgf/kcwc/see/dealer/HomeFragment.java
9f5084ef2e7d3bec3942dc973bc395b3d9a8da8f
[]
no_license
yangyusong1121/Android-car
f8fbd83b8efeb2f0e171048103f2298d96798f9e
d6215e7a59f61bd7f15720c8e46423045f41c083
refs/heads/master
2020-03-11T17:25:07.154083
2018-04-19T02:18:15
2018-04-19T02:20:19
130,146,301
0
1
null
null
null
null
UTF-8
Java
false
false
22,674
java
package com.tgf.kcwc.see.dealer; import android.content.Intent; import android.graphics.Paint; import android.net.Uri; import android.text.Html; import android.view.View; import android.widget.AdapterView; import android.widget.Button; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.RelativeLayout; import android.widget.TextView; import com.facebook.drawee.view.SimpleDraweeView; import com.hedgehog.ratingbar.RatingBar; import com.tgf.kcwc.R; import com.tgf.kcwc.adapter.WrapAdapter; import com.tgf.kcwc.base.BaseFragment; import com.tgf.kcwc.common.Constants; import com.tgf.kcwc.coupon.CouponDetailActivity; import com.tgf.kcwc.driving.driv.DrivingDetailsActivity; import com.tgf.kcwc.driving.please.PleasePlayDetailsActivity; import com.tgf.kcwc.finddiscount.LimitDetailActivity; import com.tgf.kcwc.me.UserPageActivity; import com.tgf.kcwc.mvp.model.Account; import com.tgf.kcwc.mvp.model.Comment; import com.tgf.kcwc.mvp.model.CommentModel; import com.tgf.kcwc.mvp.model.Coupon; import com.tgf.kcwc.mvp.model.StoreDetailData; import com.tgf.kcwc.mvp.model.Topic; import com.tgf.kcwc.mvp.presenter.CommentListPresenter; import com.tgf.kcwc.mvp.presenter.StoreHomePresenter; import com.tgf.kcwc.mvp.view.CommentListView; import com.tgf.kcwc.mvp.view.StoreHomeView; import com.tgf.kcwc.util.CommonUtils; import com.tgf.kcwc.util.DateFormatUtil; import com.tgf.kcwc.util.IOUtils; import com.tgf.kcwc.util.URLUtil; import com.tgf.kcwc.util.ViewUtil; import com.tgf.kcwc.view.GridViewWithHeaderAndFooter; import com.tgf.kcwc.view.MultiImageView; import com.tgf.kcwc.view.nestlistview.NestFullListView; import com.tgf.kcwc.view.nestlistview.NestFullListViewAdapter; import com.tgf.kcwc.view.nestlistview.NestFullViewHolder; import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * Author:Jenny * Date:2017/3/15 15:53 * E-mail:[email protected] * 店铺主页(优惠及活动) */ public class HomeFragment extends BaseFragment implements StoreHomeView, CommentListView<CommentModel> { private SimpleDraweeView mBigHeaderImg; private TextView mImgCountText; private SimpleDraweeView mLogo; private TextView mName; private RatingBar mRatingBar; private ImageView mCall; private ListView mCouponList; private ListView mShopActivityList; private ListView mGiftsList; private ListView mLimitCouponList; private GridViewWithHeaderAndFooter mPlayerList; private GridViewWithHeaderAndFooter mSalespersonGrid; private String mOrgTitle = ""; private StoreHomePresenter mPresenter; private CommentListPresenter mCommentPresenter; private List<Topic> mPlayerDatas = new ArrayList<Topic>(); private NestFullListView mEvaluateList; private NestFullListViewAdapter mCommentsadapter; //回复列表 private NestFullListViewAdapter mReplyadapter; private RelativeLayout mEvaluationLayout; private String mOrgId; private List<Coupon> mCouponDatas = new ArrayList<Coupon>(); private LinearLayout mCouponLayout, mGiftByShoppingLayout, mLimitCouponLayout; private String lat; private String lng; private String tel; @Override protected void updateData() { } @Override protected int getLayoutId() { return R.layout.fragment_delear_home; } private RelativeLayout mActivityLayout; @Override protected void initView() { mCouponList = findView(R.id.couponList); mShopActivityList = findView(R.id.shopActivityList); mActivityLayout = findView(R.id.shopActivityLayout); mGiftsList = findView(R.id.giftList); mLimitCouponList = findView(R.id.limitCouponList); mLimitCouponList.setOnItemClickListener(mLimitItemClickListener); mPlayerList = findView(R.id.playList); mEvaluateList = findView(R.id.evaluateList); mSalespersonGrid = findView(R.id.salespersonGrid); mCouponLayout = findView(R.id.couponLayout); mGiftByShoppingLayout = findView(R.id.giftByShoppingLayout); mLimitCouponLayout = findView(R.id.limitCouponLayout); mShopActivityList.setOnItemClickListener(mShopActivityItemListener); mEvaluationLayout = findView(R.id.evaluateHeaderLayout); mEvaluationLayout.setOnClickListener(this); findView(R.id.saleEliteLayout).setOnClickListener(this); findView(R.id.salesHeaderLayout).setOnClickListener(this); findView(R.id.shopActivityHeaderLayout).setOnClickListener(this); showHeaderTitleViews(); mOrgId = getArguments().getString(Constants.IntentParams.ID); mPresenter = new StoreHomePresenter(); mPresenter.attachView(this); mPresenter.loadStoreInfo(mOrgId + "", IOUtils.getToken(mContext)); mPresenter.loadCouponList(mOrgId + ""); mPresenter.loadGiftList(mOrgId, "1", IOUtils.getToken(mContext)); mPresenter.loadGiftList(mOrgId, "2", IOUtils.getToken(mContext)); mCommentPresenter = new CommentListPresenter(); mCommentPresenter.attachView(this); mCommentPresenter.loadEvaluateList("shop_detail", mOrgId, "car"); } private AdapterView.OnItemClickListener mShopActivityItemListener = new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Topic topic = (Topic) parent.getAdapter().getItem(position); String model = topic.model; Map<String, Serializable> args = new HashMap<String, Serializable>(); args.put(Constants.IntentParams.ID, topic.id + ""); if ("cycle".equals(model)) { CommonUtils.startNewActivity(mContext, args, DrivingDetailsActivity.class); } else if ("play".equals(model)) { CommonUtils.startNewActivity(mContext, args, PleasePlayDetailsActivity.class); } } }; private AdapterView.OnItemClickListener mLimitItemClickListener = new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Coupon coupon = (Coupon) parent.getAdapter().getItem(position); Map<String, Serializable> args = new HashMap<String, Serializable>(); args.put(Constants.IntentParams.ID, coupon.id); CommonUtils.startNewActivity(mContext, args, LimitDetailActivity.class); } }; private void showHeaderTitleViews() { initCommonTitleView(mCouponLayout, R.drawable.coupon_icon, "代金券"); initCommonTitleView(mGiftByShoppingLayout, R.drawable.send_gift_icon, "购车有礼"); initCommonTitleView(mLimitCouponLayout, R.drawable.limit_privilege_icon, "限时优惠"); String[] titles = mRes.getStringArray(R.array.list_header_titles); int length = mCommonHeaderViewIds.length; for (int i = 0; i < length; i++) { View v = findView(mCommonHeaderViewIds[i]); TextView titleText = (TextView) v.findViewById(R.id.title); titleText.setText(titles[i]); if (i == length - 1) { v.findViewById(R.id.content).setVisibility(View.VISIBLE); v.findViewById(R.id.secHeaderLayout).setVisibility(View.VISIBLE); RatingBar ratingBar = (RatingBar) v.findViewById(R.id.ratingBar); ratingBar.setVisibility(View.VISIBLE); setRatingScore(ratingBar, 5, 3, R.drawable.rating_bar_star_empty, R.drawable.rating_bar_star_empty, R.drawable.rating_bar_star_fill); } } } private void initCommonTitleView(View parent, int drawableId, String title) { ImageView imgView = (ImageView) parent.findViewById(R.id.img_icon); TextView titleTv = (TextView) parent.findViewById(R.id.title); imgView.setImageResource(drawableId); titleTv.setText(title); } private int[] mCommonHeaderViewIds = {R.id.shopActivityHeaderLayout, R.id.saleEliteLayout, R.id.evaluateHeaderLayout}; private void setRatingScore(RatingBar ratingBar, int count, float star, int drawableEmptyId, int drawableHalfId, int drawableFillId) { ratingBar.setStarEmptyDrawable(getResources().getDrawable(drawableEmptyId)); ratingBar.setStarHalfDrawable(getResources().getDrawable(drawableHalfId)); ratingBar.setStarFillDrawable(getResources().getDrawable(drawableFillId)); ratingBar.setStarCount(count); ratingBar.setStarImageSize(star); ratingBar.setStar(star); ratingBar.halfStar(true); ratingBar.setmClickable(false); } @Override public void onDestroy() { super.onDestroy(); if (mPresenter != null) { mPresenter.detachView(); } if (mCommentPresenter != null) { mCommentPresenter.detachView(); } } @Override public void showCouponList(final List<Coupon> datas) { int size = datas.size(); if (size == 0) { mCouponLayout.setVisibility(View.GONE); } else { mCouponLayout.setVisibility(View.VISIBLE); } mCouponDatas.clear(); mCouponDatas.addAll(datas); final WrapAdapter<Coupon> adapter = new WrapAdapter<Coupon>(mContext, mCouponDatas, R.layout.coupon_list_item) { @Override public void convert(ViewHolder helper, final Coupon item) { helper.setImageByUrl(R.id.img, URLUtil.builderImgUrl(item.cover, 270, 203)); TextView denominationTv = helper.getView(R.id.price); TextView originalPriceText = helper.getView(R.id.originalPrice); TextView moneyTagTv = helper.getView(R.id.moneyTag); Button button = helper.getView(R.id.acquireBtn); //设置点击事件跳转到代金券领取页面 button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Map<String, Serializable> args = new HashMap<String, Serializable>(); args.put(Constants.IntentParams.ID, item.id); CommonUtils.startNewActivity(mContext, args, CouponDetailActivity.class); } }); if (item.price.equals("0.00")) { button.setText("领"); moneyTagTv.setText(""); denominationTv.setText("免费"); denominationTv.setTextColor(mRes.getColor(R.color.text_color16)); button.setBackgroundResource(R.drawable.button_bg_2); } else { button.setText("抢"); denominationTv.setText(item.price); // denominationTv.setTextColor(mRes.getColor(R.color.tab_text_s_color)); moneyTagTv.setText("¥"); button.setBackgroundResource(R.drawable.button_bg_15); } originalPriceText.setText("¥" + item.denomination); originalPriceText.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG); helper.setText(R.id.title, item.title); String exp = item.expire; if (exp.length() > 0) { exp = exp.replaceAll("-", "."); exp = exp.substring(0, 11); } helper.setText(R.id.expire, "有效期至" + exp); } }; mCouponList.setAdapter(adapter); // String formatText = String.format(getString(R.string.coupon_other_count_text), 2); // final View loadMoreView = ViewUtil.createFooterView(formatText, // Constants.Types.LOAD_MORE_STYLE_1, mCouponList); // loadMoreView.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // // mCouponDatas.addAll(datas); // adapter.notifyDataSetChanged(); // mCouponList.removeFooterView(loadMoreView); // ViewUtil.setListViewHeightBasedOnChildren(mCouponList); // } // }); // // mCouponList.addFooterView(loadMoreView); ViewUtil.setListViewHeightBasedOnChildren(mCouponList); } @Override public void showStoreInfo(StoreDetailData data) { tel = data.tel; lat = data.latitude; lng = data.longitude; showSalespersonLists(data.users); showTopicsLists(data.topics); } @Override public void showGifts(final List<Coupon> datas) { int size = datas.size(); if (size == 0) { mGiftByShoppingLayout.setVisibility(View.GONE); } else { mGiftByShoppingLayout.setVisibility(View.VISIBLE); } WrapAdapter<Coupon> adapter = new WrapAdapter<Coupon>(mContext, R.layout.gift_list_item, datas) { @Override public void convert(ViewHolder helper, Coupon item) { SimpleDraweeView coverImg = helper.getView(R.id.cover); coverImg.setImageURI(Uri.parse(URLUtil.builderImgUrl(item.cover, 270, 203))); TextView titleTv = helper.getView(R.id.title); titleTv.setText(item.title); TextView descTv = helper.getView(R.id.desc); descTv.setText(item.desc); } }; mGiftsList.setAdapter(adapter); } @Override public void showPrivileges(List<Coupon> datas) { int size = datas.size(); if (size == 0) { mLimitCouponLayout.setVisibility(View.GONE); } else { mLimitCouponLayout.setVisibility(View.VISIBLE); } WrapAdapter<Coupon> adapter = new WrapAdapter<Coupon>(mContext, R.layout.gift_list_item, datas) { @Override public void convert(ViewHolder helper, Coupon item) { SimpleDraweeView coverImg = helper.getView(R.id.cover); coverImg.setImageURI(Uri.parse(URLUtil.builderImgUrl(item.cover, 270, 203))); TextView titleTv = helper.getView(R.id.title); titleTv.setText(item.title); TextView descTv = helper.getView(R.id.desc); descTv.setText(item.desc); } }; mLimitCouponList.setAdapter(adapter); } private void showSalespersonLists(List<Account.UserInfo> users) { WrapAdapter<Account.UserInfo> adapter = new WrapAdapter<Account.UserInfo>(mContext, users, R.layout.salespersion_grid_item) { @Override public void convert(WrapAdapter.ViewHolder helper, Account.UserInfo item) { helper.setImageByUrl(R.id.img, URLUtil.builderImgUrl(item.avatar, 144, 144)); helper.setText(R.id.name, item.nickName); helper.setText(R.id.star, item.star); } }; mSalespersonGrid.setAdapter(adapter); mSalespersonGrid.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Account.UserInfo userInfo = (Account.UserInfo) parent.getAdapter() .getItem(position); Intent intent = new Intent(); intent.putExtra(Constants.IntentParams.ID, userInfo.userId); intent.setClass(mContext, UserPageActivity.class); startActivity(intent); } }); ViewUtil.setListViewHeightBasedOnChildren(mSalespersonGrid, 6); } private void showTopicsLists(List<Topic> topics) { int size = topics.size(); if (size == 0) { mActivityLayout.setVisibility(View.GONE); } else { mActivityLayout.setVisibility(View.VISIBLE); } WrapAdapter<Topic> adapter = new WrapAdapter<Topic>(mContext, topics, R.layout.topic_list_item) { @Override public void convert(ViewHolder helper, Topic item) { helper.setImageByUrl(R.id.img, URLUtil.builderImgUrl(item.itemImgUrl, 360, 360)); helper.setText(R.id.title, item.title); String expire = DateFormatUtil.dispActiveTime2(item.begin, item.end); helper.setText(R.id.expire, expire); } }; mShopActivityList.setAdapter(adapter); ViewUtil.setListViewHeightBasedOnChildren(mShopActivityList); } private void showEvaluateLists(final CommentModel model) { View v = findView(R.id.evaluateHeaderLayout); TextView contentTv = (TextView) v.findViewById(R.id.content); TextView contentTv2 = (TextView) v.findViewById(R.id.content2); contentTv2.setText(model.avgStar + ""); contentTv.setText("(" + model.count + ")"); float avgStar = Float.parseFloat(model.avgStar); RatingBar ratingBar = (RatingBar) v.findViewById(R.id.ratingBar); setRatingScore(ratingBar, 5, avgStar, R.drawable.rating_bar_star_empty, R.drawable.icon_half_a_star_n, R.drawable.rating_bar_star_fill); mCommentsadapter = new NestFullListViewAdapter<Comment>(R.layout.listview_item_evaluate, model.comments) { @Override public void onBind(final int pos, Comment comment, NestFullViewHolder holder) { SimpleDraweeView simpleDraweeView = holder.getView(R.id.img); simpleDraweeView .setImageURI(URLUtil.builderImgUrl(comment.senderInfo.avatar, 144, 144)); RatingBar ratingBar = holder.getView(R.id.ratingBar); setRatingScore(ratingBar, 5, 4.5f, R.drawable.icon_star_n, R.drawable.icon_half_a_star_1_n, R.drawable.icon_star_s); holder.setText(R.id.nametv, comment.senderInfo.nickName + ""); holder.setText(R.id.timeRecord, comment.time + ""); holder.setEmojiText(R.id.contentTv, comment.content); TextView modelText = holder.getView(R.id.comment_model_tv); TextView popmanText = holder.getView(R.id.comment_popman_tv); SimpleDraweeView genderImg = holder.getView(R.id.genderImg); if (comment.senderInfo.sex == 1) { genderImg.setImageResource(R.drawable.icon_men); } else { genderImg.setImageResource(R.drawable.icon_women); } if (comment.senderInfo.is_model == 1) { modelText.setVisibility(View.VISIBLE); } else { modelText.setVisibility(View.GONE); } if (comment.senderInfo.isDaren == 1) { popmanText.setVisibility(View.VISIBLE); } else { popmanText.setVisibility(View.GONE); } MultiImageView multiImageView = holder.getView(R.id.multiImagView); multiImageView.setList(comment.imgs); NestFullListView replyListview = holder.getView(R.id.listview_item_reply_lv); mReplyadapter = new NestFullListViewAdapter<Comment>(R.layout.listview_item_reply, comment.replies) { @Override public void onBind(final int pos2, Comment cmt, NestFullViewHolder holder) { TextView replyTv = holder.getView(R.id.replytv); String msg = String.format(mRes.getString(R.string.reply_msg), cmt.senderInfo.nickName, cmt.receiverInfo.nickName, cmt.content); if (pos2 == 2) { replyTv.setText("查看更多回复"); } else { replyTv.setText(Html.fromHtml(msg)); } } }; replyListview.setAdapter(mReplyadapter); // replyListview.setOnItemClickListener(new NestFullListView.OnItemClickListener() { // @Override // public void onItemClick(NestFullListView parent, View view, int position) { // if (position >= 2) { // // CommonUtils.showToast(mContext, "查看更多回复"); // } else { // CommonUtils.showToast(mContext, "回复评论" + pos + "postwo " + position); // CommonUtils.startNewActivity(mContext, ReplyEditActivity.class); // // } // } // }); } }; mEvaluateList.setAdapter(mCommentsadapter); } @Override public void showDatas(CommentModel commentModel) { showEvaluateLists(commentModel); } @Override public void setLoadingIndicator(boolean active) { } @Override public void showLoadingTasksError() { } @Override public void onClick(View view) { int id = view.getId(); switch (id) { case R.id.evaluateHeaderLayout: Map<String, Serializable> args = new HashMap<String, Serializable>(); args.put(Constants.IntentParams.ID, mOrgId); args.put(Constants.IntentParams.TEL, tel); args.put(Constants.IntentParams.LAT, lat); args.put(Constants.IntentParams.LNG, lng); CommonUtils.startNewActivity(mContext, args, EvaluationListActivity.class); break; case R.id.salesHeaderLayout: args = new HashMap<String, Serializable>(); args.put(Constants.IntentParams.ID, mOrgId); CommonUtils.startNewActivity(mContext, args, SalespersonListActivity.class); break; } } }
b3c3db1ac194565cb8f91257f6353716263ac3a2
55a1dd8ea437030cee7d8fc1d83af637335f3d2b
/discrete_math/Flow/A.java
54f27dc08a42e2d3fbe73ec243d97afe74ece40b
[]
no_license
mikita95/study-projects
3709dcf08fee833def97d19c8880529f3ef15a6c
42a286b76d3f080038570bf868dabb818ac1f0c2
refs/heads/master
2021-09-04T08:18:45.198559
2018-01-17T08:31:43
2018-01-17T08:31:43
115,410,993
0
0
null
null
null
null
UTF-8
Java
false
false
3,410
java
import java.io.*; import java.util.*; public class A { private final static String fileName = "matching"; ArrayList<ArrayList<Integer>> graph; ArrayList<Boolean> used; ArrayList<Integer> set; private final static int inf = -100; void initialization(int n, int m) { set = new ArrayList<Integer>(n + m); graph = new ArrayList<ArrayList<Integer>>(n + m); used = new ArrayList<Boolean>(n); for (int i = 0; i < n + m; i++) { graph.add(new ArrayList<Integer>()); set.add(inf); } for (int i = 0; i < n; i++) used.add(false); } boolean dfs(int v) { if (used.get(v)) return false; used.set(v, true); for (int i = 0, s = graph.get(v).size(); i < s; i++) { if (set.get(graph.get(v).get(i)) == inf) { set.set(graph.get(v).get(i), v); return true; } else if (dfs(set.get(graph.get(v).get(i)))) { set.set(graph.get(v).get(i), v); return true; } } return false; } public void solve() throws IOException { InputStream is = new FileInputStream(fileName + ".in"); FastScanner in = new FastScanner(is); PrintWriter out = new PrintWriter(new File(fileName + ".out")); int n = in.nextInt(); int m = in.nextInt(); int k = in.nextInt(); initialization(n, m); for (int i = 0; i < k; i++) { int x = in.nextInt(); int y = in.nextInt(); graph.get(x - 1).add(y - 1 + n); graph.get(y - 1 + n).add(x - 1); } for (int i = 0; i < n; i++) { for (int t = 0; t < used.size(); t++) used.set(t, false); dfs(i); } int answer = 0; for (int i = 0; i < n + m; i++) { if (set.get(i) != inf) answer++; } out.print(answer); out.close(); } public void run() { try { solve(); } catch (IOException e) { e.printStackTrace(); } } public static class FastScanner { private StringTokenizer tokenizer; public FastScanner(InputStream is) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(1024 * 1024); byte[] buf = new byte[1024]; while (true) { int read = is.read(buf); if (read == -1) break; bos.write(buf, 0, read); } tokenizer = new StringTokenizer(new String(bos.toByteArray())); } catch (IOException e) { throw new RuntimeException(e); } } public boolean hasNext() { return tokenizer.hasMoreTokens(); } public int nextInt() { return Integer.parseInt(tokenizer.nextToken()); } public long nextLong() { return Long.parseLong(tokenizer.nextToken()); } public double nextDouble() { return Double.parseDouble(tokenizer.nextToken()); } public String list() { return tokenizer.nextToken(); } } public static void main(String[] arg) { new A().run(); } }
3d7f0e3f0e9a3433acbe6dc5bdd838920e9e9b31
18a4c22f4ba44488548975ad64e734521938d580
/src/gamestate/GameState.java
daf9abc9a02cea3591947e8281a57455f57f16ce
[]
no_license
JoshMLiu/SpriteFighter
17047c547919d75643eb1226f9fa4dfb5eb50a2f
4689b57760237471dee4e9e341c030c0602393d4
refs/heads/master
2021-06-06T04:20:54.827073
2016-09-25T06:42:33
2016-09-25T06:42:33
null
0
0
null
null
null
null
UTF-8
Java
false
false
357
java
package gamestate; public abstract class GameState { protected GameStateManager gsm; protected GameState(GameStateManager gsm) { this.gsm = gsm; init(); } protected abstract void init(); protected abstract void update(float dt); protected abstract void draw(); protected abstract void handleInput(); protected abstract void dispose(); }
fc580e120babe5fdf93d0134b01f57fbb21097eb
b18880f236fe069eb4f3ed1c37c3696f6143a4b1
/src/main/java/org/launchcode/models/Category.java
7767be03eec809b67f9a5356aee2b645b467acf7
[]
no_license
bngetich/cheese-mvc-persistent
9107ee99da64f1dc779bae6a47a2eb1d48bb54f6
fed2fa7c2e6ae49a81350eaa1612db8520787b4c
refs/heads/master
2020-03-20T22:50:41.519083
2018-06-26T02:36:38
2018-06-26T02:36:38
137,817,912
0
0
null
2018-06-18T23:40:20
2018-06-18T23:40:19
null
UTF-8
Java
false
false
739
java
package org.launchcode.models; import javax.persistence.*; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import java.util.ArrayList; import java.util.List; @Entity public class Category { @Id @GeneratedValue private int id; @NotNull @Size(min = 3, max = 15) private String name; @OneToMany @JoinColumn(name = "category_id") private List<Cheese> cheeses = new ArrayList<>(); public Category() { } public Category(String name) { this.name = name; } public int getId() { return id; } public String getName() { return name; } public void setName(String name) { this.name = name; } }
bb6a7f3295fa30186d706d50e6dcbb55c9eb5e8b
7190ed9102333e68767f807f14143d9aa35ebe96
/Test14/app/src/main/java/cn/mcandroid/test14/db/User.java
6db859c9768543a1c933821b1b345c4e4a70f35b
[]
no_license
LCQ622/Android__Exercise
862e6bcc6e8ed25bbc6cb0038229614bbbf1203b
b263fa1295a2307ae4625e6185a16cd9fe2179f8
refs/heads/master
2020-05-24T13:43:16.205062
2019-05-18T00:03:00
2019-05-18T00:03:00
null
0
0
null
null
null
null
UTF-8
Java
false
false
964
java
package cn.mcandroid.test14.db; public class User { private int id ; private String name; private String phone_number; public User (){} public User(int id, String name, String phone_number) { this.id = id; this.name = name; this.phone_number = phone_number; } 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 String getPhone_number() { return phone_number; } public void setPhone_number(String phone_number) { this.phone_number = phone_number; } @Override public String toString() { return "User{" + "id=" + id + ", name='" + name + '\'' + ", phone_number='" + phone_number + '\'' + '}'; } }
655b46fcdd16c426224d85872194f259a0502af4
efb7efbbd6baa5951748dfbe4139e18c0c3608be
/sources/p015io/grpc/internal/SharedResourceHolder.java
c08f342e3c0634cd339af2a4651eb9cfe84bca10
[]
no_license
blockparty-sh/600302-1_source_from_JADX
08b757291e7c7a593d7ec20c7c47236311e12196
b443bbcde6def10895756b67752bb1834a12650d
refs/heads/master
2020-12-31T22:17:36.845550
2020-02-07T23:09:42
2020-02-07T23:09:42
239,038,650
0
0
null
null
null
null
UTF-8
Java
false
false
4,908
java
package p015io.grpc.internal; import com.google.common.base.Preconditions; import java.util.IdentityHashMap; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import javax.annotation.concurrent.ThreadSafe; @ThreadSafe /* renamed from: io.grpc.internal.SharedResourceHolder */ public final class SharedResourceHolder { static final long DESTROY_DELAY_SECONDS = 1; private static final SharedResourceHolder holder = new SharedResourceHolder(new ScheduledExecutorFactory() { public ScheduledExecutorService createScheduledExecutor() { return Executors.newSingleThreadScheduledExecutor(GrpcUtil.getThreadFactory("grpc-shared-destroyer-%d", true)); } }); /* access modifiers changed from: private */ public ScheduledExecutorService destroyer; private final ScheduledExecutorFactory destroyerFactory; /* access modifiers changed from: private */ public final IdentityHashMap<Resource<?>, Instance> instances = new IdentityHashMap<>(); /* renamed from: io.grpc.internal.SharedResourceHolder$Instance */ private static class Instance { ScheduledFuture<?> destroyTask; final Object payload; int refcount; Instance(Object obj) { this.payload = obj; } } /* renamed from: io.grpc.internal.SharedResourceHolder$Resource */ public interface Resource<T> { void close(T t); T create(); } /* renamed from: io.grpc.internal.SharedResourceHolder$ScheduledExecutorFactory */ interface ScheduledExecutorFactory { ScheduledExecutorService createScheduledExecutor(); } SharedResourceHolder(ScheduledExecutorFactory scheduledExecutorFactory) { this.destroyerFactory = scheduledExecutorFactory; } public static <T> T get(Resource<T> resource) { return holder.getInternal(resource); } public static <T> T release(Resource<T> resource, T t) { return holder.releaseInternal(resource, t); } /* access modifiers changed from: 0000 */ public synchronized <T> T getInternal(Resource<T> resource) { Instance instance; instance = (Instance) this.instances.get(resource); if (instance == null) { instance = new Instance(resource.create()); this.instances.put(resource, instance); } if (instance.destroyTask != null) { instance.destroyTask.cancel(false); instance.destroyTask = null; } instance.refcount++; return instance.payload; } /* access modifiers changed from: 0000 */ public synchronized <T> T releaseInternal(final Resource<T> resource, final T t) { final Instance instance = (Instance) this.instances.get(resource); if (instance != null) { boolean z = false; Preconditions.checkArgument(t == instance.payload, "Releasing the wrong instance"); Preconditions.checkState(instance.refcount > 0, "Refcount has already reached zero"); instance.refcount--; if (instance.refcount == 0) { if (GrpcUtil.IS_RESTRICTED_APPENGINE) { resource.close(t); this.instances.remove(resource); } else { if (instance.destroyTask == null) { z = true; } Preconditions.checkState(z, "Destroy task already scheduled"); if (this.destroyer == null) { this.destroyer = this.destroyerFactory.createScheduledExecutor(); } instance.destroyTask = this.destroyer.schedule(new LogExceptionRunnable(new Runnable() { public void run() { synchronized (SharedResourceHolder.this) { if (instance.refcount == 0) { resource.close(t); SharedResourceHolder.this.instances.remove(resource); if (SharedResourceHolder.this.instances.isEmpty()) { SharedResourceHolder.this.destroyer.shutdown(); SharedResourceHolder.this.destroyer = null; } } } } }), 1, TimeUnit.SECONDS); } } } else { StringBuilder sb = new StringBuilder(); sb.append("No cached instance found for "); sb.append(resource); throw new IllegalArgumentException(sb.toString()); } return null; } }
d26337f1f88718bc4be8aaf7db6d934750c36488
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/29/29_ddfeacaac83bef36007cffde81d22eba054346c1/CommandListSpawns/29_ddfeacaac83bef36007cffde81d22eba054346c1_CommandListSpawns_t.java
d68205c302110f72df71b6dc7f24a2d2ac22d10c
[]
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
5,160
java
package jas.common.command; import jas.common.spawner.biome.group.BiomeHelper; import jas.common.spawner.creature.entry.SpawnListEntry; import jas.common.spawner.creature.type.CreatureType; import jas.common.spawner.creature.type.CreatureTypeRegistry; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandSender; import net.minecraft.command.WrongUsageException; import net.minecraft.entity.EntityList; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.server.MinecraftServer; import net.minecraft.util.ChatMessageComponent; public class CommandListSpawns extends CommandBase { public String getCommandName() { return "jaslistspawns"; } /** * Return the required permission level for this command. */ public int getRequiredPermissionLevel() { return 2; } @Override public String getCommandUsage(ICommandSender commandSender) { return "commands.jaslistspawns.usage"; } /** * Command stringArgs : * * /jaslistspawns <targetPlayer> <EntityType> --OUTPUT--> For Biome Player is in: <entityTypeName>: <spawnEntry1>, * <spawnEntry2> */ @Override public void processCommand(ICommandSender commandSender, String[] stringArgs) { if (stringArgs.length == 0 || stringArgs.length >= 4) { throw new WrongUsageException("commands.jaslistspawns.usage", new Object[0]); } EntityPlayerMP targetPlayer = func_82359_c(commandSender, stringArgs[0]); String biomePckgName = BiomeHelper.getPackageName(targetPlayer.worldObj.getBiomeGenForCoords( (int) targetPlayer.posX, (int) targetPlayer.posZ)); String entityCategName = stringArgs[1]; boolean expandedEntries = stringArgs.length == 3 ? stringArgs[2].equalsIgnoreCase("true") : false; StringBuilder biomeContents = new StringBuilder(); biomeContents.append("Biome "); biomeContents.append(biomePckgName); biomeContents.append(" contains entries:"); boolean foundMatch = false; Iterator<CreatureType> iterator = CreatureTypeRegistry.INSTANCE.getCreatureTypes(); while (iterator.hasNext()) { CreatureType entityType = iterator.next(); if (entityCategName.equals("*") || entityType.typeID.equalsIgnoreCase(entityCategName)) { if (!foundMatch) { foundMatch = true; biomeContents.append(" "); } else { biomeContents.append(", "); } biomeContents.append("\u00A71").append(entityType.typeID).append("\u00A7r| "); Iterator<SpawnListEntry> spawnListIterator = entityType.getSpawnList(biomePckgName).iterator(); while (spawnListIterator.hasNext()) { SpawnListEntry entry = spawnListIterator.next(); biomeContents.append(EntityList.classToStringMapping.get(entry.livingClass)).append("[\u00A74") .append(entry.itemWeight).append("\u00A7r"); if (expandedEntries) { biomeContents.append("/").append(entry.packSize).append("/").append(entry.minChunkPack) .append("/").append(entry.maxChunkPack); } biomeContents.append("]"); if (spawnListIterator.hasNext()) { biomeContents.append(", "); } } } } if (!foundMatch) { throw new WrongUsageException("commands.jaslistspawns.typenotfound", new Object[0]); } else { commandSender.sendChatToPlayer(new ChatMessageComponent().func_111079_a(biomeContents.toString())); } } /** * Adds the strings available in this command to the given list of tab completion options. */ @Override @SuppressWarnings("rawtypes") public List addTabCompletionOptions(ICommandSender commandSender, String[] stringArgs) { if (stringArgs.length == 1) { return getListOfStringsMatchingLastWord(stringArgs, MinecraftServer.getServer().getAllUsernames()); } else if (stringArgs.length == 2) { List<String> values = new ArrayList<String>(); Iterator<CreatureType> iterator = CreatureTypeRegistry.INSTANCE.getCreatureTypes(); while (iterator.hasNext()) { CreatureType entityType = iterator.next(); values.add(entityType.typeID); } String[] arrayValues = values.toArray(new String[values.size()]); return getListOfStringsMatchingLastWord(stringArgs, arrayValues); } else if (stringArgs.length == 3) { return getListOfStringsMatchingLastWord(stringArgs, new String[] { "true", "false" }); } else { return null; } } }
69a574d90a019a587b0629adc3b50aab6536512b
50dcceac691e9200b15e091185dc0a461fdb2287
/springMavenApp/src/main/java/com/itwill1/bean/annotation/CreateBean1.java
678a4d7122ef044e7cd34a687e300d81a8c8ba3d
[]
no_license
helprun/workspace-spring-tool-suite-4-4.8.0.RELEASE
29e6b097fbb54b55162e25289b5dc81fd60b9948
79141e657b03b2973bfb1a9c800066d0dc779cfa
refs/heads/master
2023-01-01T13:51:03.991733
2020-10-27T08:42:27
2020-10-27T08:42:27
304,572,454
0
0
null
null
null
null
UTF-8
Java
false
false
407
java
package com.itwill1.bean.annotation; import org.springframework.context.annotation.DependsOn; import org.springframework.stereotype.Component; @Component("createBean1") @DependsOn("createBean4") public class CreateBean1 { public CreateBean1() { System.out.println("### CreateBean1() 기본생성자"); } public void method1() { System.out.println("### CreateBean1()method1()메쏘드호출"); } }
0ef08d16006bfcd1c5fa031dfe1b7bf715417933
ad77b63efe8f5005970e16ffadd3cb4086fc6514
/src/main/java/com/samourai/whirlpool/client/utils/MessageErrorListener.java
b91dedc866afbb7ab735ba2d8a3a8a4f2e349dd3
[ "LicenseRef-scancode-other-copyleft", "AGPL-3.0-only", "GPL-1.0-or-later", "AGPL-3.0-or-later" ]
permissive
Samourai-Wallet/whirlpool-client
8a8de4f52a0c3a42d000c6d52df29c044f719830
bc4110dfbae7a265435db5b49e4301ba4394044e
refs/heads/develop
2021-07-16T06:24:29.694746
2020-04-28T08:26:25
2020-04-28T08:26:25
130,805,464
9
8
Unlicense
2018-12-08T11:16:31
2018-04-24T06:17:05
Java
UTF-8
Java
false
false
146
java
package com.samourai.whirlpool.client.utils; public interface MessageErrorListener<S, E> extends MessageListener<S> { void onError(E error); }
9e14ce3afb91fa875e16c24620862d239b11ff14
776f8c993a42ae44d10f3f762387e3c61ce30e66
/BugReopenPredictor/ModifiedFiles/TestHelper.java
a60e06d802511ec7af4c882299d0536182ba4b1e
[]
no_license
talalelafchal/ReopenBugPrediction
a75199e66601551335544b4fa3e7dd15966ffce1
187614a310f4118f3730089a5dd4835bfe5b168b
refs/heads/master
2021-01-20T03:17:15.686341
2017-05-16T12:13:51
2017-05-16T12:13:51
89,519,804
0
0
null
null
null
null
UTF-8
Java
false
false
66,138
java
/** * Copyright 2016 Netflix, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See * the License for the specific language governing permissions and limitations under the License. */ package io.reactivex; import static org.junit.Assert.*; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import java.lang.reflect.*; import java.util.*; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicInteger; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.reactivestreams.*; import io.reactivex.disposables.*; import io.reactivex.exceptions.CompositeException; import io.reactivex.functions.*; import io.reactivex.internal.fuseable.*; import io.reactivex.internal.operators.maybe.MaybeToFlowable; import io.reactivex.internal.operators.single.SingleToFlowable; import io.reactivex.internal.subscriptions.BooleanSubscription; import io.reactivex.internal.util.ExceptionHelper; import io.reactivex.observers.TestObserver; import io.reactivex.plugins.RxJavaPlugins; import io.reactivex.processors.PublishProcessor; import io.reactivex.subjects.Subject; import io.reactivex.subscribers.TestSubscriber; /** * Common methods for helping with tests from 1.x mostly. */ public enum TestHelper { ; /** * Mocks a subscriber and prepares it to request Long.MAX_VALUE. * @param <T> the value type * @return the mocked subscriber */ @SuppressWarnings("unchecked") public static <T> Subscriber<T> mockSubscriber() { Subscriber<T> w = mock(Subscriber.class); Mockito.doAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock a) throws Throwable { Subscription s = a.getArgument(0); s.request(Long.MAX_VALUE); return null; } }).when(w).onSubscribe((Subscription)any()); return w; } /** * Mocks an Observer with the proper receiver type. * @param <T> the value type * @return the mocked observer */ @SuppressWarnings("unchecked") public static <T> Observer<T> mockObserver() { return mock(Observer.class); } /** * Mocks an MaybeObserver with the proper receiver type. * @param <T> the value type * @return the mocked observer */ @SuppressWarnings("unchecked") public static <T> MaybeObserver<T> mockMaybeObserver() { return mock(MaybeObserver.class); } /** * Mocks an SingleObserver with the proper receiver type. * @param <T> the value type * @return the mocked observer */ @SuppressWarnings("unchecked") public static <T> SingleObserver<T> mockSingleObserver() { return mock(SingleObserver.class); } /** * Mocks an CompletableObserver. * @return the mocked observer */ public static CompletableObserver mockCompletableObserver() { return mock(CompletableObserver.class); } /** * Validates that the given class, when forcefully instantiated throws * an IllegalArgumentException("No instances!") exception. * @param clazz the class to test, not null */ public static void checkUtilityClass(Class<?> clazz) { try { Constructor<?> c = clazz.getDeclaredConstructor(); c.setAccessible(true); try { c.newInstance(); fail("Should have thrown InvocationTargetException(IllegalStateException)"); } catch (InvocationTargetException ex) { assertEquals("No instances!", ex.getCause().getMessage()); } } catch (Exception ex) { AssertionError ae = new AssertionError(ex.toString()); ae.initCause(ex); throw ae; } } public static List<Throwable> trackPluginErrors() { final List<Throwable> list = Collections.synchronizedList(new ArrayList<Throwable>()); RxJavaPlugins.setErrorHandler(new Consumer<Throwable>() { @Override public void accept(Throwable t) { list.add(t); } }); return list; } public static void assertError(List<Throwable> list, int index, Class<? extends Throwable> clazz) { assertTrue(list.get(index).toString(), clazz.isInstance(list.get(index))); } public static void assertError(List<Throwable> list, int index, Class<? extends Throwable> clazz, String message) { assertTrue(list.get(index).toString(), clazz.isInstance(list.get(index))); assertEquals(message, list.get(index).getMessage()); } public static void assertError(TestObserver<?> ts, int index, Class<? extends Throwable> clazz) { Throwable ex = ts.errors().get(0); if (ex instanceof CompositeException) { CompositeException ce = (CompositeException) ex; List<Throwable> cel = ce.getExceptions(); assertTrue(cel.get(index).toString(), clazz.isInstance(cel.get(index))); } else { fail(ex.toString() + ": not a CompositeException"); } } public static void assertError(TestSubscriber<?> ts, int index, Class<? extends Throwable> clazz) { Throwable ex = ts.errors().get(0); if (ex instanceof CompositeException) { CompositeException ce = (CompositeException) ex; List<Throwable> cel = ce.getExceptions(); assertTrue(cel.get(index).toString(), clazz.isInstance(cel.get(index))); } else { fail(ex.toString() + ": not a CompositeException"); } } public static void assertError(TestObserver<?> ts, int index, Class<? extends Throwable> clazz, String message) { Throwable ex = ts.errors().get(0); if (ex instanceof CompositeException) { CompositeException ce = (CompositeException) ex; List<Throwable> cel = ce.getExceptions(); assertTrue(cel.get(index).toString(), clazz.isInstance(cel.get(index))); assertEquals(message, cel.get(index).getMessage()); } else { fail(ex.toString() + ": not a CompositeException"); } } public static void assertError(TestSubscriber<?> ts, int index, Class<? extends Throwable> clazz, String message) { Throwable ex = ts.errors().get(0); if (ex instanceof CompositeException) { CompositeException ce = (CompositeException) ex; List<Throwable> cel = ce.getExceptions(); assertTrue(cel.get(index).toString(), clazz.isInstance(cel.get(index))); assertEquals(message, cel.get(index).getMessage()); } else { fail(ex.toString() + ": not a CompositeException"); } } /** * Verify that a specific enum type has no enum constants. * @param <E> the enum type * @param e the enum class instance */ public static <E extends Enum<E>> void assertEmptyEnum(Class<E> e) { assertEquals(0, e.getEnumConstants().length); try { try { Method m0 = e.getDeclaredMethod("values"); Object[] a = (Object[])m0.invoke(null); assertEquals(0, a.length); Method m = e.getDeclaredMethod("valueOf", String.class); m.invoke("INSTANCE"); fail("Should have thrown!"); } catch (InvocationTargetException ex) { fail(ex.toString()); } catch (IllegalAccessException ex) { fail(ex.toString()); } catch (IllegalArgumentException ex) { // we expected this } } catch (NoSuchMethodException ex) { fail(ex.toString()); } } /** * Assert that by consuming the Publisher with a bad request amount, it is * reported to the plugin error handler promptly. * @param source the source to consume */ public static void assertBadRequestReported(Publisher<?> source) { List<Throwable> list = trackPluginErrors(); try { final CountDownLatch cdl = new CountDownLatch(1); source.subscribe(new Subscriber<Object>() { @Override public void onSubscribe(Subscription s) { try { s.request(-99); s.cancel(); s.cancel(); } finally { cdl.countDown(); } } @Override public void onNext(Object t) { } @Override public void onError(Throwable t) { } @Override public void onComplete() { } }); try { assertTrue(cdl.await(5, TimeUnit.SECONDS)); } catch (InterruptedException ex) { throw new AssertionError(ex.getMessage()); } assertTrue(list.toString(), list.get(0) instanceof IllegalArgumentException); assertEquals("n > 0 required but it was -99", list.get(0).getMessage()); } finally { RxJavaPlugins.setErrorHandler(null); } } /** * Synchronizes the execution of two runnables (as much as possible) * to test race conditions. * <p>The method blocks until both have run to completion. * @param r1 the first runnable * @param r2 the second runnable * @param s the scheduler to use */ public static void race(final Runnable r1, final Runnable r2, Scheduler s) { final AtomicInteger count = new AtomicInteger(2); final CountDownLatch cdl = new CountDownLatch(2); final Throwable[] errors = { null, null }; s.scheduleDirect(new Runnable() { @Override public void run() { if (count.decrementAndGet() != 0) { while (count.get() != 0) { } } try { try { r1.run(); } catch (Throwable ex) { errors[0] = ex; } } finally { cdl.countDown(); } } }); if (count.decrementAndGet() != 0) { while (count.get() != 0) { } } try { try { r2.run(); } catch (Throwable ex) { errors[1] = ex; } } finally { cdl.countDown(); } try { if (!cdl.await(5, TimeUnit.SECONDS)) { throw new AssertionError("The wait timed out!"); } } catch (InterruptedException ex) { throw new RuntimeException(ex); } if (errors[0] != null && errors[1] == null) { throw ExceptionHelper.wrapOrThrow(errors[0]); } if (errors[0] == null && errors[1] != null) { throw ExceptionHelper.wrapOrThrow(errors[1]); } if (errors[0] != null && errors[1] != null) { throw new CompositeException(errors); } } /** * Cast the given Throwable to CompositeException and returns its inner * Throwable list. * @param ex the target Throwable * @return the list of Throwables */ public static List<Throwable> compositeList(Throwable ex) { return ((CompositeException)ex).getExceptions(); } /** * Assert that the offer methods throw UnsupportedOperationExcetpion. * @param q the queue implementation */ public static void assertNoOffer(SimpleQueue<?> q) { try { q.offer(null); fail("Should have thrown!"); } catch (UnsupportedOperationException ex) { // expected } try { q.offer(null, null); fail("Should have thrown!"); } catch (UnsupportedOperationException ex) { // expected } } @SuppressWarnings("unchecked") public static <E extends Enum<E>> void checkEnum(Class<E> enumClass) { try { Method m = enumClass.getMethod("values"); m.setAccessible(true); Method e = enumClass.getMethod("valueOf", String.class); m.setAccessible(true); for (Enum<E> o : (Enum<E>[])m.invoke(null)) { assertSame(o, e.invoke(null, o.name())); } } catch (Throwable ex) { throw ExceptionHelper.wrapOrThrow(ex); } } /** * Returns an Consumer that asserts the TestSubscriber has exaclty one value + completed * normally and that single value is not the value specified. * @param <T> the value type * @param value the value not expected * @return the consumer */ public static <T> Consumer<TestSubscriber<T>> subscriberSingleNot(final T value) { return new Consumer<TestSubscriber<T>>() { @Override public void accept(TestSubscriber<T> ts) throws Exception { ts .assertSubscribed() .assertValueCount(1) .assertNoErrors() .assertComplete(); T v = ts.values().get(0); assertNotEquals(value, v); } }; } /** * Returns an Consumer that asserts the TestObserver has exaclty one value + completed * normally and that single value is not the value specified. * @param <T> the value type * @param value the value not expected * @return the consumer */ public static <T> Consumer<TestObserver<T>> observerSingleNot(final T value) { return new Consumer<TestObserver<T>>() { @Override public void accept(TestObserver<T> ts) throws Exception { ts .assertSubscribed() .assertValueCount(1) .assertNoErrors() .assertComplete(); T v = ts.values().get(0); assertNotEquals(value, v); } }; } /** * Calls onSubscribe twice and checks if it doesn't affect the first Subscription while * reporting it to plugin error handler. * @param subscriber the target */ public static void doubleOnSubscribe(Subscriber<?> subscriber) { List<Throwable> errors = trackPluginErrors(); try { BooleanSubscription s1 = new BooleanSubscription(); subscriber.onSubscribe(s1); BooleanSubscription s2 = new BooleanSubscription(); subscriber.onSubscribe(s2); assertFalse(s1.isCancelled()); assertTrue(s2.isCancelled()); assertError(errors, 0, IllegalStateException.class, "Subscription already set!"); } finally { RxJavaPlugins.reset(); } } /** * Calls onSubscribe twice and checks if it doesn't affect the first Disposable while * reporting it to plugin error handler. * @param subscriber the target */ public static void doubleOnSubscribe(Observer<?> subscriber) { List<Throwable> errors = trackPluginErrors(); try { Disposable d1 = Disposables.empty(); subscriber.onSubscribe(d1); Disposable d2 = Disposables.empty(); subscriber.onSubscribe(d2); assertFalse(d1.isDisposed()); assertTrue(d2.isDisposed()); assertError(errors, 0, IllegalStateException.class, "Disposable already set!"); } finally { RxJavaPlugins.reset(); } } /** * Calls onSubscribe twice and checks if it doesn't affect the first Disposable while * reporting it to plugin error handler. * @param subscriber the target */ public static void doubleOnSubscribe(SingleObserver<?> subscriber) { List<Throwable> errors = trackPluginErrors(); try { Disposable d1 = Disposables.empty(); subscriber.onSubscribe(d1); Disposable d2 = Disposables.empty(); subscriber.onSubscribe(d2); assertFalse(d1.isDisposed()); assertTrue(d2.isDisposed()); assertError(errors, 0, IllegalStateException.class, "Disposable already set!"); } finally { RxJavaPlugins.reset(); } } /** * Calls onSubscribe twice and checks if it doesn't affect the first Disposable while * reporting it to plugin error handler. * @param subscriber the target */ public static void doubleOnSubscribe(CompletableObserver subscriber) { List<Throwable> errors = trackPluginErrors(); try { Disposable d1 = Disposables.empty(); subscriber.onSubscribe(d1); Disposable d2 = Disposables.empty(); subscriber.onSubscribe(d2); assertFalse(d1.isDisposed()); assertTrue(d2.isDisposed()); assertError(errors, 0, IllegalStateException.class, "Disposable already set!"); } finally { RxJavaPlugins.reset(); } } /** * Calls onSubscribe twice and checks if it doesn't affect the first Disposable while * reporting it to plugin error handler. * @param subscriber the target */ public static void doubleOnSubscribe(MaybeObserver<?> subscriber) { List<Throwable> errors = trackPluginErrors(); try { Disposable d1 = Disposables.empty(); subscriber.onSubscribe(d1); Disposable d2 = Disposables.empty(); subscriber.onSubscribe(d2); assertFalse(d1.isDisposed()); assertTrue(d2.isDisposed()); assertError(errors, 0, IllegalStateException.class, "Disposable already set!"); } finally { RxJavaPlugins.reset(); } } /** * Checks if the upstream's Disposable sent through the onSubscribe reports * isDisposed properly before and after calling dispose. * @param source the source to test */ public static void checkDisposed(Maybe<?> source) { final Boolean[] b = { null, null }; final CountDownLatch cdl = new CountDownLatch(1); source.subscribe(new MaybeObserver<Object>() { @Override public void onSubscribe(Disposable d) { try { b[0] = d.isDisposed(); d.dispose(); b[1] = d.isDisposed(); } finally { cdl.countDown(); } } @Override public void onSuccess(Object value) { // ignored } @Override public void onError(Throwable e) { // ignored } @Override public void onComplete() { // ignored } }); try { assertTrue("Timed out", cdl.await(5, TimeUnit.SECONDS)); } catch (InterruptedException ex) { throw ExceptionHelper.wrapOrThrow(ex); } assertEquals("Reports disposed upfront?", false, b[0]); assertEquals("Didn't report disposed after?", true, b[1]); } /** * Checks if the upstream's Disposable sent through the onSubscribe reports * isDisposed properly before and after calling dispose. * @param source the source to test */ public static void checkDisposed(Observable<?> source) { final Boolean[] b = { null, null }; final CountDownLatch cdl = new CountDownLatch(1); source.subscribe(new Observer<Object>() { @Override public void onSubscribe(Disposable d) { try { b[0] = d.isDisposed(); d.dispose(); b[1] = d.isDisposed(); } finally { cdl.countDown(); } } @Override public void onNext(Object value) { // ignored } @Override public void onError(Throwable e) { // ignored } @Override public void onComplete() { // ignored } }); try { assertTrue("Timed out", cdl.await(5, TimeUnit.SECONDS)); } catch (InterruptedException ex) { throw ExceptionHelper.wrapOrThrow(ex); } assertEquals("Reports disposed upfront?", false, b[0]); assertEquals("Didn't report disposed after?", true, b[1]); } /** * Checks if the upstream's Disposable sent through the onSubscribe reports * isDisposed properly before and after calling dispose. * @param source the source to test */ public static void checkDisposed(Single<?> source) { final Boolean[] b = { null, null }; final CountDownLatch cdl = new CountDownLatch(1); source.subscribe(new SingleObserver<Object>() { @Override public void onSubscribe(Disposable d) { try { b[0] = d.isDisposed(); d.dispose(); b[1] = d.isDisposed(); } finally { cdl.countDown(); } } @Override public void onSuccess(Object value) { // ignored } @Override public void onError(Throwable e) { // ignored } }); try { assertTrue("Timed out", cdl.await(5, TimeUnit.SECONDS)); } catch (InterruptedException ex) { throw ExceptionHelper.wrapOrThrow(ex); } assertEquals("Reports disposed upfront?", false, b[0]); assertEquals("Didn't report disposed after?", true, b[1]); } /** * Checks if the upstream's Disposable sent through the onSubscribe reports * isDisposed properly before and after calling dispose. * @param source the source to test */ public static void checkDisposed(Completable source) { final Boolean[] b = { null, null }; final CountDownLatch cdl = new CountDownLatch(1); source.subscribe(new CompletableObserver() { @Override public void onSubscribe(Disposable d) { try { b[0] = d.isDisposed(); d.dispose(); b[1] = d.isDisposed(); } finally { cdl.countDown(); } } @Override public void onError(Throwable e) { // ignored } @Override public void onComplete() { // ignored } }); try { assertTrue("Timed out", cdl.await(5, TimeUnit.SECONDS)); } catch (InterruptedException ex) { throw ExceptionHelper.wrapOrThrow(ex); } assertEquals("Reports disposed upfront?", false, b[0]); assertEquals("Didn't report disposed after?", true, b[1]); } /** * Consumer for all base reactive types. */ enum NoOpConsumer implements Subscriber<Object>, Observer<Object>, MaybeObserver<Object>, SingleObserver<Object>, CompletableObserver { INSTANCE; @Override public void onSubscribe(Disposable d) { // deliberately no-op } @Override public void onSuccess(Object value) { // deliberately no-op } @Override public void onError(Throwable e) { // deliberately no-op } @Override public void onComplete() { // deliberately no-op } @Override public void onSubscribe(Subscription s) { // deliberately no-op } @Override public void onNext(Object t) { // deliberately no-op } } /** * Check if the given transformed reactive type reports multiple onSubscribe calls to * RxJavaPlugins. * @param <T> the input value type * @param <R> the output value type * @param transform the transform to drive an operator */ public static <T, R> void checkDoubleOnSubscribeMaybe(Function<Maybe<T>, ? extends MaybeSource<R>> transform) { List<Throwable> errors = trackPluginErrors(); try { final Boolean[] b = { null, null }; final CountDownLatch cdl = new CountDownLatch(1); Maybe<T> source = new Maybe<T>() { @Override protected void subscribeActual(MaybeObserver<? super T> observer) { try { Disposable d1 = Disposables.empty(); observer.onSubscribe(d1); Disposable d2 = Disposables.empty(); observer.onSubscribe(d2); b[0] = d1.isDisposed(); b[1] = d2.isDisposed(); } finally { cdl.countDown(); } } }; MaybeSource<R> out = transform.apply(source); out.subscribe(NoOpConsumer.INSTANCE); try { assertTrue("Timed out", cdl.await(5, TimeUnit.SECONDS)); } catch (InterruptedException ex) { throw ExceptionHelper.wrapOrThrow(ex); } assertEquals("First disposed?", false, b[0]); assertEquals("Second not disposed?", true, b[1]); assertError(errors, 0, IllegalStateException.class, "Disposable already set!"); } catch (Throwable ex) { throw ExceptionHelper.wrapOrThrow(ex); } finally { RxJavaPlugins.reset(); } } /** * Check if the given transformed reactive type reports multiple onSubscribe calls to * RxJavaPlugins. * @param <T> the input value type * @param <R> the output value type * @param transform the transform to drive an operator */ public static <T, R> void checkDoubleOnSubscribeMaybeToSingle(Function<Maybe<T>, ? extends SingleSource<R>> transform) { List<Throwable> errors = trackPluginErrors(); try { final Boolean[] b = { null, null }; final CountDownLatch cdl = new CountDownLatch(1); Maybe<T> source = new Maybe<T>() { @Override protected void subscribeActual(MaybeObserver<? super T> observer) { try { Disposable d1 = Disposables.empty(); observer.onSubscribe(d1); Disposable d2 = Disposables.empty(); observer.onSubscribe(d2); b[0] = d1.isDisposed(); b[1] = d2.isDisposed(); } finally { cdl.countDown(); } } }; SingleSource<R> out = transform.apply(source); out.subscribe(NoOpConsumer.INSTANCE); try { assertTrue("Timed out", cdl.await(5, TimeUnit.SECONDS)); } catch (InterruptedException ex) { throw ExceptionHelper.wrapOrThrow(ex); } assertEquals("First disposed?", false, b[0]); assertEquals("Second not disposed?", true, b[1]); assertError(errors, 0, IllegalStateException.class, "Disposable already set!"); } catch (Throwable ex) { throw ExceptionHelper.wrapOrThrow(ex); } finally { RxJavaPlugins.reset(); } } /** * Check if the given transformed reactive type reports multiple onSubscribe calls to * RxJavaPlugins. * @param <T> the input value type * @param <R> the output value type * @param transform the transform to drive an operator */ public static <T, R> void checkDoubleOnSubscribeMaybeToObservable(Function<Maybe<T>, ? extends ObservableSource<R>> transform) { List<Throwable> errors = trackPluginErrors(); try { final Boolean[] b = { null, null }; final CountDownLatch cdl = new CountDownLatch(1); Maybe<T> source = new Maybe<T>() { @Override protected void subscribeActual(MaybeObserver<? super T> observer) { try { Disposable d1 = Disposables.empty(); observer.onSubscribe(d1); Disposable d2 = Disposables.empty(); observer.onSubscribe(d2); b[0] = d1.isDisposed(); b[1] = d2.isDisposed(); } finally { cdl.countDown(); } } }; ObservableSource<R> out = transform.apply(source); out.subscribe(NoOpConsumer.INSTANCE); try { assertTrue("Timed out", cdl.await(5, TimeUnit.SECONDS)); } catch (InterruptedException ex) { throw ExceptionHelper.wrapOrThrow(ex); } assertEquals("First disposed?", false, b[0]); assertEquals("Second not disposed?", true, b[1]); assertError(errors, 0, IllegalStateException.class, "Disposable already set!"); } catch (Throwable ex) { throw ExceptionHelper.wrapOrThrow(ex); } finally { RxJavaPlugins.reset(); } } /** * Check if the given transformed reactive type reports multiple onSubscribe calls to * RxJavaPlugins. * @param <T> the input value type * @param <R> the output value type * @param transform the transform to drive an operator */ public static <T, R> void checkDoubleOnSubscribeMaybeToFlowable(Function<Maybe<T>, ? extends Publisher<R>> transform) { List<Throwable> errors = trackPluginErrors(); try { final Boolean[] b = { null, null }; final CountDownLatch cdl = new CountDownLatch(1); Maybe<T> source = new Maybe<T>() { @Override protected void subscribeActual(MaybeObserver<? super T> observer) { try { Disposable d1 = Disposables.empty(); observer.onSubscribe(d1); Disposable d2 = Disposables.empty(); observer.onSubscribe(d2); b[0] = d1.isDisposed(); b[1] = d2.isDisposed(); } finally { cdl.countDown(); } } }; Publisher<R> out = transform.apply(source); out.subscribe(NoOpConsumer.INSTANCE); try { assertTrue("Timed out", cdl.await(5, TimeUnit.SECONDS)); } catch (InterruptedException ex) { throw ExceptionHelper.wrapOrThrow(ex); } assertEquals("First disposed?", false, b[0]); assertEquals("Second not disposed?", true, b[1]); assertError(errors, 0, IllegalStateException.class, "Disposable already set!"); } catch (Throwable ex) { throw ExceptionHelper.wrapOrThrow(ex); } finally { RxJavaPlugins.reset(); } } /** * Check if the given transformed reactive type reports multiple onSubscribe calls to * RxJavaPlugins. * @param <T> the input value type * @param <R> the output value type * @param transform the transform to drive an operator */ public static <T, R> void checkDoubleOnSubscribeSingleToMaybe(Function<Single<T>, ? extends MaybeSource<R>> transform) { List<Throwable> errors = trackPluginErrors(); try { final Boolean[] b = { null, null }; final CountDownLatch cdl = new CountDownLatch(1); Single<T> source = new Single<T>() { @Override protected void subscribeActual(SingleObserver<? super T> observer) { try { Disposable d1 = Disposables.empty(); observer.onSubscribe(d1); Disposable d2 = Disposables.empty(); observer.onSubscribe(d2); b[0] = d1.isDisposed(); b[1] = d2.isDisposed(); } finally { cdl.countDown(); } } }; MaybeSource<R> out = transform.apply(source); out.subscribe(NoOpConsumer.INSTANCE); try { assertTrue("Timed out", cdl.await(5, TimeUnit.SECONDS)); } catch (InterruptedException ex) { throw ExceptionHelper.wrapOrThrow(ex); } assertEquals("First disposed?", false, b[0]); assertEquals("Second not disposed?", true, b[1]); assertError(errors, 0, IllegalStateException.class, "Disposable already set!"); } catch (Throwable ex) { throw ExceptionHelper.wrapOrThrow(ex); } finally { RxJavaPlugins.reset(); } } /** * Check if the given transformed reactive type reports multiple onSubscribe calls to * RxJavaPlugins. * @param <T> the input value type * @param <R> the output value type * @param transform the transform to drive an operator */ public static <T, R> void checkDoubleOnSubscribeSingleToObservable(Function<Single<T>, ? extends ObservableSource<R>> transform) { List<Throwable> errors = trackPluginErrors(); try { final Boolean[] b = { null, null }; final CountDownLatch cdl = new CountDownLatch(1); Single<T> source = new Single<T>() { @Override protected void subscribeActual(SingleObserver<? super T> observer) { try { Disposable d1 = Disposables.empty(); observer.onSubscribe(d1); Disposable d2 = Disposables.empty(); observer.onSubscribe(d2); b[0] = d1.isDisposed(); b[1] = d2.isDisposed(); } finally { cdl.countDown(); } } }; ObservableSource<R> out = transform.apply(source); out.subscribe(NoOpConsumer.INSTANCE); try { assertTrue("Timed out", cdl.await(5, TimeUnit.SECONDS)); } catch (InterruptedException ex) { throw ExceptionHelper.wrapOrThrow(ex); } assertEquals("First disposed?", false, b[0]); assertEquals("Second not disposed?", true, b[1]); assertError(errors, 0, IllegalStateException.class, "Disposable already set!"); } catch (Throwable ex) { throw ExceptionHelper.wrapOrThrow(ex); } finally { RxJavaPlugins.reset(); } } /** * Check if the given transformed reactive type reports multiple onSubscribe calls to * RxJavaPlugins. * @param <T> the input value type * @param transform the transform to drive an operator */ public static <T> void checkDoubleOnSubscribeMaybeToCompletable(Function<Maybe<T>, ? extends CompletableSource> transform) { List<Throwable> errors = trackPluginErrors(); try { final Boolean[] b = { null, null }; final CountDownLatch cdl = new CountDownLatch(1); Maybe<T> source = new Maybe<T>() { @Override protected void subscribeActual(MaybeObserver<? super T> observer) { try { Disposable d1 = Disposables.empty(); observer.onSubscribe(d1); Disposable d2 = Disposables.empty(); observer.onSubscribe(d2); b[0] = d1.isDisposed(); b[1] = d2.isDisposed(); } finally { cdl.countDown(); } } }; CompletableSource out = transform.apply(source); out.subscribe(NoOpConsumer.INSTANCE); try { assertTrue("Timed out", cdl.await(5, TimeUnit.SECONDS)); } catch (InterruptedException ex) { throw ExceptionHelper.wrapOrThrow(ex); } assertEquals("First disposed?", false, b[0]); assertEquals("Second not disposed?", true, b[1]); assertError(errors, 0, IllegalStateException.class, "Disposable already set!"); } catch (Throwable ex) { throw ExceptionHelper.wrapOrThrow(ex); } finally { RxJavaPlugins.reset(); } } /** * Check if the given transformed reactive type reports multiple onSubscribe calls to * RxJavaPlugins. * @param <T> the input value type * @param <R> the output value type * @param transform the transform to drive an operator */ public static <T, R> void checkDoubleOnSubscribeSingle(Function<Single<T>, ? extends SingleSource<R>> transform) { List<Throwable> errors = trackPluginErrors(); try { final Boolean[] b = { null, null }; final CountDownLatch cdl = new CountDownLatch(1); Single<T> source = new Single<T>() { @Override protected void subscribeActual(SingleObserver<? super T> observer) { try { Disposable d1 = Disposables.empty(); observer.onSubscribe(d1); Disposable d2 = Disposables.empty(); observer.onSubscribe(d2); b[0] = d1.isDisposed(); b[1] = d2.isDisposed(); } finally { cdl.countDown(); } } }; SingleSource<R> out = transform.apply(source); out.subscribe(NoOpConsumer.INSTANCE); try { assertTrue("Timed out", cdl.await(5, TimeUnit.SECONDS)); } catch (InterruptedException ex) { throw ExceptionHelper.wrapOrThrow(ex); } assertEquals("First disposed?", false, b[0]); assertEquals("Second not disposed?", true, b[1]); assertError(errors, 0, IllegalStateException.class, "Disposable already set!"); } catch (Throwable ex) { throw ExceptionHelper.wrapOrThrow(ex); } finally { RxJavaPlugins.reset(); } } /** * Check if the given transformed reactive type reports multiple onSubscribe calls to * RxJavaPlugins. * @param <T> the input value type * @param <R> the output value type * @param transform the transform to drive an operator */ public static <T, R> void checkDoubleOnSubscribeFlowable(Function<Flowable<T>, ? extends Publisher<R>> transform) { List<Throwable> errors = trackPluginErrors(); try { final Boolean[] b = { null, null }; final CountDownLatch cdl = new CountDownLatch(1); Flowable<T> source = new Flowable<T>() { @Override protected void subscribeActual(Subscriber<? super T> subscriber) { try { BooleanSubscription d1 = new BooleanSubscription(); subscriber.onSubscribe(d1); BooleanSubscription d2 = new BooleanSubscription(); subscriber.onSubscribe(d2); b[0] = d1.isCancelled(); b[1] = d2.isCancelled(); } finally { cdl.countDown(); } } }; Publisher<R> out = transform.apply(source); out.subscribe(NoOpConsumer.INSTANCE); try { assertTrue("Timed out", cdl.await(5, TimeUnit.SECONDS)); } catch (InterruptedException ex) { throw ExceptionHelper.wrapOrThrow(ex); } assertEquals("First disposed?", false, b[0]); assertEquals("Second not disposed?", true, b[1]); assertError(errors, 0, IllegalStateException.class, "Subscription already set!"); } catch (Throwable ex) { throw ExceptionHelper.wrapOrThrow(ex); } finally { RxJavaPlugins.reset(); } } /** * Check if the given transformed reactive type reports multiple onSubscribe calls to * RxJavaPlugins. * @param <T> the input value type * @param <R> the output value type * @param transform the transform to drive an operator */ public static <T, R> void checkDoubleOnSubscribeObservable(Function<Observable<T>, ? extends ObservableSource<R>> transform) { List<Throwable> errors = trackPluginErrors(); try { final Boolean[] b = { null, null }; final CountDownLatch cdl = new CountDownLatch(1); Observable<T> source = new Observable<T>() { @Override protected void subscribeActual(Observer<? super T> observer) { try { Disposable d1 = Disposables.empty(); observer.onSubscribe(d1); Disposable d2 = Disposables.empty(); observer.onSubscribe(d2); b[0] = d1.isDisposed(); b[1] = d2.isDisposed(); } finally { cdl.countDown(); } } }; ObservableSource<R> out = transform.apply(source); out.subscribe(NoOpConsumer.INSTANCE); try { assertTrue("Timed out", cdl.await(5, TimeUnit.SECONDS)); } catch (InterruptedException ex) { throw ExceptionHelper.wrapOrThrow(ex); } assertEquals("First disposed?", false, b[0]); assertEquals("Second not disposed?", true, b[1]); assertError(errors, 0, IllegalStateException.class, "Disposable already set!"); } catch (Throwable ex) { throw ExceptionHelper.wrapOrThrow(ex); } finally { RxJavaPlugins.reset(); } } /** * Check if the given transformed reactive type reports multiple onSubscribe calls to * RxJavaPlugins. * @param <T> the input value type * @param <R> the output value type * @param transform the transform to drive an operator */ public static <T, R> void checkDoubleOnSubscribeObservableToSingle(Function<Observable<T>, ? extends SingleSource<R>> transform) { List<Throwable> errors = trackPluginErrors(); try { final Boolean[] b = { null, null }; final CountDownLatch cdl = new CountDownLatch(1); Observable<T> source = new Observable<T>() { @Override protected void subscribeActual(Observer<? super T> observer) { try { Disposable d1 = Disposables.empty(); observer.onSubscribe(d1); Disposable d2 = Disposables.empty(); observer.onSubscribe(d2); b[0] = d1.isDisposed(); b[1] = d2.isDisposed(); } finally { cdl.countDown(); } } }; SingleSource<R> out = transform.apply(source); out.subscribe(NoOpConsumer.INSTANCE); try { assertTrue("Timed out", cdl.await(5, TimeUnit.SECONDS)); } catch (InterruptedException ex) { throw ExceptionHelper.wrapOrThrow(ex); } assertEquals("First disposed?", false, b[0]); assertEquals("Second not disposed?", true, b[1]); assertError(errors, 0, IllegalStateException.class, "Disposable already set!"); } catch (Throwable ex) { throw ExceptionHelper.wrapOrThrow(ex); } finally { RxJavaPlugins.reset(); } } /** * Check if the given transformed reactive type reports multiple onSubscribe calls to * RxJavaPlugins. * @param <T> the input value type * @param <R> the output value type * @param transform the transform to drive an operator */ public static <T, R> void checkDoubleOnSubscribeObservableToMaybe(Function<Observable<T>, ? extends MaybeSource<R>> transform) { List<Throwable> errors = trackPluginErrors(); try { final Boolean[] b = { null, null }; final CountDownLatch cdl = new CountDownLatch(1); Observable<T> source = new Observable<T>() { @Override protected void subscribeActual(Observer<? super T> observer) { try { Disposable d1 = Disposables.empty(); observer.onSubscribe(d1); Disposable d2 = Disposables.empty(); observer.onSubscribe(d2); b[0] = d1.isDisposed(); b[1] = d2.isDisposed(); } finally { cdl.countDown(); } } }; MaybeSource<R> out = transform.apply(source); out.subscribe(NoOpConsumer.INSTANCE); try { assertTrue("Timed out", cdl.await(5, TimeUnit.SECONDS)); } catch (InterruptedException ex) { throw ExceptionHelper.wrapOrThrow(ex); } assertEquals("First disposed?", false, b[0]); assertEquals("Second not disposed?", true, b[1]); assertError(errors, 0, IllegalStateException.class, "Disposable already set!"); } catch (Throwable ex) { throw ExceptionHelper.wrapOrThrow(ex); } finally { RxJavaPlugins.reset(); } } /** * Check if the given transformed reactive type reports multiple onSubscribe calls to * RxJavaPlugins. * @param <T> the input value type * @param transform the transform to drive an operator */ public static <T> void checkDoubleOnSubscribeObservableToCompletable(Function<Observable<T>, ? extends CompletableSource> transform) { List<Throwable> errors = trackPluginErrors(); try { final Boolean[] b = { null, null }; final CountDownLatch cdl = new CountDownLatch(1); Observable<T> source = new Observable<T>() { @Override protected void subscribeActual(Observer<? super T> observer) { try { Disposable d1 = Disposables.empty(); observer.onSubscribe(d1); Disposable d2 = Disposables.empty(); observer.onSubscribe(d2); b[0] = d1.isDisposed(); b[1] = d2.isDisposed(); } finally { cdl.countDown(); } } }; CompletableSource out = transform.apply(source); out.subscribe(NoOpConsumer.INSTANCE); try { assertTrue("Timed out", cdl.await(5, TimeUnit.SECONDS)); } catch (InterruptedException ex) { throw ExceptionHelper.wrapOrThrow(ex); } assertEquals("First disposed?", false, b[0]); assertEquals("Second not disposed?", true, b[1]); assertError(errors, 0, IllegalStateException.class, "Disposable already set!"); } catch (Throwable ex) { throw ExceptionHelper.wrapOrThrow(ex); } finally { RxJavaPlugins.reset(); } } /** * Check if the given transformed reactive type reports multiple onSubscribe calls to * RxJavaPlugins. * @param <T> the input value type * @param <R> the output value type * @param transform the transform to drive an operator */ public static <T, R> void checkDoubleOnSubscribeFlowableToObservable(Function<Flowable<T>, ? extends ObservableSource<R>> transform) { List<Throwable> errors = trackPluginErrors(); try { final Boolean[] b = { null, null }; final CountDownLatch cdl = new CountDownLatch(1); Flowable<T> source = new Flowable<T>() { @Override protected void subscribeActual(Subscriber<? super T> observer) { try { BooleanSubscription d1 = new BooleanSubscription(); observer.onSubscribe(d1); BooleanSubscription d2 = new BooleanSubscription(); observer.onSubscribe(d2); b[0] = d1.isCancelled(); b[1] = d2.isCancelled(); } finally { cdl.countDown(); } } }; ObservableSource<R> out = transform.apply(source); out.subscribe(NoOpConsumer.INSTANCE); try { assertTrue("Timed out", cdl.await(5, TimeUnit.SECONDS)); } catch (InterruptedException ex) { throw ExceptionHelper.wrapOrThrow(ex); } assertEquals("First cancelled?", false, b[0]); assertEquals("Second not cancelled?", true, b[1]); assertError(errors, 0, IllegalStateException.class, "Subscription already set!"); } catch (Throwable ex) { throw ExceptionHelper.wrapOrThrow(ex); } finally { RxJavaPlugins.reset(); } } /** * Check if the given transformed reactive type reports multiple onSubscribe calls to * RxJavaPlugins. * @param transform the transform to drive an operator */ public static void checkDoubleOnSubscribeCompletable(Function<Completable, ? extends CompletableSource> transform) { List<Throwable> errors = trackPluginErrors(); try { final Boolean[] b = { null, null }; final CountDownLatch cdl = new CountDownLatch(1); Completable source = new Completable() { @Override protected void subscribeActual(CompletableObserver observer) { try { Disposable d1 = Disposables.empty(); observer.onSubscribe(d1); Disposable d2 = Disposables.empty(); observer.onSubscribe(d2); b[0] = d1.isDisposed(); b[1] = d2.isDisposed(); } finally { cdl.countDown(); } } }; CompletableSource out = transform.apply(source); out.subscribe(NoOpConsumer.INSTANCE); try { assertTrue("Timed out", cdl.await(5, TimeUnit.SECONDS)); } catch (InterruptedException ex) { throw ExceptionHelper.wrapOrThrow(ex); } assertEquals("First disposed?", false, b[0]); assertEquals("Second not disposed?", true, b[1]); assertError(errors, 0, IllegalStateException.class, "Disposable already set!"); } catch (Throwable ex) { throw ExceptionHelper.wrapOrThrow(ex); } finally { RxJavaPlugins.reset(); } } /** * Check if the given transformed reactive type reports multiple onSubscribe calls to * RxJavaPlugins. * @param <T> the output value tye * @param transform the transform to drive an operator */ public static <T> void checkDoubleOnSubscribeCompletableToMaybe(Function<Completable, ? extends MaybeSource<T>> transform) { List<Throwable> errors = trackPluginErrors(); try { final Boolean[] b = { null, null }; final CountDownLatch cdl = new CountDownLatch(1); Completable source = new Completable() { @Override protected void subscribeActual(CompletableObserver observer) { try { Disposable d1 = Disposables.empty(); observer.onSubscribe(d1); Disposable d2 = Disposables.empty(); observer.onSubscribe(d2); b[0] = d1.isDisposed(); b[1] = d2.isDisposed(); } finally { cdl.countDown(); } } }; MaybeSource<T> out = transform.apply(source); out.subscribe(NoOpConsumer.INSTANCE); try { assertTrue("Timed out", cdl.await(5, TimeUnit.SECONDS)); } catch (InterruptedException ex) { throw ExceptionHelper.wrapOrThrow(ex); } assertEquals("First disposed?", false, b[0]); assertEquals("Second not disposed?", true, b[1]); assertError(errors, 0, IllegalStateException.class, "Disposable already set!"); } catch (Throwable ex) { throw ExceptionHelper.wrapOrThrow(ex); } finally { RxJavaPlugins.reset(); } } /** * Check if the given transformed reactive type reports multiple onSubscribe calls to * RxJavaPlugins. * @param <T> the output value tye * @param transform the transform to drive an operator */ public static <T> void checkDoubleOnSubscribeCompletableToSingle(Function<Completable, ? extends SingleSource<T>> transform) { List<Throwable> errors = trackPluginErrors(); try { final Boolean[] b = { null, null }; final CountDownLatch cdl = new CountDownLatch(1); Completable source = new Completable() { @Override protected void subscribeActual(CompletableObserver observer) { try { Disposable d1 = Disposables.empty(); observer.onSubscribe(d1); Disposable d2 = Disposables.empty(); observer.onSubscribe(d2); b[0] = d1.isDisposed(); b[1] = d2.isDisposed(); } finally { cdl.countDown(); } } }; SingleSource<T> out = transform.apply(source); out.subscribe(NoOpConsumer.INSTANCE); try { assertTrue("Timed out", cdl.await(5, TimeUnit.SECONDS)); } catch (InterruptedException ex) { throw ExceptionHelper.wrapOrThrow(ex); } assertEquals("First disposed?", false, b[0]); assertEquals("Second not disposed?", true, b[1]); assertError(errors, 0, IllegalStateException.class, "Disposable already set!"); } catch (Throwable ex) { throw ExceptionHelper.wrapOrThrow(ex); } finally { RxJavaPlugins.reset(); } } /** * Check if the operator applied to a Maybe source propagates dispose properly. * @param <T> the source value type * @param <U> the output value type * @param composer the function to apply an operator to the provided Maybe source */ public static <T, U> void checkDisposedMaybe(Function<Maybe<T>, ? extends MaybeSource<U>> composer) { PublishProcessor<T> pp = PublishProcessor.create(); TestSubscriber<U> ts = new TestSubscriber<U>(); try { new MaybeToFlowable<U>(composer.apply(pp.singleElement())).subscribe(ts); } catch (Throwable ex) { throw ExceptionHelper.wrapOrThrow(ex); } assertTrue("Not subscribed to source!", pp.hasSubscribers()); ts.cancel(); assertFalse("Dispose not propagated!", pp.hasSubscribers()); } /** * Check if the operator applied to a Maybe source propagates dispose properly. * @param <T> the source value type * @param <U> the output value type * @param composer the function to apply an operator to the provided Maybe source */ public static <T, U> void checkDisposedMaybeToSingle(Function<Maybe<T>, ? extends SingleSource<U>> composer) { PublishProcessor<T> pp = PublishProcessor.create(); TestSubscriber<U> ts = new TestSubscriber<U>(); try { new SingleToFlowable<U>(composer.apply(pp.singleElement())).subscribe(ts); } catch (Throwable ex) { throw ExceptionHelper.wrapOrThrow(ex); } assertTrue(pp.hasSubscribers()); ts.cancel(); assertFalse(pp.hasSubscribers()); } /** * Check if the TestSubscriber has a CompositeException with the specified class * of Throwables in the given order. * @param ts the TestSubscriber instance * @param classes the array of expected Throwables inside the Composite */ public static void assertCompositeExceptions(TestSubscriber<?> ts, Class<? extends Throwable>... classes) { ts .assertSubscribed() .assertError(CompositeException.class) .assertNotComplete(); List<Throwable> list = compositeList(ts.errors().get(0)); assertEquals(classes.length, list.size()); for (int i = 0; i < classes.length; i++) { assertError(list, i, classes[i]); } } /** * Check if the TestSubscriber has a CompositeException with the specified class * of Throwables in the given order. * @param ts the TestSubscriber instance * @param classes the array of subsequent Class and String instances representing the * expected Throwable class and the expected error message */ @SuppressWarnings("unchecked") public static void assertCompositeExceptions(TestSubscriber<?> ts, Object... classes) { ts .assertSubscribed() .assertError(CompositeException.class) .assertNotComplete(); List<Throwable> list = compositeList(ts.errors().get(0)); assertEquals(classes.length, list.size()); for (int i = 0; i < classes.length; i += 2) { assertError(list, i, (Class<Throwable>)classes[i], (String)classes[i + 1]); } } /** * Check if the TestSubscriber has a CompositeException with the specified class * of Throwables in the given order. * @param ts the TestSubscriber instance * @param classes the array of expected Throwables inside the Composite */ public static void assertCompositeExceptions(TestObserver<?> ts, Class<? extends Throwable>... classes) { ts .assertSubscribed() .assertError(CompositeException.class) .assertNotComplete(); List<Throwable> list = compositeList(ts.errors().get(0)); assertEquals(classes.length, list.size()); for (int i = 0; i < classes.length; i++) { assertError(list, i, classes[i]); } } /** * Check if the TestSubscriber has a CompositeException with the specified class * of Throwables in the given order. * @param ts the TestSubscriber instance * @param classes the array of subsequent Class and String instances representing the * expected Throwable class and the expected error message */ @SuppressWarnings("unchecked") public static void assertCompositeExceptions(TestObserver<?> ts, Object... classes) { ts .assertSubscribed() .assertError(CompositeException.class) .assertNotComplete(); List<Throwable> list = compositeList(ts.errors().get(0)); assertEquals(classes.length, list.size()); for (int i = 0; i < classes.length; i += 2) { assertError(list, i, (Class<Throwable>)classes[i], (String)classes[i + 1]); } } /** * Emit the given values and complete the Processor. * @param <T> the value type * @param p the target processor * @param values the values to emit */ public static <T> void emit(Processor<T, ?> p, T... values) { for (T v : values) { p.onNext(v); } p.onComplete(); } /** * Emit the given values and complete the Subject. * @param <T> the value type * @param p the target subject * @param values the values to emit */ public static <T> void emit(Subject<T> p, T... values) { for (T v : values) { p.onNext(v); } p.onComplete(); } /** * Checks if the source is fuseable and its isEmpty/clear works properly. * @param <T> the value type * @param source the source sequence */ public static <T> void checkFusedIsEmptyClear(Observable<T> source) { final CountDownLatch cdl = new CountDownLatch(1); final Boolean[] state = { null, null, null, null }; source.subscribe(new Observer<T>() { @Override public void onSubscribe(Disposable d) { try { if (d instanceof QueueDisposable) { @SuppressWarnings("unchecked") QueueDisposable<Object> qd = (QueueDisposable<Object>) d; state[0] = true; int m = qd.requestFusion(QueueDisposable.ANY); if (m != QueueDisposable.NONE) { state[1] = true; state[2] = qd.isEmpty(); qd.clear(); state[3] = qd.isEmpty(); } } cdl.countDown(); } finally { d.dispose(); } } @Override public void onNext(T value) { } @Override public void onError(Throwable e) { } @Override public void onComplete() { } }); try { assertTrue(cdl.await(5, TimeUnit.SECONDS)); assertTrue("Not fuseable", state[0]); assertTrue("Fusion rejected", state[1]); assertNotNull(state[2]); assertTrue("Did not empty", state[3]); } catch (InterruptedException ex) { throw new RuntimeException(ex); } } /** * Checks if the source is fuseable and its isEmpty/clear works properly. * @param <T> the value type * @param source the source sequence */ public static <T> void checkFusedIsEmptyClear(Flowable<T> source) { final CountDownLatch cdl = new CountDownLatch(1); final Boolean[] state = { null, null, null, null }; source.subscribe(new Subscriber<T>() { @Override public void onSubscribe(Subscription d) { try { if (d instanceof QueueSubscription) { @SuppressWarnings("unchecked") QueueSubscription<Object> qd = (QueueSubscription<Object>) d; state[0] = true; int m = qd.requestFusion(QueueSubscription.ANY); if (m != QueueSubscription.NONE) { state[1] = true; state[2] = qd.isEmpty(); qd.clear(); state[3] = qd.isEmpty(); } } cdl.countDown(); } finally { d.cancel(); } } @Override public void onNext(T value) { } @Override public void onError(Throwable e) { } @Override public void onComplete() { } }); try { assertTrue(cdl.await(5, TimeUnit.SECONDS)); assertTrue("Not fuseable", state[0]); assertTrue("Fusion rejected", state[1]); assertNotNull(state[2]); assertTrue("Did not empty", state[3]); } catch (InterruptedException ex) { throw new RuntimeException(ex); } } }
99544bf8e3a26137ad067aa54824620369fb38b6
7ae6ef414b132c8c21dd38ee526434b14109b942
/src/com/chinasofti/util/bean/FillBeanException.java
83bfe1189bfabb65a93e2ec96695684a05a391e2
[]
no_license
alexliao-lrj/online-ordersys
bde8ed8b0e6a2a451c50a1580f5089e1296f9ce6
8d2bdce739853fcf0808e8155892ba5ea307d769
refs/heads/master
2021-01-17T10:42:01.534764
2019-01-13T04:28:03
2019-01-13T04:28:03
84,019,847
0
0
null
null
null
null
GB18030
Java
false
false
861
java
/** * Copyright 2014 ChinaSoft International Ltd. All rights reserved. */ package com.chinasofti.util.bean; /** * <p> * Title: FillBeanException * </p> * <p> * Description: 自定义的业务异常类,描述填充JavaBean属性时出现异常状况 * </p> * <p> * Copyright: Copyright (c) 2014 * </p> * <p> * Company: ChinaSoft International Ltd. * </p> * * @author etc * @version 1.0 */ public class FillBeanException extends RuntimeException { /** * 构造方法,构建异常信息 * * @param beanClassName * 出现异常时正在填充的JavaBean的类名 * @param propertyName * 出现异常时正在填充的属性名称 * */ public FillBeanException(String beanClassName, String propertyName) { super("填充Bean类" + beanClassName + "的属性" + propertyName + "时发生异常"); } }
e4eef4c227b4af0a200d8e09f12d76337a6ee8e4
e593d0a760d469ebcd7eec1c36470f2480262e22
/restful-web-services/src/main/java/com/vyom/rest/webservices/restfulwebservices/todo/Todo.java
3e21d67f5623687ce0545376ff0a5dcf20a2aac2
[]
no_license
vyom-shah/Angular-Sprint-boot-TODO-Application
921f28a2b5a1734dca5d4a9f68afdabd2e7bf1c9
72cdd81fc58d7b50d0b7048d66f9d73415bbea63
refs/heads/master
2022-11-10T06:34:08.482855
2020-06-27T04:55:14
2020-06-27T04:55:14
269,433,577
0
0
null
2020-06-04T19:28:11
2020-06-04T18:21:38
TypeScript
UTF-8
Java
false
false
1,674
java
package com.vyom.rest.webservices.restfulwebservices.todo; import java.util.Date; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; @Entity public class Todo { @Id @GeneratedValue private Long id; private String username; private String description; private Date targetDate; private boolean isDone; protected Todo() { } public Todo(long id, String username, String description, Date targetDate, boolean isDone) { super(); this.id = id; this.username = username; this.description = description; this.targetDate = targetDate; this.isDone = isDone; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public Date getTargetDate() { return targetDate; } public void setTargetDate(Date targetDate) { this.targetDate = targetDate; } public boolean isDone() { return isDone; } public void setDone(boolean isDone) { this.isDone = isDone; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + (int) (id ^ (id >>> 32)); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Todo other = (Todo) obj; if (id != other.id) return false; return true; } }
104ab5799532e6263a979058473b1472cd1a2cb9
8304ccab6a75579cfac64b3b7c4d3286077eeb14
/src/main/java/co/com/s4n/main/UserController.java
9e55e7b09c2e49a06dca8f3046980beed03e60cb
[]
no_license
afrancoc2000/medellin-java-rest-api
7168c9c698791edf41465a02ed6b963911d2e26a
2f29997669d6c4dfb5f74225dba0cb25ec9f1835
refs/heads/master
2021-01-24T22:52:53.789228
2015-05-12T03:50:47
2015-05-12T03:50:47
null
0
0
null
null
null
null
UTF-8
Java
false
false
3,243
java
package co.com.s4n.main; import java.io.IOException; import java.net.URI; import java.util.ArrayList; import java.util.Collections; import java.util.List; import javax.ws.rs.*; import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.UriInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import co.com.s4n.rest.model.User; import co.com.s4n.rest.model.UserRepo; import net.hamnaberg.json.*; import net.hamnaberg.json.Error; import net.hamnaberg.json.parser.CollectionParser; import net.hamnaberg.funclite.*; @Component @Path("/users") public class UserController { @Context private UriInfo uriInfo; private UserRepo userRepo; public UserController(){ super(); } @Autowired public UserController(UserRepo userRepo){ this.userRepo = userRepo; this.userRepo.getUsers(); } @GET // Sin anotaciones adicionales se atiende el request del @Path de la clase /users @Produces("application/json") public Response getUsers() { try{ ObjectMapper mapper = new ObjectMapper(); String userStr = new String(mapper.writeValueAsBytes(userRepo.getUsers())); Response retResponse = Response.ok(userStr).build(); return retResponse; }catch(JsonProcessingException e){ return Response.serverError().entity("Error serializing list of all users").build(); } } @GET @Path("/{id}") @Produces("application/json") public Response getUserById(@PathParam("id") int id) { try{ ObjectMapper mapper = new ObjectMapper(); User user = userRepo.getUserById(id); String userStr = new String(mapper.writeValueAsBytes(user)); Response retResponse = Response.ok(userStr).build(); return retResponse; }catch(JsonProcessingException e){ return Response.serverError().entity("Error serializing User("+id+")").build(); } } @POST @Produces("application/json") public Response createUser(String userStr) { try{ ObjectMapper mapper = new ObjectMapper(); User user = mapper.readValue(userStr, User.class); boolean resAdd = userRepo.addUser(user); Response retResponse = null; if(resAdd){ retResponse = Response.created(new URI(uriInfo.getAbsolutePath().toString()+"/"+user.getId())).build(); } else{ retResponse = Response.status(Status.CONFLICT).build(); } return retResponse; }catch(JsonProcessingException e){ return Response.serverError().entity("Error creating user "+ e.getMessage()).build(); }catch(IOException e){ return Response.serverError().entity("Error creating user "+ e.getMessage()).build(); }catch(Exception e){ return Response.serverError().entity("Error creating user "+ e.getMessage()).build(); } } }
ffa6267a93410fc0c16b468434db9bd666cdff3e
83a213744b00b8cf10413b025402bdeb540a9076
/homework1219/src/zuoye1219/digui.java
06e3928ceaa4593b248b6f105371aa437e9f1986
[]
no_license
MRong138/java.shangke
4d6931519cd7eeb5d0b50fe75f6ee5916fb47aee
12ed66a788e91ac1a949607ba39b5f77ff9aa1eb
refs/heads/master
2021-01-13T14:07:05.025550
2016-12-23T06:43:31
2016-12-23T06:43:31
76,161,742
0
0
null
null
null
null
UTF-8
Java
false
false
283
java
package zuoye1219; public class digui { public static void main(String[] args) { System.out.println("5的阶乘是"+jicheng(5)); } public static double jicheng(int n){ double res; if(n==1||n==0) res=1; else res=n*jicheng(n-1); return res; } }
5d6bc6571e0d29d9f340a5546ece49f78bcab569
b91ad3f47d4aad5c988cc380778fa69d14b1b6c1
/src/com/markchess/model/board/Square.java
1f9dc70797cb20298b3bd955a24f3fcdfbda30c0
[]
no_license
ResidualPhoenixCoder/chess
59651b7e03b81d860b334dbe31f8f8e6429c99ef
38e5a4604f541ec30858c9b565c3581b98b63b26
refs/heads/master
2020-09-12T19:23:30.687541
2014-07-20T01:46:26
2014-07-20T01:46:26
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,228
java
package com.markchess.model.board; import java.io.Serializable; public class Square implements Serializable { private static final long serialVersionUID = -90811719167427601L; private Piece mPiece; private final int mRowPos; private final BoardCol mColPos; private int mColor; public Square(final Piece piece, final int rowPos, final BoardCol colPos, final int color) { this(rowPos, colPos, color); setPiece(piece); } public Square(final int rowPos, final BoardCol colPos, final int color) { mRowPos = rowPos; mColPos = colPos; mColor = color; mPiece = null; } public Piece getPiece() { return mPiece; } public void setPiece(final Piece piece) { mPiece = piece; } public BoardCol getColumnPosition() { return mColPos; } public int getRowPosition() { return mRowPos; } public int getColor() { return mColor; } public void setColor(final int color) { mColor = color; } public boolean hasPiece() { return mPiece != null; } @Override public String toString() { return mColPos.toString() + mRowPos; } }
191828d0cca2be2d43dc5d1dd4b756c31271624b
33929538072253a36862bc22e0f479e534a3069d
/core/src/main/java/com/abc/core/SimpleMetadataReader.java
52e96ecad4330e1962406e1079d4b16b075b7845
[]
no_license
prehonor/abc
30349352a60e5af09d8fda8f3b53617efabeb310
49153952dd19136b6b0bfa272edbae842e7d2f22
refs/heads/master
2020-04-02T14:26:22.713797
2018-11-13T17:29:26
2018-11-13T17:29:26
154,524,669
0
0
null
null
null
null
UTF-8
Java
false
false
959
java
package com.abc.core; import com.abc.core.io.Resource; import com.sun.istack.internal.Nullable; import org.objectweb.asm.ClassReader; import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; public class SimpleMetadataReader { private final Resource resource; public final ClassMetadata classMetadata; SimpleMetadataReader(Resource resource, @Nullable ClassLoader classLoader) throws IOException { InputStream is = new BufferedInputStream(resource.getInputStream()); ClassReader classReader; try { classReader = new ClassReader(is); } catch (IllegalArgumentException ex) { throw ex; } finally { is.close(); } AsmClassVisitor visitor = new AsmClassVisitor(); classReader.accept(visitor, ClassReader.SKIP_DEBUG); this.classMetadata = visitor; this.resource = resource; } }
b83a722d1cdc14c7e1f18466799e2deda29cb273
cb2e90414945ed06d3ec093b2bcbc6cc049fcf76
/app/src/main/java/app/integro/dioceseofbangalore/models/PalanaBavanaList2.java
3d1e75fa2877a93858e4e5467f46af5d5fa1664a
[]
no_license
GurunathGuru/DioceseOfBangalore
d8647f4fd86214af43fdf855d9a6d3853a72d7ec
fdd48ccf7a0900e40e81615f3e9867dab8286fc7
refs/heads/master
2021-07-14T18:57:50.537841
2020-11-10T09:43:25
2020-11-10T09:43:25
224,134,180
0
0
null
null
null
null
UTF-8
Java
false
false
861
java
package app.integro.dioceseofbangalore.models; import com.google.gson.annotations.SerializedName; import java.util.ArrayList; public class PalanaBavanaList2 { @SerializedName("data") private ArrayList<PalanaBavana2> bavana2ArrayList; private String success; private String message; public ArrayList<PalanaBavana2> getBavana2ArrayList() { return bavana2ArrayList; } public void setBavana2ArrayList(ArrayList<PalanaBavana2> bavana2ArrayList) { this.bavana2ArrayList = bavana2ArrayList; } public String getSuccess () { return success; } public void setSuccess (String success) { this.success = success; } public String getMessage () { return message; } public void setMessage (String message) { this.message = message; } }
e289f07cc10fe2ac32e7bfe27e6c3a1a2c97e902
75197d4a192092985165a01f4cddbe409fcf8341
/MinesweeperFX/src/Board.java
1aaf0c48971854bafcb14310c69133e7247e81a5
[]
no_license
jonathannun/Minesweeper-FX
602c15218b85a71c9568b8714eddaffc7bfebd1f
9acb03d9a432799c333c03dddab04340a911676c
refs/heads/master
2023-02-19T00:56:23.639126
2021-01-11T12:44:05
2021-01-11T12:44:05
326,964,405
0
0
null
null
null
null
UTF-8
Java
false
false
2,664
java
public class Board { public Tile[][] data; //Two-dimensional Tile-array public Board(int widthOfBoard, int heightOfBoard) { this.data = new Tile[widthOfBoard][heightOfBoard]; //Initializes null object-array for (int i = 0; i < heightOfBoard; i++) { for (int j = 0; j < widthOfBoard; j++) { this.data[j][i] = new Tile(); //Fills object-array } } } public void populateBoard(int numberOfBombs) { int x, y; int i = 0; while(i < numberOfBombs) { //'Pool' of bombs x = (int) (Math.random() * this.data.length); //Coordinates for bomb chosen randomly y = (int) (Math.random() * this.data[0].length); if (!this.data[x][y].isTileBomb()) { //Bomb placed at coordinates if empty this.data[x][y].setBomb(); i++; //Increment } } for (i = 0; i < this.data[0].length; i++) { for (int j = 0; j < this.data.length; j++) { countNeighbours(j, i); //Counts number of bombs adjacent to tile } } } public void revealEmpty(int j, int i) { int x, y; for (int iOffset = -1; iOffset <= 1; iOffset++) { y = (i + iOffset) < this.data[0].length ? i + iOffset : -1; for (int jOffset = -1; jOffset <= 1; jOffset++) { x = (j + jOffset) < this.data.length ? j + jOffset : -1; if (x > -1 && y > -1 && !this.data[j][i].isTileBomb() && !this.data[x][y].isTileVisible()) { if (this.data[j][i].getNeighbours() == 0) { this.data[x][y].revealTile(); System.out.println(x + " : " + y); } if (this.data[x][y].getNeighbours() == 0) { revealEmpty(x, y); } } } } } public void countNeighbours(int j, int i) { int x, y; int count = 0; for (int iOffset = -1; iOffset <= 1; iOffset++) { //Adjacency reach as coordinate offset y = (i + iOffset) < this.data[0].length ? i + iOffset : -1; //OoB for (int jOffset = -1; jOffset <= 1; jOffset++) { x = (j + jOffset) < this.data.length ? j + jOffset : -1; if (x > -1 && y > -1) { //Checks if tile-coordinates are valid count += this.data[x][y].isTileBomb() ? 1 : 0; //Increment counter if bomb present } } } this.data[j][i].setNeighbours(count); //Update object } public String toString() { //Temporary toString method for troubleshooting String out = ""; for (int i = 0; i < this.data[0].length; i++) { for (int j = 0; j < this.data.length; j++) { out += this.data[j][i].isTileBomb() ? "X" : this.data[j][i].getNeighbours(); } out += "\n"; } return out; } }
f9e46c7df7159776dc61c69e7068de3eaad09d66
9a71195a939708fab72856be93d2531b446ced14
/Kite/src/main/java/com/po/MzywBnb.java
a161adb0ea4b75225f4ebc8ae2604dabc85a378e
[]
no_license
oldcicada/Demo05
667dc556a0b82dbfad39216714773267fc79868d
dcc2c79d92c4e65a9c5010463b650fc3bfaa241e
refs/heads/master
2020-03-16T19:13:30.758830
2018-05-24T12:51:07
2018-05-24T12:51:07
132,906,084
0
0
null
null
null
null
UTF-8
Java
false
false
5,241
java
package com.po; import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; import org.hibernate.annotations.GenericGenerator; @Entity @Table(name = "T_MZYW_BNB") public class MzywBnb implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(generator = "uuid") @GenericGenerator(name = "uuid", strategy = "uuid") private String id; @Column(columnDefinition = "VARCHAR(20) COMMENT '信息标题'") private String xxbt; @Column(columnDefinition = "VARCHAR(255) COMMENT '不能办基本情况'") private String bnbjbqk; @Column(columnDefinition = "VARCHAR(255) COMMENT '不能办原因'") private String bnbyy; @Column(columnDefinition = "VARCHAR(255) COMMENT '科处室意见'") private String kcsyj; @Column(columnDefinition = "VARCHAR(200) COMMENT '领导意见'") private String ldyj; @Column(columnDefinition = "VARCHAR(8) COMMENT '办结时间'") private String bjsj; @Column(columnDefinition = "VARCHAR(100) COMMENT '办结情况'") private String bjqk; @Column(columnDefinition = "VARCHAR(100) COMMENT '备注'") private String bz; @Column(columnDefinition = "VARCHAR(100) COMMENT '上报单位'") private String sbdw; @Column(columnDefinition = "VARCHAR(200) COMMENT '上报单位名称'") private String sbdwmc; @Column(columnDefinition = "VARCHAR(50) COMMENT '暂存报送'") private String zcbs; @Column(columnDefinition = "VARCHAR(50) COMMENT '有效标识'") private String yxbs; @Column(columnDefinition = "VARCHAR(100) COMMENT '创建用户'") private String cjyh; @Column(columnDefinition = "VARCHAR(14) COMMENT '创建时间'") private String cjsj; @Column(columnDefinition = "VARCHAR(100) COMMENT '最后修改用户'") private String zhxgyh; @Column(columnDefinition = "VARCHAR(14) COMMENT '最后修改时间'") private String zhxgsj; public MzywBnb(String id,String bnbjbqk, String bnbyy, String kcsyj, String ldyj, String bjsj, String bjqk, String bz, String sbdw, String sbdwmc, String zcbs, String cjsj, String zhxgyh, String zhxgsj) { super(); this.id=id; this.bnbjbqk = bnbjbqk; this.bnbyy = bnbyy; this.kcsyj = kcsyj; this.ldyj = ldyj; this.bjsj = bjsj; this.bjqk = bjqk; this.bz = bz; this.sbdw = sbdw; this.sbdwmc = sbdwmc; this.zcbs = zcbs; this.cjsj = cjsj; this.zhxgyh = zhxgyh; this.zhxgsj = zhxgsj; } public MzywBnb(String bnbjbqk, String bnbyy, String kcsyj, String ldyj, String bjsj, String bjqk, String bz, String sbdw, String sbdwmc, String zcbs, String cjsj, String zhxgyh, String zhxgsj) { super(); this.bnbjbqk = bnbjbqk; this.bnbyy = bnbyy; this.kcsyj = kcsyj; this.ldyj = ldyj; this.bjsj = bjsj; this.bjqk = bjqk; this.bz = bz; this.sbdw = sbdw; this.sbdwmc = sbdwmc; this.zcbs = zcbs; this.cjsj = cjsj; this.zhxgyh = zhxgyh; this.zhxgsj = zhxgsj; } public MzywBnb(String bnbjbqk, String bnbyy, String kcsyj, String ldyj, String bjsj, String bjqk, String bz, String sbdw, String sbdwmc, String zcbs,String zhxgyh, String zhxgsj) { super(); this.bnbjbqk = bnbjbqk; this.bnbyy = bnbyy; this.kcsyj = kcsyj; this.ldyj = ldyj; this.bjsj = bjsj; this.bjqk = bjqk; this.bz = bz; this.sbdw = sbdw; this.sbdwmc = sbdwmc; this.zcbs = zcbs; this.zhxgyh = zhxgyh; this.zhxgsj = zhxgsj; } public MzywBnb() { } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getBnbjbqk() { return bnbjbqk; } public void setBnbjbqk(String bnbjbqk) { this.bnbjbqk = bnbjbqk; } public String getBnbyy() { return bnbyy; } public void setBnbyy(String bnbyy) { this.bnbyy = bnbyy; } public String getKcsyj() { return kcsyj; } public void setKcsyj(String kcsyj) { this.kcsyj = kcsyj; } public String getLdyj() { return ldyj; } public void setLdyj(String ldyj) { this.ldyj = ldyj; } public String getBjsj() { return bjsj; } public void setBjsj(String bjsj) { this.bjsj = bjsj; } public String getBjqk() { return bjqk; } public void setBjqk(String bjqk) { this.bjqk = bjqk; } public String getBz() { return bz; } public void setBz(String bz) { this.bz = bz; } public String getSbdw() { return sbdw; } public void setSbdw(String sbdw) { this.sbdw = sbdw; } public String getSbdwmc() { return sbdwmc; } public void setSbdwmc(String sbdwmc) { this.sbdwmc = sbdwmc; } public String getZcbs() { return zcbs; } public void setZcbs(String zcbs) { this.zcbs = zcbs; } public String getYxbs() { return yxbs; } public void setYxbs(String yxbs) { this.yxbs = yxbs; } public String getCjyh() { return cjyh; } public void setCjyh(String cjyh) { this.cjyh = cjyh; } public String getCjsj() { return cjsj; } public void setCjsj(String cjsj) { this.cjsj = cjsj; } public String getZhxgyh() { return zhxgyh; } public void setZhxgyh(String zhxgyh) { this.zhxgyh = zhxgyh; } public String getZhxgsj() { return zhxgsj; } public void setZhxgsj(String zhxgsj) { this.zhxgsj = zhxgsj; } }
0ede68593366272e1f1ad1d628c615a876755bf5
99f4c3f90c996cf7ccef5cb9a86ba5c03824ffb5
/app/src/main/java/com/sprvtec/whizzy/vo/PhoneContact.java
a9101444815124210063089c753aa397a150ce75
[]
no_license
aartisoft/Whizzy_customer
cc684d5946434f9f8eeb5be67398b8336edd5e89
23113e2371ec2522f0f3920243efa78821cc6722
refs/heads/master
2020-05-02T18:38:11.309353
2019-03-13T10:41:22
2019-03-13T10:41:22
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,369
java
package com.sprvtec.whizzy.vo; import android.os.Parcel; import android.os.Parcelable; /** * Created by SPRV on 12/1/2015. */ public class PhoneContact implements Comparable, Parcelable { public String Name = "", MobileNumber = ""; public int selected = 0, active = 1; public PhoneContact(String Name, String MobileNumber) { this.Name = Name; this.MobileNumber = MobileNumber; } protected PhoneContact(Parcel in) { Name = in.readString(); MobileNumber = in.readString(); selected = in.readInt(); } public static final Creator<PhoneContact> CREATOR = new Creator<PhoneContact>() { @Override public PhoneContact createFromParcel(Parcel in) { return new PhoneContact(in); } @Override public PhoneContact[] newArray(int size) { return new PhoneContact[size]; } }; @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } PhoneContact custom = (PhoneContact) o; if (!Name.equals(custom.Name)) { return false; } if (!MobileNumber.equals(custom.MobileNumber)) { return false; } return true; } @Override public int hashCode() { int result = Name.hashCode(); result = 31 * result + MobileNumber.hashCode(); return result; } @Override public int compareTo(Object another) { // int compareage=Integer.parseInt(((PhoneContact)another).Name); /* For Ascending order*/ String TickedId2 = ((PhoneContact) another).Name; int num1 = this.active; int num2 = ((PhoneContact) another).active; if (num1 > num2) return 1; else if (num1 < num2) return -1; else return this.Name.compareToIgnoreCase(((PhoneContact) another).Name); // return this.Name.compareTo((((PhoneContact) another).Name)); } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(Name); dest.writeString(MobileNumber); dest.writeInt(selected); } }
f0ca81b8aeecde8185ef0ed778eb2ec9d3edcf72
bd5cc34e1973e0a5c820e232bf4814fe04dcc758
/src/main/java/annoyance/model/Destination.java
fe2b0ad8fd135b7f41f5d7a2b822eb70acb2c17c
[ "BSD-2-Clause" ]
permissive
plan3/annoyance
ab10d3beb8dadc6a0bb254178d2531cc43f52c70
dbfd50314f355eeca7f1d79ece9d33cbc6190c7f
refs/heads/master
2020-04-14T14:22:31.341415
2017-04-16T15:07:23
2017-04-16T15:07:23
33,639,139
0
2
null
2017-04-16T15:07:24
2015-04-09T00:11:54
Java
UTF-8
Java
false
false
1,451
java
package annoyance.model; import static java.util.Arrays.asList; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Optional; import org.kohsuke.github.GHRepository; import org.kohsuke.github.GitHub; public class Destination { private final Template path; private final Repository repository; private final Optional<String> message; public Destination(final Repository repository, final String path, final Optional<String> message) { this(repository, new Template(path), message); } public Destination(final Repository repository, final Template template, final Optional<String> message) { this.repository = repository; this.message = message; this.path = template; } public String getPath() { return this.path.render(); } @Override public String toString() { return getClass().getSimpleName() + '[' + this.repository + ':' + this.path + ']'; } public GHRepository from(final GitHub github) throws IOException { return this.repository.from(github); } public String getMessage() { return this.message.orElse(""); } public static Destination parse(final String job, final Optional<String> message) { final List<String> dst = new ArrayList<>(asList(job.split("/"))); return new Destination(new Repository(dst), String.join("/", dst), message); } }
833a817a6421e4804807843a92920ea1263d278e
6e39cd31267881070ed9fa1ecdba5845cf573e9c
/inject-resources-spring/src/main/java/com/adelean/inject/resources/spring/yaml/YamlResourceInjectedElement.java
479ee63b4b8e5005b50518baef191655cffc203e
[ "Apache-2.0" ]
permissive
fishermans/inject-resources
a82bb05f10ef73e161b4023f3ef06321918bb6d7
0d77710516e4df602f8c0751881a6175d5ba1cca
refs/heads/master
2023-07-25T08:31:47.555138
2021-09-05T14:04:44
2021-09-05T14:04:44
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,668
java
package com.adelean.inject.resources.spring.yaml; import static com.adelean.inject.resources.core.InjectResources.resource; import java.lang.reflect.Member; import java.lang.reflect.Type; import java.nio.charset.Charset; import org.yaml.snakeyaml.Yaml; import org.springframework.context.ApplicationContext; import com.adelean.inject.resources.commons.AnnotationSupport; import com.adelean.inject.resources.commons.ClassSupport; import com.adelean.inject.resources.core.helpers.StringUtils; import com.adelean.inject.resources.spring.YamlResource; import com.adelean.inject.resources.spring.core.AbstractResourceInjectedElement; public class YamlResourceInjectedElement extends AbstractResourceInjectedElement<YamlResource> { public YamlResourceInjectedElement( Member member, YamlResource resourceAnnotation, ApplicationContext applicationContext) { super(member, resourceAnnotation, applicationContext); } @Override public Object valueToInject(Type valueType, YamlResource resourceAnnotation) { String path = AnnotationSupport.getFrom(resourceAnnotation); Charset charset = Charset.forName(resourceAnnotation.charset()); Yaml yaml = StringUtils.isNotBlank(resourceAnnotation.yamlBean()) ? applicationContext.getBean(resourceAnnotation.yamlBean(), Yaml.class) : applicationContext.getBean(Yaml.class); Class<?> targetClass = ClassSupport.fromType(valueType); return resource() .withPath(path) .asReader(charset) .parseChecked(reader -> yaml.loadAs(reader, targetClass)); } }
ffa1e4d26421dd3d3c849ad4c0bbaa600516b8b7
750d26eef421463a1f8e8cb4e825808d419adb21
/master/SPICSwound/src/action/db/impl/RoleDAO.java
4b28f40b04103dc307ab155562cec03b8920c744
[ "Apache-2.0" ]
permissive
dzena/tuwien
d5e47e8441058e4845f39cac019dff3024b670c9
80bfb4cf2f3ee2cc1761930465b776a0befccd4b
refs/heads/master
2021-01-18T17:20:13.376444
2013-11-01T19:45:39
2013-11-01T19:45:39
59,845,669
28
0
null
2016-05-27T15:43:56
2016-05-27T15:43:56
null
UTF-8
Java
false
false
760
java
package db.impl; import javax.ejb.Stateless; import javax.persistence.EntityManager; import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Name; import db.interfaces.IRoleDAO; import entities.UserRole; @Stateless @Name("roleDAO") public class RoleDAO implements IRoleDAO { @In private EntityManager entityManager; public UserRole findByID(String id) { return entityManager.find(UserRole.class, id); } public UserRole merge(UserRole element) { return entityManager.merge(element); } public void persist(UserRole element) { entityManager.persist(element); } public void refresh(UserRole element) { entityManager.refresh(element); } public void remove(UserRole element) { entityManager.remove(element); } }
aaa0098a5b4cd788e3a2906a82bcf339ba2443e4
01a5a422bc5ca9cff5c41165e653b07afb42941c
/src/main/java/com/celso/springmc/services/validation/ClienteUpdate.java
25b81e14949ee5c54b562085e5e6361e3781339e
[]
no_license
celsonyl/Spring-mc
2e6103ced4ec4fb3b45417a5e23f063729d625a7
3a258eeabbc8cf5d23f2b8096db146ce9912246b
refs/heads/master
2023-03-28T06:54:33.432463
2021-03-31T13:02:03
2021-03-31T13:02:03
340,103,078
1
0
null
null
null
null
UTF-8
Java
false
false
582
java
package com.celso.springmc.services.validation; import javax.validation.Constraint; import javax.validation.Payload; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Constraint(validatedBy = ClienteUpdateValidator.class) @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface ClienteUpdate { String message() default "Erro de validação"; Class<?>[] groups() default {}; Class<? extends Payload>[] payload() default {}; }
83934a3c7632357a4dc24877d4d34ed9a53ae392
5a402865f757c60cbb95aa6938babd01f321c4c2
/src/com/dgut/bean/Post.java
676278b120ae34868835a82993ef3c37b96d5c72
[]
no_license
DGUT-JSP/ex2
8da59c070d5f95a69bc2403f6485f9cfd511d5bf
58f46290e312f0335884d166a0d3522d2f907221
refs/heads/master
2020-03-29T21:54:09.354813
2018-09-13T03:11:53
2018-09-13T03:11:53
150,393,303
0
0
null
null
null
null
UTF-8
Java
false
false
657
java
package com.dgut.bean; import java.sql.Timestamp; public class Post { int id; int authorId; String context; Timestamp dateIssued; public int getId() { return id; } public void setId(int id) { this.id = id; } public int getAuthorId() { return authorId; } public void setAuthorId(int authorId) { this.authorId = authorId; } public String getContext() { return context; } public void setContext(String context) { this.context = context; } public Timestamp getDateIssued() { return dateIssued; } public void setDateIssued(Timestamp dateIssued) { this.dateIssued = dateIssued; } }
[ "JimCao@DESKTOP-E4DLFG3" ]
JimCao@DESKTOP-E4DLFG3
5d8c76f64f95b28a947f298bffd4796131a383eb
020396db4e351a9b080edd2bf0518cd8c0996895
/product-service/src/main/java/com/yhb/dao/ItemDao.java
7667e0dba791a632bce22caa60136fcfcf0f56e5
[]
no_license
bltlsp/springCloud-demo
4843965c87bb5421dbed911bba938064784ea3f3
99537af663930627518de2f569841939eb4556fc
refs/heads/master
2021-06-17T01:18:45.021353
2019-08-06T11:44:18
2019-08-06T11:44:18
199,640,897
0
0
null
2021-04-26T19:23:02
2019-07-30T11:44:47
Java
UTF-8
Java
false
false
143
java
package com.yhb.dao; import com.yhb.base.BaseDao; import com.yhb.dao.entity.Item; public interface ItemDao extends BaseDao<Item>{ }
ce8d82821d569ac440dc5bc1c48a127f72d31963
0545b653543d2518964024ed9dd05512219b1e07
/hcg/src/main/java/com/deco2800/hcg/items/tools/Tool.java
fd923506becf865f6d2491a1d1368c07685c7263
[]
no_license
hobrien17/deco2800-hcg-copy
0b48a5c40960ca21850c245eaabd2c633939cd61
f5a32a1b25ce81f8e60dbb35c5667845263b6638
refs/heads/master
2021-04-06T02:13:58.428468
2017-10-22T19:25:08
2017-10-22T19:25:08
124,708,884
1
0
null
null
null
null
UTF-8
Java
false
false
1,129
java
package com.deco2800.hcg.items.tools; import java.util.Optional; import com.deco2800.hcg.entities.AbstractEntity; import com.deco2800.hcg.entities.Player; import com.deco2800.hcg.entities.garden_entities.plants.Pot; import com.deco2800.hcg.items.StackableItem; import com.deco2800.hcg.managers.GameManager; import com.deco2800.hcg.managers.PlayerManager; import com.deco2800.hcg.util.WorldUtil; public abstract class Tool extends StackableItem { protected Player player; public Tool() { PlayerManager manager = (PlayerManager)GameManager.get().getManager(PlayerManager.class); player = manager.getPlayer(); } @Override public boolean isWearable() { return false; } @Override public boolean isEquippable() { return true; } @Override public boolean isTradable() { return true; } public void use() { Optional<AbstractEntity> closest = WorldUtil.closestEntityToPosition(player.getPosX(), player.getPosY(), 1.5f, Pot.class); if(closest.isPresent()) { Pot pot = (Pot)closest.get(); if(!pot.isEmpty()) { effect(pot); } } } public abstract void effect(Pot pot); }
3ba4887c3439d82c2b348c64dc539eeef1daa4ea
60cdeada0735d6c1ba7f73688cd92bf553af4483
/src/JGF.java
d870aa422ea72bc46eae75571dc06efd17b5c8d6
[]
no_license
ViniGodoy/jgf
7aed48cf069d0f182e963f0d9c7155d861257376
018f8843412552047ae84caff58c15474518a285
refs/heads/master
2021-01-23T11:40:52.106657
2013-06-07T13:17:13
2013-06-07T13:17:13
10,549,536
1
0
null
null
null
null
ISO-8859-1
Java
false
false
1,342
java
package jgf; import javax.swing.JOptionPane; import jgf.util.Version; /****************************************************************************** * * COPYRIGHT Vinícius G. Mendonça ALL RIGHTS RESERVED. * * This software cannot be copied, stored, distributed without * Vinícius G.Mendonça prior authorization. * * This file was made available on http://www.pontov.com.br and it is free * to be restributed or used under Creative Commons license 2.5 br: * http://creativecommons.org/licenses/by-sa/2.5/br/ * ******************************************************************************* * Este software nao pode ser copiado, armazenado, distribuido sem autorização * a priori de Vinícius G. Mendonça * * Este arquivo foi disponibilizado no site http://www.pontov.com.br e esta * livre para distribuição seguindo a licença Creative Commons 2.5 br: * http://creativecommons.org/licenses/by-sa/2.5/br/ * ******************************************************************************/ public class JGF { public static final Version VERSION = new Version(1,1,0); public static void main(String[] args) { String text = "<html>Java Game Framework " + (VERSION.isBeta() ? "<font color=\"red\">" : "") + "v." + VERSION; JOptionPane.showMessageDialog(null, text); } }
9b854320e65035763e0d0d989558064d0d0808a6
6c777cf936e7375f8f50f47124e58397e61971f3
/editor/src/main/java/com/platforge/editor/maker/SelectorMapObjectInstance.java
2f60684b92922d66d2299b0e767cccecd302323b
[]
no_license
thomaswp/platforge
ace1a3c8385b7b477d146ddd15cf89e868ba9355
067aab6cc31b3419596f7e42d28340db9ad82727
refs/heads/master
2021-01-18T13:53:31.231287
2015-01-02T03:53:22
2015-01-02T03:53:22
12,644,628
0
0
null
null
null
null
UTF-8
Java
false
false
3,531
java
package com.platforge.editor.maker; import com.platforge.data.Map; import com.platforge.data.ObjectInstance; import com.platforge.data.PlatformGame; import com.platforge.editor.input.Input; import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.RectF; import android.graphics.Paint.Style; import android.os.Bundle; import android.view.SurfaceHolder; public class SelectorMapObjectInstance extends SelectorMapBase { private int originalId; @Override protected MapView getMapView(PlatformGame game, Bundle savedInstanceState) { originalId = getIntent().getExtras().getInt("id"); return new ObjectInstanceView(this, game, savedInstanceState, originalId); } @Override protected boolean hasChanged() { ObjectInstanceView view = (ObjectInstanceView)this.view; return view.selectedId != originalId; } @Override protected void finishOk(Intent intent) { ObjectInstanceView view = (ObjectInstanceView)this.view; intent.putExtra("id", view.selectedId); super.finishOk(intent); } private static class ObjectInstanceView extends SelectorMapView { private int selectedId; private RectF selectedRect = new RectF(); public ObjectInstanceView(Context context, PlatformGame game, Bundle savedInstanceState, int selectedId) { super(context, game, savedInstanceState); this.selectedId = selectedId; paint = new Paint(); } @Override public void surfaceCreated(SurfaceHolder holder) { super.surfaceCreated(holder); Map map = game.getSelectedMap(); if (selectedId >= 0) { ObjectInstance instance = map.objects.get(selectedId); offX = -instance.startX; offY = -instance.startY; doOriginBounding(width, height); } } @Override protected void drawObjects(Canvas c) { selectedRect.setEmpty(); super.drawObjects(c); } @Override protected void drawGrid(Canvas c) { super.drawGrid(c); if (!selectedRect.isEmpty()) { paint.setColor(selectionBorderColor); paint.setStyle(Style.STROKE); paint.setStrokeWidth(selectionBorderWidth); paint.setAntiAlias(false); c.drawRect(selectedRect, paint); } } @Override protected void drawObject(Canvas c, ObjectInstance instance, float cx, float cy, Bitmap bitmap, Paint paint) { if (instance.id == selectedId) { paint.setColor(selectionFillColor); paint.setStyle(Style.FILL); selectedRect.set(cx - bitmap.getWidth() / 2, cy - bitmap.getHeight() / 2, cx + bitmap.getWidth() / 2, cy + bitmap.getHeight() / 2); c.drawRect(selectedRect, paint); } super.drawObject(c, instance, cx, cy, bitmap, paint); } @Override protected boolean doSelection() { if (Input.isTapped()) { Map map = game.getSelectedMap(); float x = Input.getLastTouchX() - offX; float y = Input.getLastTouchY() - offY; boolean select = false; for (int i = 0; i < map.objects.size(); i++) { ObjectInstance instance = map.objects.get(i); Bitmap bmp = objects[instance.classIndex]; float left = instance.startX - bmp.getWidth() / 2; float top = instance.startY - bmp.getHeight() / 2; float right = instance.startX + bmp.getWidth() / 2; float bottom = instance.startY + bmp.getHeight() / 2; if (x >= left && x < right && y >= top && y < bottom) { selectedId = instance.id; select = true; } } return select; } return false; } } }
39f5a731917280b78710000f76583196d455e4b1
5b62fdb4bdd9405eaf5084f0b3a679d744cd2397
/shiro-ant/src/main/java/com/wpp/shiro/AuthRealm.java
9e1d2db8a7de9b54a0279d682f3cc25b0b940fbf
[]
no_license
edfeff/apache-demo
65693d527c98a63dc160a1a2139bcec483a49dfa
c4dd6122775a24bb20cafe8c5aa51469c27fb572
refs/heads/master
2022-12-22T03:24:57.494017
2020-03-17T09:30:42
2020-03-17T09:30:42
244,822,317
0
0
null
2022-12-12T05:44:09
2020-03-04T06:14:10
Java
UTF-8
Java
false
false
2,438
java
package com.wpp.shiro; import com.wpp.shiro.model.Permission; import com.wpp.shiro.model.Role; import com.wpp.shiro.model.User; import com.wpp.shiro.service.UserService; import org.apache.commons.collections.CollectionUtils; import org.apache.shiro.authc.*; import org.apache.shiro.authz.AuthorizationInfo; import org.apache.shiro.authz.SimpleAuthorizationInfo; import org.apache.shiro.realm.AuthorizingRealm; import org.apache.shiro.subject.PrincipalCollection; import org.springframework.beans.factory.annotation.Autowired; import java.util.ArrayList; import java.util.List; import java.util.Set; /** * @author wangpp */ public class AuthRealm extends AuthorizingRealm { @Autowired UserService userService; /** * 授权 * * @param principals * @return */ @Override protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { User user = (User) principals.fromRealm(this.getClass().getName()).iterator().next(); Set<Role> roleSet = user.getRoles(); List<String> permissionList = new ArrayList<>(); List<String> roleNameList = new ArrayList<>(); if (CollectionUtils.isNotEmpty(roleSet)) { for (Role role : roleSet) { roleNameList.add(role.getRname()); Set<Permission> permissionSet = role.getPermissions(); if (CollectionUtils.isNotEmpty(permissionList)) { for (Permission permission : permissionSet) { permissionList.add(permission.getName()); } } } } SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); info.addStringPermissions(permissionList); info.addRoles(roleNameList); return info; } /** * 认证通过后,认证的相关信息放入到AuthRealm中 * * @param token * @return * @throws AuthenticationException */ @Override protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { UsernamePasswordToken usernamePasswordToken = (UsernamePasswordToken) token; String username = usernamePasswordToken.getUsername(); User user = userService.findByUsername(username); return new SimpleAuthenticationInfo(user, user.getPassword(), this.getClass().getName()); } }
21d9e050ff5907cd62ff0c1b792764ed32565fb6
0ee5eb0679f3176ab1fa8c7353908f9207c61f13
/poneymon_fx/src/main/java/fr/univ_lyon1/info/m1/poneymon_fx/reseau/host/HostThread.java
a9cd3e642889815bebedd092d9511aa3141669a4
[]
no_license
Jeremy-Duval/Project_Ponymon_3.0
dc1d014dd756e1c94fc3b36f61fcd052c4552a0b
fe2779600676faa5300ae495012459f6ce5c7776
refs/heads/master
2020-04-27T12:26:33.746074
2019-03-07T11:30:50
2019-03-07T11:30:50
174,331,680
0
0
null
null
null
null
UTF-8
Java
false
false
3,399
java
package fr.univ_lyon1.info.m1.poneymon_fx.reseau.host; import fr.univ_lyon1.info.m1.poneymon_fx.reseau.Info.FieldInfo; import fr.univ_lyon1.info.m1.poneymon_fx.reseau.Info.MapInfo; import fr.univ_lyon1.info.m1.poneymon_fx.reseau.Interface; import fr.univ_lyon1.info.m1.poneymon_fx.reseau.Envoi; import fr.univ_lyon1.info.m1.poneymon_fx.reseau.Reception; import fr.univ_lyon1.info.m1.poneymon_fx.reseau.Info.Beginning; import fr.univ_lyon1.info.m1.poneymon_fx.reseau.Info.UpdateModel; import fr.univ_lyon1.info.m1.poneymon_fx.reseau.Interpreteur.InterpreteurConnect; import fr.univ_lyon1.info.m1.poneymon_fx.reseau.Interpreteur.InterpreteurJmpPwr; import fr.univ_lyon1.info.m1.poneymon_fx.reseau.Interpreteur.InterpreteurReady; import java.io.IOException; import java.io.Serializable; import java.net.Socket; public class HostThread extends Thread { protected Socket socket; private Interface anInterface; public HostThread(Socket clientSocket, Interface anInterface) { this.anInterface = anInterface; this.socket = clientSocket; } @Override public void run() { System.out.println("Client connecté"); try { new Reception(socket,new InterpreteurConnect(),anInterface).run(); } catch (IOException e) { e.printStackTrace(); anInterface.setQuit(true); } /*try { new Envoi(socket, new MapInfo(anInterface.getMap(),anInterface.getQuit())).run(); } catch (IOException e) { e.printStackTrace(); anInterface.setQuit(true); }*/ try { new Reception(socket,new InterpreteurReady(),anInterface).run(); } catch (IOException e) { e.printStackTrace(); anInterface.setQuit(true); } synchronized (anInterface.getLock()) { while (!anInterface.isBeginning()) { try { anInterface.getLock().wait(); } catch (InterruptedException e) { e.printStackTrace(); anInterface.setQuit(true); } } } try { new Envoi(socket, new Beginning(new FieldInfo(anInterface.getModel()),anInterface.getQuit())).run(); } catch (IOException e) { e.printStackTrace(); anInterface.setQuit(true); } boolean quit = false; while (!quit) { if (anInterface.getModel().getWinner() != null) { anInterface.setQuit(true); } try { new Envoi(socket, new UpdateModel(anInterface.getModel(),anInterface.getQuit())).run(); } catch (IOException e) { //e.printStackTrace(); anInterface.setQuit(true); } try { new Reception(socket,new InterpreteurJmpPwr(),anInterface).run(); } catch (IOException e) { //e.printStackTrace(); anInterface.setQuit(true); } quit = anInterface.getQuit(); } try { socket.close(); } catch (IOException e) { e.printStackTrace(); } //System.out.println("Connection Closed"); } }
3ca4b6d894de4c87a7e61b3e2716703df2e2cbe9
e9d074918e02e2e5e7fc91c816db51f6bb7ccf55
/testng/src/main/java/com/test/testng/BasicAnnotation.java
150185879f29c1aade0bd0d2611d70f6024eef8f
[ "Unlicense" ]
permissive
anjie0818/Auto-API
d88ef48e76c960c7c8b609bd8e9f39eabb00fd40
75f45b92e449563189669018492a463d24bd5b2b
refs/heads/master
2020-04-26T21:57:27.169158
2019-03-19T11:09:42
2019-03-19T11:09:42
173,857,120
0
0
null
null
null
null
UTF-8
Java
false
false
1,646
java
package com.test.testng; import com.mongodb.annotations.ThreadSafe; import org.testng.annotations.*; /** * @创建人 anjie * @创建时间 2019/3/6 * @描述 */ public class BasicAnnotation { @Test public void testCase1(){ System.out.println("-----testCase1"); } @Test(dependsOnMethods = {"testCase1"}) public void testCase2(){ System.out.println("-----testCase2"); } @Test(enabled = false) public void testCase3(){ System.out.println("-----testCase3------------"); } @Test(expectedExceptions = Exception.class) public void testException() throws Exception { System.out.println("异常测试"); throw new Exception(); } @Test(timeOut = 2000) public void testSleep() throws InterruptedException { Thread.sleep(20022); } @BeforeMethod public void BeforeMethod(){ System.out.println("-----BeforeMethod"); } @AfterMethod public void AfterMethod(){ System.out.println("-----AfterMethod"); } @BeforeClass public void beforeClass(){ System.out.println("------BeforeClass"); } @AfterClass public void AfterClass(){ System.out.println("------AfterClass"); } @BeforeSuite public void BeforeSuite(){ System.out.println("------BeforeSuite"); } @AfterSuite public void AfterSuite(){ System.out.println("------AfterSuite"); } @AfterTest public void AfterTest(){ System.out.println("------AfterTest"); } @BeforeTest public void BeforeTest(){ System.out.println("------BeforeTest"); } }
8c89dff81720124cd5c7f41fe1c258fcb120cb71
9819243279408707952c157e4b28c09476242aa9
/objectos.comuns-cep/src/br/com/objectos/comuns/cep/Aplicacao.java
91c11c59a1ac07724d7c99c4e84e24fefbf1e828
[]
no_license
gustavomel0/objectos.comuns-cep
9d0c4492bb0d3227814660f72afaaf268b376934
7f6a60b35270fb6823d7f360710561960984a40d
refs/heads/master
2016-09-10T20:04:02.136711
2012-12-13T16:47:23
2012-12-13T16:47:23
null
0
0
null
null
null
null
UTF-8
Java
false
false
893
java
/* * Aplicacao.java criado em 13/12/2012 * * Propriedade de Objectos Fábrica de Software LTDA. * Reprodução parcial ou total proibida. */ package br.com.objectos.comuns.cep; import java.util.Scanner; /** * @author [email protected] (Gustavo Melo) */ public class Aplicacao { static String cep = ""; public static void main(String[] args) { Scanner entrada = new Scanner(System.in); String r = "s"; while (r.equals("s")) { System.out.println("Informe o CEP:"); cep = entrada.next(); Cep c = new Cep(); if (c.buscarCep(cep) == true) { System.out.println("Logradouro: " + c.getLogradouro() + "\nBairro: " + c.getBairro() + "\nCidade: " + c.getCidade() + "\nEstado: " + c.getEstado()); } else { System.out.println("CEP inexistente."); } System.out.println("\n\nDeseja repetir? (s/n)"); r = entrada.next(); } } }
98a242a5522e2e945a23b6848a45b5dce59813ec
e19fd4dca268a2462b13260239d631bc987010fc
/src/com/thiru/broadcastreceiver/MainActivity.java
aa8504598a277e78d9cc13404461bc4703b1c279
[]
no_license
suryapalukuri/BroadcastReceiversAlaram
0471bf66922f25e07502109ab0baad8b4af73758
c946ac32789261b6213126cc652b885d0ed5cf40
refs/heads/master
2020-03-30T19:42:43.017645
2018-10-04T10:25:31
2018-10-04T10:25:31
null
0
0
null
null
null
null
UTF-8
Java
false
false
846
java
package com.thiru.broadcastreceiver; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.telephony.TelephonyManager; import android.widget.Toast; public class MainActivity extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub String state=intent.getStringExtra(TelephonyManager.EXTRA_STATE); if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) { Toast.makeText(context, "ringing", Toast.LENGTH_SHORT).show(); } else if (state.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) { Toast.makeText(context, "received", Toast.LENGTH_SHORT).show(); } else if (state.equals(TelephonyManager.EXTRA_STATE_IDLE)) { Toast.makeText(context, "Ended", Toast.LENGTH_SHORT).show(); } } }
c743284196ac1e49e689eb3b93b26b602affc805
43c997b64e00261d2229f4db8b99d99e68977f3b
/app/src/main/java/com/example/az/myeasemobdemo/Const.java
7d68fb7d4363cec1184775c23ca2cea9f19f9f96
[]
no_license
eeqg/MyEasemobDemo
526c2a81d203c1a3db9bf634666703e94a7d89da
93ed4527d0ed38c0a9dcc0f08941277ed07c4dad
refs/heads/master
2020-03-17T10:05:07.539099
2018-05-16T03:15:33
2018-05-16T03:15:33
133,498,985
0
0
null
null
null
null
UTF-8
Java
false
false
164
java
package com.example.az.myeasemobdemo; /** * Created by wp on 2018/5/15. */ public class Const { public static String EM_APP_KEY = "1170180515146416#test"; }
20377a6fca885cdab3340c8135ebad4a7c209876
b6298b6427aa127dc0195e8532bcc1595b5d2634
/goods2b/goods2b-client/src/main/java/com/iwhalecloud/retail/goods2b/dto/req/MerchantTagRelDeleteReq.java
3d163c65ef803c49926ea3432e75427503f17133
[]
no_license
chenmget/spring-cloud-demo
2ecbdeeb5102dc7523ef9fc59a405fc5c77bf6ad
0b4100973d2f6525883e0e73f000ac6e9c0b9060
refs/heads/release
2022-07-17T13:41:20.595393
2020-04-02T07:40:19
2020-04-02T07:40:19
249,857,665
1
3
null
2022-06-29T18:02:22
2020-03-25T01:23:07
Java
UTF-8
Java
false
false
862
java
package com.iwhalecloud.retail.goods2b.dto.req; import com.iwhalecloud.retail.dto.AbstractRequest; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data @ApiModel(value = "店中商(分销商)和标签 关联关系 删除请求对象,对应模型prod_partner_tag_rel, 对应实体PartnerTagRel类") public class MerchantTagRelDeleteReq extends AbstractRequest implements java.io.Serializable { private static final long serialVersionUID = -177975597198048658L; //属性 begin /** * 关联ID */ @ApiModelProperty(value = "关联ID") private String relId; /** * 标签ID */ @ApiModelProperty(value = "标签ID") private String tagId; /** * 商家 ID */ @ApiModelProperty(value = "商家 ID") private String merchantId; }
1a98f091fca5fcab1216fada1cefc180924d6743
ef8dca3bb57d3789e0d2088423ac000a15ab6a2d
/src/main/java/com/papers/utils/AutoToPaperUtil.java
d8b0db0db86b3be79b69759b457acb895a884bca
[]
no_license
zzhouyyong/OrganizePapers
5b7f33ecd937a0b05f4bd73cbe8a5ae972dd907c
e03df2301738c94bb22693dacc3c9dff2d5cfe42
refs/heads/main
2023-05-21T09:57:31.061060
2021-06-09T04:26:32
2021-06-09T04:26:32
316,908,816
2
0
null
null
null
null
UTF-8
Java
false
false
1,131
java
package com.papers.utils; import java.util.*; /** * @author zhouyong * @date 2021/3/18 16:15 * 随机组卷算法 */ public class AutoToPaperUtil { public static void shufflePaperIds (List<?> list) { int size = list.size(); final Random random = new Random(); // 判断当前传入的list是否是ArrayList if ( list instanceof RandomAccess) { for (int i = size; i > 1; i--) swap(list, i-1, random.nextInt(i)); // 若是linkedList走这 } else { Object arr[] = list.toArray(); for (int i=size; i>1; i--) swap(arr, i-1, random.nextInt(i)); ListIterator it = list.listIterator(); for (int i=0; i<arr.length; i++) { it.next(); it.set(arr[i]); } } } public static void swap(List<?> list, int i, int j) { final List l = list; l.set(i, l.set(j, l.get(i))); } private static void swap(Object[] arr, int i, int j) { Object tmp = arr[i]; arr[i] = arr[j]; arr[j] = tmp; } }
c69666929989e5b42ca255a64770cf67f075bb6e
e07008c748cea4e175dbbba120d7ae851765b72d
/YiLifang/e3parent/e3-manager/e3-manager-dao/src/main/java/mapper/TbItemParamMapper.java
e63be710acd315c0f8e91bdc698dc53a963ccdf4
[]
no_license
lijian20190221/CRM
79bfa2462bc3ddc590affe1a9fadedf71cbd91d1
d4d845f6049a1e55253076c2727dc3624a696964
refs/heads/master
2020-04-24T08:02:13.924847
2019-02-22T07:11:41
2019-02-22T07:11:41
171,818,174
1
0
null
null
null
null
UTF-8
Java
false
false
1,109
java
package mapper; import org.apache.ibatis.annotations.Param; import pojo.TbItemParam; import pojo.TbItemParamExample; import java.util.List; public interface TbItemParamMapper { int countByExample(TbItemParamExample example); int deleteByExample(TbItemParamExample example); int deleteByPrimaryKey(Long id); int insert(TbItemParam record); int insertSelective(TbItemParam record); List<TbItemParam> selectByExampleWithBLOBs(TbItemParamExample example); List<TbItemParam> selectByExample(TbItemParamExample example); TbItemParam selectByPrimaryKey(Long id); int updateByExampleSelective(@Param("record") TbItemParam record, @Param("example") TbItemParamExample example); int updateByExampleWithBLOBs(@Param("record") TbItemParam record, @Param("example") TbItemParamExample example); int updateByExample(@Param("record") TbItemParam record, @Param("example") TbItemParamExample example); int updateByPrimaryKeySelective(TbItemParam record); int updateByPrimaryKeyWithBLOBs(TbItemParam record); int updateByPrimaryKey(TbItemParam record); }
6cd287c8ad48cb7dce29721f5a4254f2417cb079
d0e7d04a0a7396ba0f11a953a5f0ff911516a57b
/app/src/main/java/com/im/smarto/ui/authentication/IAuthActivity.java
3d0b1ee504977a9693fb9c83076d18305cdc22b9
[]
no_license
SmartOProject/Android
d50b497d23444d0228fb53d2a7f2a99758547d5c
49609b556a7e95bb24332c2b881bdb167bb9f8b7
refs/heads/master
2021-09-12T02:06:13.345390
2018-04-13T14:14:54
2018-04-13T14:14:54
118,889,829
0
0
null
null
null
null
UTF-8
Java
false
false
451
java
package com.im.smarto.ui.authentication; import com.im.smarto.ui.ILoading; import com.im.smarto.ui.base.BaseView; /** * Created by Anatoly Chernyshev on 25.01.18. */ public interface IAuthActivity extends BaseView, ILoading{ void openNavigationActivity(String token); void openRegisterActivity(); void showIncorrectPhoneNumberError(); void showEmptyFieldsError(); void showAuthenticationFailedError(); }
44b96b22917b5cff6b521f747702a008267d55d1
2c812f2dbebf7443ef1cdd39f598f50268e2a9ba
/app/src/main/java/com/android/traveling/entity/comment/Comment.java
ee4b273b4e7d07f31d62d23fc9e355109f8ae8e1
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
12313kaihuang/Traveling
feb1db49bef92619d88f5cb47a932ebc9492853a
4ebb01130a8fc111f62b340709d7cb0496b8be92
refs/heads/master
2021-07-23T09:07:01.030208
2019-04-21T08:55:23
2019-04-21T08:55:23
149,836,010
16
1
Apache-2.0
2019-04-21T08:55:24
2018-09-22T01:44:08
Java
UTF-8
Java
false
false
4,288
java
package com.android.traveling.entity.comment; import android.support.annotation.NonNull; import com.android.traveling.entity.msg.Msg; import com.android.traveling.entity.service.CommentService; import com.android.traveling.entity.user.User; import com.android.traveling.util.DateUtil; import com.android.traveling.util.LogUtil; import com.android.traveling.util.StaticClass; import com.android.traveling.util.UtilTools; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; import retrofit2.Retrofit; /** * Created by HY * 2019/2/25 16:26 * 评论 */ @SuppressWarnings("unused") public class Comment implements Serializable { public static final int FLAG_COMMENT = 0; //评论 private Integer id; //评论id private Integer userId; private String nickName; private String userImg; private String content; private String commentTime; private List<Reply> replies; public Comment() { } public Comment(User user, BaseComment baseComment) { this.id = baseComment.getId(); this.userId = baseComment.getUserId(); this.nickName = user.getNickName(); this.userImg = user.getDirectImg(); this.content = baseComment.getContent(); this.commentTime = DateUtil.transform(baseComment.getCommentTime()); this.replies = new ArrayList<>(); LogUtil.d("Comment", "userImg" + userImg); } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public Integer getUserId() { return userId; } public String getContent() { return content; } public void setContent(String content) { this.content = content; } public void setUserId(Integer userId) { this.userId = userId; } public String getNickName() { return nickName; } public void setNickName(String nickName) { this.nickName = nickName; } public String getUserImg() { return StaticClass.IMG_URL + userImg; } public void setUserImg(String userImg) { this.userImg = userImg; } public String getCommentTime() { return commentTime; } public void setCommentTime(String commentTime) { this.commentTime = commentTime; } public List<Reply> getReplies() { return replies; } public void setReplies(List<Reply> replies) { this.replies = replies; } //添加回复 public void addReply(User currentUser, BaseComment baseComment) { if (replies == null) { replies = new ArrayList<>(); } Reply reply = new Reply(currentUser, nickName, baseComment); replies.add(reply); } /** * retrofit请求 删除评论 * * @param id 评论id */ public static void deleteComment(int id, DeleteCommentListener listener) { Retrofit retrofit = UtilTools.getRetrofit(); CommentService commentService = retrofit.create(CommentService.class); Call<Msg> msgCall = commentService.deleteComment(id); msgCall.enqueue(new Callback<Msg>() { @Override public void onResponse(@NonNull Call<Msg> call, @NonNull Response<Msg> response) { Msg msg = response.body(); if (msg != null) { if (msg.getStatus() == Msg.CORRECT_STATUS) { listener.onSuccess(); return; } listener.onFailure(msg.getInfo()); } else { listener.onFailure("msg == null"); } } @Override public void onFailure(@NonNull Call<Msg> call, @NonNull Throwable t) { t.printStackTrace(); listener.onFailure(t.getMessage()); } }); } public interface DeleteCommentListener { void onSuccess(); void onFailure(String reason); } }
5f9691e6421035de330debd9d897336255f31b7b
96a0dc05d76e7667236cd33a8a0731626ac0f2f2
/cluemining-admin/src/main/java/com/ksrs/clue/config/swagger2/Swagger2.java
8ca6cc2104ebd7e69e21af67bf7fa46dd37ca0c4
[]
no_license
dubonumber2/ksrs-cms
e8fa84bd29fc91b49757f781e24b7c4ea5d2ce2b
320af5651f1f8a8f5e19bbbf323ca27e9475da69
refs/heads/master
2022-10-30T00:26:47.859321
2019-06-02T10:10:14
2019-06-02T10:10:14
189,831,986
1
0
null
2022-10-12T20:27:26
2019-06-02T10:17:12
Java
UTF-8
Java
false
false
1,207
java
package com.ksrs.clue.config.swagger2; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.service.ApiInfo; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.swagger2.annotations.EnableSwagger2; @Configuration @EnableSwagger2 public class Swagger2 { @Bean public Docket createRestApi(){ return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.basePackage("com.ksrs.clue.controller")) .paths(PathSelectors.any()) .build(); } private ApiInfo apiInfo(){ return new ApiInfoBuilder() .title("线索挖掘用户端相关接口") .description("正式") .contact("杜波") .version("1.0") .build(); } }
8165c05e643fe11500d54ff716f48c2442938152
f7cc8938ccf25a514c6a6ccdfb4dcc49f80b5c12
/microvibe-base/microvibe-castor/src/main/java/io/microvibe/castor/support/NullCastor.java
23a05aab7a7ba4be3110dd293c380243f2e60e8c
[ "Apache-2.0" ]
permissive
microsignal/vibe
6f8b8d91aa6fa0dfc7020ca023ea8c3cb0d82e37
4b3e2d5b5a6f3b3e021276b7e496d6eaa1b7b665
refs/heads/master
2021-09-25T13:07:16.911688
2018-10-22T05:14:14
2018-10-22T05:14:14
null
0
0
null
null
null
null
UTF-8
Java
false
false
363
java
package io.microvibe.castor.support; public class NullCastor extends AbstractMarshallableCastor<Object> { public NullCastor() { super(Object.class); } public NullCastor(Class<Object> type) { super(type); } @Override public Object castFromBasic(Object orig) { return null; } @Override public Object fromString(String s) { return null; } }
3900b000e632ec056156b8cf29d39a3d692ccf35
7733f23e42cda1758fa37e7765b4d726cb3793b7
/app/src/main/java/supenta/florent/testapplication/MainActivity.java
808150298c18ba93ba22f9704eaf8b1c3d95f2fd
[]
no_license
CoreFloDev/TestSupenta
14ac6fc27244c80da51bca806c4f54123e7c1e04
0ffe97318c268fa57e2fc15502560fa255210c59
refs/heads/master
2021-01-19T21:25:31.866803
2015-01-29T21:12:57
2015-01-29T21:12:57
29,880,905
0
0
null
null
null
null
UTF-8
Java
false
false
5,705
java
package supenta.florent.testapplication; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import supenta.florent.testapplication.service.AppEventService; public class MainActivity extends ActionBarActivity implements NavigationDrawerFragment.NavigationDrawerCallbacks { /** * Fragment managing the behaviors, interactions and presentation of the navigation drawer. */ private NavigationDrawerFragment mNavigationDrawerFragment; /** * Used to store the last screen title. For use in {@link #restoreActionBar()}. */ private CharSequence mTitle; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager().findFragmentById(R.id.navigation_drawer); mTitle = getTitle(); // Set up the drawer. mNavigationDrawerFragment.setUp( R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout)); } @Override public void onNavigationDrawerItemSelected(int position) { // update the main content by replacing fragments FragmentManager fragmentManager = getSupportFragmentManager(); fragmentManager.beginTransaction() .replace(R.id.container, PlaceholderFragment.newInstance(position + 1)) .commit(); } public void onSectionAttached(int number) { switch (number) { case 1: mTitle = getString(R.string.title_section1); break; case 2: mTitle = getString(R.string.title_section2); break; case 3: mTitle = getString(R.string.title_section3); break; } } public void restoreActionBar() { ActionBar actionBar = getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setDisplayShowTitleEnabled(true); actionBar.setTitle(mTitle); } @Override public boolean onCreateOptionsMenu(Menu menu) { if (!mNavigationDrawerFragment.isDrawerOpen()) { // Only show items in the action bar relevant to this screen // if the drawer is not showing. Otherwise, let the drawer // decide what to show in the action bar. getMenuInflater().inflate(R.menu.main, menu); restoreActionBar(); return true; } return super.onCreateOptionsMenu(menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment argument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle args = new Bundle(); args.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(args); return fragment; } public PlaceholderFragment() { } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); // add Action to buttons start and stop service final Button startButton = (Button) rootView.findViewById(R.id.buttonStartService); startButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getActivity().startService(new Intent(getActivity(), AppEventService.class)); } }); final Button stopButton = (Button) rootView.findViewById(R.id.buttonStopService); stopButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getActivity().stopService(new Intent(getActivity(), AppEventService.class)); } }); return rootView; } @Override public void onAttach(Activity activity) { super.onAttach(activity); ((MainActivity) activity).onSectionAttached( getArguments().getInt(ARG_SECTION_NUMBER)); } } }
a53a8d150abbc90ac976648c416bcdf1f7a2f253
2e8c30ccdd1708660f880487650a8b9ad4f17393
/src/company/netease/Main2.java
e1fb44cc65dc183f751ca8b31059a9ddde2b16c3
[]
no_license
mindawei/practice
71ca9e9f31f5119f82002fa723812ebf8b462457
a3bdafdf4682bb99f32e5d8a022c36bd2d3327d5
refs/heads/master
2020-12-02T22:04:33.438715
2017-09-22T14:44:49
2017-09-22T14:44:49
96,078,023
0
0
null
null
null
null
UTF-8
Java
false
false
2,477
java
package company.netease; import java.util.Arrays; import java.util.Scanner; public class Main2 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] x = new int[n]; for(int i=0;i<n;++i){ x[i] = sc.nextInt(); } int[] y = new int[n]; for(int i=0;i<n;++i){ y[i] = sc.nextInt(); } final int inf = 99999999; int[] res = new int[n]; Arrays.fill(res,inf); for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { for(int k = 0; k < n; k++) { int[] res2 = new int[n]; for(int l = 0; l < n; l++) { res2[l] = Math.abs(x[l] - x[j]) + Math.abs(y[l] - y[k]); } Arrays.sort(res2); int res3 = 0; for(int l = 0; l < i + 1; l++) res3 += res2[l]; res[i] = Math.min(res[i], res3); } } } for(int i = 0; i < n; i++) { if(i==0){ System.out.print(res[i]); }else{ System.out.print(" "+res[i]); } } System.out.println(); } // private static int min = Integer.MAX_VALUE; // // // private static int solve(int[] xs, int[] ys, int n) { // ArrayList<Integer> tx = new ArrayList<Integer>(); // ArrayList<Integer> ty = new ArrayList<Integer>(); // min = Integer.MAX_VALUE; // walk(xs,ys,tx,ty,0,n); // return min; // } // // private static void walk(int[] xs, int[] ys, ArrayList<Integer> tx, ArrayList<Integer> ty, int pos, int n) { // if(n==0){ // int centerX = 0; // int centerY = 0; // int num = tx.size(); // for(int i=0;i<num;++i){ // centerX+=tx.get(i); // centerY+=ty.get(i); // } // // centerX = centerX / num; // centerY = centerY / num; // // for(int i=-50;i<=50;++i){ // for(int j=-50;j<=50;++j){ // // int nx = centerX +i; // int ny = centerY +j; // // int minDiff = 0; // for(int k=0;k<num;++k){ // minDiff+= Math.abs(nx - tx.get(k)); // minDiff+= Math.abs(ny - ty.get(k)); // } // // min = Math.min(minDiff, min); // } // } // // // } // // if(pos==xs.length){ // return; // } // // for(int i=pos;i<xs.length ;++i){ // if(xs.length-i+1<n){ // continue; // } // // tx.add(xs[i]); // ty.add(ys[i]); // // walk(xs, ys, tx, ty, i+1, n-1); // // tx.remove(tx.size()-1); // ty.remove(ty.size()-1); // } // } }
[ "mindw" ]
mindw
2651c7f2351e5b685bb58b2c635abceb58531e9b
4019e28e914801437b42ce42fbffda8c3dbe29e4
/app/src/main/java/com/stay4it/framework/widgets/pull/layoutmanager/MyStaggeredGridLayoutManager.java
24b77b17b8ff33d544c1e47b83856ae64fa97399
[]
no_license
guhuizaifeiyang/AppFramework
642adb15edd59ac18627268c2b62448e59217b8a
349fa9aa0e24219f789956372c8c768f45c804f5
refs/heads/master
2020-03-06T15:35:38.901314
2018-03-27T09:03:16
2018-03-27T09:03:16
126,958,758
0
0
null
null
null
null
UTF-8
Java
false
false
1,133
java
package com.stay4it.framework.widgets.pull.layoutmanager; import android.content.Context; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.StaggeredGridLayoutManager; import android.util.AttributeSet; import com.stay4it.framework.widgets.pull.BaseListAdapter; /** * Created by Stay on 5/3/16. * Powered by www.stay4it.com */ public class MyStaggeredGridLayoutManager extends StaggeredGridLayoutManager implements ILayoutManager { public MyStaggeredGridLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } public MyStaggeredGridLayoutManager(int spanCount, int orientation) { super(spanCount, orientation); } @Override public RecyclerView.LayoutManager getLayoutManager() { return this; } @Override public int findLastVisiblePosition() { int[] positions = null; positions = findLastVisibleItemPositions(positions); return positions[0]; } @Override public void setUpAdapter(BaseListAdapter adapter) { } }
b0eba334fa44e4f75e5924af5f3f704bd44b598d
76bd8201c2e627c5a2a52cf21f1c34e1108da4c4
/JavaTheHardWay/PrintingChoices.java
b418136385e46a728db86e1feda2b007252b02f9
[]
no_license
jaredm3/SDPre
c0a88116887381809e200069927cc6a2818b3d0f
1054c4f9f63655599a1a4f4cf77cfb5db3426f8e
refs/heads/master
2020-07-06T13:14:28.726003
2019-11-04T19:55:11
2019-11-04T19:55:11
203,029,057
0
0
null
null
null
null
UTF-8
Java
false
false
611
java
public class PrintingChoices { public static void main( String[] args ) { System.out.println( "Alpha" ); System.out.println( "Bravo" ); System.out.println( "Charlie" ); System.out.println( "Delta" ); System.out.println(); System.out.print( "Echo" ); System.out.print( "Foxtrot" ); System.out.println( "Golf" ); System.out.print( "Hotel" ); System.out.println(); System.out.println( "India" ); System.out.println(); System.out.println( "This" + " " + "is" + " " + "a" + " test." ); System.out.println( "I am " + "learning Java " + "the Hard " + "Way!" ); } }
4bf7b9239dec250b016a6c7e536e6f34cdf8fcb4
1bb64892a8adf99800848f33639d8b9536c9ad3b
/app/src/androidTest/java/net/polybugger/apollot/db/ClassItemTypeContractTest.java
8998034875818fa2b3c2e4c736aef9a567354d06
[ "Apache-2.0" ]
permissive
polybugger/ApolloV3
09294a14a719c5335122d6c3df99da27485ad21b
9b741cadc6bdd0d68bf581e7efefd1330ccdd325
refs/heads/master
2021-01-21T04:51:00.321359
2016-07-16T12:54:59
2016-07-16T12:54:59
54,937,064
0
0
null
null
null
null
UTF-8
Java
false
false
7,893
java
package net.polybugger.apollot.db; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.support.test.InstrumentationRegistry; import android.support.test.runner.AndroidJUnit4; import android.test.RenamingDelegatingContext; import android.test.suitebuilder.annotation.MediumTest; import java.util.ArrayList; import net.polybugger.apollot.R; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @MediumTest public class ClassItemTypeContractTest { private SQLiteDatabase mDb; private Context mContext; private long mItemTyp0Id; private String mItemTyp0Description; private String mItemTyp0Color; private long mItemTyp1Id; private String mItemTyp1Description; private String mItemTyp1Color; @Before public void setUp() throws Exception { mContext = new RenamingDelegatingContext(InstrumentationRegistry.getTargetContext(), "test_"); ApolloDbAdapter.setAppContext(mContext); mDb = ApolloDbAdapter.open(); mDb.setForeignKeyConstraintsEnabled(false); mDb.execSQL(ClassItemTypeContract.DELETE_ALL_SQL); ClassItemTypeContract._insertDefaultClassItemTypes(mDb, mContext); mItemTyp0Description = mContext.getString(R.string.default_class_item_type_0); //mItemTyp0Color = mContext.getString(R.string.default_class_item_type_color_0); mItemTyp0Id = ClassItemTypeContract._getEntryByDescription(mDb, mItemTyp0Description).getId(); mItemTyp1Description = mContext.getString(R.string.default_class_item_type_1); //mItemTyp1Color = mContext.getString(R.string.default_class_item_type_color_1); mItemTyp1Id = ClassItemTypeContract._getEntryByDescription(mDb, mItemTyp1Description).getId(); } @After public void tearDown() throws Exception { mDb.execSQL(ClassItemTypeContract.DELETE_ALL_SQL); ClassItemTypeContract._insertDefaultClassItemTypes(mDb, mContext); ApolloDbAdapter.close(); } @Test public void test_methods() throws Exception { ClassItemTypeContract.ClassItemTypeEntry entry = ClassItemTypeContract._getEntry(mDb, mItemTyp0Id); assertEquals(mItemTyp0Id, entry.getId()); assertEquals(mItemTyp0Description, entry.getDescription()); assertEquals(mItemTyp0Color, entry.getColor()); assertNotEquals(mItemTyp0Id, mItemTyp1Id); assertNotEquals(mItemTyp0Description, mItemTyp1Description); assertNotEquals(mItemTyp0Color, mItemTyp1Color); entry.setId(mItemTyp1Id); entry.setDescription(mItemTyp1Description); entry.setColor(mItemTyp1Color); assertEquals(mItemTyp1Id, entry.getId()); assertEquals(mItemTyp1Description, entry.getDescription()); assertEquals(mItemTyp1Color, entry.getColor()); } @Test public void test_getEntryByDescription() throws Exception { ClassItemTypeContract.ClassItemTypeEntry entryByDescription = ClassItemTypeContract._getEntryByDescription(mDb, mItemTyp0Description); assertEquals(mItemTyp0Id, entryByDescription.getId()); assertEquals(mItemTyp0Description, entryByDescription.getDescription()); assertEquals(mItemTyp0Color, entryByDescription.getColor()); } @Test public void test_getEntries() throws Exception { ArrayList<ClassItemTypeContract.ClassItemTypeEntry> entries = ClassItemTypeContract._getEntries(mDb); ClassItemTypeContract.ClassItemTypeEntry entry0 = ClassItemTypeContract._getEntryByDescription(mDb, mContext.getString(R.string.default_class_item_type_0)); ClassItemTypeContract.ClassItemTypeEntry entry0a = ClassItemTypeContract._getEntryByDescription(mDb, mContext.getString(R.string.default_class_item_type_0a)); ClassItemTypeContract.ClassItemTypeEntry entry1 = ClassItemTypeContract._getEntryByDescription(mDb, mContext.getString(R.string.default_class_item_type_1)); ClassItemTypeContract.ClassItemTypeEntry entry1a = ClassItemTypeContract._getEntryByDescription(mDb, mContext.getString(R.string.default_class_item_type_1a)); ClassItemTypeContract.ClassItemTypeEntry entry2 = ClassItemTypeContract._getEntryByDescription(mDb, mContext.getString(R.string.default_class_item_type_2)); ClassItemTypeContract.ClassItemTypeEntry entry3 = ClassItemTypeContract._getEntryByDescription(mDb, mContext.getString(R.string.default_class_item_type_3)); ClassItemTypeContract.ClassItemTypeEntry entry4 = ClassItemTypeContract._getEntryByDescription(mDb, mContext.getString(R.string.default_class_item_type_4)); ClassItemTypeContract.ClassItemTypeEntry entry5 = ClassItemTypeContract._getEntryByDescription(mDb, mContext.getString(R.string.default_class_item_type_5)); ClassItemTypeContract.ClassItemTypeEntry entry6 = ClassItemTypeContract._getEntryByDescription(mDb, mContext.getString(R.string.default_class_item_type_6)); ClassItemTypeContract.ClassItemTypeEntry entry7 = ClassItemTypeContract._getEntryByDescription(mDb, mContext.getString(R.string.default_class_item_type_7)); ClassItemTypeContract.ClassItemTypeEntry entry8 = ClassItemTypeContract._getEntryByDescription(mDb, mContext.getString(R.string.default_class_item_type_8)); ClassItemTypeContract.ClassItemTypeEntry entry9 = ClassItemTypeContract._getEntryByDescription(mDb, mContext.getString(R.string.default_class_item_type_9)); ClassItemTypeContract.ClassItemTypeEntry entry10 = ClassItemTypeContract._getEntryByDescription(mDb, mContext.getString(R.string.default_class_item_type_10)); assertNotNull(entries); assertNotNull(entry0); assertTrue(entries.contains(entry0)); assertNotNull(entry0a); assertTrue(entries.contains(entry0a)); assertNotNull(entry1); assertTrue(entries.contains(entry1)); assertNotNull(entry1a); assertTrue(entries.contains(entry1a)); assertNotNull(entry2); assertTrue(entries.contains(entry2)); assertNotNull(entry3); assertTrue(entries.contains(entry3)); assertNotNull(entry4); assertTrue(entries.contains(entry4)); assertNotNull(entry5); assertTrue(entries.contains(entry5)); assertNotNull(entry6); assertTrue(entries.contains(entry6)); assertNotNull(entry7); assertTrue(entries.contains(entry7)); assertNotNull(entry8); assertTrue(entries.contains(entry8)); assertNotNull(entry9); assertTrue(entries.contains(entry9)); assertNotNull(entry10); assertTrue(entries.contains(entry10)); } @Test public void test_delete() throws Exception { int rowsDeleted = ClassItemTypeContract._delete(mDb, mItemTyp0Id); assertEquals(1, rowsDeleted); rowsDeleted = ClassItemTypeContract._delete(mDb, mItemTyp0Id); assertEquals(0, rowsDeleted); ClassItemTypeContract.ClassItemTypeEntry entry = ClassItemTypeContract._getEntry(mDb, mItemTyp0Id); assertNull(entry); } @Test public void test_update() throws Exception { int rowsUpdated = ClassItemTypeContract._update(mDb, mItemTyp0Id, mItemTyp1Description, mItemTyp1Color); assertEquals(1, rowsUpdated); ClassItemTypeContract.ClassItemTypeEntry entry = ClassItemTypeContract._getEntry(mDb, mItemTyp0Id); assertNotNull(entry); assertEquals(mItemTyp0Id, entry.getId()); assertEquals(mItemTyp1Description, entry.getDescription()); assertEquals(mItemTyp1Color, entry.getColor()); } }
40a7aec3f2775bd340f2977ac856c13dd1a97d4e
a1c9360fde20787aa44db42965af8d8fc68efb32
/app/src/test/java/com/prd/ExampleUnitTest.java
221fa17a80d88acc5c68c011fba2ef4b7fa79811
[]
no_license
isaacbaccah/PRD
4c312b54d2456ffe9af02f2255bcc506d5c3638d
feb75c383af69a903e01066825b3ca71e532da1b
refs/heads/master
2020-03-11T08:17:57.528383
2018-04-26T13:38:33
2018-04-26T13:38:33
129,880,106
0
0
null
null
null
null
UTF-8
Java
false
false
385
java
package com.prd; import org.junit.Test; import static org.junit.Assert.*; /** * Example local unit test, which will execute on the development machine (host). * * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> */ public class ExampleUnitTest { @Test public void addition_isCorrect() throws Exception { assertEquals(4, 2 + 2); } }
66a9bef6a5e211dd3ea339801650b5ed740601ce
133780c480dfc6a1c8d9ebb471e491f7f7032ead
/src/hwe/one/tour/po/Score.java
d499bc9730d6da8b71b582aebae7615afbca82e3
[]
no_license
ShangYiGood/cool
43f3130172d5d5146bdc63d94fea9eb8fedc9b5f
5416af0237f18f40e513e751da6982d6d3e11eaf
refs/heads/master
2020-07-21T02:47:41.890287
2019-09-06T08:23:37
2019-09-06T08:23:37
206,745,577
0
0
null
null
null
null
UTF-8
Java
false
false
631
java
package hwe.one.tour.po; public class Score { private int userId; private int sceneryId; private int score; public int getUserId() { return userId; } public void setUserId(int userId) { this.userId = userId; } public int getSceneryId() { return sceneryId; } public void setSceneryId(int sceneryId) { this.sceneryId = sceneryId; } public int getScore() { return score; } public void setScore(int score) { this.score = score; } @Override public String toString() { return "Score [userId=" + userId + ", sceneryId=" + sceneryId + ", score=" + score + "]"; } }
8fe231b404c5932c35eaf9ed34445d9aa7c5c748
642304f98a2989ca874af1007efa58a22d6bc9b5
/principle/src/main/java/com/zd/lsp/Cricle.java
d6e4c74da2fec453a876cbc52826516f252b8a0c
[]
no_license
VioletZhao/agileDevelopment
05b0929fa7d3e44a0a513d8f7faf2b54d0c1439a
34781d74abb0c4d5a0f6c5da2b4881b434d3ac8d
refs/heads/master
2021-05-06T12:26:12.436081
2017-12-05T04:05:12
2017-12-05T04:05:12
113,130,437
7
1
null
null
null
null
UTF-8
Java
false
false
167
java
package com.zd.lsp; /** * Created by ZD on 2017/10/19. */ public class Cricle extends Shape { Cricle(ShapeType t) { super(t); } void draw(){} }
38da4178731ccb7dd3d48780d76ab42d8b40ab10
51372449753735b64b78e57f0774fd7e99f4838e
/DiscordAuthPluginJava/src/com/inebriatedstudios/DiscordAuth/socketServer.java
c549be39213990109dc75b132108254adff3a436
[]
no_license
dfunston/Discord-Auto-Moderator
64787b14ce7ce302cd95bd555f8f56335d2ddcc5
1f7f3cb785a4ec0aef7dde91840394abd47e4cad
refs/heads/master
2021-01-22T19:13:46.087359
2017-09-06T06:24:01
2017-09-06T06:24:01
102,416,365
1
0
null
null
null
null
UTF-8
Java
false
false
3,292
java
package com.inebriatedstudios.DiscordAuth; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.ServerSocket; import java.net.Socket; import com.google.gson.JsonObject; import com.google.gson.JsonParser; //TODO: //Create initiator and shutdown functions //Thread this sucka to keep it listening //Thread currently closes after first servClient //Make loop? //Yes. Make loop. //Class extends thread to run concurrently with other processes //Otherwise, hangs the server on startup public class socketServer extends Thread { //Create needed variables. //Server stuff private static ServerSocket server; private static Socket servClient; //Parsing data private static InputStream input; //Thread private static Thread t; //Unimplemented for now? private static boolean runFlag = true; //Server listening port private static int listenPort = 1010; //Threaded process. Loops when finished public void run(){ //Do something while(runFlag){ try{ //Wait for servClient connection servClient = server.accept(); //Get servClient input input = servClient.getInputStream(); //Parse servClient input String inputString = socketServer.inputStreamAsString(input); //Do something with it (debug for now) JsonParser parse = new JsonParser(); JsonObject obj = parse.parse(inputString).getAsJsonObject(); System.out.println(inputString); /*switch(obj.get("cmd").toString()){ }*/ //Drop the servClient servClient.close(); } catch (Exception e){ //Maybe ignore //Todo: Don't ignore, filter e.printStackTrace(); } } } public static void startSocket() throws InterruptedException { try{ //Open the server for new connections on port 1010 server = new ServerSocket(listenPort); System.out.println("Websocket Server has started on Localhost.\r\nWaiting for a connection..."); }catch (Exception e){ e.printStackTrace(); } //Start the thread t = new Thread(new socketServer()); t.start(); } public static void closeSocket(){ runFlag = false; //Maybe try creating a dummy connection to the server? //Interrupt the thread if it's still running if(t.isAlive()){ t.interrupt(); } try{ //Close servClient //May just always throw an error. Deal with it. //This is really messy, but everyone seems to agree it's just the best way servClient.shutdownInput(); servClient.close(); }catch(IOException e){ System.out.println("No longer accepting connections. Shutting down with grace."); } try{ //Close server server.close(); }catch(IOException e){ e.printStackTrace(); } } public static String inputStreamAsString(InputStream stream) throws IOException{ //This will read the servClient input and return a string //Eventually will parse JSON BufferedReader br = new BufferedReader(new InputStreamReader(stream)); StringBuilder sb = new StringBuilder(); String line = null; while((line = br.readLine()) != null) { sb.append(line + "\n"); } br.close(); return sb.toString(); } }
472fbdb33dc875f4eb8761fc4563c44128d69cbc
bde48e88df866f6a94c8967f2fa292d086858823
/src/com/ajax/test/dao/UserInfoDAO.java
15fba6c28c604d233029bde1c621fe65d4b17476
[]
no_license
yksong0303/ajaxHome
da66eeb6b04d8e065b939a83b1ff7bd2938ee971
f26e94d7f77bdb8d250b804f3957381d68d7804e
refs/heads/master
2022-12-08T18:04:03.052066
2020-08-13T07:17:45
2020-08-13T07:17:45
286,404,946
0
0
null
null
null
null
UTF-8
Java
false
false
422
java
package com.ajax.test.dao; import java.util.List; import java.util.Map; public interface UserInfoDAO { int insertUserInfo(Map<String,Object> ui); int updateUserInfo(Map<String,Object> ui); int deleteUserInfo(Map<String,Object> ui); Map<String,Object> selectUserInfo(Map<String,Object> ui); Map<String,Object> selectUserInfoByUiId(String uiId); List<Map<String,Object>> selectUserInfoList(Map<String,Object> ui); }
732ab41c583c38661a5a7b1cc26ffbf06dc36377
338ff87ad4c25c918e3ed10f4b16f72643af08e0
/app/src/main/java/njoize/dai_ka/com/demotestprint/CategoryAdapter.java
9b48a3e7ecf22e224cc4cdef83387b15a8813df3
[]
no_license
njoize/ShopPOSnjoize_25decV2
1b207a59722b1875fa2ddf39733a24ca4178ae44
12d1cadb2e4c7b4c1e621a45dd6a63060ff36453
refs/heads/master
2020-04-13T07:50:46.509757
2019-03-11T03:50:17
2019-03-11T03:50:17
163,063,971
0
3
null
2019-03-11T03:50:18
2018-12-25T08:37:50
Java
UTF-8
Java
false
false
2,068
java
package njoize.dai_ka.com.demotestprint; import android.content.Context; import android.support.annotation.NonNull; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import java.util.ArrayList; public class CategoryAdapter extends RecyclerView.Adapter<CategoryAdapter.CategoryViewHolder>{ private Context context; private ArrayList<String> categoryStringArrayList; private OnClickItem onClickItem; private LayoutInflater layoutInflater; public CategoryAdapter(Context context, ArrayList<String> categoryStringArrayList, OnClickItem onClickItem) { this.layoutInflater = LayoutInflater.from(context); this.categoryStringArrayList = categoryStringArrayList; this.onClickItem = onClickItem; } @NonNull @Override public CategoryViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) { View view = layoutInflater.inflate(R.layout.recycler_category, viewGroup, false); CategoryViewHolder categoryViewHolder = new CategoryViewHolder(view); return categoryViewHolder; } @Override public void onBindViewHolder(@NonNull final CategoryViewHolder categoryViewHolder, int i) { String categoryString = categoryStringArrayList.get(i); categoryViewHolder.textView.setText(categoryString); categoryViewHolder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onClickItem.onClickItem(v, categoryViewHolder.getAdapterPosition()); } }); } @Override public int getItemCount() { return categoryStringArrayList.size(); } public class CategoryViewHolder extends RecyclerView.ViewHolder { TextView textView; public CategoryViewHolder(@NonNull View itemView) { super(itemView); textView = itemView.findViewById(R.id.txtcategory); } } }
df0b3d77847bda9b487ac5a76a7bd872fd1be128
c71f843426c780a779bc52be88b48caf1d18222c
/ClientPart/app/src/main/java/com/example/coursework/ControlPanel.java
bacc74dbf141436cf023c0b925d6555f339b3fd7
[]
no_license
Chebotkov/RemoteControl
c23662e46284eed874a6421e673f46da3637bdb2
6db869b510123c734106308984f3b54d4738240e
refs/heads/master
2020-04-11T08:35:48.626439
2018-12-30T14:41:44
2018-12-30T14:41:44
161,648,828
0
0
null
null
null
null
UTF-8
Java
false
false
2,999
java
package com.example.coursework; import android.os.AsyncTask; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.MotionEvent; import android.view.View; import android.widget.Button; import android.widget.ImageView; import android.widget.Toast; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.OutputStream; import java.net.InetAddress; import java.net.Socket; import java.nio.ByteBuffer; import java.nio.ByteOrder; import AdditionalClasses.Commands; public class ControlPanel extends AppCompatActivity implements View.OnTouchListener { private float deltaX = (float)129.111; private float deltaY = (float)-133.5111; private byte command; private String ipAddress; private int port = 10000; private ControlPanel view = this; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle arguments = getIntent().getExtras(); ipAddress = arguments.get("IP").toString(); setContentView(R.layout.activity_control_panel); ImageView image = findViewById(R.id.TouchPad); image.setOnTouchListener(this); } @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_MOVE) { //deltaX = event.getX() - deltaX; //deltaY = event.getY() - deltaY; } if (event.getAction() == MotionEvent.ACTION_DOWN) { command = Commands.moveMouse; new SenderThread().execute(); } return true; } class SenderThread extends AsyncTask<Void, Void, Void> { @Override protected Void doInBackground(Void... params) { try { Socket socket = null; try { InetAddress ip = InetAddress.getByName(ipAddress); socket = new Socket(ip, port); OutputStream outputStream = socket.getOutputStream(); DataOutputStream out = new DataOutputStream(outputStream); DataInputStream in = new DataInputStream(socket.getInputStream()); byte[] parcel = new byte[2]; parcel[0] = 0; parcel[1] = command; out.write(parcel); out.writeFloat(deltaX); out.writeFloat(deltaY); } catch (java.io.IOException e) { e.printStackTrace(); } finally { if (socket != null) { socket.close(); } } } catch(java.io.IOException e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(Void aVoid) { } } }
db69ecc52ab4b11712ec7b6fd28a9094356ab571
69a4f2d51ebeea36c4d8192e25cfb5f3f77bef5e
/methods/Method_28194.java
cb817608d48f9a8bd64f07ecb143f77a9f81163c
[]
no_license
P79N6A/icse_20_user_study
5b9c42c6384502fdc9588430899f257761f1f506
8a3676bc96059ea2c4f6d209016f5088a5628f3c
refs/heads/master
2020-06-24T08:25:22.606717
2019-07-25T15:31:16
2019-07-25T15:31:16
null
0
0
null
null
null
null
UTF-8
Java
false
false
817
java
@Override public void onHandleComment(@NonNull String text,@Nullable Bundle bundle){ if (getView() == null) return; Issue issue=getView().getIssue(); if (issue != null) { if (bundle == null) { CommentRequestModel commentRequestModel=new CommentRequestModel(); commentRequestModel.setBody(text); manageDisposable(RxHelper.getObservable(RestProvider.getIssueService(isEnterprise()).createIssueComment(issue.getLogin(),issue.getRepoId(),issue.getNumber(),commentRequestModel)).doOnSubscribe(disposable -> sendToView(view -> view.showBlockingProgress(0))).subscribe(comment -> sendToView(view -> view.addNewComment(TimelineModel.constructComment(comment))),throwable -> { onError(throwable); sendToView(IssueTimelineMvp.View::onHideBlockingProgress); } )); } } }
e3b84d6ca1064f1311daa6376b6543df8e238729
11776f4e570464f1162e0ebb705bc1134cc33243
/modulo-01/ExercitoDeSaints.java
00894a35fc2969a9e394a5fdede62ded0164e5c5
[]
no_license
cwi-crescer-2017-1/jomar.cardoso
7eabc22fd1f9e4c583a5572c0e036fdd6bb79ea3
6288b18ff029da246d1b523a980b08ba1f9a2a58
refs/heads/master
2021-01-19T08:02:07.398550
2017-07-24T20:35:54
2017-07-24T20:35:54
87,595,702
0
0
null
null
null
null
UTF-8
Java
false
false
872
java
import java.util.ArrayList; public abstract class ExercitoDeSaints { protected ArrayList<Saint> ordemDeBatalha = new ArrayList<>(); public void alistar(Saint saint){ Categoria categoria = saint.getArmadura().getCategoria(); if(categoria.equals(Categoria.BRONZE)) { this.ordemDeBatalha.add(0, saint); } else if(categoria.equals(Categoria.PRATA)) { for(int i = 0 ; i < ordemDeBatalha.size() ; i++) { if(ordemDeBatalha.get(i).getArmadura().getCategoria().equals(Categoria.OURO)) { this.ordemDeBatalha.add(i, saint); return; } } this.ordemDeBatalha.add(saint); } else { this.ordemDeBatalha.add(saint); } } public abstract Saint getProximoSaint(); }
7754943bdff7351fd61335915828b993c1306ce0
d2b48be9cbf494aad41a8a07bfbc6551cacf2f23
/data-providers/data-provider-base/src/main/java/datart/data/provider/calcite/QueryScriptProcessor.java
88439d3e1b83cb64dea73e6df3e2ee975e2dd80a
[ "Apache-2.0" ]
permissive
running-elephant/datart
9a9b1ca11928357dddfcb7a867aa22ae4a474b8a
f52621a3064cd919b631b3cfbc5972edf7501875
refs/heads/master
2023-07-09T14:45:47.307315
2023-04-07T04:34:34
2023-04-07T04:34:34
417,448,864
1,357
470
Apache-2.0
2023-09-06T06:22:32
2021-10-15T09:50:39
TypeScript
UTF-8
Java
false
false
800
java
/* * Datart * <p> * Copyright 2021 * <p> * 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 * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * 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 datart.data.provider.calcite; import datart.core.data.provider.QueryScript; public interface QueryScriptProcessor { QueryScriptProcessResult process(QueryScript queryScript); }
13cf09943df3549d54936202ccf0ed3f279f9ff6
934f45459061929be086410a9d548480c45a6f02
/junit_task/src/main/java/com/ranga/junit_task/App.java
ff6cb1c987054f5cf178d63fce297d5a477745bf
[]
no_license
RangaraoPadarthi/RangaraoPadarthi_junit
6940dcacf388a27bd4668ec23cc09af2fb95ec9d
1e68c9f86f6727c5150a24a5de434db8895282b9
refs/heads/master
2022-12-30T21:06:41.646094
2020-07-22T10:39:40
2020-07-22T10:39:40
281,648,003
0
0
null
2020-10-13T23:48:39
2020-07-22T10:33:07
Java
UTF-8
Java
false
false
196
java
package com.ranga.junit_task; /** * Hello world! * */ public class App { public static void main( String[] args ) { System.out.println( "Hello World!" ); } }
f3a8ec7f8c7d1c775e279a6352e37d8654a86d6e
831ef50a04866027f27ea117c308eeba829d01f2
/core/src/test/java/com/vladmihalcea/book/hpjp/jdbc/fetching/SQLServerResultSetLimitTest.java
ee961dfe138412e3af09557650ec90a799f1e13f
[ "Apache-2.0" ]
permissive
rudyENgithub/high-performance-java-persistence
5750af21f3daa852f83e2a546f56857f07baff3c
45de7277923d751d68b1d4c6026ea98ea3459ec2
refs/heads/master
2021-01-19T01:48:01.100459
2017-04-04T07:44:31
2017-04-04T07:44:31
87,254,232
0
1
null
null
null
null
UTF-8
Java
false
false
5,601
java
package com.vladmihalcea.book.hpjp.jdbc.fetching; import com.vladmihalcea.book.hpjp.util.DataSourceProviderIntegrationTest; import com.vladmihalcea.book.hpjp.util.providers.BlogEntityProvider; import org.hibernate.engine.spi.RowSelection; import org.junit.Test; import org.junit.runners.Parameterized; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.concurrent.TimeUnit; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; /** * SQLServerResultSetLimitTest - Test limiting result set vs fetching and discarding rows * * @author Vlad Mihalcea */ public class SQLServerResultSetLimitTest extends DataSourceProviderIntegrationTest { public static final String INSERT_POST = "insert into post (title, version, id) values (?, ?, ?)"; public static final String INSERT_POST_COMMENT = "insert into post_comment (post_id, review, version, id) values (?, ?, ?, ?)"; public static final String SELECT_POST_COMMENT_1 = "SELECT pc.id AS pc_id, p.id AS p_id " + "FROM post_comment pc " + "INNER JOIN post p ON p.id = pc.post_id "; public static final String SELECT_POST_COMMENT_2 = "SELECT * " + "FROM post_comment pc "; private BlogEntityProvider entityProvider = new BlogEntityProvider(); public SQLServerResultSetLimitTest(DataSourceProvider dataSourceProvider) { super(dataSourceProvider); } @Parameterized.Parameters public static Collection<DataSourceProvider[]> rdbmsDataSourceProvider() { List<DataSourceProvider[]> providers = new ArrayList<>(); providers.add(new DataSourceProvider[]{new SQLServerDataSourceProvider()}); return providers; } @Override protected Class<?>[] entities() { return entityProvider.entities(); } @Override public void init() { super.init(); doInJDBC(connection -> { try ( PreparedStatement postStatement = connection.prepareStatement(INSERT_POST); PreparedStatement postCommentStatement = connection.prepareStatement(INSERT_POST_COMMENT); ) { int postCount = getPostCount(); int postCommentCount = getPostCommentCount(); int index; for (int i = 0; i < postCount; i++) { if (i > 0 && i % 100 == 0) { postStatement.executeBatch(); } index = 0; postStatement.setString(++index, String.format("Post no. %1$d", i)); postStatement.setInt(++index, 0); postStatement.setLong(++index, i); postStatement.addBatch(); } postStatement.executeBatch(); for (int i = 0; i < postCount; i++) { for (int j = 0; j < postCommentCount; j++) { index = 0; postCommentStatement.setLong(++index, i); postCommentStatement.setString(++index, String.format("Post comment %1$d", j)); postCommentStatement.setInt(++index, (int) (Math.random() * 1000)); postCommentStatement.setLong(++index, (postCommentCount * i) + j); postCommentStatement.addBatch(); if (j % 100 == 0) { postCommentStatement.executeBatch(); } } } postCommentStatement.executeBatch(); } catch (SQLException e) { fail(e.getMessage()); } }); } @Test public void testLimit() { RowSelection rowSelection = new RowSelection(); rowSelection.setMaxRows(getMaxRows()); long startNanos = System.nanoTime(); doInJDBC(connection -> { try (PreparedStatement statement1 = connection.prepareStatement(SELECT_POST_COMMENT_1); PreparedStatement statement11 = connection.prepareStatement(SELECT_POST_COMMENT_1); PreparedStatement statement2 = connection.prepareStatement(SELECT_POST_COMMENT_2); ) { statement1.setMaxRows(getMaxRows()); assertEquals(getMaxRows(), processResultSet(statement1)); assertEquals(getPostCommentCount() * getPostCount(), processResultSet(statement11)); assertEquals(getPostCommentCount() * getPostCount(), processResultSet(statement2)); } catch (SQLException e) { fail(e.getMessage()); } }); LOGGER.info("{} Result Set with limit took {} millis", dataSourceProvider().database(), TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNanos)); } protected int processResultSet(PreparedStatement statement) throws SQLException { statement.execute(); int count = 0; ResultSet resultSet = statement.getResultSet(); while (resultSet.next()) { resultSet.getLong(1); count++; } return count; } protected int getPostCount() { return 100; } protected int getPostCommentCount() { return 10; } protected int getMaxRows() { return 5; } @Override protected boolean proxyDataSource() { return false; } }
b02751037839bb919281887b35f1aee78d2a6309
dc2c0a1e63d22474cd8d5370103ec1ed73f5dcfb
/head-first-design-pattern/src/com/test/hfdp/command/RemoteControlTest.java
bad4516f0ec9ce3e01de198c18ba467c1de3f049
[]
no_license
jitu1991/CoreJava
f1af0b4f3af8f0176c0324ba202843a0d362b5a2
8bc74b50e53b2b12bdea3af23a1523c7e563c952
refs/heads/master
2022-07-08T19:45:32.500177
2021-05-04T11:37:02
2021-05-04T11:56:00
137,873,952
0
0
null
null
null
null
UTF-8
Java
false
false
504
java
package com.test.hfdp.command; public class RemoteControlTest { public static void main(String[] args) { SimpleRemoteControl remote = new SimpleRemoteControl(); Light light = new Light(); LightOnCommand lightOnCommand = new LightOnCommand(light); remote.setSlot(lightOnCommand); remote.buttonWasPressed(); GarageDoor garageDoor= new GarageDoor(); GargeDoorOpenCommand doorOpen = new GargeDoorOpenCommand(garageDoor); remote.setSlot(doorOpen); remote.buttonWasPressed(); } }
815055dfb195e4ec521b8868d5a8258b013b1e2e
5c07eef22413aa697a6660fcd0c854b644d41889
/src/main/java/com/api/demo/exception/InvalidSearchParameterException.java
6a67878c591d3c6bc7393b374b4f8093335d92c4
[]
no_license
mercadoaj/simple-springboot-crud-with-mysql
9c560f66d6f78c147c5c36e9f2d046e05236a0cd
7d36d97b3cc402bf92cab9bc896eb8eca4fb381c
refs/heads/main
2023-07-13T11:38:57.694079
2021-08-09T09:12:25
2021-08-09T09:12:25
391,522,362
0
0
null
null
null
null
UTF-8
Java
false
false
227
java
package com.api.demo.exception; public class InvalidSearchParameterException extends RuntimeException { public InvalidSearchParameterException(String param) { super("Invalid Search Parameters. " + param); } }
948ab11a1609fa682787bd1aa27b02b011f046cd
ba83108e8bfa5c6b2e56768985bad5fa6e5eb1f4
/gmall-wms/src/main/java/com/atguigu/gmall/wms/service/ShAreaService.java
d0efe3375f5bd3fb644bc2c8c3bd02e66054232a
[ "Apache-2.0" ]
permissive
wozhendebushihuluwa/gmall
e383e71febab7710858d861328762e1203271f49
a3f30a14eb011bf23428904b2513cc907375e48b
refs/heads/master
2022-12-26T08:06:42.287198
2020-02-11T07:41:44
2020-02-11T07:41:44
231,019,181
0
0
Apache-2.0
2022-12-15T23:35:31
2019-12-31T03:29:25
JavaScript
UTF-8
Java
false
false
461
java
package com.atguigu.gmall.wms.service; import com.baomidou.mybatisplus.extension.service.IService; import com.atguigu.gmall.wms.entity.ShAreaEntity; import com.atguigu.core.bean.PageVo; import com.atguigu.core.bean.QueryCondition; /** * 全国省市区信息 * * @author zhanghuixin * @email [email protected] * @date 2020-01-02 16:36:01 */ public interface ShAreaService extends IService<ShAreaEntity> { PageVo queryPage(QueryCondition params); }
d2a282920f5bbff3cf4da34b15fe93412766d9fd
8af1164bac943cef64e41bae312223c3c0e38114
/results-java/JetBrains--kotlin/8e5f0abb8413a8c325201663b50fcd8a0c68f63b/after/ExpressionTypingServices.java
692812b5eb445d5773ab62568894c1e2513d7667
[]
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
19,168
java
/* * Copyright 2010-2013 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.jet.lang.types.expressions; import com.google.common.base.Function; import com.google.common.collect.Lists; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; import com.intellij.psi.tree.IElementType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; import org.jetbrains.jet.lang.descriptors.FunctionDescriptor; import org.jetbrains.jet.lang.descriptors.impl.FunctionDescriptorUtil; import org.jetbrains.jet.lang.descriptors.ScriptDescriptor; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.*; import org.jetbrains.jet.lang.resolve.calls.CallExpressionResolver; import org.jetbrains.jet.lang.resolve.calls.CallResolver; import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo; import org.jetbrains.jet.lang.resolve.calls.context.ExpressionPosition; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.resolve.scopes.WritableScope; import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl; import org.jetbrains.jet.lang.types.CommonSupertypes; import org.jetbrains.jet.lang.types.ErrorUtils; import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.JetTypeInfo; import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; import org.jetbrains.jet.lexer.JetTokens; import javax.inject.Inject; import java.util.*; import static org.jetbrains.jet.lang.resolve.BindingContext.LABEL_TARGET; import static org.jetbrains.jet.lang.resolve.BindingContext.STATEMENT; import static org.jetbrains.jet.lang.types.TypeUtils.NO_EXPECTED_TYPE; import static org.jetbrains.jet.lang.types.expressions.ExpressionTypingUtils.makeTraceInterceptingTypeMismatch; public class ExpressionTypingServices { private final ExpressionTypingFacade expressionTypingFacade = ExpressionTypingVisitorDispatcher.create(); @NotNull private Project project; @NotNull private CallResolver callResolver; @NotNull private CallExpressionResolver callExpressionResolver; @NotNull private DescriptorResolver descriptorResolver; @NotNull private TypeResolver typeResolver; @NotNull public Project getProject() { return project; } @Inject public void setProject(@NotNull Project project) { this.project = project; } @NotNull public CallResolver getCallResolver() { return callResolver; } @Inject public void setCallResolver(@NotNull CallResolver callResolver) { this.callResolver = callResolver; } @NotNull public CallExpressionResolver getCallExpressionResolver() { return callExpressionResolver; } @Inject public void setCallExpressionResolver(@NotNull CallExpressionResolver callExpressionResolver) { this.callExpressionResolver = callExpressionResolver; } @NotNull public DescriptorResolver getDescriptorResolver() { return descriptorResolver; } @Inject public void setDescriptorResolver(@NotNull DescriptorResolver descriptorResolver) { this.descriptorResolver = descriptorResolver; } @NotNull public TypeResolver getTypeResolver() { return typeResolver; } @Inject public void setTypeResolver(@NotNull TypeResolver typeResolver) { this.typeResolver = typeResolver; } @NotNull public JetType safeGetType(@NotNull JetScope scope, @NotNull JetExpression expression, @NotNull JetType expectedType, @NotNull DataFlowInfo dataFlowInfo, @NotNull BindingTrace trace) { JetType type = getType(scope, expression, expectedType, dataFlowInfo, trace); if (type != null) { return type; } return ErrorUtils.createErrorType("Type for " + expression.getText()); } @NotNull public JetTypeInfo getTypeInfo(@NotNull JetScope scope, @NotNull JetExpression expression, @NotNull JetType expectedType, @NotNull DataFlowInfo dataFlowInfo, @NotNull BindingTrace trace) { ExpressionTypingContext context = ExpressionTypingContext.newContext( this, trace, scope, dataFlowInfo, expectedType, ExpressionPosition.FREE ); return expressionTypingFacade.getTypeInfo(expression, context); } @Nullable public JetType getType(@NotNull JetScope scope, @NotNull JetExpression expression, @NotNull JetType expectedType, @NotNull DataFlowInfo dataFlowInfo, @NotNull BindingTrace trace) { return getTypeInfo(scope, expression, expectedType, dataFlowInfo, trace).getType(); } public JetTypeInfo getTypeInfoWithNamespaces(@NotNull JetExpression expression, @NotNull JetScope scope, @NotNull JetType expectedType, @NotNull DataFlowInfo dataFlowInfo, @NotNull BindingTrace trace) { ExpressionTypingContext context = ExpressionTypingContext.newContext( this, trace, scope, dataFlowInfo, expectedType, ExpressionPosition.LHS_OF_DOT); return expressionTypingFacade.getTypeInfo(expression, context); } @NotNull public JetType inferFunctionReturnType(@NotNull JetScope outerScope, @NotNull JetDeclarationWithBody function, @NotNull FunctionDescriptor functionDescriptor, @NotNull BindingTrace trace) { Map<JetExpression, JetType> typeMap = collectReturnedExpressionsWithTypes(trace, outerScope, function, functionDescriptor); Collection<JetType> types = typeMap.values(); return types.isEmpty() ? KotlinBuiltIns.getInstance().getNothingType() : CommonSupertypes.commonSupertype(types); } ///////////////////////////////////////////////////////// public void checkFunctionReturnType(@NotNull JetScope functionInnerScope, @NotNull JetDeclarationWithBody function, @NotNull FunctionDescriptor functionDescriptor, @NotNull DataFlowInfo dataFlowInfo, @Nullable JetType expectedReturnType, BindingTrace trace) { if (expectedReturnType == null) { expectedReturnType = functionDescriptor.getReturnType(); if (!function.hasBlockBody() && !function.hasDeclaredReturnType()) { expectedReturnType = NO_EXPECTED_TYPE; } } checkFunctionReturnType(function, ExpressionTypingContext.newContext( this, trace, functionInnerScope, dataFlowInfo, expectedReturnType != null ? expectedReturnType : NO_EXPECTED_TYPE, ExpressionPosition.FREE ), trace); } /*package*/ void checkFunctionReturnType(JetDeclarationWithBody function, ExpressionTypingContext context, BindingTrace trace) { JetExpression bodyExpression = function.getBodyExpression(); if (bodyExpression == null) return; boolean blockBody = function.hasBlockBody(); ExpressionTypingContext newContext = blockBody ? context.replaceExpectedType(NO_EXPECTED_TYPE) : context; if (function instanceof JetFunctionLiteral) { JetFunctionLiteral functionLiteral = (JetFunctionLiteral) function; JetBlockExpression blockExpression = functionLiteral.getBodyExpression(); assert blockExpression != null; getBlockReturnedType(newContext.scope, blockExpression, CoercionStrategy.COERCION_TO_UNIT, context, trace); } else { expressionTypingFacade.getTypeInfo(bodyExpression, newContext, !blockBody); } } @NotNull public JetTypeInfo getBlockReturnedType(@NotNull JetScope outerScope, @NotNull JetBlockExpression expression, @NotNull CoercionStrategy coercionStrategyForLastExpression, ExpressionTypingContext context, BindingTrace trace) { List<JetElement> block = expression.getStatements(); DeclarationDescriptor containingDescriptor = outerScope.getContainingDeclaration(); if (containingDescriptor instanceof ScriptDescriptor) { if (!(expression.getParent() instanceof JetScript)) { // top level script declarations should have ScriptDescriptor parent // and lower level script declarations should be ScriptCodeDescriptor parent containingDescriptor = ((ScriptDescriptor) containingDescriptor).getScriptCodeDescriptor(); } } WritableScope scope = new WritableScopeImpl( outerScope, containingDescriptor, new TraceBasedRedeclarationHandler(context.trace), "getBlockReturnedType"); scope.changeLockLevel(WritableScope.LockLevel.BOTH); JetTypeInfo r; if (block.isEmpty()) { r = DataFlowUtils.checkType(KotlinBuiltIns.getInstance().getUnitType(), expression, context, context.dataFlowInfo); } else { r = getBlockReturnedTypeWithWritableScope(scope, block, coercionStrategyForLastExpression, context, trace); } scope.changeLockLevel(WritableScope.LockLevel.READING); if (containingDescriptor instanceof ScriptDescriptor) { trace.record(BindingContext.SCRIPT_SCOPE, (ScriptDescriptor) containingDescriptor, scope); } return r; } private Map<JetExpression, JetType> collectReturnedExpressionsWithTypes( final @NotNull BindingTrace trace, JetScope outerScope, final JetDeclarationWithBody function, FunctionDescriptor functionDescriptor) { JetExpression bodyExpression = function.getBodyExpression(); assert bodyExpression != null; JetScope functionInnerScope = FunctionDescriptorUtil.getFunctionInnerScope(outerScope, functionDescriptor, trace); expressionTypingFacade.getTypeInfo(bodyExpression, ExpressionTypingContext.newContext( this, trace, functionInnerScope, DataFlowInfo.EMPTY, NO_EXPECTED_TYPE, ExpressionPosition.FREE), !function.hasBlockBody()); //todo function literals final Collection<JetExpression> returnedExpressions = Lists.newArrayList(); if (function.hasBlockBody()) { //now this code is never invoked!, it should be invoked for inference of return type of function literal with local returns bodyExpression.accept(new JetTreeVisitor<JetDeclarationWithBody>() { @Override public Void visitReturnExpression(JetReturnExpression expression, JetDeclarationWithBody outerFunction) { JetSimpleNameExpression targetLabel = expression.getTargetLabel(); PsiElement element = targetLabel != null ? trace.get(LABEL_TARGET, targetLabel) : null; if (element == function || (targetLabel == null && outerFunction == function)) { returnedExpressions.add(expression); } return null; } @Override public Void visitFunctionLiteralExpression(JetFunctionLiteralExpression expression, JetDeclarationWithBody outerFunction) { return super.visitFunctionLiteralExpression(expression, expression.getFunctionLiteral()); } @Override public Void visitNamedFunction(JetNamedFunction function, JetDeclarationWithBody outerFunction) { return super.visitNamedFunction(function, function); } }, function); } else { returnedExpressions.add(bodyExpression); } Map<JetExpression, JetType> typeMap = new HashMap<JetExpression, JetType>(); for (JetExpression returnedExpression : returnedExpressions) { JetType cachedType = trace.getBindingContext().get(BindingContext.EXPRESSION_TYPE, returnedExpression); trace.record(STATEMENT, returnedExpression, false); if (cachedType != null) { typeMap.put(returnedExpression, cachedType); } else { typeMap.put(returnedExpression, ErrorUtils.createErrorType("Error function type")); } } return typeMap; } /*package*/ @SuppressWarnings("SuspiciousMethodCalls") JetTypeInfo getBlockReturnedTypeWithWritableScope(@NotNull WritableScope scope, @NotNull List<? extends JetElement> block, @NotNull CoercionStrategy coercionStrategyForLastExpression, ExpressionTypingContext context, BindingTrace trace) { if (block.isEmpty()) { return JetTypeInfo.create(KotlinBuiltIns.getInstance().getUnitType(), context.dataFlowInfo); } ExpressionTypingInternals blockLevelVisitor = ExpressionTypingVisitorDispatcher.createForBlock(scope); ExpressionTypingContext newContext = createContext(context, trace, scope, context.dataFlowInfo, NO_EXPECTED_TYPE); JetTypeInfo result = JetTypeInfo.create(null, context.dataFlowInfo); for (Iterator<? extends JetElement> iterator = block.iterator(); iterator.hasNext(); ) { JetElement statement = iterator.next(); if (!(statement instanceof JetExpression)) { continue; } trace.record(STATEMENT, statement); JetExpression statementExpression = (JetExpression) statement; //TODO constructor assert context.expectedType != FORBIDDEN : "" if (!iterator.hasNext()) { if (context.expectedType != NO_EXPECTED_TYPE) { if (coercionStrategyForLastExpression == CoercionStrategy.COERCION_TO_UNIT && KotlinBuiltIns.getInstance().isUnit(context.expectedType)) { // This implements coercion to Unit TemporaryBindingTrace temporaryTraceExpectingUnit = TemporaryBindingTrace.create(trace, "trace to resolve coercion to unit with expected type"); boolean[] mismatch = new boolean[1]; ObservableBindingTrace errorInterceptingTrace = makeTraceInterceptingTypeMismatch(temporaryTraceExpectingUnit, statementExpression, mismatch); newContext = createContext(newContext, errorInterceptingTrace, scope, newContext.dataFlowInfo, context.expectedType); result = blockLevelVisitor.getTypeInfo(statementExpression, newContext, true); if (mismatch[0]) { TemporaryBindingTrace temporaryTraceNoExpectedType = TemporaryBindingTrace.create(trace, "trace to resolve coercion to unit without expected type"); mismatch[0] = false; ObservableBindingTrace interceptingTrace = makeTraceInterceptingTypeMismatch(temporaryTraceNoExpectedType, statementExpression, mismatch); newContext = createContext(newContext, interceptingTrace, scope, newContext.dataFlowInfo, NO_EXPECTED_TYPE); result = blockLevelVisitor.getTypeInfo(statementExpression, newContext, true); if (mismatch[0]) { temporaryTraceExpectingUnit.commit(); } else { temporaryTraceNoExpectedType.commit(); } } else { temporaryTraceExpectingUnit.commit(); } } else { newContext = createContext(newContext, trace, scope, newContext.dataFlowInfo, context.expectedType); result = blockLevelVisitor.getTypeInfo(statementExpression, newContext, true); } } else { result = blockLevelVisitor.getTypeInfo(statementExpression, newContext, true); if (coercionStrategyForLastExpression == CoercionStrategy.COERCION_TO_UNIT) { boolean mightBeUnit = false; if (statementExpression instanceof JetDeclaration) { mightBeUnit = true; } if (statementExpression instanceof JetBinaryExpression) { JetBinaryExpression binaryExpression = (JetBinaryExpression) statementExpression; IElementType operationType = binaryExpression.getOperationToken(); if (operationType == JetTokens.EQ || OperatorConventions.ASSIGNMENT_OPERATIONS.containsKey(operationType)) { mightBeUnit = true; } } if (mightBeUnit) { // ExpressionTypingVisitorForStatements should return only null or Unit for declarations and assignments assert result.getType() == null || KotlinBuiltIns.getInstance().isUnit(result.getType()); result = JetTypeInfo.create(KotlinBuiltIns.getInstance().getUnitType(), newContext.dataFlowInfo); } } } } else { result = blockLevelVisitor.getTypeInfo(statementExpression, newContext, true); } DataFlowInfo newDataFlowInfo = result.getDataFlowInfo(); if (newDataFlowInfo != context.dataFlowInfo) { newContext = createContext(newContext, trace, scope, newDataFlowInfo, NO_EXPECTED_TYPE); } blockLevelVisitor = ExpressionTypingVisitorDispatcher.createForBlock(scope); } return result; } private ExpressionTypingContext createContext(ExpressionTypingContext oldContext, BindingTrace trace, WritableScope scope, DataFlowInfo dataFlowInfo, JetType expectedType) { return ExpressionTypingContext.newContext( this, oldContext.labelResolver, trace, scope, dataFlowInfo, expectedType, oldContext.expressionPosition); } @Nullable public JetExpression deparenthesize( @NotNull JetExpression expression, @NotNull final ExpressionTypingContext context) { return JetPsiUtil.deparenthesizeWithResolutionStrategy(expression, new Function<JetTypeReference, Void>() { @Override public Void apply(JetTypeReference reference) { getTypeResolver().resolveType(context.scope, reference, context.trace, true); return null; } }); } }
04f76e3a5a585ddd4c57e238afaf0af52e2bbe48
6cbc47a79abc839c24f542fdbfc281f5189f30c9
/src/main/java/hamburg/remme/lwjgl/engine/texture/ImageLoader.java
31312ecc36d17c1c7c5a426968cb2a8cd3bb778b
[ "MIT" ]
permissive
dremme/lwjgl-engine
c72bb936b82b1e63ca468c39f3d8abe57e971ea3
6da09dcdb15245248da4346a64b0cbfcfe49dd67
refs/heads/master
2020-03-23T00:29:24.533113
2018-12-21T11:38:52
2018-12-21T11:38:52
140,866,616
1
0
null
null
null
null
UTF-8
Java
false
false
2,147
java
package hamburg.remme.lwjgl.engine.texture; import static java.lang.Math.round; import static java.nio.file.Files.readAllBytes; import static org.lwjgl.BufferUtils.createByteBuffer; import static org.lwjgl.stb.STBImage.stbi_info_from_memory; import static org.lwjgl.stb.STBImage.stbi_load_from_memory; import static org.lwjgl.system.MemoryStack.stackPush; import hamburg.remme.lwjgl.engine.shader.ShaderFactory; import java.nio.ByteBuffer; import java.nio.file.Paths; import lombok.SneakyThrows; import lombok.experimental.UtilityClass; import lombok.val; @UtilityClass public class ImageLoader { public Image load(String imageFile) { val raw = readFile(imageFile); try (val stack = stackPush()) { val pWidth = stack.mallocInt(1); val pHeight = stack.mallocInt(1); val pComp = stack.mallocInt(1); stbi_info_from_memory(raw, pWidth, pHeight, pComp); val data = stbi_load_from_memory(raw, pWidth, pHeight, pComp, 0); // Pre-multiply alpha values for correctness if there is an alpha channel if (pComp.get() == 4) premultiplyAlpha(data, pWidth.get(0), pHeight.get(0)); return new Image(pWidth.get(0), pHeight.get(0), pComp.get(0), data); } } @SneakyThrows private ByteBuffer readFile(String file) { val uri = ImageLoader.class.getResource(file).toURI(); val bytes = readAllBytes(Paths.get(uri)); val buffer = createByteBuffer(bytes.length); buffer.put(bytes); buffer.flip(); return buffer; } private void premultiplyAlpha(ByteBuffer data, int w, int h) { val stride = w * 4; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { val i = y * stride + x * 4; val alpha = (data.get(i + 3) & 0xFF) / 255.0f; data.put(i + 0, (byte) round(((data.get(i + 0) & 0xFF) * alpha))); data.put(i + 1, (byte) round(((data.get(i + 1) & 0xFF) * alpha))); data.put(i + 2, (byte) round(((data.get(i + 2) & 0xFF) * alpha))); } } } }
b08b00dcc39f174d34a560ea7848cceed1430a02
8bcff0700c64c841b6231334188f93b36a9e138e
/app/src/main/java/cz/pikadorama/uome/fragment/GroupListTransactionsFragment.java
cf7af7f9d877a311cd44b9a5525c85928ea77d9c
[]
no_license
natix643/uome
70f7dae2a6aad142c67f5705ad91accf7638f535
1196d6a620d0b0c64b0629dbd296a9a3dcf8d3ce
refs/heads/master
2021-12-07T10:49:05.327924
2021-10-17T10:28:57
2021-10-17T10:28:57
49,818,962
1
0
null
2021-10-17T10:28:58
2016-01-17T13:44:59
Java
UTF-8
Java
false
false
840
java
package cz.pikadorama.uome.fragment; import com.madgag.android.listviews.ViewHoldingListAdapter; import java.util.List; import cz.pikadorama.uome.adapter.viewholder.TransactionViewHolder; import cz.pikadorama.uome.common.Constants; import cz.pikadorama.uome.model.Transaction; public class GroupListTransactionsFragment extends ListTransactionsFragment { @Override protected List<Transaction> filter(List<Transaction> transactions) { return transactions; } @Override protected long getGroupId() { return requireArgument(Constants.GROUP_ID); } @Override protected ViewHoldingListAdapter<Transaction> createAdapter() { return TransactionViewHolder.forGroupDebts(getBaseActivity()); } @Override protected boolean canEditTransactions() { return false; } }
bdffb5f8d0269eee0b4503ddca7a781692bdb466
1eda3bb6cc5d9e6dde6960cd40c112a5f7e9ba37
/src/main/java/eu/gillissen/topicus/loader/UserLoader.java
330453026eb0c41a05504d2f0d7b544ec54c889d
[]
no_license
Witik/Gifkikker
65bebcc43a87a0de81b383fa064decafecce446a
8ba7b4809fc78efa0d247ea6000f5c9a26f52107
refs/heads/master
2021-01-13T11:16:43.910624
2017-02-14T10:03:55
2017-02-14T10:03:55
81,395,005
0
0
null
null
null
null
UTF-8
Java
false
false
2,061
java
package eu.gillissen.topicus.loader; import eu.gillissen.topicus.model.Address; import eu.gillissen.topicus.model.User; import eu.gillissen.topicus.repositories.UserRepository; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationListener; import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.stereotype.Component; /** * Populates the database with user-information. */ @Component public class UserLoader implements ApplicationListener<ContextRefreshedEvent> { private Logger logger = Logger.getLogger(UserLoader.class); private UserRepository userRepository; @Autowired public UserLoader(UserRepository userRepository) { this.userRepository = userRepository; } @Override public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) { User admin = new User(); admin.setName("admin"); admin.setPassword("admin"); admin.setRole("ADMIN"); User saved = userRepository.save(admin); logger.info("Saved " + saved.getName() + " - " + saved.getId()); Address address = new Address(); address.setCity("Deventer"); address.setHouseNumber("69"); address.setNumberAddition("b"); address.setPostalCode("1337XD"); address.setStreet("Edwinstraat"); address.setRecipient("Edwin van de Ridder"); User edwin = new User(); edwin.setName("edwin"); edwin.setPassword("edwin"); edwin.setRole("USER"); edwin.setAddress(address); saved = userRepository.save(edwin); logger.info("Saved " + saved.getName() + " - " + saved.getId()); User user = new User(); user.setName("user"); user.setPassword("user"); user.setRole("USER"); saved = userRepository.save(user); logger.info("Saved " + saved.getName() + " - " + saved.getId()); } }
9c9a48437b7aef877aed4eaf6806a9780ea78dc4
29a0f6e0f327905bd0f3badf96cba1764c62e1fc
/src/main/java/com/devsuperior/movieflix/resources/exceptions/FieldMessage.java
4ad7c4890a650aa104ef7c212f462f28f0333bb2
[]
no_license
teixeira17/movieflix
c18d08dc3a04329fa3bc7150dec5b45966a1984b
96e6e88186130fc7cc7f5dcb404fcbfd4e0d5290
refs/heads/master
2023-08-14T09:52:08.986978
2021-10-19T22:52:19
2021-10-19T22:52:19
null
0
0
null
null
null
null
UTF-8
Java
false
false
663
java
package com.devsuperior.movieflix.resources.exceptions; import java.io.Serializable; public class FieldMessage implements Serializable { private static final long serialVersionUID = 1L; private String fieldName; private String message; public FieldMessage() { } public FieldMessage(String fieldName, String message) { super(); this.fieldName = fieldName; this.message = message; } public String getFieldName() { return fieldName; } public void setFieldName(String fieldName) { this.fieldName = fieldName; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } }
ad05f28e3d64c8014d29189fee23a52851bc0fdb
11517952a4f206f62534a209752b09595add7fa6
/app/src/main/java/com/example/rh/artlive/activity/OutFitActivity.java
37f7b7e752d48da25f24985b80090458073b482a
[]
no_license
xunliguo/ArtLive
9da237e4f8704aa32b9d9a2b736379f4da82c04c
fae8f6fe5b95d91e66fdd255122e3dd779df7609
refs/heads/master
2021-05-13T12:09:28.893635
2018-01-08T10:56:28
2018-01-08T10:56:28
116,664,524
0
0
null
null
null
null
UTF-8
Java
false
false
15,902
java
package com.example.rh.artlive.activity; import android.content.Intent; import android.graphics.drawable.BitmapDrawable; import android.os.Bundle; import android.support.v4.app.FragmentManager; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.OrientationHelper; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.PopupWindow; import android.widget.SimpleAdapter; import android.widget.TextView; import com.alibaba.fastjson.JSON; import com.example.rh.artlive.R; import com.example.rh.artlive.adapter.OutFitAdapter; import com.example.rh.artlive.adapter.TeacherAdapter; import com.example.rh.artlive.bean.HomeBean; import com.example.rh.artlive.bean.OutFitBean; import com.example.rh.artlive.util.HttpUtil; import com.example.rh.artlive.util.Log; import com.example.rh.artlive.util.SharedPerfenceConstant; import com.example.rh.artlive.util.UrlConstant; import com.example.rh.artlive.view.LoadRecyclerView; import com.example.rh.artlive.view.OnItemClickListener; import com.example.rh.artlive.view.PullToRefreshLayout; import com.zhy.http.okhttp.callback.StringCallback; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import okhttp3.Call; /** * Created by rh on 2017/11/20. */ public class OutFitActivity extends BaseFragmentActivity implements View.OnClickListener,PullToRefreshLayout.OnRefreshListener,LoadRecyclerView.LoadListener,OnItemClickListener<OutFitBean> { private static final String MENU_DATA_KEY = "name"; private int supplierMenuIndex = 0; private ImageView mShowDraw; private PullToRefreshLayout mAuto; private LoadRecyclerView mLoad; private OutFitAdapter mChestAdapter; private ArrayList<OutFitBean> mData = new ArrayList<>(); private GridLayoutManager mManager; private List<Map<String, String>> mMenuData1 = new ArrayList<>();; //默认 private List<Map<String, String>> mMenuData2 = new ArrayList<>();; //品牌 private List<Map<String, String>> mMenuData3 = new ArrayList<>();; //种类 private ListView mPopListView; private PopupWindow mPopupWindow; private SimpleAdapter mMenuAdapter1; private SimpleAdapter mMenuAdapter2; private SimpleAdapter mMenuAdapter3; private LinearLayout mSupplierListProduct; private LinearLayout mSupplierListSort; private LinearLayout mSupplierListActivity; private TextView mSupplierListTvProduct; private TextView mSupplierListTvSort; private TextView mSupplierListTvActivity; List<String> tea_list ; List<String> tea_list1 ; List<String> tea_list2 ; private String mMoir=""; private String mCity=""; private String mSchool=""; private int pageNo=1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_outfit); init(); getTeacherClass(); setAdapter(); setListener(); initPopMenu(); initData(getSupportFragmentManager(),mMoir,mCity,mSchool); } private void init(){ mSupplierListTvProduct = (TextView) findViewById(R.id.around_supplier_list_tv_product); mSupplierListTvSort = (TextView) findViewById(R.id.around_supplier_list_tv_sort); mSupplierListTvActivity = (TextView) findViewById(R.id.around_supplier_list_tv_activity); mSupplierListProduct = (LinearLayout) findViewById(R.id.around_supplier_list_product); mSupplierListSort = (LinearLayout) findViewById(R.id.around_supplier_list_sort); mSupplierListActivity = (LinearLayout) findViewById(R.id.around_supplier_list_activity); mAuto = (PullToRefreshLayout)findViewById(R.id.network_pager_myAuto); mLoad = (LoadRecyclerView) findViewById(R.id.network_myLoad); mManager = new GridLayoutManager(this, 2); mShowDraw=(ImageView)findViewById(R.id.showDraw); LinearLayoutManager lm=new LinearLayoutManager(this); lm.setOrientation(OrientationHelper.VERTICAL); mLoad.setLayoutManager(lm); mLoad.setLayoutManager(mManager); } private void setListener(){ mAuto.setOnRefreshListener(this); mLoad.setLoadListener(this); mShowDraw.setOnClickListener(this); mSupplierListProduct.setOnClickListener(this); mSupplierListSort.setOnClickListener(this); mSupplierListActivity.setOnClickListener(this); } private void setAdapter() { mChestAdapter = new OutFitAdapter(this, R.layout.recycler_outfit_adapter, mData); mLoad.setAdapter(mChestAdapter); mLoad.setIsHaveData(false); mChestAdapter.setOnItemClickListener(this); } /** * 三个列表popu文件的数据 */ private void getTeacherClass(){ tea_list = new ArrayList<String>(); tea_list1 = new ArrayList<String>(); tea_list2 = new ArrayList<String>(); HashMap<String, String> map = new HashMap<>(); map.put("access_token",mSharePreferenceUtil.getString(SharedPerfenceConstant.TOKEN)); HttpUtil.postHttpRequstProgess(OutFitActivity.this, "正在加载", UrlConstant.OUTFIT_DOWN, map, new StringCallback() { @Override public void onError(Call call, Exception e) { } @Override public void onResponse(String response) { Log.e("机构下拉"+response); JSONObject jsonObject; try { jsonObject = new JSONObject(response); if (jsonObject.has("data")) { JSONObject data = jsonObject.getJSONObject("data"); //专业 JSONArray major=data.getJSONArray("major"); for (int i = 0; i < data.length(); i++) { JSONObject obj = major.getJSONObject(i); tea_list.add(obj.getString("tag_name")); } int size=tea_list.size(); String[] array = (String[])tea_list.toArray(new String[size]); for(int i=0;i<array.length;i++){ Map<String, String> map = new HashMap<>(); map.put(MENU_DATA_KEY, array[i]); mMenuData1.add(map); } //所在地 JSONArray local=data.getJSONArray("address"); for (int i=0;i<local.length();i++){ JSONObject obj=local.getJSONObject(i); tea_list1.add(obj.getString("city_name")); } int size1=tea_list1.size(); String[] array1 = (String[])tea_list1.toArray(new String[size1]); for(int i=0;i<array1.length;i++){ Map<String, String> map = new HashMap<>(); map.put(MENU_DATA_KEY, array1[i]); mMenuData2.add(map); } //排序 JSONArray sort=data.getJSONArray("paixu"); for (int i=0;i<sort.length();i++){ JSONObject obj=sort.getJSONObject(i); tea_list2.add(obj.getString("sort")); } int size2=tea_list2.size(); String[] array2 = (String[])tea_list2.toArray(new String[size2]); for(int i=0;i<array2.length;i++){ Map<String, String> map = new HashMap<>(); map.put(MENU_DATA_KEY, array2[i]); mMenuData3.add(map); } } } catch (JSONException e) { e.printStackTrace(); } } }, "dataleaseclass", null); } private void initData(FragmentManager fm,String mMoir, String mCity, String mSchool){ mData = new ArrayList<>(); HashMap<String, String> map = new HashMap<>(); map.put("access_token",mSharePreferenceUtil.getString(SharedPerfenceConstant.TOKEN)); map.put("major",mMoir); map.put("city",mCity); map.put("school",mSchool); HttpUtil.postHttpRequstProgess(this, "正在加载", UrlConstant.OUTFIT, map, new StringCallback() { @Override public void onError(Call call, Exception e) { mAuto.refreshFinish(PullToRefreshLayout.FAIL); } @Override public void onResponse(String response) { Log.e("机构数据"+response); mAuto.refreshFinish(PullToRefreshLayout.FAIL); JSONObject jsonObject; try { jsonObject = new JSONObject(response); if ("1".equals(jsonObject.getString("state"))) { if (jsonObject.has("data")) { JSONObject data=jsonObject.getJSONObject("data"); JSONArray inst=data.getJSONArray("institution"); for (int i=0;i<inst.length();i++){ JSONObject bobject=inst.getJSONObject(i); OutFitBean homeBean= JSON.parseObject(bobject.toString(), OutFitBean.class); mData.add(homeBean); } setAdapter(); } } } catch (JSONException e) { e.printStackTrace(); } } }, "teacher", fm); } @Override public void onClick(View v) { switch (v.getId()){ case R.id.showDraw: finish(); break; case R.id.around_supplier_list_product: mSupplierListTvProduct.setTextColor(getResources().getColor(R.color.around_supplier_title_selected_color)); mPopListView.setAdapter(mMenuAdapter1); mPopupWindow.showAsDropDown(mSupplierListProduct, 0, 2); supplierMenuIndex = 0; break; case R.id.around_supplier_list_sort: mSupplierListTvSort.setTextColor(getResources().getColor(R.color.around_supplier_title_selected_color)); mPopListView.setAdapter(mMenuAdapter2); mPopupWindow.showAsDropDown(mSupplierListSort, 0, 2); supplierMenuIndex = 1; break; case R.id.around_supplier_list_activity: mSupplierListTvActivity.setTextColor(getResources().getColor(R.color.around_supplier_title_selected_color)); mPopListView.setAdapter(mMenuAdapter3); mPopupWindow.showAsDropDown(mSupplierListActivity, 0, 2); supplierMenuIndex = 2; break; } } /** * popu文件 */ private void initPopMenu() { View popView = LayoutInflater.from(this).inflate(R.layout.layout_popwin_supplier_list, null); mPopListView = (ListView) popView.findViewById(R.id.popwin_list_view); mPopupWindow = new PopupWindow(popView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); mPopupWindow.setOutsideTouchable(true); mPopupWindow.setBackgroundDrawable(new BitmapDrawable()); mPopupWindow.setFocusable(true); mPopupWindow.setAnimationStyle(R.style.popwin_anim_style); mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { mSupplierListTvProduct.setTextColor(getResources().getColor(R.color.around_supplier_title_color)); mSupplierListTvSort.setTextColor(getResources().getColor(R.color.around_supplier_title_color)); mSupplierListTvActivity.setTextColor(getResources().getColor(R.color.around_supplier_title_color)); } }); popView.findViewById(R.id.popwin_bottom).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mPopupWindow.dismiss(); } }); /** * 用来显示item的标题 */ mMenuAdapter1 = new SimpleAdapter(this, mMenuData1, R.layout.item_popwin_list, new String[]{"name"}, new int[]{R.id.item_popwin_tv}); mMenuAdapter2 = new SimpleAdapter(this, mMenuData2, R.layout.item_popwin_list, new String[]{"name"}, new int[]{R.id.item_popwin_tv}); mMenuAdapter3 = new SimpleAdapter(this, mMenuData3, R.layout.item_popwin_list, new String[]{"name"}, new int[]{R.id.item_popwin_tv}); /** * 获取点击item 的name */ mPopListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { switch (supplierMenuIndex) { case 0: mMoir=mMenuData1.get(i).get(MENU_DATA_KEY); mSupplierListTvProduct.setText(mMenuData1.get(i).get(MENU_DATA_KEY)); mPopupWindow.dismiss(); Log.e("点击的专业"+mMoir); initData(getSupportFragmentManager(),mMoir,mCity,mSchool); break; case 1: mCity=mMenuData2.get(i).get(MENU_DATA_KEY); mSupplierListTvSort.setText(mMenuData2.get(i).get(MENU_DATA_KEY)); mPopupWindow.dismiss(); Log.e("点击的城市"+mCity); initData(getSupportFragmentManager(),mMoir,mCity,mSchool); break; case 2: mSchool=mMenuData3.get(i).get(MENU_DATA_KEY); mSupplierListTvActivity.setText(mMenuData3.get(i).get(MENU_DATA_KEY)); mPopupWindow.dismiss(); Log.e("点击的排序"+mSchool); initData(getSupportFragmentManager(),mMoir,mCity,mSchool); break; default: break; } } }); } @Override public void onItemClick(ViewGroup parent, View view, OutFitBean s, int position) { Intent intent=new Intent(OutFitActivity.this,OutFitMainActivity.class); intent.putExtra("inst_id",s.getInst_id()); startActivity(intent); } @Override public boolean onItemLongClick(ViewGroup parent, View view, OutFitBean s, int position) { return false; } @Override public void onLoad() { } @Override public void loadFinish() { } @Override public void onRefresh(PullToRefreshLayout pullToRefreshLayout) { mLoad.setIsHaveData(false); pageNo = 1; mData = new ArrayList<>(); initData(getSupportFragmentManager(),mMoir,mCity,mSchool); } @Override public void onLoadMore(PullToRefreshLayout pullToRefreshLayout) { pageNo=pageNo+1; initData(null,mMoir,mCity,mSchool); } }
70fd92f343bba1c144c9992836a456f63b16431d
c5b42be4908b741add31c6fb500e83bfae56ce4e
/ClipChildren/gen/com/example/clipchildren/Manifest.java
da1b3a744ec8af8735678e3d01f09584afd28402
[]
no_license
alexlzl/JavaDemo2
804674d3fd52412e9c7f92867c330fc39c06abd0
cc23c1adf604f227d3fb954ba3970df7f421830b
refs/heads/master
2021-01-20T11:00:09.685749
2018-06-05T09:58:37
2018-06-05T09:58:37
101,659,065
0
0
null
null
null
null
UTF-8
Java
false
false
194
java
/*___Generated_by_IDEA___*/ package com.example.clipchildren; /* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */ public final class Manifest { }