Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
bug fix
  • Loading branch information
nuclearfog committed Sep 22, 2018
1 parent 3132869 commit 4bb0b2f
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ private String stringTime(long mills) {


public interface OnItemSelected extends OnTagClickListener {

void onAnswer(int pos);

void onDelete(int pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ protected Long doInBackground(Long... param) {
protected void onPostExecute(Long mode) {
if (ui.get() == null) return;

if (mode == LOAD || mode == DELETE) {
mAdapter.setData(message);
mAdapter.notifyDataSetChanged();
} else if (mode == FAIL) {
mAdapter.setData(message);
mAdapter.notifyDataSetChanged();
SwipeRefreshLayout mRefresh = ui.get().findViewById(R.id.dm_reload);
mRefresh.setRefreshing(false);

if (mode == FAIL) {
switch (returnCode) {
case 420:
Toast.makeText(ui.get(), R.string.rate_limit_exceeded, Toast.LENGTH_SHORT).show();
Expand All @@ -101,7 +103,5 @@ protected void onPostExecute(Long mode) {
Toast.makeText(ui.get(), errorMsg, Toast.LENGTH_LONG).show();
}
}
SwipeRefreshLayout mRefresh = ui.get().findViewById(R.id.dm_reload);
mRefresh.setRefreshing(false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,6 @@ public void onClick(View v) {
protected void onPostExecute(final Long MODE) {
if (ui.get() == null) return;

SwipeRefreshLayout homeReload = ui.get().findViewById(R.id.hometweets);
SwipeRefreshLayout favReload = ui.get().findViewById(R.id.homefavorits);
homeReload.setRefreshing(false);
favReload.setRefreshing(false);

if (MODE == ACTION_FOLLOW) {
if (isFollowing)
Toast.makeText(ui.get(), R.string.followed, Toast.LENGTH_SHORT).show();
Expand All @@ -294,6 +289,11 @@ protected void onPostExecute(final Long MODE) {
Toast.makeText(ui.get(), R.string.unmuted, Toast.LENGTH_SHORT).show();

} else if (MODE == FAILURE) {
SwipeRefreshLayout homeReload = ui.get().findViewById(R.id.hometweets);
SwipeRefreshLayout favReload = ui.get().findViewById(R.id.homefavorits);
homeReload.setRefreshing(false);
favReload.setRefreshing(false);

switch (returnCode) {
case 420:
Toast.makeText(ui.get(), R.string.rate_limit_exceeded, Toast.LENGTH_LONG).show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ protected void onPostExecute(Boolean success) {
usrAdp.setData(user);
usrAdp.notifyDataSetChanged();
} else {
SwipeRefreshLayout refresh = ui.get().findViewById(R.id.user_refresh);
refresh.setRefreshing(false);

switch (returnCode) {
case 420:
Toast.makeText(ui.get(), R.string.rate_limit_exceeded, Toast.LENGTH_SHORT).show();
Expand All @@ -85,7 +88,5 @@ protected void onPostExecute(Boolean success) {
Toast.makeText(ui.get(), errorMessage, Toast.LENGTH_SHORT).show();
}
}
SwipeRefreshLayout refresh = ui.get().findViewById(R.id.user_refresh);
refresh.setRefreshing(false);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.nuclearfog.twidda.backend.clickable;

import android.support.annotation.NonNull;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
Expand All @@ -17,7 +18,7 @@ public abstract class Tagger {
private static final int MODE = Spanned.SPAN_EXCLUSIVE_EXCLUSIVE;


public static Spannable makeText(final String text, final int color, final OnTagClickListener l) {
public static Spannable makeText(final String text, final int color, @NonNull final OnTagClickListener l) {
SpannableStringBuilder sText = new SpannableStringBuilder(text);
Pattern p = Pattern.compile(PATTERN);
Matcher m = p.matcher(text);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ protected void onStart() {

@Override
protected void onStop() {
if (mLoader != null && mLoader.getStatus() == RUNNING)
if (mLoader != null && mLoader.getStatus() == RUNNING) {
mLoader.cancel(true);
refresh.setRefreshing(false);
refresh.setRefreshing(false);
}
super.onStop();
}

Expand Down
23 changes: 12 additions & 11 deletions app/src/main/java/org/nuclearfog/twidda/window/SearchPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class SearchPage extends AppCompatActivity implements UserAdapter.OnItemC

private RecyclerView tweetSearch, userSearch;
private SwipeRefreshLayout tweetReload;
private GlobalSettings settings;
private TwitterSearch mSearch;
private TabHost tabhost;
private View lastView;
Expand All @@ -62,7 +63,7 @@ protected void onCreate(Bundle b) {
tabhost = findViewById(R.id.search_tab);
Toolbar tool = findViewById(R.id.search_toolbar);

GlobalSettings settings = GlobalSettings.getInstance(this);
settings = GlobalSettings.getInstance(this);
root.setBackgroundColor(settings.getBackgroundColor());

setSupportActionBar(tool);
Expand All @@ -84,16 +85,6 @@ protected void onCreate(Bundle b) {
tweetSearch.setLayoutManager(new LinearLayoutManager(this));
userSearch.setLayoutManager(new LinearLayoutManager(this));

TimelineAdapter searchAdapter = new TimelineAdapter(this);
searchAdapter.setColor(settings.getHighlightColor(), settings.getFontColor());
searchAdapter.toggleImage(settings.loadImages());
tweetSearch.setAdapter(searchAdapter);

UserAdapter userAdapter = new UserAdapter(this);
userAdapter.toggleImage(settings.loadImages());
userAdapter.setColor(settings.getFontColor());
userSearch.setAdapter(userAdapter);

tabhost.setOnTabChangedListener(this);
tweetReload.setOnRefreshListener(this);
}
Expand All @@ -103,6 +94,16 @@ protected void onCreate(Bundle b) {
protected void onStart() {
super.onStart();
if (mSearch == null) {
TimelineAdapter searchAdapter = new TimelineAdapter(this);
searchAdapter.setColor(settings.getHighlightColor(), settings.getFontColor());
searchAdapter.toggleImage(settings.loadImages());
tweetSearch.setAdapter(searchAdapter);

UserAdapter userAdapter = new UserAdapter(this);
userAdapter.toggleImage(settings.loadImages());
userAdapter.setColor(settings.getFontColor());
userSearch.setAdapter(userAdapter);

mSearch = new TwitterSearch(this);
tweetReload.setRefreshing(true);
mSearch.execute(search);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ protected void onCreate(Bundle b) {
mConnect = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);

View root = findViewById(R.id.tweet_layout);

View retweet = findViewById(R.id.rt_button_detail);
View favorite = findViewById(R.id.fav_button_detail);
View txtRt = findViewById(R.id.no_rt_detail);
Expand Down
16 changes: 9 additions & 7 deletions app/src/main/java/org/nuclearfog/twidda/window/UserDetail.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class UserDetail extends AppCompatActivity implements OnItemClicked, OnRe

private RecyclerView userList;
private SwipeRefreshLayout refresh;
private GlobalSettings settings;
private UserLists uList;
private int mode = -1;
private long id = 0;
Expand All @@ -55,14 +56,9 @@ else if (b.containsKey("userID"))
Toolbar toolbar = findViewById(R.id.user_toolbar);
setSupportActionBar(toolbar);

GlobalSettings settings = GlobalSettings.getInstance(this);
settings = GlobalSettings.getInstance(this);
root.setBackgroundColor(settings.getBackgroundColor());

UserAdapter usrAdp = new UserAdapter(this);
usrAdp.toggleImage(settings.loadImages());
usrAdp.setColor(settings.getFontColor());
userList.setAdapter(usrAdp);

refresh.setRefreshing(true);
refresh.setOnRefreshListener(this);
}
Expand All @@ -72,8 +68,14 @@ else if (b.containsKey("userID"))
protected void onStart() {
super.onStart();
if (uList == null) {
uList = new UserLists(UserDetail.this);
UserAdapter usrAdp = new UserAdapter(this);
usrAdp.toggleImage(settings.loadImages());
usrAdp.setColor(settings.getFontColor());
userList.setAdapter(usrAdp);

int titleId;
uList = new UserLists(UserDetail.this);

switch (mode) {
case 0:
titleId = R.string.following;
Expand Down

0 comments on commit 4bb0b2f

Please sign in to comment.