Jobbat med att få färgruta på MinDag
This commit is contained in:
13
.gitignore
vendored
13
.gitignore
vendored
@@ -1,3 +1,16 @@
|
|||||||
|
# Skip application files
|
||||||
|
*.apk
|
||||||
|
*.ap_
|
||||||
|
|
||||||
|
# files for the dex VM
|
||||||
|
*.dex
|
||||||
|
|
||||||
|
# Java class files
|
||||||
|
*.class
|
||||||
|
|
||||||
|
# generated files
|
||||||
bin/
|
bin/
|
||||||
gen/
|
gen/
|
||||||
|
|
||||||
|
# Local configuration file (sdk path, etc)
|
||||||
|
local.properties
|
||||||
|
|||||||
@@ -2,45 +2,48 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical" >
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/mydayTitle"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingTop="6dip"
|
|
||||||
android:textColor="@color/general_title"
|
|
||||||
android:textSize="20sp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/mydayDate"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="left"
|
|
||||||
android:paddingBottom="4dip"
|
|
||||||
android:textColor="#acacac"
|
|
||||||
android:textSize="12sp" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/mydayTag"
|
android:id="@+id/mydayTag"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="left"
|
android:gravity="left" />
|
||||||
android:paddingBottom="4dip"
|
|
||||||
android:textColor="#acacac"
|
|
||||||
android:textSize="12sp" />
|
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/mydayDescription"
|
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="#acacac"
|
android:orientation="vertical" >
|
||||||
android:textSize="14sp" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/mydayLink"
|
android:id="@+id/mydayTitle"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="invisible" />
|
android:paddingTop="6dip"
|
||||||
|
android:textColor="@color/general_title"
|
||||||
|
android:textSize="20sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/mydayDate"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="left"
|
||||||
|
android:paddingBottom="4dip"
|
||||||
|
android:textColor="#acacac"
|
||||||
|
android:textSize="12sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/mydayDescription"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="#acacac"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/mydayLink"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:visibility="invisible" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -2,29 +2,40 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="?android:attr/listPreferredItemHeight"
|
android:layout_height="?android:attr/listPreferredItemHeight"
|
||||||
android:orientation="vertical"
|
android:orientation="horizontal"
|
||||||
android:padding="6dip" >
|
android:padding="6dip" >
|
||||||
|
|
||||||
<TextView
|
<ImageView
|
||||||
android:id="@+id/tweet_from"
|
android:id="@+id/twitterPic"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="60dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="60dp" />
|
||||||
android:textColor="@color/general_title"
|
|
||||||
android:textSize="20sp" />
|
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/tweet_date"
|
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="#acacac"
|
android:orientation="vertical" >
|
||||||
android:textSize="12sp" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tweet_text"
|
android:id="@+id/tweet_from"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="6dip"
|
android:textColor="@color/general_title"
|
||||||
android:textColor="#acacac"
|
android:textSize="20sp" />
|
||||||
android:textSize="14sp" />
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tweet_date"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="#acacac"
|
||||||
|
android:textSize="12sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tweet_text"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="6dip"
|
||||||
|
android:textColor="#acacac"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -6,8 +6,11 @@ import java.util.concurrent.ExecutionException;
|
|||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.ListActivity;
|
import android.app.ListActivity;
|
||||||
|
import android.content.ClipData.Item;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -32,6 +35,7 @@ public class MyDay extends ListActivity {
|
|||||||
static final String KEY_TITLE = "title";
|
static final String KEY_TITLE = "title";
|
||||||
static final String KEY_DESC = "description";
|
static final String KEY_DESC = "description";
|
||||||
static final String KEY_DATE = "pubDate";
|
static final String KEY_DATE = "pubDate";
|
||||||
|
static final String KEY_TAG = "tag";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fires up the activity_myday and waits for the Login-button to be pressed.
|
* Fires up the activity_myday and waits for the Login-button to be pressed.
|
||||||
@@ -66,18 +70,31 @@ public class MyDay extends ListActivity {
|
|||||||
// Add the menuItems to our ListView
|
// Add the menuItems to our ListView
|
||||||
ListAdapter adapter = new SimpleAdapter(this, myDayItems,
|
ListAdapter adapter = new SimpleAdapter(this, myDayItems,
|
||||||
R.layout.activity_myday_list, new String[] { KEY_TITLE,
|
R.layout.activity_myday_list, new String[] { KEY_TITLE,
|
||||||
KEY_LINK, KEY_DESC, KEY_DATE }, new int[] {
|
KEY_LINK, KEY_DESC, KEY_DATE, KEY_TAG }, new int[] {
|
||||||
R.id.mydayTitle, R.id.mydayLink,
|
R.id.mydayTitle, R.id.mydayLink,
|
||||||
R.id.mydayDescription, R.id.mydayDate });
|
R.id.mydayDescription, R.id.mydayDate,
|
||||||
|
R.id.mydayTag });
|
||||||
setListAdapter(adapter);
|
setListAdapter(adapter);
|
||||||
|
|
||||||
ListView lv = (ListView) findViewById(R.id.myDayList);
|
ListView lv = (ListView) findViewById(R.id.myDayList);
|
||||||
|
for (int i = 0; i <= myDayItems.size(); i++) {
|
||||||
|
String theTag = myDayItems.get(i).get(KEY_TAG);
|
||||||
|
if (theTag.contains("schema")) {
|
||||||
|
Log.i("TAG", "Schema hittad");
|
||||||
|
// TextView tv = (TextView) myDayItems.get(i);
|
||||||
|
}
|
||||||
|
else if (theTag.contains("kronox"))
|
||||||
|
Log.i("TAG", "Kronox hittad");
|
||||||
|
else if (theTag.contains("ladok"))
|
||||||
|
Log.i("TAG", "Ladok hittad");
|
||||||
|
else if (theTag.contains("disco"))
|
||||||
|
Log.i("TAG", "Disco hittad");
|
||||||
|
else
|
||||||
|
Log.i("TAG ANNAT", theTag);
|
||||||
|
}
|
||||||
// Wait for an item in the list to be clicked
|
// Wait for an item in the list to be clicked
|
||||||
lv.setOnItemClickListener(new OnItemClickListener() {
|
lv.setOnItemClickListener(new OnItemClickListener() {
|
||||||
|
|
||||||
|
|
||||||
public void onItemClick(AdapterView<?> parent, View view,
|
public void onItemClick(AdapterView<?> parent, View view,
|
||||||
int position, long id) {
|
int position, long id) {
|
||||||
// getting values from selected ListItem
|
// getting values from selected ListItem
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import android.os.AsyncTask;
|
|||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class manages the loading of external data. It uses the ASynkTask class
|
* This class manages the loading of external data. It uses the ASynkTask class
|
||||||
|
|||||||
@@ -4,4 +4,5 @@ public class Tweet {
|
|||||||
String from;
|
String from;
|
||||||
String text;
|
String text;
|
||||||
String date;
|
String date;
|
||||||
|
String pic;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package se.hv.dindag;
|
package se.hv.dindag;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -17,6 +18,8 @@ import org.json.JSONObject;
|
|||||||
import android.app.ListActivity;
|
import android.app.ListActivity;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -24,6 +27,7 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class TwitterFeed extends ListActivity {
|
public class TwitterFeed extends ListActivity {
|
||||||
@@ -62,6 +66,7 @@ public class TwitterFeed extends ListActivity {
|
|||||||
tweet.from = session.getString("from_user");
|
tweet.from = session.getString("from_user");
|
||||||
tweet.date = prettyfyDate(session
|
tweet.date = prettyfyDate(session
|
||||||
.getString("created_at"));
|
.getString("created_at"));
|
||||||
|
tweet.pic = session.getString("profile_image_url");
|
||||||
tweets.add(tweet);
|
tweets.add(tweet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,6 +106,43 @@ public class TwitterFeed extends ListActivity {
|
|||||||
return theDate;
|
return theDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Laddar hem Twitter-bilden
|
||||||
|
*
|
||||||
|
* @author imcoh
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
|
||||||
|
ImageView bmImage = (ImageView) findViewById(R.id.twitterPic);
|
||||||
|
|
||||||
|
public DownloadImageTask(ImageView bmImage) {
|
||||||
|
this.bmImage = bmImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Bitmap doInBackground(String... urls) {
|
||||||
|
String urldisplay = urls[0];
|
||||||
|
Bitmap mIcon11 = null;
|
||||||
|
try {
|
||||||
|
InputStream in = new java.net.URL(urldisplay).openStream();
|
||||||
|
mIcon11 = BitmapFactory.decodeStream(in);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e("Error", e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return mIcon11;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onPostExecute(Bitmap result) {
|
||||||
|
bmImage.setImageBitmap(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stoppar in alla funna resultat i listan
|
||||||
|
*
|
||||||
|
* @author imcoh
|
||||||
|
*
|
||||||
|
*/
|
||||||
private class TweetListAdaptor extends ArrayAdapter<Tweet> {
|
private class TweetListAdaptor extends ArrayAdapter<Tweet> {
|
||||||
private ArrayList<Tweet> tweets;
|
private ArrayList<Tweet> tweets;
|
||||||
|
|
||||||
@@ -121,6 +163,9 @@ public class TwitterFeed extends ListActivity {
|
|||||||
TextView tvText = (TextView) v.findViewById(R.id.tweet_text);
|
TextView tvText = (TextView) v.findViewById(R.id.tweet_text);
|
||||||
TextView tvDate = (TextView) v.findViewById(R.id.tweet_date);
|
TextView tvDate = (TextView) v.findViewById(R.id.tweet_date);
|
||||||
TextView tvFrom = (TextView) v.findViewById(R.id.tweet_from);
|
TextView tvFrom = (TextView) v.findViewById(R.id.tweet_from);
|
||||||
|
|
||||||
|
// new DownloadImageTask((ImageView)
|
||||||
|
// findViewById(R.id.twitterPic)).execute(o.pic);
|
||||||
tvFrom.setText("@" + o.from);
|
tvFrom.setText("@" + o.from);
|
||||||
tvDate.setText(o.date);
|
tvDate.setText(o.date);
|
||||||
tvText.setText(o.text);
|
tvText.setText(o.text);
|
||||||
|
|||||||
Reference in New Issue
Block a user