mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-02-03 12:37:33 +01:00
Bugfix
Code Cleanup
This commit is contained in:
parent
51b90e6db5
commit
0779de7c27
@ -10,8 +10,10 @@
|
||||
android:icon="@mipmap/shitter"
|
||||
android:theme="@style/AppTheme"
|
||||
android:label="@string/app_name">
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:theme="@style/AppTheme"
|
||||
android:screenOrientation="portrait">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
@ -21,32 +23,39 @@
|
||||
|
||||
<activity
|
||||
android:name=".window.SearchPage"
|
||||
android:theme="@style/AppTheme"
|
||||
android:screenOrientation="portrait"/>
|
||||
|
||||
<activity
|
||||
android:name=".window.UserProfile"
|
||||
android:theme="@style/AppTheme"
|
||||
android:screenOrientation="portrait"/>
|
||||
|
||||
<activity
|
||||
android:name=".window.TweetPopup"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Transparency"/>
|
||||
android:theme="@style/Transparency"
|
||||
android:screenOrientation="portrait"/>
|
||||
|
||||
<activity
|
||||
android:name=".window.AppSettings"
|
||||
android:theme="@style/AppTheme"
|
||||
android:screenOrientation="portrait"/>
|
||||
|
||||
<activity
|
||||
android:name=".window.TweetDetail"
|
||||
android:theme="@style/AppTheme"
|
||||
android:screenOrientation="portrait"/>
|
||||
|
||||
<activity
|
||||
android:name=".window.UserDetail"
|
||||
android:theme="@style/AppTheme"
|
||||
android:screenOrientation="portrait"/>
|
||||
|
||||
<activity
|
||||
android:name=".window.LoginPage"
|
||||
android:theme="@style/AppTheme"
|
||||
android:screenOrientation="portrait"/>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -53,7 +53,7 @@ public class MainActivity extends AppCompatActivity implements AdapterView.OnIte
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.mainpage);
|
||||
con = getApplicationContext();
|
||||
settings = con.getSharedPreferences("settings", 0);
|
||||
settings = getSharedPreferences("settings", 0);
|
||||
boolean login = settings.getBoolean("login", false);
|
||||
if( !login ) {
|
||||
Intent i = new Intent(con,LoginPage.class);
|
||||
@ -170,10 +170,12 @@ public class MainActivity extends AppCompatActivity implements AdapterView.OnIte
|
||||
TweetDatabase twDB = tlAdp.getData();
|
||||
long tweetID = twDB.getTweetId(position);
|
||||
long userID = twDB.getUserID(position);
|
||||
String username = twDB.getScreenname(position);
|
||||
Intent intent = new Intent(con, TweetDetail.class);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putLong("tweetID",tweetID);
|
||||
bundle.putLong("userID",userID);
|
||||
bundle.putString("username",username);
|
||||
intent.putExtras(bundle);
|
||||
startActivity(intent);
|
||||
}
|
||||
@ -198,10 +200,12 @@ public class MainActivity extends AppCompatActivity implements AdapterView.OnIte
|
||||
TweetDatabase twDB = tlAdp.getData();
|
||||
long tweetID = twDB.getTweetId(position);
|
||||
long userID = twDB.getUserID(position);
|
||||
String username = twDB.getScreenname(position);
|
||||
Intent intent = new Intent(con, TweetDetail.class);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putLong("tweetID",tweetID);
|
||||
bundle.putLong("userID",userID);
|
||||
bundle.putString("username",username);
|
||||
intent.putExtras(bundle);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
@ -165,11 +165,11 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long>
|
||||
txtFollower.setText(follower);
|
||||
txtFollowing.setText(following);
|
||||
txtCreated.setText(dateString);
|
||||
if(location!= null) {
|
||||
if(location!= null && !location.isEmpty()) {
|
||||
txtLocation.setText(location);
|
||||
locationIcon.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if(link != null) {
|
||||
if(link != null && !link.isEmpty()) {
|
||||
txtLink.setText(link);
|
||||
linkIcon.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> implements View.On
|
||||
private String errMSG = "";
|
||||
private boolean retweeted, favorited, toggleImg, verified;
|
||||
private boolean rtFlag = false;
|
||||
private long userReply, tweetReplyID, userID;
|
||||
private long userReply, tweetReplyID;
|
||||
private int rt, fav, ansNo = 0;
|
||||
private int highlight;
|
||||
|
||||
@ -125,8 +125,6 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> implements View.On
|
||||
User user = currentTweet.getUser();
|
||||
|
||||
if(mode == LOAD_TWEET) {
|
||||
|
||||
userID = user.getId();
|
||||
userReply = currentTweet.getInReplyToUserId();
|
||||
tweetReplyID = currentTweet.getInReplyToStatusId();
|
||||
tweetStr = currentTweet.getText();
|
||||
@ -135,10 +133,9 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> implements View.On
|
||||
scrNameStr = '@'+user.getScreenName();
|
||||
apiName = formatString(currentTweet.getSource());
|
||||
dateString = new SimpleDateFormat("dd.MM.yyyy hh:mm:ss").format(currentTweet.getCreatedAt());
|
||||
tweetlink = "https://twitter.com/"+user.getScreenName()+"/status/"+tweetID;
|
||||
|
||||
if(userReply > 0)
|
||||
repliedUsername = "Antwort @"+currentTweet.getInReplyToScreenName();
|
||||
repliedUsername = currentTweet.getInReplyToScreenName();
|
||||
if(toggleImg) {
|
||||
String pbLink = user.getProfileImageURL();
|
||||
InputStream iStream = new URL(pbLink).openStream();
|
||||
@ -217,7 +214,7 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> implements View.On
|
||||
|
||||
setIcons();
|
||||
if(repliedUsername != null) {
|
||||
replyName.setText(repliedUsername);
|
||||
replyName.setText("antwort @"+repliedUsername);
|
||||
replyName.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if(rtFlag) {
|
||||
@ -228,7 +225,6 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> implements View.On
|
||||
}
|
||||
if(toggleImg) {
|
||||
profile_img.setImageBitmap(profile_btm);
|
||||
profile_img.setOnClickListener(this);
|
||||
if(medialinks.length != 0) {
|
||||
mediabutton.setVisibility(View.VISIBLE);
|
||||
mediabutton.setOnClickListener(this);
|
||||
@ -236,8 +232,6 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> implements View.On
|
||||
}
|
||||
setIcons();
|
||||
replyName.setOnClickListener(this);
|
||||
date.setOnClickListener(this);
|
||||
|
||||
}
|
||||
else if(mode == RETWEET) {
|
||||
String rtStr = Integer.toString(rt);
|
||||
@ -279,14 +273,6 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> implements View.On
|
||||
public void onClick(View v) {
|
||||
Intent intent;
|
||||
switch(v.getId()) {
|
||||
case R.id.profileimage_detail:
|
||||
intent = new Intent(c, UserProfile.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putLong("userID",userID);
|
||||
intent.putExtras(b);
|
||||
c.startActivity(intent);
|
||||
break;
|
||||
|
||||
case R.id.image_attach:
|
||||
new ImagePopup(c).execute(medialinks);
|
||||
break;
|
||||
@ -296,15 +282,10 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> implements View.On
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putLong("tweetID",tweetReplyID);
|
||||
bundle.putLong("userID",userReply);
|
||||
bundle.putString("username", repliedUsername);
|
||||
intent.putExtras(bundle);
|
||||
c.startActivity(intent);
|
||||
break;
|
||||
|
||||
case R.id.timedetail:
|
||||
intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(tweetlink));
|
||||
c.startActivity(intent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,6 @@ public class AppSettings extends AppCompatActivity implements View.OnClickListen
|
||||
protected void onCreate(Bundle savedInst) {
|
||||
super.onCreate(savedInst);
|
||||
setContentView(R.layout.settings);
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_setting);
|
||||
setSupportActionBar(toolbar);
|
||||
if(getSupportActionBar() != null)
|
||||
|
@ -34,17 +34,18 @@ public class SearchPage extends AppCompatActivity implements AdapterView.OnItemC
|
||||
private String search = "";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
protected void onCreate(Bundle b) {
|
||||
super.onCreate(b);
|
||||
setContentView(R.layout.search);
|
||||
search = getIntent().getExtras().getString("search");
|
||||
getExtras(getIntent().getExtras());
|
||||
|
||||
Toolbar tool = (Toolbar) findViewById(R.id.search_toolbar);
|
||||
tweetSearch = (ListView) findViewById(R.id.tweet_result);
|
||||
userSearch = (ListView) findViewById(R.id.user_result);
|
||||
tweetReload = (SwipeRefreshLayout) findViewById(R.id.searchtweets);
|
||||
setSupportActionBar(tool);
|
||||
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
||||
if(getSupportActionBar() != null)
|
||||
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
||||
TabHost tabhost = (TabHost)findViewById(R.id.search_tab);
|
||||
tabhost.setup();
|
||||
setTabs(tabhost);
|
||||
@ -122,10 +123,12 @@ public class SearchPage extends AppCompatActivity implements AdapterView.OnItemC
|
||||
TweetDatabase twDB = tlAdp.getData();
|
||||
long tweetID = twDB.getTweetId(position);
|
||||
long userID = twDB.getUserID(position);
|
||||
String username = twDB.getScreenname(position);
|
||||
Intent intent = new Intent(getApplicationContext(), TweetDetail.class);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putLong("tweetID",tweetID);
|
||||
bundle.putLong("userID",userID);
|
||||
bundle.putString("username", username);
|
||||
intent.putExtras(bundle);
|
||||
startActivity(intent);
|
||||
}
|
||||
@ -170,4 +173,9 @@ public class SearchPage extends AppCompatActivity implements AdapterView.OnItemC
|
||||
mSearch = new TwitterSearch(this);
|
||||
mSearch.execute(search);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private void getExtras(Bundle b) {
|
||||
search = b.getString("search");
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ package org.nuclearfog.twidda.window;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.CollapsingToolbarLayout;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
@ -33,14 +34,15 @@ public class TweetDetail extends AppCompatActivity implements View.OnClickListen
|
||||
private long tweetID;
|
||||
private long userID;
|
||||
private StatusLoader mStat, mReply;
|
||||
private static String username;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle b) {
|
||||
super.onCreate(b);
|
||||
setContentView(R.layout.tweet_detail);
|
||||
tweetID = getIntent().getExtras().getLong("tweetID");
|
||||
userID = getIntent().getExtras().getLong("userID");
|
||||
SharedPreferences settings = getApplicationContext().getSharedPreferences("settings", 0);
|
||||
getExtras(getIntent().getExtras());
|
||||
|
||||
SharedPreferences settings = getSharedPreferences("settings", 0);
|
||||
boolean home = userID == settings.getLong("userID", -1);
|
||||
|
||||
answer_list = (ListView) findViewById(R.id.answer_list);
|
||||
@ -48,11 +50,12 @@ public class TweetDetail extends AppCompatActivity implements View.OnClickListen
|
||||
Button retweet = (Button) findViewById(R.id.rt_button_detail);
|
||||
Button favorite = (Button) findViewById(R.id.fav_button_detail);
|
||||
Button delete = (Button) findViewById(R.id.delete);
|
||||
ImageView pb = (ImageView) findViewById(R.id.profileimage_detail);
|
||||
ImageView pb =(ImageView) findViewById(R.id.profileimage_detail);
|
||||
SwipeRefreshLayout answerReload = (SwipeRefreshLayout) findViewById(R.id.answer_reload);
|
||||
|
||||
TextView txtRt = (TextView) findViewById(R.id.no_rt_detail);
|
||||
TextView txtFav = (TextView) findViewById(R.id.no_fav_detail);
|
||||
TextView date = (TextView) findViewById(R.id.timedetail);
|
||||
if(home) {
|
||||
delete.setVisibility(View.VISIBLE);
|
||||
}
|
||||
@ -64,7 +67,9 @@ public class TweetDetail extends AppCompatActivity implements View.OnClickListen
|
||||
answer.setOnClickListener(this);
|
||||
txtFav.setOnClickListener(this);
|
||||
txtRt.setOnClickListener(this);
|
||||
date.setOnClickListener(this);
|
||||
delete.setOnClickListener(this);
|
||||
pb.setOnClickListener(this);
|
||||
setContent();
|
||||
}
|
||||
|
||||
@ -93,6 +98,7 @@ public class TweetDetail extends AppCompatActivity implements View.OnClickListen
|
||||
case R.id.answer_button:
|
||||
intent = new Intent(getApplicationContext(), TweetPopup.class);
|
||||
bundle.putLong("TweetID", tweetID);
|
||||
bundle.putString("Addition", username);
|
||||
intent.putExtras(bundle);
|
||||
startActivity(intent);
|
||||
break;
|
||||
@ -125,6 +131,20 @@ public class TweetDetail extends AppCompatActivity implements View.OnClickListen
|
||||
alerta.setNegativeButton(R.string.no_confirm, this);
|
||||
alerta.show();
|
||||
break;
|
||||
case R.id.profileimage_detail:
|
||||
intent = new Intent(getApplicationContext(), UserProfile.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putLong("userID",userID);
|
||||
b.putString("username", username);
|
||||
intent.putExtras(b);
|
||||
startActivity(intent);
|
||||
break;
|
||||
case R.id.timedetail:
|
||||
intent = new Intent(Intent.ACTION_VIEW);
|
||||
String tweetlink = "https://twitter.com/"+username+"/status/"+tweetID;
|
||||
intent.setData(Uri.parse(tweetlink));
|
||||
startActivity(intent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,4 +196,11 @@ public class TweetDetail extends AppCompatActivity implements View.OnClickListen
|
||||
mStat.execute(tweetID, StatusLoader.LOAD_TWEET);
|
||||
mReply.execute(tweetID, StatusLoader.LOAD_REPLY);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private void getExtras(Bundle b) {
|
||||
tweetID = b.getLong("tweetID");
|
||||
userID = b.getLong("userID");
|
||||
username = b.getString("username");
|
||||
}
|
||||
}
|
@ -12,7 +12,6 @@ import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import static android.content.DialogInterface.*;
|
||||
|
||||
import org.nuclearfog.twidda.backend.ImagePopup;
|
||||
@ -38,28 +37,22 @@ public class TweetPopup extends AppCompatActivity implements View.OnClickListene
|
||||
private List<String> mediaPath;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle SavedInstance) {
|
||||
super.onCreate(SavedInstance);
|
||||
protected void onCreate(Bundle b) {
|
||||
super.onCreate(b);
|
||||
setContentView(R.layout.tweetwindow);
|
||||
if(getIntent().hasExtra("TweetID"))
|
||||
inReplyId = getIntent().getExtras().getLong("TweetID");
|
||||
if(getIntent().hasExtra("Addition"))
|
||||
addition = getIntent().getExtras().getString("Addition");
|
||||
getExtras(getIntent().getExtras());
|
||||
|
||||
mediaPath = new ArrayList<>();
|
||||
|
||||
|
||||
Button tweetButton = (Button) findViewById(R.id.sendTweet);
|
||||
Button closeButton = (Button) findViewById(R.id.close);
|
||||
imageButton = (Button) findViewById(R.id.image);
|
||||
previewBtn = (Button) findViewById(R.id.img_preview);
|
||||
tweetfield = (EditText) findViewById(R.id.tweet_input);
|
||||
imgcount = (TextView) findViewById(R.id.imgcount);
|
||||
|
||||
Button tweetButton = (Button) findViewById(R.id.sendTweet);
|
||||
Button closeButton = (Button) findViewById(R.id.close);
|
||||
LinearLayout root = (LinearLayout) findViewById(R.id.tweet_popup);
|
||||
ColorPreferences mColor = ColorPreferences.getInstance(this);
|
||||
root.setBackgroundColor(mColor.getColor(ColorPreferences.TWEET_COLOR));
|
||||
tweetfield.setText(addition);
|
||||
tweetfield.append(addition);
|
||||
|
||||
closeButton.setOnClickListener(this);
|
||||
tweetButton.setOnClickListener(this);
|
||||
@ -162,4 +155,12 @@ public class TweetPopup extends AppCompatActivity implements View.OnClickListene
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantCondidions")
|
||||
private void getExtras(Bundle b) {
|
||||
if(b.containsKey("TweetID"))
|
||||
inReplyId = b.getLong("TweetID");
|
||||
if(b.containsKey("Addition"))
|
||||
addition = b.getString("Addition")+" ";
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
@ -20,25 +21,20 @@ import org.nuclearfog.twidda.viewadapter.UserAdapter;
|
||||
*/
|
||||
public class UserDetail extends AppCompatActivity implements AdapterView.OnItemClickListener {
|
||||
|
||||
private long userID, tweetID;
|
||||
private long userID;
|
||||
private long mode;
|
||||
private ListView userListview;
|
||||
private Toolbar toolbar;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle b) {
|
||||
super.onCreate(b);
|
||||
setContentView(R.layout.user);
|
||||
Intent i = getIntent();
|
||||
userID = i.getExtras().getLong("userID");
|
||||
mode = i.getExtras().getLong("mode");
|
||||
if(i.hasExtra("tweetID")){
|
||||
tweetID = i.getExtras().getLong("tweetID");
|
||||
}
|
||||
getExtras(getIntent().getExtras());
|
||||
|
||||
userListview = (ListView) findViewById(R.id.userlist);
|
||||
userListview.setOnItemClickListener(this);
|
||||
toolbar = (Toolbar) findViewById(R.id.follow_toolbar);
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.user_toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
userListview.setOnItemClickListener(this);
|
||||
getUsers();
|
||||
}
|
||||
|
||||
@ -53,22 +49,34 @@ public class UserDetail extends AppCompatActivity implements AdapterView.OnItemC
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu( Menu m ) {
|
||||
toolbar.inflateMenu(R.menu.setting);
|
||||
getMenuInflater().inflate(R.menu.user, m);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if(item.getItemId() == R.id.user_back) {
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
UserAdapter uAdp = (UserAdapter) userListview.getAdapter();
|
||||
UserDatabase uDB = uAdp.getData();
|
||||
long userID = uDB.getUserID(position);
|
||||
String username = uDB.getScreenname(position);
|
||||
Intent intent = new Intent(getApplicationContext(), UserProfile.class);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putLong("userID",userID);
|
||||
bundle.putString("username", username);
|
||||
intent.putExtras(bundle);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private void getUsers() {
|
||||
UserLists uList = new UserLists(UserDetail.this);
|
||||
if(mode == 0L){
|
||||
@ -85,4 +93,10 @@ public class UserDetail extends AppCompatActivity implements AdapterView.OnItemC
|
||||
uList.execute(userID, UserLists.FAVORISER, -1L);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantCondidions")
|
||||
private void getExtras(Bundle b) {
|
||||
userID = b.getLong("userID");
|
||||
mode = b.getLong("mode");
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@ package org.nuclearfog.twidda.window;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.AppBarLayout;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
@ -26,32 +25,34 @@ import org.nuclearfog.twidda.viewadapter.TimelineAdapter;
|
||||
*/
|
||||
public class UserProfile extends AppCompatActivity implements View.OnClickListener,
|
||||
AdapterView.OnItemClickListener, SwipeRefreshLayout.OnRefreshListener,
|
||||
TabHost.OnTabChangeListener, AppBarLayout.OnOffsetChangedListener {
|
||||
TabHost.OnTabChangeListener {
|
||||
|
||||
private ProfileLoader mProfile, mTweets, mFavorits;
|
||||
private SwipeRefreshLayout homeReload, favoriteReload;
|
||||
private ListView homeTweets, homeFavorits;
|
||||
private long userId;
|
||||
private boolean home;
|
||||
private String username = "";
|
||||
private String currentTab = "tweets";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstance) {
|
||||
super.onCreate(savedInstance);
|
||||
protected void onCreate(Bundle b) {
|
||||
super.onCreate(b);
|
||||
setContentView(R.layout.profile);
|
||||
getExtras(getIntent().getExtras());
|
||||
Toolbar tool = (Toolbar) findViewById(R.id.profile_toolbar);
|
||||
setSupportActionBar(tool);
|
||||
if(getSupportActionBar() != null)
|
||||
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
||||
userId = getIntent().getExtras().getLong("userID");
|
||||
SharedPreferences settings = getApplicationContext().getSharedPreferences("settings", 0);
|
||||
|
||||
SharedPreferences settings = getSharedPreferences("settings", 0);
|
||||
home = userId == settings.getLong("userID", -1);
|
||||
homeTweets = (ListView)findViewById(R.id.ht_list);
|
||||
homeFavorits = (ListView)findViewById(R.id.hf_list);
|
||||
TextView txtFollowing = (TextView)findViewById(R.id.following);
|
||||
TextView txtFollower = (TextView)findViewById(R.id.follower);
|
||||
homeReload = (SwipeRefreshLayout) findViewById(R.id.hometweets);
|
||||
favoriteReload = (SwipeRefreshLayout) findViewById(R.id.homefavorits);
|
||||
TextView txtFollowing = (TextView)findViewById(R.id.following);
|
||||
TextView txtFollower = (TextView)findViewById(R.id.follower);
|
||||
TabHost mTab = (TabHost)findViewById(R.id.profile_tab);
|
||||
setTabs(mTab);
|
||||
mTab.setOnTabChangedListener(this);
|
||||
@ -104,7 +105,11 @@ public class UserProfile extends AppCompatActivity implements View.OnClickListen
|
||||
mProfile = new ProfileLoader(this);
|
||||
switch(item.getItemId()) {
|
||||
case R.id.profile_tweet:
|
||||
Bundle extra = new Bundle();
|
||||
intent = new Intent(this, TweetPopup.class);
|
||||
if(username != null)
|
||||
extra.putString("Addition", username);
|
||||
intent.putExtras(extra);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
case R.id.profile_follow:
|
||||
@ -132,27 +137,22 @@ public class UserProfile extends AppCompatActivity implements View.OnClickListen
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
TimelineAdapter tlAdp;
|
||||
|
||||
if(parent.getId() == R.id.ht_list) {
|
||||
tlAdp = (TimelineAdapter) homeTweets.getAdapter();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
tlAdp = (TimelineAdapter) homeFavorits.getAdapter();
|
||||
}
|
||||
|
||||
if(position >= tlAdp.getCount()) {
|
||||
|
||||
} else {
|
||||
TweetDatabase twDB = tlAdp.getData();
|
||||
long tweetID = twDB.getTweetId(position);
|
||||
long userID = twDB.getUserID(position);
|
||||
Intent intent = new Intent(getApplicationContext(), TweetDetail.class);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putLong("tweetID",tweetID);
|
||||
bundle.putLong("userID",userID);
|
||||
intent.putExtras(bundle);
|
||||
startActivity(intent);
|
||||
}
|
||||
TweetDatabase twDB = tlAdp.getData();
|
||||
long tweetID = twDB.getTweetId(position);
|
||||
long userID = twDB.getUserID(position);
|
||||
String username = twDB.getScreenname(position);
|
||||
Intent intent = new Intent(getApplicationContext(), TweetDetail.class);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putLong("tweetID",tweetID);
|
||||
bundle.putLong("userID",userID);
|
||||
bundle.putString("username", username);
|
||||
intent.putExtras(bundle);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -176,21 +176,6 @@ public class UserProfile extends AppCompatActivity implements View.OnClickListen
|
||||
currentTab = tabId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deaktiviert
|
||||
*/
|
||||
@Override
|
||||
public void onOffsetChanged(AppBarLayout mBar, int high) {
|
||||
int max = - mBar.getTotalScrollRange();
|
||||
if(high == max) {
|
||||
homeTweets.setNestedScrollingEnabled(true);
|
||||
homeFavorits.setNestedScrollingEnabled(true);
|
||||
} else if (high == 0) {
|
||||
homeTweets.setNestedScrollingEnabled(false);
|
||||
homeFavorits.setNestedScrollingEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void setTabs(TabHost mTab) {
|
||||
mTab.setup();
|
||||
// Tab #1
|
||||
@ -209,20 +194,26 @@ public class UserProfile extends AppCompatActivity implements View.OnClickListen
|
||||
* Tab Content
|
||||
*/
|
||||
private void getContent() {
|
||||
TweetDatabase mTweet = new TweetDatabase(UserProfile.this, TweetDatabase.USER_TL, userId);
|
||||
TweetDatabase fTweet = new TweetDatabase(UserProfile.this, TweetDatabase.FAV_TL, userId);
|
||||
mTweets = new ProfileLoader(this);
|
||||
mFavorits = new ProfileLoader(this);
|
||||
if( mTweet.getSize() > 0 ) {
|
||||
homeTweets.setAdapter(new TimelineAdapter(UserProfile.this,mTweet));
|
||||
}else {
|
||||
mTweets.execute(userId, ProfileLoader.GET_TWEETS,1L);
|
||||
}
|
||||
if( fTweet.getSize() > 0 ) {
|
||||
homeFavorits.setAdapter(new TimelineAdapter(UserProfile.this,fTweet));
|
||||
} else {
|
||||
mFavorits.execute(userId, ProfileLoader.GET_FAVS,1L);
|
||||
}
|
||||
new Thread( new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TweetDatabase mTweet = new TweetDatabase(UserProfile.this, TweetDatabase.USER_TL, userId);
|
||||
TweetDatabase fTweet = new TweetDatabase(UserProfile.this, TweetDatabase.FAV_TL, userId);
|
||||
mTweets = new ProfileLoader(UserProfile.this);
|
||||
mFavorits = new ProfileLoader(UserProfile.this);
|
||||
if( mTweet.getSize() > 0 ) {
|
||||
homeTweets.setAdapter(new TimelineAdapter(UserProfile.this,mTweet));
|
||||
}else {
|
||||
mTweets.execute(userId, ProfileLoader.GET_TWEETS,1L);
|
||||
}
|
||||
if( fTweet.getSize() > 0 ) {
|
||||
homeFavorits.setAdapter(new TimelineAdapter(UserProfile.this,fTweet));
|
||||
} else {
|
||||
mFavorits.execute(userId, ProfileLoader.GET_FAVS,1L);
|
||||
}
|
||||
}
|
||||
}
|
||||
).run();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -244,4 +235,10 @@ public class UserProfile extends AppCompatActivity implements View.OnClickListen
|
||||
intent.putExtras(bundle);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private void getExtras(Bundle b) {
|
||||
userId = b.getLong("userID");
|
||||
username = b.getString("username");
|
||||
}
|
||||
}
|
@ -75,7 +75,7 @@
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="5dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
@ -94,6 +94,7 @@
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
|
@ -1,11 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/follow_toolbar"
|
||||
android:id="@+id/user_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize" />
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user