From 2535a1bc5533f50a047f15cfb6ef940b2e204e82 Mon Sep 17 00:00:00 2001 From: NudeDude Date: Fri, 29 Dec 2017 23:05:28 +0100 Subject: [PATCH] Base 1.1 --- .../twidda/DataBase/TweetDatabase.java | 3 ++- .../org/nuclearfog/twidda/MainActivity.java | 19 +++++++------- .../twidda/ViewAdapter/TimelineAdapter.java | 1 - .../org/nuclearfog/twidda/Window/Tweet.java | 25 ++++++++++++------- app/src/main/res/drawable/hash.xml | 6 ++--- 5 files changed, 30 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/org/nuclearfog/twidda/DataBase/TweetDatabase.java b/app/src/main/java/org/nuclearfog/twidda/DataBase/TweetDatabase.java index 0fdcc41c..da5ce1c6 100644 --- a/app/src/main/java/org/nuclearfog/twidda/DataBase/TweetDatabase.java +++ b/app/src/main/java/org/nuclearfog/twidda/DataBase/TweetDatabase.java @@ -24,6 +24,7 @@ public class TweetDatabase { private List stats; private int size = 0; private int mode = 0; + private int length = 50; private long CurrentId = 0; private SharedPreferences settings; @@ -153,7 +154,7 @@ public class TweetDatabase { index = cursor.getColumnIndex("tweetID"); // tweetID tweetId.add(cursor.getLong(index) ); size++; - } while(cursor.moveToNext()); + } while(cursor.moveToNext() && size < length); } cursor.close(); db.close(); diff --git a/app/src/main/java/org/nuclearfog/twidda/MainActivity.java b/app/src/main/java/org/nuclearfog/twidda/MainActivity.java index 6018ff0f..a5d85209 100644 --- a/app/src/main/java/org/nuclearfog/twidda/MainActivity.java +++ b/app/src/main/java/org/nuclearfog/twidda/MainActivity.java @@ -9,14 +9,9 @@ import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import android.view.View; -import android.view.animation.Animation; -import android.view.animation.AnimationSet; -import android.view.animation.TranslateAnimation; import android.widget.AdapterView; -import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; -import android.widget.FrameLayout; import android.widget.ListView; import android.widget.TabHost; import android.widget.TabHost.TabSpec; @@ -39,8 +34,6 @@ public class MainActivity extends AppCompatActivity private SwipeRefreshLayout timelineReload,trendReload,mentionReload; private ListView timelineList, trendList,mentionList; private SharedPreferences settings; - private TweetDatabase tweetDeck; - private TrendDatabase trendDeck; private EditText pin; private Context con; private Toolbar toolbar; @@ -188,8 +181,8 @@ public class MainActivity extends AppCompatActivity * separate THREAD */ private void setTabContent() { - tweetDeck = new TweetDatabase(con,TweetDatabase.HOME_TL, 0L); - trendDeck = new TrendDatabase(con); + TweetDatabase tweetDeck = new TweetDatabase(con,TweetDatabase.HOME_TL, 0L); + TrendDatabase trendDeck = new TrendDatabase(con); TimelineAdapter tlAdapt = new TimelineAdapter(con,tweetDeck); TrendsAdapter trendAdp = new TrendsAdapter(con,trendDeck); timelineList.setAdapter(tlAdapt); @@ -223,16 +216,23 @@ public class MainActivity extends AppCompatActivity }); } + + /** + * Item Listener for a Tweet + */ private void setListViewListener() { timelineList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { if(!timelineReload.isRefreshing()) { + TweetDatabase tweetDeck = new TweetDatabase(con,TweetDatabase.HOME_TL, 0L); int index = timelineList.getPositionForView(view); long tweetID = tweetDeck.getTweetId(index); + long userID = tweetDeck.getUserID(index); Intent intent = new Intent(con, Tweet.class); Bundle bundle = new Bundle(); bundle.putLong("tweetID",tweetID); + bundle.putLong("userID",userID); intent.putExtras(bundle); startActivity(intent); } @@ -275,5 +275,4 @@ public class MainActivity extends AppCompatActivity break; } } - } \ No newline at end of file diff --git a/app/src/main/java/org/nuclearfog/twidda/ViewAdapter/TimelineAdapter.java b/app/src/main/java/org/nuclearfog/twidda/ViewAdapter/TimelineAdapter.java index 56d4678a..d3ec463b 100644 --- a/app/src/main/java/org/nuclearfog/twidda/ViewAdapter/TimelineAdapter.java +++ b/app/src/main/java/org/nuclearfog/twidda/ViewAdapter/TimelineAdapter.java @@ -4,7 +4,6 @@ import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.ViewParent; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.ListView; diff --git a/app/src/main/java/org/nuclearfog/twidda/Window/Tweet.java b/app/src/main/java/org/nuclearfog/twidda/Window/Tweet.java index 52b1f1e4..79a68c3f 100644 --- a/app/src/main/java/org/nuclearfog/twidda/Window/Tweet.java +++ b/app/src/main/java/org/nuclearfog/twidda/Window/Tweet.java @@ -1,7 +1,9 @@ package org.nuclearfog.twidda.Window; +import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; +import android.view.View; import android.widget.ImageView; import android.widget.TextView; @@ -12,26 +14,30 @@ public class Tweet extends AppCompatActivity { private TweetDatabase mTweet; private TextView tweet, username; - - private long tweetID; + private long userID; @Override protected void onCreate(Bundle b){ super.onCreate(b); setContentView(R.layout.tweet_detail); - + tweetID = getIntent().getExtras().getLong("tweetID"); + userID = getIntent().getExtras().getLong("userID"); tweet = (TextView) findViewById(R.id.tweetdetail); username = (TextView) findViewById(R.id.usernamedetail); ImageView pb = (ImageView) findViewById(R.id.profileimage_detail); - - - - tweetID = getIntent().getExtras().getLong("tweetID"); - + pb.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent profile = new Intent(getApplicationContext(), Profile.class); + Bundle bundle = new Bundle(); + bundle.putLong("userID",userID); + profile.putExtras(bundle); + startActivity(profile); + } + }); setContent(); - } @@ -40,5 +46,6 @@ public class Tweet extends AppCompatActivity { mTweet = new TweetDatabase(getApplicationContext(),TweetDatabase.GET_TWEET,tweetID); tweet.setText(mTweet.getTweet(0)); username.setText(mTweet.getUsername(0)); + } } \ No newline at end of file diff --git a/app/src/main/res/drawable/hash.xml b/app/src/main/res/drawable/hash.xml index 9d7d3461..60fd7f11 100644 --- a/app/src/main/res/drawable/hash.xml +++ b/app/src/main/res/drawable/hash.xml @@ -1,4 +1,4 @@ - - + +