Skip to content

Commit 2fedf64

Browse files
committed
initial commit. lame implementation beginnings...
0 parents  commit 2fedf64

28 files changed

+1110
-0
lines changed

.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# built application files
2+
*.apk
3+
*.ap_
4+
5+
# files for the dex VM
6+
*.dex
7+
8+
# Java class files
9+
*.class
10+
11+
# generated files
12+
bin/
13+
gen/
14+
15+
# Local configuration file (sdk path, etc)
16+
local.properties
17+
18+
# Eclipse project files
19+
.classpath
20+
.project
21+
.idea
22+
.css
23+
*.html
24+
.img
25+
.DS_Store
26+
jobqueue/out
27+
coverage-report
28+
junitvmwatcher*.properties
29+
jobqueue/cobertura.ser
30+
jobqueue/javadoc
31+
out
32+
*.iml
33+
pages
34+
.gradle
35+
build

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apply plugin: 'android'
2+
3+
android {
4+
compileSdkVersion 19
5+
buildToolsVersion "19.0.1"
6+
7+
defaultConfig {
8+
minSdkVersion 14
9+
targetSdkVersion 19
10+
versionCode 1
11+
versionName "1.0"
12+
}
13+
repositories {
14+
mavenLocal()
15+
mavenCentral()
16+
maven { url 'http://repo1.maven.org/maven2' }
17+
maven { url 'http://download.crashlytics.com/maven' }
18+
}
19+
20+
dependencies {
21+
compile 'com.squareup.retrofit:retrofit:1.4.0'
22+
compile 'com.google.code.gson:gson:2.2.4'
23+
compile 'com.squareup.okhttp:okhttp:1.3.0'
24+
}
25+
26+
buildTypes {
27+
release {
28+
runProguard false
29+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
30+
}
31+
}
32+
}
33+
34+

app/proguard-rules.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /Users/yigit/android/sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the ProGuard
5+
# include property in project.properties.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}

app/src/main/AndroidManifest.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.birbit.android.livecode.twitter">
3+
<uses-permission android:name="android.permission.INTERNET" />
4+
5+
<application android:allowBackup="true"
6+
android:debuggable="true"
7+
android:name=".App"
8+
android:label="@string/app_name"
9+
android:icon="@drawable/ic_launcher"
10+
android:theme="@style/AppTheme">
11+
<activity android:name=".MainActivity">
12+
<intent-filter>
13+
<action android:name="android.intent.action.MAIN" />
14+
<category android:name="android.intent.category.LAUNCHER" />
15+
</intent-filter>
16+
</activity>
17+
</application>
18+
19+
</manifest>

app/src/main/ic_launcher-web.png

