Android Open Source - tdpforce App






From Project

Back to project page tdpforce.

License

The source code is released under:

Apache License

If you think the Android project tdpforce listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.telugudesam.cadre;
// w ww  .jav  a2s  .  c  om
import java.lang.Thread.UncaughtExceptionHandler;
import java.lang.reflect.Field;
import java.util.ArrayList;

import org.json.JSONArray;
import org.telugudesam.cadre.activity.TdpMainActivity;
import org.telugudesam.cadre.objects.DevelopmentCard;
import org.telugudesam.cadre.objects.Section;
import org.telugudesam.cadre.objects.dao.DevelopmentCardDao;
import org.telugudesam.cadre.util.L;

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.view.ViewConfiguration;

import com.facebook.model.GraphUser;
import com.parse.Parse;
import com.parse.ParseFacebookUtils;
import com.parse.ParseInstallation;
import com.parse.ParseObject;
import com.parse.PushService;

public class App extends Application implements UncaughtExceptionHandler {

  private static App appInstance;
  private static SharedPreferences sharedPreferences;

  public static App getApp() {
    return appInstance;
  }

  public static Context getContext() {
    return appInstance.getApplicationContext();
  }

  @Override
  public void onCreate() {
    super.onCreate();
    appInstance = this;
    Thread.setDefaultUncaughtExceptionHandler(this);
    initParse();
    sharedPreferences = getSharedPreferences("app_prefs", MODE_PRIVATE);
    forceTheOverflowMenuForDevicesWithHardMenuButton();
  }

  private void forceTheOverflowMenuForDevicesWithHardMenuButton() {
    try {
      ViewConfiguration config = ViewConfiguration.get(this);
      Field menuKeyField = ViewConfiguration.class
          .getDeclaredField("sHasPermanentMenuKey");

      if (menuKeyField != null) {
        menuKeyField.setAccessible(true);
        menuKeyField.setBoolean(config, false);
      }
    } catch (Exception e) {
      // presumably, not relevant
    }

  }

  private void initParse() {
    Parse.initialize(this, Config.PARSE_APP_ID, Config.PARSE_CLIENT_KEY);
    ParseFacebookUtils.initialize(Config.FACEBOOK_ID);
    ParseInstallation.getCurrentInstallation().saveInBackground();
    PushService.setDefaultPushCallback(this, TdpMainActivity.class);
  }

  private void generateDummyData() {
    ArrayList<DevelopmentCard> cards = new ArrayList<DevelopmentCard>();
    cards.add(createTDPCard());
    cards.add(createTDPCard());
    cards.add(createTDPCard());
    cards.add(createTDPCard());
    cards.add(createTDPCard());
    cards.add(createTDPCard());
    cards.add(createTDPCard());
    cards.add(createYSRCPCard());
    cards.add(createYSRCPCard());
    cards.add(createCongressCard());

    DevelopmentCardDao dao = new DevelopmentCardDao(this);
    dao.insertMany(cards);

    ArrayList<ParseObject> objects = new ArrayList<ParseObject>();
    for (DevelopmentCard developmentCard : cards) {
      objects.add(developmentCard.toParseObject());
    }
    ParseObject.saveAllInBackground(objects);
  }

  private DevelopmentCard createCongressCard() {
    final DevelopmentCard card = new DevelopmentCard();
    final JSONArray jsonArray = new JSONArray();
    card.setPicsArray(jsonArray.toString());
    jsonArray.put(Section.WHY_NOT_CONGRESS.ordinal());
    card.setSectionsArray(jsonArray.toString());
    card.setTitle("An Anti-congress card");
    card.setSubTitle("A non congress subtitle");
    card.setNotes("some notes");
    return card;
    // card.setId(++id);
  }

