Code Cleanup + Database enhanced + performance raised

This commit is contained in:
NudeDude 2018-07-23 18:33:10 +02:00
parent a9b4d46f96
commit 4153c42ba1
19 changed files with 273 additions and 150 deletions

View File

@ -2,13 +2,13 @@ apply plugin: 'com.android.application'
android {
buildToolsVersion '28.0.1'
compileSdkVersion 28
compileSdkVersion 27
defaultConfig {
applicationId "org.nuclearfog.twidda"
minSdkVersion 22
targetSdkVersion 28
targetSdkVersion 27
versionCode 1
versionName '1.5'
versionName '1.6'
vectorDrawables.useSupportLibrary = true
}
buildTypes {
@ -29,9 +29,9 @@ dependencies {
implementation files('libs/picasso-2.5.2.jar')
implementation files('libs/twitter4j-core-4.0.6.jar')
implementation files('libs/twitter4j-core-4.0.6-sources.jar')
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support:cardview-v7:28.0.0-alpha3'
implementation 'com.android.support:design:28.0.0-alpha3'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
}
repositories {

View File

@ -1,7 +1,6 @@
package org.nuclearfog.twidda;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.SwipeRefreshLayout;
@ -19,6 +18,7 @@ import android.view.animation.TranslateAnimation;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import org.nuclearfog.twidda.backend.GlobalSettings;
import org.nuclearfog.twidda.backend.MainPage;
import org.nuclearfog.twidda.backend.Registration;
import org.nuclearfog.twidda.backend.TwitterEngine;
@ -45,23 +45,25 @@ public class MainActivity extends AppCompatActivity implements
private RecyclerView timelineList, trendList,mentionList;
private MenuItem profile, tweet, search, setting;
private SearchView searchQuery;
private GlobalSettings settings;
private View lastTab;
private Toolbar toolbar;
private TabHost tabhost;
private int tabIndex = 0;
private long homeId = 0L;
private boolean settingChanged = false;
private final int REQCODE = 1;
private final int REQ_CODE = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mainpage);
TwitterEngine mTwitter = TwitterEngine.getInstance(this);
settings = GlobalSettings.getInstance(this);
boolean login = mTwitter.loggedIn();
if( !login ) {
Intent i = new Intent(this, LoginPage.class);
startActivityForResult(i,REQCODE);
startActivityForResult(i,REQ_CODE);
} else {
login();
}
@ -70,7 +72,7 @@ public class MainActivity extends AppCompatActivity implements
@Override
protected void onActivityResult(int reqCode, int returnCode, Intent i) {
super.onActivityResult(reqCode,returnCode,i);
if(reqCode == REQCODE) {
if(reqCode == REQ_CODE) {
if(returnCode == RESULT_OK) {
login();
} else {
@ -145,12 +147,6 @@ public class MainActivity extends AppCompatActivity implements
}
}
@Override
public void finish() {
super.finish();
overridePendingTransition(0,0);
}
/**
* Home Button
*/
@ -321,10 +317,9 @@ public class MainActivity extends AppCompatActivity implements
* Set Tab Content
*/
private void setTabContent() {
SharedPreferences settings = getSharedPreferences("settings", 0);
int background = settings.getInt("background_color", 0xff0f114a);
int fontcolor = settings.getInt("font_color", 0xffffffff);
int highlight = settings.getInt("highlight_color", 0xffff00ff);
int background = settings.getBackgroundColor();
int fontcolor = settings.getFontColor();
int highlight = settings.getHighlightColor();
timelineList.setBackgroundColor(background);
trendList.setBackgroundColor(background);

View File

@ -0,0 +1,122 @@
package org.nuclearfog.twidda.backend;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
public class GlobalSettings {
private static GlobalSettings ourInstance;
private SharedPreferences settings;
private int background_color;
private int font_color;
private int highlight_color;
private int tweet_color;
private boolean loadImage;
private int row;
private int woeid;
private GlobalSettings(Context context) {
settings = context.getSharedPreferences("settings",0);
woeid = settings.getInt("world_id",23424829);
background_color = settings.getInt("background_color", 0xff0f114a);
highlight_color = settings.getInt("highlight_color", 0xffff00ff);
font_color = settings.getInt("font_color", 0xffffffff);
tweet_color = settings.getInt("tweet_color",0xff19aae8);
row = settings.getInt("preload",20);
loadImage = settings.getBoolean("image_load", true);
}
public int getBackgroundColor() {
return background_color;
}
public int getFontColor() {
return font_color;
}
public int getHighlightColor() {
return highlight_color;
}
public int getTweetColor() {
return tweet_color;
}
public boolean loadImages() {
return loadImage;
}
public int getWoeId() {
return woeid;
}
public int getRowLimit() {
return row;
}
public void setBackgroundColor(int color) {
Editor edit = settings.edit();
edit.putInt("background_color",color);
background_color = color;
edit.apply();
}
public void setFontColor(int color) {
Editor edit = settings.edit();
edit.putInt("font_color",color);
font_color = color;
edit.apply();
}
public void setHighlightColor(int color) {
Editor edit = settings.edit();
edit.putInt("highlight_color",color);
highlight_color = color;
edit.apply();
}
public void setTweetColor(int color) {
Editor edit = settings.edit();
edit.putInt("tweet_color",color);
tweet_color = color;
edit.apply();
}
public void setImageLoad(boolean image) {
Editor edit = settings.edit();
edit.putBoolean("image_load", image);
loadImage = image;
edit.apply();
}
public void setWoeId(int id) {
Editor edit = settings.edit();
edit.putInt("world_id", id);
woeid = id;
edit.apply();
}
public void setRowLimit(int limit) {
Editor edit = settings.edit();
edit.putInt("preload", limit);
row = limit;
edit.apply();
}
public static GlobalSettings getInstance(Context context) {
if(ourInstance == null) {
ourInstance = new GlobalSettings(context);
}
return ourInstance;
}
}

View File

@ -1,7 +1,6 @@
package org.nuclearfog.twidda.backend;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.RecyclerView;
@ -49,11 +48,11 @@ public class MainPage extends AsyncTask<Integer, Void, Integer> {
public MainPage(Context context) {
ui = new WeakReference<>((MainActivity)context);
mTwitter = TwitterEngine.getInstance(context);
SharedPreferences settings = context.getSharedPreferences("settings", 0);
woeid = settings.getInt("woeid",23424829); // Germany WOEID
highlight = settings.getInt("highlight_color", 0xffff00ff);
font = settings.getInt("font_color", 0xffffffff);
image = settings.getBoolean("image_load", true);
GlobalSettings settings = GlobalSettings.getInstance(context);
woeid = settings.getWoeId();
highlight = settings.getHighlightColor();
font = settings.getFontColor();
image = settings.loadImages();
RecyclerView timelineList = ui.get().findViewById(R.id.tl_list);
RecyclerView trendList = ui.get().findViewById(R.id.tr_list);

View File

@ -1,7 +1,6 @@
package org.nuclearfog.twidda.backend;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.RecyclerView;
@ -32,10 +31,10 @@ import twitter4j.TwitterException;
public class ProfileLoader extends AsyncTask<Long,Void,Long> {
public static final long GET_INFORMATION = 0x0;
public static final long ACTION_FOLLOW = 0x1;
public static final long GET_TWEETS = 0x2;
public static final long GET_FAVS = 0x3;
public static final long GET_INFORMATION = 0x0; //Profilinformation
public static final long ACTION_FOLLOW = 0x1; // Folgen/Entfolgen
public static final long GET_TWEETS = 0x2; // Tweets Laden
public static final long GET_FAVS = 0x3; // Favoriten Laden
public static final long ACTION_MUTE = 0x4;
public static final long LOAD_DB = 0x5;
private static final long FAILURE = 0x6;
@ -63,10 +62,10 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long> {
public ProfileLoader(Context context) {
ui = new WeakReference<>((UserProfile)context);
mTwitter = TwitterEngine.getInstance(context);
SharedPreferences settings = context.getSharedPreferences("settings", 0);
font = settings.getInt("font_color", 0xffffffff);
highlight = settings.getInt("highlight_color", 0xffff00ff);
imgEnabled = settings.getBoolean("image_load",true);
GlobalSettings settings = GlobalSettings.getInstance(context);
font = settings.getFontColor();
highlight = settings.getHighlightColor();
imgEnabled = settings.loadImages();
RecyclerView profileTweets = ui.get().findViewById(R.id.ht_list);
RecyclerView profileFavorits = ui.get().findViewById(R.id.hf_list);
@ -123,6 +122,7 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long> {
Date d = new Date(user.created);
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy, HH:mm:ss", Locale.GERMANY);
dateString = "seit "+ sdf.format(d);
description = description.replace('\n', ' ');
}
else if(MODE == GET_TWEETS)
{

View File

@ -2,7 +2,6 @@ package org.nuclearfog.twidda.backend;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
@ -65,10 +64,10 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> implements View.On
public StatusLoader(Context c) {
mTwitter = TwitterEngine.getInstance(c);
SharedPreferences settings = c.getSharedPreferences("settings", 0);
font = settings.getInt("font_color", 0xffffffff);
highlight = settings.getInt("highlight_color", 0xffff00ff);
toggleImg = settings.getBoolean("image_load",true);
GlobalSettings settings = GlobalSettings.getInstance(c);
font = settings.getFontColor();
highlight = settings.getHighlightColor();
toggleImg = settings.loadImages();
ui = new WeakReference<>((TweetDetail)c);
RecyclerView replyList = ui.get().findViewById(R.id.answer_list);
tlAdp = (TimelineRecycler) replyList.getAdapter();

View File

@ -1,7 +1,6 @@
package org.nuclearfog.twidda.backend;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.RecyclerView;
@ -29,16 +28,16 @@ public class TwitterSearch extends AsyncTask<String, Void, Void> {
private WeakReference<SearchPage> ui;
private int highlight, font_color;
private String error;
private boolean imageload;
private boolean imageLoad;
public TwitterSearch(Context context) {
ui = new WeakReference<>((SearchPage)context);
mTwitter = TwitterEngine.getInstance(context);
SharedPreferences settings = context.getSharedPreferences("settings", 0);
font_color = settings.getInt("font_color", 0xffffffff);
highlight = settings.getInt("highlight_color", 0xffff00ff);
imageload = settings.getBoolean("image_load",true);
GlobalSettings settings = GlobalSettings.getInstance(context);
font_color = settings.getFontColor();
highlight = settings.getHighlightColor();
imageLoad = settings.loadImages();
RecyclerView tweetSearch = ui.get().findViewById(R.id.tweet_result);
RecyclerView userSearch = ui.get().findViewById(R.id.user_result);
@ -76,15 +75,19 @@ public class TwitterSearch extends AsyncTask<String, Void, Void> {
}
searchAdapter.setColor(highlight,font_color);
searchAdapter.toggleImage(imageload);
userAdapter.toggleImage(imageload);
searchAdapter.toggleImage(imageLoad);
userAdapter.toggleImage(imageLoad);
} catch (TwitterException err) {
int errCode = err.getErrorCode();
if(errCode == 420) {
int retry = err.getRetryAfter();
error = "Rate limit erreicht!\n Weiter in "+retry+" Sekunden";
} else {
error = err.getErrorMessage();
}
ErrorLog errorLog = new ErrorLog(ui.get());
errorLog.add(error);
} catch(Exception err) {
error = err.getMessage();
ErrorLog errorLog = new ErrorLog(ui.get());

View File

@ -1,7 +1,6 @@
package org.nuclearfog.twidda.backend;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.support.v7.widget.RecyclerView;
import android.view.View;
@ -35,8 +34,8 @@ public class UserLists extends AsyncTask <Long, Void, Void> {
*@see UserDetail
*/
public UserLists(Context context) {
SharedPreferences settings = context.getSharedPreferences("settings", 0);
imageload = settings.getBoolean("image_load",true);
GlobalSettings settings = GlobalSettings.getInstance(context);
imageload = settings.loadImages();
ui = new WeakReference<>((UserDetail)context);
mTwitter = TwitterEngine.getInstance(context);

View File

@ -17,6 +17,7 @@ import static android.database.sqlite.SQLiteDatabase.CONFLICT_REPLACE;
public class DatabaseAdapter {
private static int LIMIT = 100;
private AppDatabase dataHelper;
public DatabaseAdapter(Context context) {
@ -118,7 +119,7 @@ public class DatabaseAdapter {
String SQL_GET_HOME = "SELECT * FROM tweet " +
"INNER JOIN user ON tweet.userID=user.userID " +
"WHERE statusregister&(1<<2)>0 " +
"ORDER BY tweetID DESC";
"ORDER BY tweetID DESC LIMIT "+LIMIT;
Cursor cursor = db.rawQuery(SQL_GET_HOME,null);
if(cursor.moveToFirst()) {
do {
@ -141,7 +142,7 @@ public class DatabaseAdapter {
String SQL_GET_HOME = "SELECT * FROM tweet " +
"INNER JOIN user ON tweet.userID=user.userID " +
"WHERE statusregister&(1<<3)>0 " +
"ORDER BY tweetID DESC";
"ORDER BY tweetID DESC LIMIT "+LIMIT;
Cursor cursor = db.rawQuery(SQL_GET_HOME,null);
if(cursor.moveToFirst()) {
do {
@ -166,7 +167,7 @@ public class DatabaseAdapter {
String SQL_GET_HOME = "SELECT * FROM tweet " +
"INNER JOIN user ON tweet.userID = user.userID "+
"WHERE statusregister&(1<<4)>0 " +
"AND user.userID ="+userID+" ORDER BY tweetID DESC";
"AND user.userID ="+userID+" ORDER BY tweetID DESC LIMIT "+LIMIT;
Cursor cursor = db.rawQuery(SQL_GET_HOME,null);
@ -192,7 +193,7 @@ public class DatabaseAdapter {
String SQL_GET_HOME = "SELECT * FROM tweet " +
"INNER JOIN user ON tweet.userID = user.userID " +
"INNER JOIN favorit on tweet.tweetID = favorit.tweetID " +
"WHERE favorit.userID ="+userID + " ORDER BY tweetID DESC";
"WHERE favorit.userID ="+userID + " ORDER BY tweetID DESC LIMIT "+LIMIT;
Cursor cursor = db.rawQuery(SQL_GET_HOME,null);
if(cursor.moveToFirst()) {
do {
@ -217,7 +218,7 @@ public class DatabaseAdapter {
String SQL_GET_HOME = "SELECT * FROM tweet " +
"INNER JOIN user ON tweet.userID = user.userID " +
"WHERE tweet.replyID="+tweetId+" AND statusregister&(1<<5)>0 " +
"ORDER BY tweetID DESC";
"ORDER BY tweetID DESC LIMIT "+LIMIT;
Cursor cursor = db.rawQuery(SQL_GET_HOME,null);
if(cursor.moveToFirst()) {
do {
@ -241,7 +242,7 @@ public class DatabaseAdapter {
Tweet result = null;
String query = "SELECT * FROM tweet " +
"INNER JOIN user ON user.userID = tweet.userID " +
"WHERE tweet.tweetID == " + tweetId;
"WHERE tweet.tweetID == " + tweetId + " LIMIT 1";
Cursor cursor = db.rawQuery(query,null);
if(cursor.moveToFirst())
result = getStatus(cursor);
@ -259,7 +260,7 @@ public class DatabaseAdapter {
public TwitterUser getUser(long userId) {
SQLiteDatabase db = dataHelper.getReadableDatabase();
TwitterUser user = null;
String query = "SELECT * FROM user WHERE userID ="+ userId;
String query = "SELECT * FROM user WHERE userID ="+ userId+" LIMIT 1";
Cursor cursor = db.rawQuery(query, null);
if(cursor.moveToFirst())
user = getUser(cursor);
@ -287,14 +288,9 @@ public class DatabaseAdapter {
* @param id Tweet ID
*/
public void removeStatus(final long id) {
new Thread(new Runnable() {
@Override
public void run() {
SQLiteDatabase db = dataHelper.getWritableDatabase();
db.delete("tweet", "tweetID="+id, null);
db.close();
}
}).start();
SQLiteDatabase db = dataHelper.getWritableDatabase();
db.delete("tweet", "tweetID="+id, null);
db.close();
}
@ -346,7 +342,7 @@ public class DatabaseAdapter {
TwitterUser user = getUser(cursor);
Tweet embeddedTweet = null;
if(retweetId > 0)
if(retweetId > 1)
embeddedTweet = getStatus(retweetId);
return new Tweet(tweetId,retweet,favorit,user,tweettext,time,replyname,medias,
source,replyStatusId,embeddedTweet,retweeted,favorited);

View File

@ -25,12 +25,14 @@ public class ErrorLog {
item.put("time", time);
item.put("message", message);
mData.insertWithOnConflict("error",null,item,SQLiteDatabase.CONFLICT_IGNORE);
mData.close();
}
public void remove(long time) {
SQLiteDatabase mData = dataHelper.getWritableDatabase();
mData.delete("error", "time = "+time, null);
mData.close();
}
public List<String> getErrorList() {
@ -52,6 +54,7 @@ public class ErrorLog {
} while(cursor.moveToNext() && limit++ < 100);
}
cursor.close();
mData.close();
return list;
}
}

View File

@ -25,8 +25,7 @@ public class TrendDatabase {
public List<Trend> load() {
SQLiteDatabase db = dataHelper.getReadableDatabase();
List<Trend> trends = new ArrayList<>();
String SQL_TREND = "SELECT * FROM trend ORDER BY trendpos ASC";
Cursor cursor = db.rawQuery(SQL_TREND,null);
Cursor cursor = db.rawQuery("SELECT * FROM trend ORDER BY trendpos ASC",null);
if(cursor.moveToFirst()) {
do {
int index = cursor.getColumnIndex("trendpos");
@ -44,23 +43,20 @@ public class TrendDatabase {
}
/**
* Store Trend List
* Speichere Twitter Trends
* @param trends List of Trends
*/
public void store(final List<Trend> trends) {
new Thread(new Runnable() {
@Override
public void run() {
SQLiteDatabase db = dataHelper.getWritableDatabase();
ContentValues trendcolumn = new ContentValues();
for(int pos = 0; pos < trends.size(); pos++) {
Trend trend = trends.get(pos);
trendcolumn.put("trendpos", trend.position);
trendcolumn.put("trendname", trend.trend);
trendcolumn.put("trendlink", trend.link);
db.insertWithOnConflict("trend",null, trendcolumn,SQLiteDatabase.CONFLICT_REPLACE);
}
}
}).start();
SQLiteDatabase db = dataHelper.getWritableDatabase();
ContentValues trendcolumn = new ContentValues();
db.execSQL("DELETE FROM trend"); //Alte Einträge löschen
for(int pos = 0; pos < trends.size(); pos++) {
Trend trend = trends.get(pos);
trendcolumn.put("trendpos", trend.position);
trendcolumn.put("trendname", trend.trend);
trendcolumn.put("trendlink", trend.link);
db.insertWithOnConflict("trend",null, trendcolumn,SQLiteDatabase.CONFLICT_REPLACE);
}
db.close();
}
}

View File

@ -4,8 +4,6 @@ import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.ClipboardManager;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
@ -27,6 +25,7 @@ import com.flask.colorpicker.OnColorChangedListener;
import com.flask.colorpicker.builder.ColorPickerDialogBuilder;
import org.nuclearfog.twidda.R;
import org.nuclearfog.twidda.backend.GlobalSettings;
import org.nuclearfog.twidda.database.ErrorLog;
import org.nuclearfog.twidda.viewadapter.LogAdapter;
@ -39,7 +38,7 @@ public class AppSettings extends AppCompatActivity implements View.OnClickListen
CompoundButton.OnCheckedChangeListener, OnColorChangedListener {
private EditText woeId;
private SharedPreferences settings;
private GlobalSettings settings;
private ClipboardManager clip;
private CheckBox toggleImg;
private Button colorButton1,colorButton2,colorButton3,colorButton4;
@ -57,6 +56,8 @@ public class AppSettings extends AppCompatActivity implements View.OnClickListen
if(getSupportActionBar() != null)
getSupportActionBar().setDisplayShowTitleEnabled(false);
settings = GlobalSettings.getInstance(this);
clip = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
Button delButton = findViewById(R.id.delete_db);
@ -230,14 +231,13 @@ public class AppSettings extends AppCompatActivity implements View.OnClickListen
}
private void load() {
settings = getSharedPreferences("settings",0);
background = settings.getInt("background_color",0xff0f114a);
font = settings.getInt("font_color",0xffffffff);
tweet = settings.getInt("tweet_color",0xff19aae8);
highlight = settings.getInt("highlight_color",0xffff00ff);
row = settings.getInt("preload",20);
wId = settings.getInt("woeid",23424829);
imgEnabled = settings.getBoolean("image_load",true);
background = settings.getBackgroundColor();
font = settings.getFontColor();
tweet = settings.getTweetColor();
highlight = settings.getHighlightColor();
row = settings.getRowLimit();
wId = settings.getWoeId();
imgEnabled = settings.loadImages();
String location = Integer.toString(wId);
woeId.setText(location);
toggleImg.setChecked(imgEnabled);
@ -245,15 +245,13 @@ public class AppSettings extends AppCompatActivity implements View.OnClickListen
private void save() {
wId = Integer.parseInt(woeId.getText().toString());
Editor edit = settings.edit();
edit.putInt("woeid", wId);
edit.putInt("preload", row);
edit.putBoolean("image_load", imgEnabled);
edit.putInt("background_color",background);
edit.putInt("font_color",font);
edit.putInt("tweet_color", tweet);
edit.putInt("highlight_color", highlight);
edit.apply();
Toast.makeText(this, "Gespeichert", Toast.LENGTH_SHORT).show();
settings.setBackgroundColor(background);
settings.setHighlightColor(highlight);
settings.setTweetColor(tweet);
settings.setFontColor(font);
settings.setImageLoad(imgEnabled);
settings.setWoeId(wId);
settings.setRowLimit(row);
Toast.makeText(getApplicationContext(),"Gespeichert", Toast.LENGTH_SHORT).show();
}
}

View File

@ -1,7 +1,6 @@
package org.nuclearfog.twidda.window;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
@ -20,6 +19,7 @@ import android.view.animation.TranslateAnimation;
import android.widget.TabHost;
import org.nuclearfog.twidda.R;
import org.nuclearfog.twidda.backend.GlobalSettings;
import org.nuclearfog.twidda.backend.TwitterSearch;
import org.nuclearfog.twidda.backend.listitems.Tweet;
import org.nuclearfog.twidda.backend.listitems.TwitterUser;
@ -47,21 +47,24 @@ public class SearchPage extends AppCompatActivity implements UserRecycler.OnItem
setContentView(R.layout.searchpage);
getExtras(getIntent().getExtras());
SharedPreferences settings = getSharedPreferences("settings", 0);
int background = settings.getInt("background_color", 0xff0f114a);
GlobalSettings settings = GlobalSettings.getInstance(this);
int background = settings.getBackgroundColor();
Toolbar tool = findViewById(R.id.search_toolbar);
tweetSearch = findViewById(R.id.tweet_result);
userSearch = findViewById(R.id.user_result);
tweetReload = findViewById(R.id.searchtweets);
tweetSearch.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
userSearch.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
tweetSearch.setBackgroundColor(background);
userSearch.setBackgroundColor(background);
setSupportActionBar(tool);
if(getSupportActionBar() != null)
getSupportActionBar().setDisplayShowTitleEnabled(false);
tweetSearch = findViewById(R.id.tweet_result);
tweetSearch.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
tweetSearch.setBackgroundColor(background);
userSearch = findViewById(R.id.user_result);
userSearch.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
userSearch.setBackgroundColor(background);
tweetReload = findViewById(R.id.searchtweets);
tabhost = findViewById(R.id.search_tab);
tabhost.setup();
setTabs(tabhost);
@ -83,7 +86,8 @@ public class SearchPage extends AppCompatActivity implements UserRecycler.OnItem
@Override
protected void onDestroy() {
mSearch.cancel(true);
if(mSearch != null)
mSearch.cancel(true);
super.onDestroy();
}

View File

@ -2,7 +2,6 @@ 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;
@ -18,6 +17,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import org.nuclearfog.twidda.R;
import org.nuclearfog.twidda.backend.GlobalSettings;
import org.nuclearfog.twidda.backend.StatusLoader;
import org.nuclearfog.twidda.backend.TwitterEngine;
import org.nuclearfog.twidda.backend.listitems.Tweet;
@ -71,7 +71,8 @@ public class TweetDetail extends AppCompatActivity implements View.OnClickListen
@Override
protected void onDestroy() {
mStat.cancel(true);
if(mStat != null)
mStat.cancel(true);
if(mReply != null)
mReply.cancel(true);
super.onDestroy();
@ -162,9 +163,9 @@ public class TweetDetail extends AppCompatActivity implements View.OnClickListen
}
private void setContent() {
SharedPreferences settings = getSharedPreferences("settings", 0);
int backgroundColor = settings.getInt("background_color", 0xff0f114a);
int fontColor = settings.getInt("font_color", 0xffffffff);
GlobalSettings settings = GlobalSettings.getInstance(this);
int backgroundColor = settings.getBackgroundColor();
int fontColor = settings.getFontColor();
CollapsingToolbarLayout cLayout = findViewById(R.id.tweet_detail);
LinearLayout tweetaction = findViewById(R.id.tweetbar);
TextView txtTw = findViewById(R.id.tweet_detailed);

View File

@ -3,7 +3,6 @@ package org.nuclearfog.twidda.window;
import android.Manifest;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.os.Build;
@ -20,6 +19,7 @@ import android.widget.ProgressBar;
import android.widget.TextView;
import org.nuclearfog.twidda.R;
import org.nuclearfog.twidda.backend.GlobalSettings;
import org.nuclearfog.twidda.backend.ImagePopup;
import org.nuclearfog.twidda.backend.StatusUpload;
@ -40,7 +40,7 @@ public class TweetPopup extends AppCompatActivity implements View.OnClickListene
private ProgressBar send_circle;
private EditText tweet;
private Button imageButton, previewBtn;
private TextView imgcount;
private TextView imgCount;
private long inReplyId =-1L;
private String addition="";
private int imgIndex = 0;
@ -56,13 +56,13 @@ public class TweetPopup extends AppCompatActivity implements View.OnClickListene
imageButton = findViewById(R.id.image);
previewBtn = findViewById(R.id.img_preview);
tweet = findViewById(R.id.tweet_input);
imgcount = findViewById(R.id.imgcount);
imgCount = findViewById(R.id.imgcount);
send_circle = findViewById(R.id.tweet_sending);
Button tweetButton = findViewById(R.id.sendTweet);
Button closeButton = findViewById(R.id.close);
LinearLayout root = findViewById(R.id.tweet_popup);
SharedPreferences settings = getSharedPreferences("settings", 0);
int tweetColor = settings.getInt("tweet_color", 0xff19aae8);
GlobalSettings settings = GlobalSettings.getInstance(this);
int tweetColor = settings.getTweetColor();
root.setBackgroundColor(tweetColor);
tweet.append(addition);
@ -102,7 +102,7 @@ public class TweetPopup extends AppCompatActivity implements View.OnClickListene
int index = c.getColumnIndex(mode[0]);
mediaPath.add(c.getString(index));
String count = Integer.toString(++imgIndex);
imgcount.setText(count);
imgCount.setText(count);
}
if(imgIndex == 4) {
imageButton.setVisibility(View.INVISIBLE);

View File

@ -1,7 +1,6 @@
package org.nuclearfog.twidda.window;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
@ -13,6 +12,7 @@ import android.view.View;
import android.view.ViewGroup;
import org.nuclearfog.twidda.R;
import org.nuclearfog.twidda.backend.GlobalSettings;
import org.nuclearfog.twidda.backend.UserLists;
import org.nuclearfog.twidda.backend.listitems.TwitterUser;
import org.nuclearfog.twidda.viewadapter.UserRecycler;
@ -39,8 +39,8 @@ public class UserDetail extends AppCompatActivity implements UserRecycler.OnItem
userList.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
Toolbar toolbar = findViewById(R.id.user_toolbar);
setSupportActionBar(toolbar);
SharedPreferences settings = getSharedPreferences("settings", 0);
int background = settings.getInt("background_color", 0xff0f114a);
GlobalSettings settings = GlobalSettings.getInstance(this);
int background = settings.getBackgroundColor();
userList.setBackgroundColor(background);
getUsers();
@ -48,7 +48,8 @@ public class UserDetail extends AppCompatActivity implements UserRecycler.OnItem
@Override
protected void onDestroy() {
uList.cancel(true);
if(uList != null)
uList.cancel(true);
super.onDestroy();
}

View File

@ -1,7 +1,6 @@
package org.nuclearfog.twidda.window;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
@ -20,6 +19,7 @@ import android.widget.TabHost;
import android.widget.TextView;
import org.nuclearfog.twidda.R;
import org.nuclearfog.twidda.backend.GlobalSettings;
import org.nuclearfog.twidda.backend.ProfileLoader;
import org.nuclearfog.twidda.backend.TwitterEngine;
import org.nuclearfog.twidda.backend.listitems.Tweet;
@ -56,24 +56,26 @@ public class UserProfile extends AppCompatActivity implements View.OnClickListen
home = userId == TwitterEngine.getHomeId();
SharedPreferences settings = getSharedPreferences("settings", 0);
background = settings.getInt("background_color", 0xff0f114a);
font_color = settings.getInt("font_color", 0xffffffff);
highlight = settings.getInt("highlight_color", 0xffff00ff);
GlobalSettings settings = GlobalSettings.getInstance(this);
background = settings.getBackgroundColor();
font_color = settings.getFontColor();
highlight = settings.getHighlightColor();
homeList = findViewById(R.id.ht_list);
homeList.setLayoutManager(new LinearLayoutManager(this));
homeList.setBackgroundColor(background);
favoritList = findViewById(R.id.hf_list);
favoritList.setLayoutManager(new LinearLayoutManager(this));
favoritList.setBackgroundColor(background);
homeReload = findViewById(R.id.hometweets);
favoriteReload = findViewById(R.id.homefavorits);
homeReload.setBackgroundColor(0xffff0000);
favoriteReload.setBackgroundColor(0xffff0000);
homeReload.measure(0,0);
favoriteReload.measure(0,0);
homeReload = findViewById(R.id.hometweets);
homeReload.setBackgroundColor(0xffff0000);
//homeReload.measure(0,0); //TODO
favoriteReload = findViewById(R.id.homefavorits);
favoriteReload.setBackgroundColor(0xffff0000);
//favoriteReload.measure(0,0);
TextView txtFollowing = findViewById(R.id.following);
TextView txtFollower = findViewById(R.id.follower);
@ -107,7 +109,8 @@ public class UserProfile extends AppCompatActivity implements View.OnClickListen
@Override
protected void onDestroy() {
mProfile.cancel(true);
if(mProfile != null)
mProfile.cancel(true);
if(mTweets != null)
mTweets.cancel(true);
if(mFavorits != null)

View File

@ -45,11 +45,13 @@
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginEnd="5dp"
android:layout_weight="1"
android:contentDescription="@string/profile_image" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="10dp"
android:orientation="vertical">
<LinearLayout
@ -156,7 +158,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" />
android:layout_marginRight="5dp"
android:linksClickable="true" />
<LinearLayout
android:layout_width="match_parent"
@ -201,8 +204,8 @@
android:id="@+id/profile_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:singleLine="true"
android:textSize="12sp" />

View File

@ -152,12 +152,13 @@
android:id="@+id/tweetbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:addStatesFromChildren="false"
android:gravity="center_vertical|center_horizontal"
android:orientation="horizontal"
android:padding="5dp">
android:paddingBottom="5dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="5dp">
<Button
android:id="@+id/answer_button"