11.5 KB
Loading
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.birbit.android.livecode.twitter;
2+
3+
import android.app.Application;
4+
import android.os.StrictMode;
5+
6+
import com.birbit.android.livecode.twitter.business.TwitterApiClient;
7+
8+
/**
9+
* Created by yigit on 2/1/14.
10+
*/
11+
public class App extends Application {
12+
private static App instance;
13+
private TwitterApiClient apiClient;
14+
public App() {
15+
instance = this;
16+
}
17+
18+
@Override
19+
public void onCreate() {
20+
super.onCreate();
21+
apiClient = new TwitterApiClient();
22+
if(Config.ENABLE_STRICT_MODE) {
23+
enableStrictModel();
24+
}
25+
}
26+
27+
private void enableStrictModel() {
28+
new android.os.Handler().postAtFrontOfQueue(new Runnable() {
29+
@Override
30+
public void run() {
31+
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
32+
.detectAll()
33+
.penaltyDeath().build());
34+
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
35+
.detectAll()
36+
.penaltyLog().build());
37+
}
38+
});
39+
}
40+
41+
public TwitterApiClient getApiClient() {
42+
return apiClient;
43+
}
44+
45+
public static App getInstance() {
46+
return instance;
47+
}
48+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.birbit.android.livecode.twitter;
2+
3+
import android.util.TimeUtils;
4+
5+
import java.util.concurrent.TimeUnit;
6+
7+
/**
8+
* Created by yigit on 2/1/14.
9+
*/
10+
public class Config {
11+
public static final long ARTIFICIAL_REQUEST_DELAY = TimeUnit.SECONDS.toMillis(10);//MS
12+
public static final boolean ENABLE_STRICT_MODE = true;
13+
public static final ConnectionConfiguration CONNECTION_CONFIGURATION = ConnectionConfiguration.LIVECODE_DEMO_1;
14+
15+
public static enum ConnectionConfiguration {
16+
JOBQUEUE_TEST_APP("GfonALJ3wScsJfPsjLpl5g", "7EYvqptQeBQ9FFcbaPHv0WVe9rRbDi8dmX9DffIMIE",
17+
"1443060589-h6JU83NsHMYx5M47Is2RzlVZmvHPbxQND9xT6KQ", "QLut9Mgwge5WptlVnCz9wxmbJrqBFNazkEYrGDZKYE"),
18+
JOBQUEUE_TEST_APP_2("APEGHy66BMYzvgEktDfc1Q","wf8XXYwivxHQtiIqPSD3lpq6po9JGRyYBIX0lT0",
19+
"1443060589-ZW0lPmcN0NOwy2AchLjZjixHLhPXClYOPQ0IhWG","Tq8aVvT1PA6PXtKHgI5v1EL5UQj3JcGlFzXla2zethjYO"),
20+
LIVECODE_DEMO_1("wEIMoUSx5St3KOYx1NxPQ", "rHMma9V97DlgBt8G0hEwRo4yHs0QHPwjRLr9cC3cGNc",
21+
"1443060589-DVRvnx1sUfqf73arhU8G7icabNlpVxWT9MaVN0t", "TGtukAgzNgNFTcaQlOfwqlpCFpu6h3fy8rwmcmfryJ1Bc")
22+
;
23+
public final String consumerKey;
24+
public final String consumerSecret;
25+
public final String accessToken;
26+
public final String accessTokenSecret;
27+
ConnectionConfiguration(String consumerKey, String consumerSecret, String accessToken, String accessTokenSecret) {
28+
this.consumerKey = consumerKey;
29+
this.consumerSecret = consumerSecret;
30+
this.accessToken = accessToken;
31+
this.accessTokenSecret = accessTokenSecret;
32+
}
33+
}
34+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package com.birbit.android.livecode.twitter;
2+
3+
import android.app.Activity;
4+
import android.os.AsyncTask;
5+
import android.os.Bundle;
6+
import android.util.Log;
7+
import android.view.View;
8+
import android.view.ViewGroup;
9+
import android.view.Window;
10+
import android.widget.BaseAdapter;
11+
import android.widget.ListView;
12+
import android.widget.TextView;
13+
14+
import com.birbit.android.livecode.twitter.vo.Tweet;
15+
16+
import java.util.List;
17+
18+
/**
19+
* Created by yigit on 2/1/14.
20+
*/
21+
public class MainActivity extends Activity {
22+
private ListView tweetList;
23+
@Override
24+
protected void onCreate(Bundle savedInstanceState) {
25+
super.onCreate(savedInstanceState);
26+
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
27+
setContentView(R.layout.activity_main);
28+
tweetList = ((ListView) findViewById(R.id.tweet_list));
29+
loadTweets();
30+
}
31+
32+
private void loadTweets() {
33+
new AsyncTask<Void, Void, List<Tweet>>() {
34+
@Override
35+
protected void onPreExecute() {
36+
super.onPreExecute();
37+
setProgressBarIndeterminateVisibility(true);
38+
}
39+
40+
@Override
41+
protected List<Tweet> doInBackground(Void... params) {
42+
return App.getInstance().getApiClient().getService().homeTimeline();
43+
}
44+
45+
@Override
46+
protected void onCancelled() {
47+
super.onCancelled();
48+
setProgressBarIndeterminateVisibility(false);
49+
}
50+
51+
@Override
52+
protected void onPostExecute(List<Tweet> tweets) {
53+
super.onPostExecute(tweets);
54+
setProgressBarIndeterminateVisibility(false);
55+
tweetList.setAdapter(new TweetAdapter(tweets));
56+
}
57+
}.execute();
58+
}
59+
60+
private final class TweetAdapter extends BaseAdapter {
61+
final List<Tweet> tweets;
62+
public TweetAdapter(List<Tweet> tweets) {
63+
this.tweets = tweets;
64+
}
65+
@Override
66+
public int getCount() {
67+
return tweets.size();
68+
}
69+
70+
@Override
71+
public Tweet getItem(int position) {
72+
return tweets.get(position);
73+
}
74+
75+
@Override
76+
public long getItemId(int position) {
77+
return getItem(position).getId();
78+
}
79+
80+
@Override
81+
public View getView(int position, View convertView, ViewGroup parent) {
82+
if(convertView == null) {
83+
convertView = new TextView(MainActivity.this);
84+
}
85+
((TextView) convertView).setText(getItem(position).getText());
86+
return convertView;
87+
}
88+
}
89+
}

0 commit comments

Comments
 (0)