  private DevelopmentCard createYSRCPCard() {
    final DevelopmentCard card = new DevelopmentCard();
    final JSONArray jsonArray = new JSONArray();
    card.setPicsArray(jsonArray.toString());
    jsonArray.put(Section.WHY_NOT_YSRCP.ordinal());
    card.setSectionsArray(jsonArray.toString());
    card.setTitle("An Anti-ysrcp card");
    card.setSubTitle("A non ysrcp subtitle");
    card.setNotes("some notes");
    return card;
    // card.setId(++id);
  }

  int id = 0;

  private DevelopmentCard createTDPCard() {
    final DevelopmentCard card = new DevelopmentCard();
    final JSONArray jsonArray = new JSONArray();
    card.setPicsArray(jsonArray.toString());
    jsonArray.put(Section.WHY_TDP.ordinal());
    card.setSectionsArray(jsonArray.toString());
    card.setTitle("A TDP card");
    card.setSubTitle("A TDP card subtitle");
    card.setNotes("some notes");
    return card;
    // card.setId(++id);
  }

  public static void setNewConversionTarget(int newTarget) {
    sharedPreferences.edit().putInt("conversion_target", newTarget).apply();
  }

  public static int getConversionTarget() {
    return sharedPreferences.getInt("conversion_target",
        Config.DEFAULT_CONVERSION_COUNT);
  }

  @Override
  public void uncaughtException(Thread thread, Throwable ex) {
    L.d("Exception in thread: " + thread.getName());
    L.print(new Exception(ex));

  }

  public static void saveFbUser(GraphUser user) {
    // appInstance.

  }

}




Java Source Code List

com.etsy.android.grid.ClassLoaderSavedState.java
com.etsy.android.grid.ExtendableListView.java
com.etsy.android.grid.HeaderViewListAdapter.java
com.etsy.android.grid.StaggeredGridView.java
com.etsy.android.grid.util.DynamicHeightImageView.java
com.etsy.android.grid.util.DynamicHeightTextView.java
com.polites.android.Animation.java
com.polites.android.Animator.java
com.polites.android.FlingAnimationListener.java
com.polites.android.FlingAnimation.java
com.polites.android.FlingListener.java
com.polites.android.GestureImageViewListener.java
com.polites.android.GestureImageViewTouchListener.java
com.polites.android.GestureImageView.java
com.polites.android.MathUtils.java
com.polites.android.MoveAnimationListener.java
com.polites.android.MoveAnimation.java
com.polites.android.VectorF.java
com.polites.android.ZoomAnimationListener.java
com.polites.android.ZoomAnimation.java
com.readystatesoftware.systembartint.SystemBarTintManager.java
org.telugudesam.cadre.App.java
org.telugudesam.cadre.Config.java
org.telugudesam.cadre.Constants.java
org.telugudesam.cadre.activity.BaseTdpActivity.java
org.telugudesam.cadre.activity.ConversionCounterActivity.java
org.telugudesam.cadre.activity.ConversionRegistrationActivity.java
org.telugudesam.cadre.activity.PreviewActivity.java
org.telugudesam.cadre.activity.TdpMainActivity.java
org.telugudesam.cadre.adapters.DevelopmentCardsAdapter.java
org.telugudesam.cadre.components.MemCache.java
org.telugudesam.cadre.database.DbHelper.java
org.telugudesam.cadre.database.DbUtils.java
org.telugudesam.cadre.database.Tdp_cadre_boxFactory.java
org.telugudesam.cadre.fragments.DevelopmentCardsFragment.java
org.telugudesam.cadre.objects.DevelopmentCard.java
org.telugudesam.cadre.objects.Events.java
org.telugudesam.cadre.objects.Section.java
org.telugudesam.cadre.objects.dao.DevelopmentCardDao.java
org.telugudesam.cadre.objects.dao.DevelopmentCardTable.java
org.telugudesam.cadre.util.L.java
org.telugudesam.cadre.util.SystemUiHiderBase.java
org.telugudesam.cadre.util.SystemUiHiderHoneycomb.java
org.telugudesam.cadre.util.SystemUiHider.java
org.telugudesam.cadre.util.Utils.java