-
Notifications
You must be signed in to change notification settings - Fork 1
/
ViewDownInterface.m
191 lines (161 loc) · 5.58 KB
/
ViewDownInterface.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
//
// ViewDownInterface.m
// ADAM - Ausbau der Digitalisierung im Anlagenmanagement
//
// Created by Jonathan Lucas Fritz on 14.08.16.
// Copyright © 2016 NOSCIO. All rights reserved.
//
#import "ViewDownInterface.h"
#import "NosFrame.h"
#import "outrepasser.h"
//ist eigentlich alles selbsterklärend.
@implementation ViewDownInterface
NosFrame *framer;
UILabel *bigg;
UIImageView *imageview;
UIActivityIndicatorView *loadingimage;
int actindex;
-(void)setup
{
framer = [[NosFrame alloc]init];
framer.main = self;
}
-(void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
printf("\n HELLO ");
NSString *message;
UIAlertController *control;
control = [UIAlertController alertControllerWithTitle:(@"Informationen") message:message preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *action;
action = [UIAlertAction actionWithTitle:(@"Schließen") style:UIAlertActionStyleDefault handler:nil];
[control addAction:action];
[self.mapviewadam.viewc presentViewController:control animated:YES completion:nil];
}
-(void)sethiddennow
{
[bigg removeFromSuperview];
[imageview removeFromSuperview];
[loadingimage removeFromSuperview];
self.hidden = YES;
}
-(void)loadforID:(NSString *)ID
{
self.hidden = NO;
// https://adam.noncd.db.de/api/v1.0/stations/27
// NSString *number;
// number = [self typeforquipmentnumber:ID];
// NSLog(@"%@",number);
self.backgroundColor = [UIColor whiteColor];
// if ([ID containsString:(@"Aufzug")])
// {
// clean = [ID stringByReplacingOccurrencesOfString:(@"Aufzug bei Station: ") withString:(@"")];
// }
// if ([ID containsString:(@"Rolltreppe")])
// {
// clean = [ID stringByReplacingOccurrencesOfString:(@"Rolltreppe bei Station: ") withString:(@"")];
// }
//
// NSLog(@"%@",ID);
[self typeforquipmentnumber:ID];
}
-(void)typeforquipmentnumber:(NSString*)ID
{
NSString *nameofstation_;
nameofstation_ = (@"Name: ");
// https://adam.noncd.db.de/api/v1.0/stations/27
// NSString *urlstring;
// urlstring = (@"https://adam.noncd.db.de/api/v1.0/stations/");
// urlstring = [urlstring stringByAppendingString:ID];
//
// NSURL *url=[NSURL URLWithString:urlstring];
//
// NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
// [request setURL:url];
// [request setHTTPMethod:@"GET"];
//
// NSError *error;
// NSURLResponse *response;
// NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
//
// NSMutableDictionary *dicti;
// dicti = [self dicfromdata:urlData];
//
// NSString *nameders;
// nameders = [dicti valueForKey:(@"name")];
// nameofstation_ = [self.bonjour.stationnumberfornames valueForKey:ID];
// NSLog(@"%@",self.bonjour.stationnumberfornames.description);
//
imageview = [[UIImageView alloc]initWithFrame:self.frame];
[self.mapviewadam addSubview:imageview];
loadingimage = [[UIActivityIndicatorView alloc]initWithFrame:self.frame];
loadingimage.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
loadingimage.backgroundColor = [UIColor whiteColor];
[self.mapviewadam addSubview:loadingimage];
[loadingimage startAnimating];
bigg = [[UILabel alloc]initWithFrame:self.frame];
[bigg setFont:[UIFont systemFontOfSize:self.frame.size.height/5]];
bigg.textAlignment = NSTextAlignmentCenter;
if ([nummerbahnnow valueForKey:ID])
{
bigg.text = [nummerbahnnow valueForKey:ID];
}
bigg.numberOfLines = 2;
bigg.alpha = 0.6;
bigg.backgroundColor = [UIColor whiteColor];
[self.mapviewadam addSubview:bigg];
// NSLog(@"%@",nameofstation_);
}
-(void)setimageurl:(NSString *)url
{
[self loadImage:[NSURL URLWithString:url]];
}
- (void)loadImage:(NSURL *)imageURL
{
NSOperationQueue *queue = [NSOperationQueue new];
NSInvocationOperation *operation = [[NSInvocationOperation alloc]
initWithTarget:self
selector:@selector(requestRemoteImage:)
object:imageURL];
[queue addOperation:operation];
}
- (void)requestRemoteImage:(NSURL *)imageURL
{
NSLog(@"%@",imageURL.absoluteString);
NSData *imageData = [[NSData alloc] initWithContentsOfURL:imageURL];
UIImage *image = [[UIImage alloc] initWithData:imageData];
[self performSelectorOnMainThread:@selector(placeImageInUI:) withObject:image waitUntilDone:YES];
}
- (void)placeImageInUI:(UIImage *)image
{
if (![self image:[UIImage imageNamed:(@"streetview-1.jpeg")] isEqualTo:image])
{
[imageview setImage:image];
imageview.contentMode = UIViewContentModeScaleToFill;
[loadingimage stopAnimating];
[loadingimage removeFromSuperview];
loadingimage = nil;
}
else
{
printf("\n Image is same.");
imageview.image = nil;
imageview = nil;
[loadingimage stopAnimating];
[loadingimage removeFromSuperview];
loadingimage = nil;
}
}
- (BOOL)image:(UIImage *)image1 isEqualTo:(UIImage *)image2
{
NSData *data1 = UIImagePNGRepresentation(image1);
NSData *data2 = UIImagePNGRepresentation(image2);
return [data1 isEqual:data2];
}
-(NSMutableDictionary*)dicfromdata:(NSData*)responseData
{
NSError* error;
NSMutableDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];
// NSLog(@"%@",json.description);
return json;
}
@end