Skip to content

Commit 6026a51

Browse files
author
RadiationG0D
committed
Final updates for release
1 parent aa57709 commit 6026a51

File tree

5 files changed

+156
-80
lines changed

5 files changed

+156
-80
lines changed

Alleinfo/res/layout/detailview.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@
6262

6363
</RelativeLayout>
6464

65-
<RelativeLayout
65+
<RelativeLayout
6666
android:id="@+id/separator"
6767
android:layout_width="fill_parent"
6868
android:layout_height="2dp"
69-
android:background="#33B5E5"
70-
android:layout_below="@+id/top" />
69+
android:layout_below="@+id/top"
70+
android:background="#FFFFFF" />
7171

7272
<TextView
7373
android:id="@+id/textView2"

Alleinfo/src/com/alleit/alleinfo/Home.java

Lines changed: 86 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.alleit.alleinfo;
22

3+
import java.util.Arrays;
34
import java.util.Calendar;
5+
import java.util.List;
46
import java.util.Locale;
57

68
import com.actionbarsherlock.app.ActionBar;
@@ -330,52 +332,65 @@ private void makeNewsSub() {
330332
rubrik.setText(listData[0].headline);
331333
info.setText(listData[0].description);
332334
desc.setText(listData[0].longDescription);
333-
334-
if(listData[0].handler.contains(Html.fromHtml(Karlista.Ename).toString().toUpperCase(Locale.ENGLISH)))
335-
{
335+
336+
if (listData[0].handler.contains(Html.fromHtml(Karlista.Ename)
337+
.toString().toUpperCase(Locale.ENGLISH))) {
336338
Pic.setImageDrawable(getResources().getDrawable(
337339
R.drawable.elevkaren));
338340
separator.setBackgroundColor(Color.parseColor(Karlista.Ecolor));
339-
} else if(listData[0].handler.contains(Html.fromHtml(Karlista.PRname).toString().toUpperCase(Locale.ENGLISH)))
340-
{
341-
Pic.setImageDrawable(getResources().getDrawable(
342-
R.drawable.pr));
343-
separator.setBackgroundColor(Color.parseColor(Karlista.PRcolor));
344-
345-
} else if(listData[0].handler.contains(Html.fromHtml(Karlista.Fname).toString().toUpperCase(Locale.ENGLISH)))
346-
{
341+
} else if (listData[0].handler.contains(Html
342+
.fromHtml(Karlista.PRname).toString()
343+
.toUpperCase(Locale.ENGLISH))) {
344+
Pic.setImageDrawable(getResources().getDrawable(R.drawable.pr));
345+
separator
346+
.setBackgroundColor(Color.parseColor(Karlista.PRcolor));
347+
348+
} else if (listData[0].handler.contains(Html
349+
.fromHtml(Karlista.Fname).toString()
350+
.toUpperCase(Locale.ENGLISH))) {
347351
Pic.setImageDrawable(getResources().getDrawable(
348352
R.drawable.festare));
349353
separator.setBackgroundColor(Color.parseColor(Karlista.Fcolor));
350-
351-
} else if(listData[0].handler.contains(Html.fromHtml(Karlista.spexname).toString().toUpperCase(Locale.ENGLISH)))
352-
{
353-
Pic.setImageDrawable(getResources().getDrawable(
354-
R.drawable.spex));
355-
separator.setBackgroundColor(Color.parseColor(Karlista.spexcolor));
356-
357-
} else if(listData[0].handler.contains(Html.fromHtml(Karlista.IFname).toString().toUpperCase(Locale.ENGLISH)))
358-
{
354+
355+
} else if (listData[0].handler.contains(Html
356+
.fromHtml(Karlista.spexname).toString()
357+
.toUpperCase(Locale.ENGLISH))) {
358+
Pic.setImageDrawable(getResources()
359+
.getDrawable(R.drawable.spex));
360+
separator.setBackgroundColor(Color
361+
.parseColor(Karlista.spexcolor));
362+
363+
} else if (listData[0].handler.contains(Html
364+
.fromHtml(Karlista.IFname).toString()
365+
.toUpperCase(Locale.ENGLISH))) {
359366
Pic.setImageDrawable(getResources().getDrawable(
360367
R.drawable.skolif));
361-
separator.setBackgroundColor(Color.parseColor(Karlista.IFcolor));
362-
363-
} else if(listData[0].handler.contains(Html.fromHtml(Karlista.ITname).toString().toUpperCase(Locale.ENGLISH)))
364-
{
368+
separator
369+
.setBackgroundColor(Color.parseColor(Karlista.IFcolor));
370+
371+
} else if (listData[0].handler.contains(Html
372+
.fromHtml(Karlista.ITname).toString()
373+
.toUpperCase(Locale.ENGLISH))) {
365374
Pic.setImageDrawable(getResources().getDrawable(
366375
R.drawable.alleit));
367-
separator.setBackgroundColor(Color.parseColor(Karlista.ITcolor));
368-
376+
separator
377+
.setBackgroundColor(Color.parseColor(Karlista.ITcolor));
378+
369379
} else {
370-
Toast.makeText(getApplicationContext(), Html.fromHtml("Nyheten kunde inte l&aumlsas in"), Toast.LENGTH_SHORT).show();
371-
makeNews();
380+
Toast.makeText(getApplicationContext(),
381+
Html.fromHtml("Ingen ansvarig elevf&ouml;rening kunde hittas"),
382+
Toast.LENGTH_SHORT).show();
372383
}
373384

374-
375385
but.setText("Mer info");
376386

377387
String url = listData[0].butURL;
378388

389+
if(url.length() == 0)
390+
{
391+
but.setVisibility(View.INVISIBLE);
392+
}
393+
379394
final String finURL = url;
380395

381396
but.setOnClickListener(new OnClickListener() {
@@ -608,12 +623,22 @@ private void prepFeed() {
608623
@Override
609624
public void run() {
610625

611-
listData = Webber.getTinyNewsFeed();
626+
List<NewsInfo> temp = Arrays.asList(Webber.getTinyNewsFeed());
627+
628+
if (temp.isEmpty()) {
629+
listData = new NewsInfo[0];
630+
} else {
631+
int i = 0;
632+
listData = new NewsInfo[temp.size()];
633+
for (NewsInfo NI : temp) {
634+
listData[i] = NI;
635+
i++;
636+
}
637+
}
612638

613639
runOnUiThread(new Runnable() {
614640
public void run() {
615-
if(listData.length == 0)
616-
{
641+
if (listData.length == 0) {
617642
listData = new NewsInfo[1];
618643
listData[0] = new NewsInfo();
619644
listData[0].headline = "Inga nyheter hittades";
@@ -636,7 +661,7 @@ public void onItemClick(AdapterView<?> parent, View view,
636661
if (listData[position].contentType == 1) {
637662
makeNews();
638663
} else {
639-
if(listData[position].contentType != -1)
664+
if (listData[position].contentType != -1)
640665
ShowSpecNews(listData[position].uniqeIdentifier);
641666
}
642667
}
@@ -648,12 +673,23 @@ public void onItemClick(AdapterView<?> parent, View view,
648673
@Override
649674
public void run() {
650675

651-
listData = Webber.getNews("", Mode.All);
676+
List<NewsInfo> temp = Arrays.asList(Webber.getNews("",
677+
Mode.All));
678+
679+
if (temp.isEmpty()) {
680+
listData = new NewsInfo[0];
681+
} else {
682+
int i = 0;
683+
listData = new NewsInfo[temp.size()];
684+
for (NewsInfo NI : temp) {
685+
listData[i] = NI;
686+
i++;
687+
}
688+
}
652689

653690
runOnUiThread(new Runnable() {
654691
public void run() {
655-
if(listData.length == 0)
656-
{
692+
if (listData.length == 0) {
657693
listData = new NewsInfo[1];
658694
listData[0] = new NewsInfo();
659695
listData[0].headline = "Inga nyheter hittades";
@@ -689,7 +725,19 @@ private void ShowSpecNews(final String uniqeIdentifier) {
689725
@Override
690726
public void run() {
691727

692-
listData = Webber.getNews(uniqeIdentifier, Mode.Specific);
728+
List<NewsInfo> temp = Arrays.asList(Webber.getNews(
729+
uniqeIdentifier, Mode.Specific));
730+
731+
if (temp.isEmpty()) {
732+
listData = new NewsInfo[0];
733+
} else {
734+
int i = 0;
735+
listData = new NewsInfo[temp.size()];
736+
for (NewsInfo NI : temp) {
737+
listData[i] = NI;
738+
i++;
739+
}
740+
}
693741

694742
runOnUiThread(new Runnable() {
695743
public void run() {
@@ -698,7 +746,7 @@ public void run() {
698746
} else {
699747
Toast.makeText(
700748
getApplicationContext(),
701-
Html.fromHtml("Nyheten kunde inte hittas.<br>Laddar om"),
749+
Html.fromHtml("Nyheten kunde inte hittas."),
702750
Toast.LENGTH_SHORT).show();
703751
prepFeed();
704752
}

Alleinfo/src/com/alleit/alleinfo/NewsFeedAdapter.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ public View getView(int position, View convertView, ViewGroup parent) {
4141
TextView handler = (TextView) rowView.findViewById(R.id.handler);
4242
handler.setText(datas[position].handler);
4343

44+
if (datas[position].handler != null) {
45+
checkColor(handler, position);
46+
} else {
47+
handler.setTextColor(Color.BLACK);
48+
}
49+
50+
return rowView;
51+
}
52+
53+
private void checkColor(TextView handler, int position) {
4454
if (datas[position].handler.contains(Html.fromHtml(Karlista.Ename)
4555
.toString().toUpperCase(Locale.ENGLISH))) {
4656
handler.setTextColor(Color.parseColor(Karlista.Ecolor));
@@ -72,7 +82,5 @@ public View getView(int position, View convertView, ViewGroup parent) {
7282
} else {
7383
handler.setTextColor(Color.BLACK);
7484
}
75-
76-
return rowView;
7785
}
7886
}

Alleinfo/src/com/alleit/alleinfo/Webber.java

Lines changed: 57 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.alleit.alleinfo;
22

3+
import java.util.Arrays;
34
import java.util.Calendar;
5+
import java.util.List;
46

57
import org.apache.http.HttpEntity;
68
import org.apache.http.HttpHost;
@@ -12,6 +14,7 @@
1214

1315
import android.content.Context;
1416
import android.graphics.Point;
17+
import android.text.Html;
1518

1619
public class Webber {
1720

@@ -152,25 +155,32 @@ public static NewsInfo[] getTinyNewsFeed() {
152155

153156
// for each new feed update
154157
NewsInfo data = null;
155-
feed = new NewsInfo[3];
156-
NewsInfo[] temp = getNews("", Mode.All);
157-
158-
if(temp.length == 0)
159-
return new NewsInfo[0];
160-
161-
for (int i = 0; i < 2; i++) {
162-
feed[i] = temp[i];
163-
}
158+
List<NewsInfo> temp = Arrays.asList(getNews("", Mode.All));
164159

165-
// news info, show more news
166-
data = new NewsInfo();
167-
data.headline = "Fler nyheter...";
168-
data.type = null;
169-
data.handler = null;
170-
data.contentType = 1;
171-
data.uniqeIdentifier = null;
172-
feed[2] = data;
160+
if (temp.isEmpty())
161+
return new NewsInfo[0];
173162

163+
if (temp.size() > 2) {
164+
feed = new NewsInfo[3];
165+
feed[0] = temp.get(0);
166+
feed[1] = temp.get(1);
167+
168+
// news info, show more news
169+
data = new NewsInfo();
170+
data.headline = "Fler nyheter...";
171+
data.type = null;
172+
data.handler = null;
173+
data.contentType = 1;
174+
data.uniqeIdentifier = null;
175+
feed[2] = data;
176+
} else {
177+
int i = 0;
178+
feed = new NewsInfo[temp.size()];
179+
for (NewsInfo NI : temp) {
180+
feed[i] = NI;
181+
i++;
182+
}
183+
}
174184
// return value
175185
return feed;
176186
}
@@ -188,32 +198,35 @@ public static NewsInfo[] getNews(String uniqeIdentifier, Mode returnMode) {
188198
HttpEntity entity = response.getEntity();
189199
htmlResponse = EntityUtils.toString(entity);
190200
} catch (Exception e) {
191-
192201
e.printStackTrace();
193202
return new NewsInfo[0];
194203
}
195-
if(htmlResponse.contains(",") == false)
196-
{
204+
if (htmlResponse.contains("~") == false) {
197205
return new NewsInfo[0];
198206
}
199-
String[] delimitered = htmlResponse.split(",");
207+
String[] delimitered = htmlResponse.split("~");
208+
200209
if (returnMode == Mode.All) {
201210
NewsInfo[] data = new NewsInfo[delimitered.length / 7];
202-
for (int i = 0, x = 0; i < delimitered.length; i++) {
211+
for (int i = 0, x = 0; i < data.length; i++) {
203212
data[i] = new NewsInfo();
204-
data[i].headline = delimitered[x];
213+
data[i].headline = String
214+
.valueOf(Html.fromHtml(delimitered[x]));
205215
x++;
206-
data[i].description = delimitered[x];
216+
data[i].description = String.valueOf(Html
217+
.fromHtml(delimitered[x]));
207218
x++;
208-
data[i].longDescription = delimitered[x];
219+
data[i].longDescription = String.valueOf(Html
220+
.fromHtml(delimitered[x]));
209221
x++;
210-
data[i].butURL = delimitered[x];
222+
data[i].butURL = String.valueOf(Html.fromHtml(delimitered[x]));
211223
x++;
212-
data[i].type = delimitered[x];
224+
data[i].type = String.valueOf(Html.fromHtml(delimitered[x]));
213225
x++;
214-
data[i].handler = delimitered[x];
226+
data[i].handler = String.valueOf(Html.fromHtml(delimitered[x]));
215227
x++;
216-
data[i].uniqeIdentifier = delimitered[x];
228+
data[i].uniqeIdentifier = String.valueOf(Html
229+
.fromHtml(delimitered[x]));
217230
x++;
218231
data[i].contentType = 0;
219232
}
@@ -226,16 +239,23 @@ public static NewsInfo[] getNews(String uniqeIdentifier, Mode returnMode) {
226239
private static NewsInfo[] extractSpecificNews(String uniqeIdentifier,
227240
String[] delimitered) {
228241
for (int i = 6; i < delimitered.length; i += 7) {
229-
if (delimitered[i].contains("uniqeIdentifier")) {
242+
if (delimitered[i].contains(uniqeIdentifier)) {
230243
NewsInfo[] data = new NewsInfo[1];
231244
data[0] = new NewsInfo();
232-
data[0].headline = delimitered[i - 6];
233-
data[0].description = delimitered[i - 5];
234-
data[0].longDescription = delimitered[i - 4];
235-
data[0].butURL = delimitered[i - 3];
236-
data[0].type = delimitered[i - 2];
237-
data[0].handler = delimitered[i - 1];
238-
data[0].uniqeIdentifier = delimitered[i];
245+
data[0].headline = String.valueOf(Html
246+
.fromHtml(delimitered[i - 6]));
247+
data[0].description = String.valueOf(Html
248+
.fromHtml(delimitered[i - 5]));
249+
data[0].longDescription = String.valueOf(Html
250+
.fromHtml(delimitered[i - 4]));
251+
data[0].butURL = String.valueOf(Html
252+
.fromHtml(delimitered[i - 3]));
253+
data[0].type = String
254+
.valueOf(Html.fromHtml(delimitered[i - 2]));
255+
data[0].handler = String.valueOf(Html
256+
.fromHtml(delimitered[i - 1]));
257+
data[0].uniqeIdentifier = String.valueOf(Html
258+
.fromHtml(delimitered[i]));
239259
data[0].contentType = 0;
240260
return data;
241261
}

library/bin/library.jar

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)