Skip to content

Commit

Permalink
Final updates for release
Browse files Browse the repository at this point in the history
  • Loading branch information
RadiationG0D committed Dec 1, 2013
1 parent aa57709 commit 6026a51
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 80 deletions.
6 changes: 3 additions & 3 deletions Alleinfo/res/layout/detailview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@

</RelativeLayout>

<RelativeLayout
<RelativeLayout
android:id="@+id/separator"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#33B5E5"
android:layout_below="@+id/top" />
android:layout_below="@+id/top"
android:background="#FFFFFF" />

<TextView
android:id="@+id/textView2"
Expand Down
124 changes: 86 additions & 38 deletions Alleinfo/src/com/alleit/alleinfo/Home.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.alleit.alleinfo;

import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import java.util.Locale;

import com.actionbarsherlock.app.ActionBar;
Expand Down Expand Up @@ -330,52 +332,65 @@ private void makeNewsSub() {
rubrik.setText(listData[0].headline);
info.setText(listData[0].description);
desc.setText(listData[0].longDescription);
if(listData[0].handler.contains(Html.fromHtml(Karlista.Ename).toString().toUpperCase(Locale.ENGLISH)))
{

if (listData[0].handler.contains(Html.fromHtml(Karlista.Ename)
.toString().toUpperCase(Locale.ENGLISH))) {
Pic.setImageDrawable(getResources().getDrawable(
R.drawable.elevkaren));
separator.setBackgroundColor(Color.parseColor(Karlista.Ecolor));
} else if(listData[0].handler.contains(Html.fromHtml(Karlista.PRname).toString().toUpperCase(Locale.ENGLISH)))
{
Pic.setImageDrawable(getResources().getDrawable(
R.drawable.pr));
separator.setBackgroundColor(Color.parseColor(Karlista.PRcolor));

} else if(listData[0].handler.contains(Html.fromHtml(Karlista.Fname).toString().toUpperCase(Locale.ENGLISH)))
{
} else if (listData[0].handler.contains(Html
.fromHtml(Karlista.PRname).toString()
.toUpperCase(Locale.ENGLISH))) {
Pic.setImageDrawable(getResources().getDrawable(R.drawable.pr));
separator
.setBackgroundColor(Color.parseColor(Karlista.PRcolor));

} else if (listData[0].handler.contains(Html
.fromHtml(Karlista.Fname).toString()
.toUpperCase(Locale.ENGLISH))) {
Pic.setImageDrawable(getResources().getDrawable(
R.drawable.festare));
separator.setBackgroundColor(Color.parseColor(Karlista.Fcolor));

} else if(listData[0].handler.contains(Html.fromHtml(Karlista.spexname).toString().toUpperCase(Locale.ENGLISH)))
{
Pic.setImageDrawable(getResources().getDrawable(
R.drawable.spex));
separator.setBackgroundColor(Color.parseColor(Karlista.spexcolor));

} else if(listData[0].handler.contains(Html.fromHtml(Karlista.IFname).toString().toUpperCase(Locale.ENGLISH)))
{

} else if (listData[0].handler.contains(Html
.fromHtml(Karlista.spexname).toString()
.toUpperCase(Locale.ENGLISH))) {
Pic.setImageDrawable(getResources()
.getDrawable(R.drawable.spex));
separator.setBackgroundColor(Color
.parseColor(Karlista.spexcolor));

} else if (listData[0].handler.contains(Html
.fromHtml(Karlista.IFname).toString()
.toUpperCase(Locale.ENGLISH))) {
Pic.setImageDrawable(getResources().getDrawable(
R.drawable.skolif));
separator.setBackgroundColor(Color.parseColor(Karlista.IFcolor));

} else if(listData[0].handler.contains(Html.fromHtml(Karlista.ITname).toString().toUpperCase(Locale.ENGLISH)))
{
separator
.setBackgroundColor(Color.parseColor(Karlista.IFcolor));

} else if (listData[0].handler.contains(Html
.fromHtml(Karlista.ITname).toString()
.toUpperCase(Locale.ENGLISH))) {
Pic.setImageDrawable(getResources().getDrawable(
R.drawable.alleit));
separator.setBackgroundColor(Color.parseColor(Karlista.ITcolor));

separator
.setBackgroundColor(Color.parseColor(Karlista.ITcolor));

} else {
Toast.makeText(getApplicationContext(), Html.fromHtml("Nyheten kunde inte l&aumlsas in"), Toast.LENGTH_SHORT).show();
makeNews();
Toast.makeText(getApplicationContext(),
Html.fromHtml("Ingen ansvarig elevf&ouml;rening kunde hittas"),
Toast.LENGTH_SHORT).show();
}


but.setText("Mer info");

String url = listData[0].butURL;

if(url.length() == 0)
{
but.setVisibility(View.INVISIBLE);
}

final String finURL = url;

but.setOnClickListener(new OnClickListener() {
Expand Down Expand Up @@ -608,12 +623,22 @@ private void prepFeed() {
@Override
public void run() {

listData = Webber.getTinyNewsFeed();
List<NewsInfo> temp = Arrays.asList(Webber.getTinyNewsFeed());

if (temp.isEmpty()) {
listData = new NewsInfo[0];
} else {
int i = 0;
listData = new NewsInfo[temp.size()];
for (NewsInfo NI : temp) {
listData[i] = NI;
i++;
}
}

runOnUiThread(new Runnable() {
public void run() {
if(listData.length == 0)
{
if (listData.length == 0) {
listData = new NewsInfo[1];
listData[0] = new NewsInfo();
listData[0].headline = "Inga nyheter hittades";
Expand All @@ -636,7 +661,7 @@ public void onItemClick(AdapterView<?> parent, View view,
if (listData[position].contentType == 1) {
makeNews();
} else {
if(listData[position].contentType != -1)
if (listData[position].contentType != -1)
ShowSpecNews(listData[position].uniqeIdentifier);
}
}
Expand All @@ -648,12 +673,23 @@ public void onItemClick(AdapterView<?> parent, View view,
@Override
public void run() {

listData = Webber.getNews("", Mode.All);
List<NewsInfo> temp = Arrays.asList(Webber.getNews("",
Mode.All));

if (temp.isEmpty()) {
listData = new NewsInfo[0];
} else {
int i = 0;
listData = new NewsInfo[temp.size()];
for (NewsInfo NI : temp) {
listData[i] = NI;
i++;
}
}

runOnUiThread(new Runnable() {
public void run() {
if(listData.length == 0)
{
if (listData.length == 0) {
listData = new NewsInfo[1];
listData[0] = new NewsInfo();
listData[0].headline = "Inga nyheter hittades";
Expand Down Expand Up @@ -689,7 +725,19 @@ private void ShowSpecNews(final String uniqeIdentifier) {
@Override
public void run() {

listData = Webber.getNews(uniqeIdentifier, Mode.Specific);
List<NewsInfo> temp = Arrays.asList(Webber.getNews(
uniqeIdentifier, Mode.Specific));

if (temp.isEmpty()) {
listData = new NewsInfo[0];
} else {
int i = 0;
listData = new NewsInfo[temp.size()];
for (NewsInfo NI : temp) {
listData[i] = NI;
i++;
}
}

runOnUiThread(new Runnable() {
public void run() {
Expand All @@ -698,7 +746,7 @@ public void run() {
} else {
Toast.makeText(
getApplicationContext(),
Html.fromHtml("Nyheten kunde inte hittas.<br>Laddar om"),
Html.fromHtml("Nyheten kunde inte hittas."),
Toast.LENGTH_SHORT).show();
prepFeed();
}
Expand Down
12 changes: 10 additions & 2 deletions Alleinfo/src/com/alleit/alleinfo/NewsFeedAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ public View getView(int position, View convertView, ViewGroup parent) {
TextView handler = (TextView) rowView.findViewById(R.id.handler);
handler.setText(datas[position].handler);

if (datas[position].handler != null) {
checkColor(handler, position);
} else {
handler.setTextColor(Color.BLACK);
}

return rowView;
}

private void checkColor(TextView handler, int position) {
if (datas[position].handler.contains(Html.fromHtml(Karlista.Ename)
.toString().toUpperCase(Locale.ENGLISH))) {
handler.setTextColor(Color.parseColor(Karlista.Ecolor));
Expand Down Expand Up @@ -72,7 +82,5 @@ public View getView(int position, View convertView, ViewGroup parent) {
} else {
handler.setTextColor(Color.BLACK);
}

return rowView;
}
}
94 changes: 57 additions & 37 deletions Alleinfo/src/com/alleit/alleinfo/Webber.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.alleit.alleinfo;

import java.util.Arrays;
import java.util.Calendar;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
Expand All @@ -12,6 +14,7 @@

import android.content.Context;
import android.graphics.Point;
import android.text.Html;

public class Webber {

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

// for each new feed update
NewsInfo data = null;
feed = new NewsInfo[3];
NewsInfo[] temp = getNews("", Mode.All);

if(temp.length == 0)
return new NewsInfo[0];

for (int i = 0; i < 2; i++) {
feed[i] = temp[i];
}
List<NewsInfo> temp = Arrays.asList(getNews("", Mode.All));

// news info, show more news
data = new NewsInfo();
data.headline = "Fler nyheter...";
data.type = null;
data.handler = null;
data.contentType = 1;
data.uniqeIdentifier = null;
feed[2] = data;
if (temp.isEmpty())
return new NewsInfo[0];

if (temp.size() > 2) {
feed = new NewsInfo[3];
feed[0] = temp.get(0);
feed[1] = temp.get(1);

// news info, show more news
data = new NewsInfo();
data.headline = "Fler nyheter...";
data.type = null;
data.handler = null;
data.contentType = 1;
data.uniqeIdentifier = null;
feed[2] = data;
} else {
int i = 0;
feed = new NewsInfo[temp.size()];
for (NewsInfo NI : temp) {
feed[i] = NI;
i++;
}
}
// return value
return feed;
}
Expand All @@ -188,32 +198,35 @@ public static NewsInfo[] getNews(String uniqeIdentifier, Mode returnMode) {
HttpEntity entity = response.getEntity();
htmlResponse = EntityUtils.toString(entity);
} catch (Exception e) {

e.printStackTrace();
return new NewsInfo[0];
}
if(htmlResponse.contains(",") == false)
{
if (htmlResponse.contains("~") == false) {
return new NewsInfo[0];
}
String[] delimitered = htmlResponse.split(",");
String[] delimitered = htmlResponse.split("~");

if (returnMode == Mode.All) {
NewsInfo[] data = new NewsInfo[delimitered.length / 7];
for (int i = 0, x = 0; i < delimitered.length; i++) {
for (int i = 0, x = 0; i < data.length; i++) {
data[i] = new NewsInfo();
data[i].headline = delimitered[x];
data[i].headline = String
.valueOf(Html.fromHtml(delimitered[x]));
x++;
data[i].description = delimitered[x];
data[i].description = String.valueOf(Html
.fromHtml(delimitered[x]));
x++;
data[i].longDescription = delimitered[x];
data[i].longDescription = String.valueOf(Html
.fromHtml(delimitered[x]));
x++;
data[i].butURL = delimitered[x];
data[i].butURL = String.valueOf(Html.fromHtml(delimitered[x]));
x++;
data[i].type = delimitered[x];
data[i].type = String.valueOf(Html.fromHtml(delimitered[x]));
x++;
data[i].handler = delimitered[x];
data[i].handler = String.valueOf(Html.fromHtml(delimitered[x]));
x++;
data[i].uniqeIdentifier = delimitered[x];
data[i].uniqeIdentifier = String.valueOf(Html
.fromHtml(delimitered[x]));
x++;
data[i].contentType = 0;
}
Expand All @@ -226,16 +239,23 @@ public static NewsInfo[] getNews(String uniqeIdentifier, Mode returnMode) {
private static NewsInfo[] extractSpecificNews(String uniqeIdentifier,
String[] delimitered) {
for (int i = 6; i < delimitered.length; i += 7) {
if (delimitered[i].contains("uniqeIdentifier")) {
if (delimitered[i].contains(uniqeIdentifier)) {
NewsInfo[] data = new NewsInfo[1];
data[0] = new NewsInfo();
data[0].headline = delimitered[i - 6];
data[0].description = delimitered[i - 5];
data[0].longDescription = delimitered[i - 4];
data[0].butURL = delimitered[i - 3];
data[0].type = delimitered[i - 2];
data[0].handler = delimitered[i - 1];
data[0].uniqeIdentifier = delimitered[i];
data[0].headline = String.valueOf(Html
.fromHtml(delimitered[i - 6]));
data[0].description = String.valueOf(Html
.fromHtml(delimitered[i - 5]));
data[0].longDescription = String.valueOf(Html
.fromHtml(delimitered[i - 4]));
data[0].butURL = String.valueOf(Html
.fromHtml(delimitered[i - 3]));
data[0].type = String
.valueOf(Html.fromHtml(delimitered[i - 2]));
data[0].handler = String.valueOf(Html
.fromHtml(delimitered[i - 1]));
data[0].uniqeIdentifier = String.valueOf(Html
.fromHtml(delimitered[i]));
data[0].contentType = 0;
return data;
}
Expand Down
Binary file modified library/bin/library.jar
Binary file not shown.

0 comments on commit 6026a51

Please sign in to comment.